Skip to content

Commit 45b776b

Browse files
committed
OP_1.1.0, test apache#6 completed
1 parent 34f8b42 commit 45b776b

File tree

3 files changed

+187
-103
lines changed

3 files changed

+187
-103
lines changed

openjpa-lib/src/test/java/org/apache/openjpa/lib/util/MyOptionsConfigurer.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ private Class getIntermediateClass() {
156156
testState.b3 == B3_intermediate_public_attributes.WITHOUT_INTERMEDIATE_PUBLIC_ATTRIBUTES &&
157157
testState.b4 == B4_intermediate_javabean_constructor.WITH_JAVABEAN_CONSTRUCTOR) {
158158
return ObjectWithNYNYType1.class;
159+
} else if (getDeepestClass() == DeepestObjectType1.class &&
160+
testState.b1 == B1_intermediate_getter.WITHOUT_INTERMEDIATE_GETTER &&
161+
testState.b2 == B2_intermediate_setter.WITHOUT_INTERMEDIATE_SETTER &&
162+
testState.b3 == B3_intermediate_public_attributes.WITH_INTERMEDIATE_PUBLIC_ATTRIBUTES &&
163+
testState.b4 == B4_intermediate_javabean_constructor.WITH_JAVABEAN_CONSTRUCTOR) {
164+
return ObjectWithNNYYType1.class;
159165
}
160166
return null;
161167
}

openjpa-lib/src/test/java/org/apache/openjpa/lib/util/MyOptionsObjects.java

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,40 @@ public void intermediateSetDeepest(DeepestInterface deepest) {
176176
}
177177
}
178178

179+
public static class ObjectWithNNYYType1 implements IntermediateInterface, AnyDeepInterface {
180+
public ObjectWithNNYYType1 deeper;
181+
public DeepestObjectType1 deepest;
182+
183+
public ObjectWithNNYYType1() {
184+
addMethod("new IntermediateInterface");
185+
}
186+
187+
public ObjectWithNNYYType1(boolean track) {
188+
if (track)
189+
addMethod("new IntermediateInterface");
190+
}
191+
192+
@Override
193+
public IntermediateInterface intermediateGetDeeper() {
194+
return this.deeper;
195+
}
196+
197+
@Override
198+
public void intermediateSetDeeper(IntermediateInterface lower) {
199+
this.deeper = (ObjectWithNNYYType1) lower;
200+
}
201+
202+
@Override
203+
public DeepestInterface intermediateGetDeepest() {
204+
return this.deeper.deepest;
205+
}
206+
207+
@Override
208+
public void intermediateSetDeepest(DeepestInterface deepest) {
209+
this.deepest = (DeepestObjectType1) deepest;
210+
}
211+
}
212+
179213

