Skip to content

Commit 74b5487

Browse files
jhoellercbeams
authored andcommitted
IntelliJ IDEA 11 project setup
1 parent 2882ae2 commit 74b5487

File tree

2 files changed

+1270
-991
lines changed

2 files changed

+1270
-991
lines changed

org.springframework.test/src/test/java/org/springframework/test/util/ReflectionTestUtilsTests.java

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,66 @@ public void test() throws Exception {
191191
}.runTest();
192192
}
193193

194+
@Test
195+
public void invokeMethodWithAutoboxingAndUnboxing() {
196+
// IntelliJ IDEA 11 won't accept int assignment here
197+
Integer difference = invokeMethod(component, "subtract", 5, 2);
198+
assertEquals("subtract(5, 2)", 3, difference.intValue());
199+
}
200+
201+
@Ignore("[SPR-8644] findMethod() does not currently support var-args")
202+
@Test
203+
public void invokeMethodWithPrimitiveVarArgs() {
204+
// IntelliJ IDEA 11 won't accept int assignment here
205+
Integer sum = invokeMethod(component, "add", 1, 2, 3, 4);
206+
assertEquals("add(1,2,3,4)", 10, sum.intValue());
207+
}
208+
209+
@Test
210+
public void invokeMethodWithPrimitiveVarArgsAsSingleArgument() {
211+
// IntelliJ IDEA 11 won't accept int assignment here
212+
Integer sum = invokeMethod(component, "add", new int[] { 1, 2, 3, 4 });
213+
assertEquals("add(1,2,3,4)", 10, sum.intValue());
214+
}
215+
216+
@Test
217+
public void invokeMethodsSimulatingLifecycleEvents() {
218+
assertNull("number", component.getNumber());
219+
assertNull("text", component.getText());
220+
221+
// Simulate autowiring a configuration method
222+
invokeMethod(component, "configure", new Integer(42), "enigma");
223+
assertEquals("number should have been configured", new Integer(42), component.getNumber());
224+
assertEquals("text should have been configured", "enigma", component.getText());
225+
226+
// Simulate @PostConstruct life-cycle event
227+
invokeMethod(component, "init");
228+
// assertions in init() should succeed
229+
230+
// Simulate @PreDestroy life-cycle event
231+
invokeMethod(component, "destroy");
232+
assertNull("number", component.getNumber());
233+
assertNull("text", component.getText());
234+
}
235+
236+
@Test(expected = IllegalStateException.class)
237+
public void invokeMethodWithIncompatibleArgumentTypes() {
238+
invokeMethod(component, "subtract", "foo", 2.0);
239+
}
240+
241+
@Test(expected = IllegalStateException.class)
242+
public void invokeInitMethodBeforeAutowiring() {
243+
invokeMethod(component, "init");
244+
}
245+
246+
@Test(expected = IllegalStateException.class)
247+
public void invokeMethodWithTooFewArguments() {
248+
invokeMethod(component, "configure", new Integer(42));
249+
}
250+
251+
@Test(expected = IllegalStateException.class)
252+
public void invokeMethodWithTooManyArguments() {
253+
invokeMethod(component, "configure", new Integer(42), "enigma", "baz", "quux");
254+
}
255+
194256
}

0 commit comments

Comments
 (0)