@@ -116,7 +116,6 @@ class GroovyBeanDefinitionReaderTests extends GroovyTestCase {
116
116
117
117
def p = appCtx. getBean(" person" )
118
118
assertTrue (p instanceof AdvisedPerson )
119
- assertNotNull p
120
119
}
121
120
122
121
void testUseSpringNamespaceAsMethod () {
@@ -872,23 +871,26 @@ return appCtx
872
871
assertEquals " homer" , marge. bean3. person
873
872
assertEquals " lisa" , marge. bean3. bean1. person
874
873
}
875
-
876
874
}
877
875
876
+
878
877
class HolyGrailQuest {
879
878
void start () { println " lets begin" }
880
879
}
880
+
881
881
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
888
884
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
+ }
892
894
}
893
895
894
896
// simple bean
@@ -898,6 +900,7 @@ class Bean1 {
898
900
Properties props
899
901
List children
900
902
}
903
+
901
904
// bean referencing other bean
902
905
class Bean2 {
903
906
int age
@@ -908,6 +911,7 @@ class Bean2 {
908
911
List children
909
912
Bean1 parent
910
913
}
914
+
911
915
// bean with constructor args
912
916
class Bean3 {
913
917
Bean3 (String person , Bean1 bean1 ) {
@@ -918,6 +922,7 @@ class Bean3 {
918
922
Bean1 bean1
919
923
int age
920
924
}
925
+
921
926
// bean with factory method
922
927
class Bean4 {
923
928
private Bean4 () {}
@@ -926,32 +931,37 @@ class Bean4 {
926
931
}
927
932
String person
928
933
}
934
+
929
935
// bean with List-valued constructor arg
930
936
class Bean5 {
931
937
Bean5 (List<Bean1 > people ) {
932
938
this . people = people
933
939
}
934
940
List<Bean1 > people
935
941
}
942
+
936
943
// bean with Map-valued constructor arg
937
944
class Bean6 {
938
945
Bean6 (Map<String , Bean1 > peopleByName ) {
939
946
this . peopleByName = peopleByName
940
947
}
941
948
Map<String , Bean1 > peopleByName
942
949
}
950
+
943
951
// a factory bean
944
952
class Bean1Factory {
945
953
Bean1 newInstance () {
946
954
return new Bean1 ()
947
955
}
948
956
}
949
- class ScopeTest {}
957
+
958
+ class ScopeTest {
959
+ }
960
+
950
961
class TestScope implements Scope {
951
962
952
963
int instanceCount
953
964
954
-
955
965
public Object remove (String name ) {
956
966
// do nothing
957
967
}
@@ -966,27 +976,29 @@ class TestScope implements Scope {
966
976
public Object get (String name , ObjectFactory<?> objectFactory ) {
967
977
instanceCount++
968
978
objectFactory. getObject()
969
-
970
979
}
971
980
972
981
public Object resolveContextualObject (String s ) {
973
982
return null ; // noop
974
983
}
975
984
}
985
+
976
986
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
+ }
981
992
}
993
+
982
994
@Component (value = " person" )
983
995
public class AdvisedPerson {
984
- int age;
985
- String name;
996
+ int age;
997
+ String name;
986
998
987
- public void birthday () {
988
- ++ age;
989
- }
999
+ public void birthday () {
1000
+ ++ age;
1001
+ }
990
1002
}
991
1003
992
1004
class SomeClass {
0 commit comments