Skip to content

Commit 882560a

Browse files
authored
Merge pull request #1331 from danglotb/improve-test-MetaClass
test: getGetterType should throw a Exception in case of unknown property
2 parents f44dcef + b653ce5 commit 882560a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/test/java/org/apache/ibatis/reflection/MetaClassTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,18 @@ public void shouldTestDataTypeOfGenericMethod() {
4848
assertEquals(Long.class, meta.getSetterType("id"));
4949
}
5050

51+
@Test
52+
public void shouldThrowReflectionExceptionGetGetterType() throws Exception {
53+
try {
54+
ReflectorFactory reflectorFactory = new DefaultReflectorFactory();
55+
MetaClass meta = MetaClass.forClass(RichType.class, reflectorFactory);
56+
meta.getGetterType("aString");
57+
org.junit.Assert.fail("should have thrown ReflectionException");
58+
} catch (ReflectionException expected) {
59+
assertEquals("There is no getter for property named \'aString\' in \'class org.apache.ibatis.domain.misc.RichType\'", expected.getMessage());
60+
}
61+
}
62+
5163
@Test
5264
public void shouldCheckGetterExistance() {
5365
ReflectorFactory reflectorFactory = new DefaultReflectorFactory();

0 commit comments

Comments
 (0)