180214
public static class DeepestObjectType1 implements DeepestInterface, AnyDeepInterface {
181215
public String StringAttribute2;
@@ -189,7 +223,7 @@ public DeepestObjectType1() {
189223
addMethod("new DeepestInterface");
190224
}
191225

192-
public DeepestObjectType1(boolean track){
226+
public DeepestObjectType1(boolean track) {
193227
if (track)
194228
addMethod("new DeepestInterface");
195229
}

openjpa-lib/src/test/java/org/apache/openjpa/lib/util/MyOptionsTest.java

Lines changed: 146 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -28,107 +28,107 @@ private static Stream<Arguments> splitTestArguments() {
2828
List<TestState> availableTestState = new ArrayList<>();
2929
List<Arguments> activeArguments = new ArrayList<>();
3030

31-
// availableTestState.add(new TestState(
32-
// "#02: Multiple shallow properties using SUT and defaults",
33-
// A1_Number_of_properties.MULTIPLE_PROPERTIES,
34-
// null, null, null, null,
35-
// null, C2_last_instance_is_null.NON_NULL_LAST_INSTANCE,
36-
// true
37-
// ).addProperty(new PropertyState(
38-
// "1",
39-
// A2_1_depth.DEPTH_ZERO,
40-
// A2_2_number_of_values.ONE_VALUE,
41-
// A2_3_type_of_values.PRIMITIVE,
42-
// A2_4_SUT_or_defaults.ONLY_IN_SUT,
43-
// B5_1_deepest_setter.WITH_DEEPEST_SETTER,
44-
// B5_2_number_of_parameter_of_deepest_setter.SETTER_NEEDS_SAME_VALUES,
45-
// B5_3_parsable_for_setter.PARSABLE_FOR_SETTER,
46-
// B5_4_deepest_public_attribute.WITHOUT_DEEPEST_PUBLIC_ATTRIBUTE,
47-
// null,
48-
// EnumSet.of(ExpectedFlags.SET, ExpectedFlags.FINAL_SETTER)
49-
// )).addProperty(new PropertyState(
50-
// "2",
51-
// A2_1_depth.DEPTH_ZERO,
52-
// A2_2_number_of_values.ONE_VALUE,
53-
// A2_3_type_of_values.STRING,
54-
// A2_4_SUT_or_defaults.ONLY_IN_DEFAULTS,
55-
// B5_1_deepest_setter.WITHOUT_DEEPEST_SETTER,
56-
// null,
57-
// null,
58-
// B5_4_deepest_public_attribute.WITH_DEEPEST_PUBLIC_ATTRIBUTE,
59-
// B5_5_parsable_for_public_attribute.PARSABLE_FOR_PUBLIC_ATTRIBUTE,
60-
// EnumSet.of(ExpectedFlags.SET, ExpectedFlags.FINAL_PUBLIC)
61-
// )));
62-
//
63-
// availableTestState.add(new TestState(
64-
// "#03: Multiple deep properties, with getter",
65-
// A1_Number_of_properties.MULTIPLE_PROPERTIES,
66-
// B1_intermediate_getter.WITH_INTERMEDIATE_GETTER,
67-
// B2_intermediate_setter.WITH_INTERMEDIATE_SETTER,
68-
// B3_intermediate_public_attributes.WITHOUT_INTERMEDIATE_PUBLIC_ATTRIBUTES,
69-
// B4_intermediate_javabean_constructor.WITHOUT_JAVABEAN_CONSTRUCTOR,
70-
// C1_intermediate_instances_are_null.NON_NULL_INTERMEDIATE_INSTANCES,
71-
// C2_last_instance_is_null.NON_NULL_LAST_INSTANCE,
72-
// true
73-
// ).addProperty(new PropertyState(
74-
// "1",
75-
// A2_1_depth.DEPTH_GREATER_THAN_ZERO,
76-
// A2_2_number_of_values.ONE_VALUE,
77-
// A2_3_type_of_values.PRIMITIVE,
78-
// A2_4_SUT_or_defaults.BOTH_SUT_AND_DEFAULTS,
79-
// B5_1_deepest_setter.WITH_DEEPEST_SETTER,
80-
// B5_2_number_of_parameter_of_deepest_setter.SETTER_NEEDS_SAME_VALUES,
81-
// B5_3_parsable_for_setter.PARSABLE_FOR_SETTER,
82-
// B5_4_deepest_public_attribute.WITHOUT_DEEPEST_PUBLIC_ATTRIBUTE,
83-
// null,
84-
// EnumSet.of(ExpectedFlags.SET, ExpectedFlags.VIA_GETTER, ExpectedFlags.FINAL_SETTER)
85-
// )).addProperty(new PropertyState(
86-
// "2",
87-
// A2_1_depth.DEPTH_GREATER_THAN_ZERO,
88-
// A2_2_number_of_values.ONE_VALUE,
89-
// A2_3_type_of_values.SPECIAL_CLASS,
90-
// A2_4_SUT_or_defaults.ONLY_IN_SUT,
91-
// B5_1_deepest_setter.WITHOUT_DEEPEST_SETTER,
92-
// null, null,
93-
// B5_4_deepest_public_attribute.WITH_DEEPEST_PUBLIC_ATTRIBUTE,
94-
// B5_5_parsable_for_public_attribute.PARSABLE_FOR_PUBLIC_ATTRIBUTE,
95-
// EnumSet.of(ExpectedFlags.SET, ExpectedFlags.VIA_GETTER, ExpectedFlags.FINAL_PUBLIC)
96-
// )));
97-
//
98-
// availableTestState.add(new TestState(
99-
// "#04: Multiple deep properties, with getter returning null",
100-
// A1_Number_of_properties.MULTIPLE_PROPERTIES,
101-
// B1_intermediate_getter.WITH_INTERMEDIATE_GETTER,
102-
// B2_intermediate_setter.WITH_INTERMEDIATE_SETTER,
103-
// B3_intermediate_public_attributes.WITHOUT_INTERMEDIATE_PUBLIC_ATTRIBUTES,
104-
// B4_intermediate_javabean_constructor.WITH_JAVABEAN_CONSTRUCTOR,
105-
// C1_intermediate_instances_are_null.NULL_INTERMEDIATE_INSTANCES,
106-
// C2_last_instance_is_null.NULL_LAST_INSTANCE,
107-
// true
108-
// ).addProperty(new PropertyState(
109-
// "1",
110-
// A2_1_depth.DEPTH_GREATER_THAN_ZERO,
111-
// A2_2_number_of_values.ONE_VALUE,
112-
// A2_3_type_of_values.PRIMITIVE,
113-
// A2_4_SUT_or_defaults.ONLY_IN_SUT,
114-
// B5_1_deepest_setter.WITH_DEEPEST_SETTER,
115-
// B5_2_number_of_parameter_of_deepest_setter.SETTER_NEEDS_SAME_VALUES,
116-
// B5_3_parsable_for_setter.PARSABLE_FOR_SETTER,
117-
// B5_4_deepest_public_attribute.WITHOUT_DEEPEST_PUBLIC_ATTRIBUTE,
118-
// null,
119-
// EnumSet.of(ExpectedFlags.SET, ExpectedFlags.VIA_NEW_SETTER_GETTER, ExpectedFlags.FINAL_SETTER)
120-
// )).addProperty(new PropertyState(
121-
// "2",
122-
// A2_1_depth.DEPTH_GREATER_THAN_ZERO,
123-
// A2_2_number_of_values.ONE_VALUE,
124-
// A2_3_type_of_values.PRIMITIVE,
125-
// A2_4_SUT_or_defaults.ONLY_IN_SUT,
126-
// B5_1_deepest_setter.WITHOUT_DEEPEST_SETTER,
127-
// null, null,
128-
// B5_4_deepest_public_attribute.WITH_DEEPEST_PUBLIC_ATTRIBUTE,
129-
// B5_5_parsable_for_public_attribute.PARSABLE_FOR_PUBLIC_ATTRIBUTE,
130-
// EnumSet.of(ExpectedFlags.SET, ExpectedFlags.VIA_NEW_SETTER_GETTER, ExpectedFlags.FINAL_PUBLIC)
131-
// )));
31+
availableTestState.add(new TestState(
32+
"#02: Multiple shallow properties using SUT and defaults",
33+
A1_Number_of_properties.MULTIPLE_PROPERTIES,
34+
null, null, null, null,
35+
null, C2_last_instance_is_null.NON_NULL_LAST_INSTANCE,
36+
true
37+
).addProperty(new PropertyState(
38+
"1",
39+
A2_1_depth.DEPTH_ZERO,
40+
A2_2_number_of_values.ONE_VALUE,
41+
A2_3_type_of_values.PRIMITIVE,
42+
A2_4_SUT_or_defaults.ONLY_IN_SUT,
43+
B5_1_deepest_setter.WITH_DEEPEST_SETTER,
44+
B5_2_number_of_parameter_of_deepest_setter.SETTER_NEEDS_SAME_VALUES,
45+
B5_3_parsable_for_setter.PARSABLE_FOR_SETTER,
46+
B5_4_deepest_public_attribute.WITHOUT_DEEPEST_PUBLIC_ATTRIBUTE,
47+
null,
48+
EnumSet.of(ExpectedFlags.SET, ExpectedFlags.FINAL_SETTER)
49+
)).addProperty(new PropertyState(
50+
"2",
51+
A2_1_depth.DEPTH_ZERO,
52+
A2_2_number_of_values.ONE_VALUE,
53+
A2_3_type_of_values.STRING,
54+
A2_4_SUT_or_defaults.ONLY_IN_DEFAULTS,
55+
B5_1_deepest_setter.WITHOUT_DEEPEST_SETTER,
56+
null,
57+
null,
58+
B5_4_deepest_public_attribute.WITH_DEEPEST_PUBLIC_ATTRIBUTE,
59+
B5_5_parsable_for_public_attribute.PARSABLE_FOR_PUBLIC_ATTRIBUTE,
60+
EnumSet.of(ExpectedFlags.SET, ExpectedFlags.FINAL_PUBLIC)
61+
)));
62+
63+
availableTestState.add(new TestState(
64+
"#03: Multiple deep properties, with getter",
65+
A1_Number_of_properties.MULTIPLE_PROPERTIES,
66+
B1_intermediate_getter.WITH_INTERMEDIATE_GETTER,
67+
B2_intermediate_setter.WITH_INTERMEDIATE_SETTER,
68+
B3_intermediate_public_attributes.WITHOUT_INTERMEDIATE_PUBLIC_ATTRIBUTES,
69+
B4_intermediate_javabean_constructor.WITHOUT_JAVABEAN_CONSTRUCTOR,
70+
C1_intermediate_instances_are_null.NON_NULL_INTERMEDIATE_INSTANCES,
71+
C2_last_instance_is_null.NON_NULL_LAST_INSTANCE,
72+
true
73+
).addProperty(new PropertyState(
74+
"1",
75+
A2_1_depth.DEPTH_GREATER_THAN_ZERO,
76+
A2_2_number_of_values.ONE_VALUE,
77+
A2_3_type_of_values.PRIMITIVE,
78+
A2_4_SUT_or_defaults.BOTH_SUT_AND_DEFAULTS,
79+
B5_1_deepest_setter.WITH_DEEPEST_SETTER,
80+
B5_2_number_of_parameter_of_deepest_setter.SETTER_NEEDS_SAME_VALUES,
81+
B5_3_parsable_for_setter.PARSABLE_FOR_SETTER,
82+
B5_4_deepest_public_attribute.WITHOUT_DEEPEST_PUBLIC_ATTRIBUTE,
83+
null,
84+
EnumSet.of(ExpectedFlags.SET, ExpectedFlags.VIA_GETTER, ExpectedFlags.FINAL_SETTER)
85+
)).addProperty(new PropertyState(
86+
"2",
87+
A2_1_depth.DEPTH_GREATER_THAN_ZERO,
88+
A2_2_number_of_values.ONE_VALUE,
89+
A2_3_type_of_values.SPECIAL_CLASS,
90+
A2_4_SUT_or_defaults.ONLY_IN_SUT,
91+
B5_1_deepest_setter.WITHOUT_DEEPEST_SETTER,
92+
null, null,
93+
B5_4_deepest_public_attribute.WITH_DEEPEST_PUBLIC_ATTRIBUTE,
94+
B5_5_parsable_for_public_attribute.PARSABLE_FOR_PUBLIC_ATTRIBUTE,
95+
EnumSet.of(ExpectedFlags.SET, ExpectedFlags.VIA_GETTER, ExpectedFlags.FINAL_PUBLIC)
96+
)));
97+
98+
availableTestState.add(new TestState(
99+
"#04: Multiple deep properties, with getter returning null",
100+
A1_Number_of_properties.MULTIPLE_PROPERTIES,
101+
B1_intermediate_getter.WITH_INTERMEDIATE_GETTER,
102+
B2_intermediate_setter.WITH_INTERMEDIATE_SETTER,
103+
B3_intermediate_public_attributes.WITHOUT_INTERMEDIATE_PUBLIC_ATTRIBUTES,
104+
B4_intermediate_javabean_constructor.WITH_JAVABEAN_CONSTRUCTOR,
105+
C1_intermediate_instances_are_null.NULL_INTERMEDIATE_INSTANCES,
106+
C2_last_instance_is_null.NULL_LAST_INSTANCE,
107+
true
108+
).addProperty(new PropertyState(
109+
"1",
110+
A2_1_depth.DEPTH_GREATER_THAN_ZERO,
111+
A2_2_number_of_values.ONE_VALUE,
112+
A2_3_type_of_values.PRIMITIVE,
113+
A2_4_SUT_or_defaults.ONLY_IN_SUT,
114+
B5_1_deepest_setter.WITH_DEEPEST_SETTER,
115+
B5_2_number_of_parameter_of_deepest_setter.SETTER_NEEDS_SAME_VALUES,
116+
B5_3_parsable_for_setter.PARSABLE_FOR_SETTER,
117+
B5_4_deepest_public_attribute.WITHOUT_DEEPEST_PUBLIC_ATTRIBUTE,
118+
null,
119+
EnumSet.of(ExpectedFlags.SET, ExpectedFlags.VIA_NEW_SETTER_GETTER, ExpectedFlags.FINAL_SETTER)
120+
)).addProperty(new PropertyState(
121+
"2",
122+
A2_1_depth.DEPTH_GREATER_THAN_ZERO,
123+
A2_2_number_of_values.ONE_VALUE,
124+
A2_3_type_of_values.PRIMITIVE,
125+
A2_4_SUT_or_defaults.ONLY_IN_SUT,
126+
B5_1_deepest_setter.WITHOUT_DEEPEST_SETTER,
127+
null, null,
128+
B5_4_deepest_public_attribute.WITH_DEEPEST_PUBLIC_ATTRIBUTE,
129+
B5_5_parsable_for_public_attribute.PARSABLE_FOR_PUBLIC_ATTRIBUTE,
130+
EnumSet.of(ExpectedFlags.SET, ExpectedFlags.VIA_NEW_SETTER_GETTER, ExpectedFlags.FINAL_PUBLIC)
131+
)));
132132

133133
availableTestState.add(new TestState(
134134
"#05: Multiple deep properties, w/o getter and with setter",
@@ -165,6 +165,41 @@ private static Stream<Arguments> splitTestArguments() {
165165
EnumSet.of(ExpectedFlags.SET, ExpectedFlags.VIA_NEW_SETTER, ExpectedFlags.FINAL_PUBLIC)
166166
)));
167167

168+
availableTestState.add(new TestState(
169+
"#06: Multiple deep properties, w/o getter and w/o setter and null attributes",
170+
A1_Number_of_properties.MULTIPLE_PROPERTIES,
171+
B1_intermediate_getter.WITHOUT_INTERMEDIATE_GETTER,
172+
B2_intermediate_setter.WITHOUT_INTERMEDIATE_SETTER,
173+
B3_intermediate_public_attributes.WITH_INTERMEDIATE_PUBLIC_ATTRIBUTES,
174+
B4_intermediate_javabean_constructor.WITH_JAVABEAN_CONSTRUCTOR,
175+
C1_intermediate_instances_are_null.NULL_INTERMEDIATE_INSTANCES,
176+
C2_last_instance_is_null.NULL_LAST_INSTANCE,
177+
false
178+
).addProperty(new PropertyState(
179+
"1",
180+
A2_1_depth.DEPTH_GREATER_THAN_ZERO,
181+
A2_2_number_of_values.ONE_VALUE,
182+
A2_3_type_of_values.PRIMITIVE,
183+
A2_4_SUT_or_defaults.ONLY_IN_SUT,
184+
B5_1_deepest_setter.WITH_DEEPEST_SETTER,
185+
B5_2_number_of_parameter_of_deepest_setter.SETTER_NEEDS_SAME_VALUES,
186+
B5_3_parsable_for_setter.PARSABLE_FOR_SETTER,
187+
B5_4_deepest_public_attribute.WITHOUT_DEEPEST_PUBLIC_ATTRIBUTE,
188+
null,
189+
EnumSet.of(ExpectedFlags.SET, ExpectedFlags.VIA_NEW_PUBLIC, ExpectedFlags.FINAL_SETTER)
190+
)).addProperty(new PropertyState(
191+
"2",
192+
A2_1_depth.DEPTH_GREATER_THAN_ZERO,
193+
A2_2_number_of_values.ONE_VALUE,
194+
A2_3_type_of_values.PRIMITIVE,
195+
A2_4_SUT_or_defaults.ONLY_IN_SUT,
196+
B5_1_deepest_setter.WITHOUT_DEEPEST_SETTER,
197+
null, null,
198+
B5_4_deepest_public_attribute.WITH_DEEPEST_PUBLIC_ATTRIBUTE,
199+
B5_5_parsable_for_public_attribute.PARSABLE_FOR_PUBLIC_ATTRIBUTE,
200+
EnumSet.of(ExpectedFlags.SET, ExpectedFlags.VIA_NEW_PUBLIC, ExpectedFlags.FINAL_PUBLIC)
201+
)));
202+
168203
for (TestState state : availableTestState) {
169204
if (!state.successful)
170205
if (("pitest".equals(envFlag) || "onlySuccess".equals(envFlag)))
@@ -187,9 +222,12 @@ public void setIntoTest(TestState testState) {
187222

188223
Options unsetOptions = testState.SUT.setInto(testState.obj);
189224

225+
logger.info("setInto done");
226+
190227
List<String> calledMethods = MyOptionsMethodTracker.getMethods();
191228

192-
logger.info("setInto done");
229+
logger.info(String.valueOf(calledMethods));
230+
193231

194232
DeepestInterface deepestObject = ((AnyDeepInterface) testState.obj).intermediateGetDeepest();
195233
for (PropertyState property : testState.properties) {
@@ -241,6 +279,12 @@ public void setIntoTest(TestState testState) {
241279
Assertions.assertTrue(verify("setDeeper"));
242280
Assertions.assertFalse(verify("getDeepest"));
243281
Assertions.assertTrue(verify("setDeepest"));
282+
} else if (property.expectedSet.contains(ExpectedFlags.VIA_NEW_PUBLIC)) {
283+
Assertions.assertTrue(verify("new IntermediateInterface"));
284+
Assertions.assertFalse(verify("getDeeper"));
285+
Assertions.assertFalse(verify("setDeeper"));
286+
Assertions.assertFalse(verify("getDeepest"));
287+
Assertions.assertFalse(verify("setDeepest"));
244288
}
245289

246290
/* Assert the correct final way has been used to set the attribute */

0 commit comments

Comments
 (0)