Skip to content

Commit bfa3091

Browse files
committed
Polishing
1 parent 3261542 commit bfa3091

File tree

3 files changed

+82
-91
lines changed

3 files changed

+82
-91
lines changed

spring-context/src/test/groovy/org/springframework/context/groovy/GroovyBeanDefinitionReaderTests.groovy

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ class GroovyBeanDefinitionReaderTests extends GroovyTestCase {
116116

117117
def p = appCtx.getBean("person")
118118
assertTrue(p instanceof AdvisedPerson)
119-
assertNotNull p
120119
}
121120

122121
void testUseSpringNamespaceAsMethod() {
@@ -872,23 +871,26 @@ return appCtx
872871
assertEquals "homer", marge.bean3.person
873872
assertEquals "lisa", marge.bean3.bean1.person
874873
}
875-
876874
}
877875

876+
878877
class HolyGrailQuest {
879878
void start() { println "lets begin" }
880879
}
880+
881881
class KnightOfTheRoundTable {
882-
String name
883-
String leader
884-
KnightOfTheRoundTable(String n) {
885-
this.name = n
886-
}
887-
HolyGrailQuest quest
882+
String name
883+
String leader
888884

889-
void embarkOnQuest() {
890-
quest.start()
891-
}
885+
KnightOfTheRoundTable(String n) {
886+
this.name = n
887+
}
888+
889+
HolyGrailQuest quest
890+
891+
void embarkOnQuest() {
892+
quest.start()
893+
}
892894
}
893895

894896
// simple bean
@@ -898,6 +900,7 @@ class Bean1 {
898900
Properties props
899901
List children
900902
}
903+
901904
// bean referencing other bean
902905
class Bean2 {
903906
int age
@@ -908,6 +911,7 @@ class Bean2 {
908911
List children
909912
Bean1 parent
910913
}
914+
911915
// bean with constructor args
912916
class Bean3 {
913917
Bean3(String person, Bean1 bean1) {
@@ -918,6 +922,7 @@ class Bean3 {
918922
Bean1 bean1
919923
int age
920924
}
925+
921926
// bean with factory method
922927
class Bean4 {
923928
private Bean4() {}
@@ -926,32 +931,37 @@ class Bean4 {
926931
}
927932
String person
928933
}
934+
929935
// bean with List-valued constructor arg
930936
class Bean5 {
931937
Bean5(List<Bean1> people) {
932938
this.people = people
933939
}
934940
List<Bean1> people
935941
}
942+
936943
// bean with Map-valued constructor arg
937944
class Bean6 {
938945
Bean6(Map<String, Bean1> peopleByName) {
939946
this.peopleByName = peopleByName
940947
}
941948
Map<String, Bean1> peopleByName
942949
}
950+
943951
// a factory bean
944952
class Bean1Factory {
945953
Bean1 newInstance() {
946954
return new Bean1()
947955
}
948956
}
949-
class ScopeTest {}
957+
958+
class ScopeTest {
959+
}
960+
950961
class TestScope implements Scope {
951962

952963
int instanceCount
953964

954-
955965
public Object remove(String name) {
956966
// do nothing
957967
}
@@ -966,27 +976,29 @@ class TestScope implements Scope {
966976
public Object get(String name, ObjectFactory<?> objectFactory) {
967977
instanceCount++
968978
objectFactory.getObject()
969-
970979
}
971980

972981
public Object resolveContextualObject(String s) {
973982
return null; // noop
974983
}
975984
}
985+
976986
class BirthdayCardSender {
977-
List peopleSentCards = []
978-
public void onBirthday(AdvisedPerson person) {
979-
peopleSentCards << person
980-
}
987+
List peopleSentCards = []
988+
989+
public void onBirthday(AdvisedPerson person) {
990+
peopleSentCards << person
991+
}
981992
}
993+
982994
@Component(value = "person")
983995
public class AdvisedPerson {
984-
int age;
985-
String name;
996+
int age;
997+
String name;
986998

987-
public void birthday() {
988-
++age;
989-
}
999+
public void birthday() {
1000+
++age;
1001+
}
9901002
}
9911003

9921004
class SomeClass {

0 commit comments

Comments
 (0)