Skip to content

Commit 4e80530

Browse files
fix: make testInitPropertiesWithWrongType deterministic by separating valid and invalid property initialization (#6500)
Co-authored-by: Martin Monperrus <[email protected]>
1 parent d499ae7 commit 4e80530

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/test/java/spoon/test/processing/ProcessingTest.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -259,22 +259,24 @@ public void process() {
259259
Launcher launcher = new Launcher();
260260
p.setFactory(launcher.getFactory());
261261

262+
Object o = "foo";
262263
ProcessorProperties props = new ProcessorPropertiesImpl();
263264
props.set("aString", "foo");
264-
props.set("anObject", "foo");
265-
props.set("anInt", "foo");
266-
267-
try {
268-
ProcessorUtils.initProperties(p, props);
269-
fail();
270-
} catch (SpoonException e) {
271-
assertTrue(e.getMessage().contains("anInt"));
272-
}
265+
props.set("anObject", o);
266+
ProcessorUtils.initProperties(p, props);
273267

268+
assertEquals("foo", p.aString);
269+
assertEquals(0, p.anInt);
270+
assertSame(o, p.anObject);
271+
272+
ProcessorProperties bad = new ProcessorPropertiesImpl();
273+
bad.set("anInt", "foo");
274+
SpoonException ex = assertThrows(SpoonException.class, () -> ProcessorUtils.initProperties(p, bad));
275+
assertTrue(ex.getMessage().contains("anInt"));
274276

275277
assertEquals("foo", p.aString);
276278
assertEquals(0, p.anInt);
277-
assertNull(p.anObject);
279+
assertSame(o, p.anObject);
278280
}
279281

280282
@Test

0 commit comments

Comments
 (0)