Skip to content

Commit f3cbccc

Browse files
authored
Merge pull request #12 from kazuki43zoo/gh-11
Modify assertions to succeed on multiple MyBatis versions
2 parents 86d61e8 + 9ccd636 commit f3cbccc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/test/java/org/mybatis/scripting/thymeleaf/ThymeleafLanguageDriverTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.io.Reader;
1919
import java.io.UncheckedIOException;
20+
import java.lang.reflect.InvocationTargetException;
2021
import java.nio.charset.StandardCharsets;
2122
import java.sql.Connection;
2223
import java.util.Arrays;
@@ -338,7 +339,9 @@ void testCustomizerNotFound() {
338339
Assertions.fail();
339340
} catch (ScriptingException e) {
340341
Assertions.assertEquals("Failed to load language driver for org.mybatis.scripting.thymeleaf.ThymeleafLanguageDriver", e.getMessage());
341-
Assertions.assertEquals("java.lang.ClassNotFoundException: Cannot find class: org.mybatis.scripting.thymeleaf.FooTemplateEngineCustomizer", e.getCause().getMessage());
342+
// Since mybatis 3.5.1, exception is wrapped by InvocationTargetException
343+
Throwable cause = e.getCause() instanceof InvocationTargetException ? e.getCause().getCause() : e.getCause();
344+
Assertions.assertEquals("java.lang.ClassNotFoundException: Cannot find class: org.mybatis.scripting.thymeleaf.FooTemplateEngineCustomizer", cause.getMessage());
342345
}
343346
}
344347

@@ -351,7 +354,9 @@ void testCustomizerNotCreation() {
351354
Assertions.fail();
352355
} catch (ScriptingException e) {
353356
Assertions.assertEquals("Failed to load language driver for org.mybatis.scripting.thymeleaf.ThymeleafLanguageDriver", e.getMessage());
354-
Assertions.assertEquals("Cannot create an instance for class: class org.mybatis.scripting.thymeleaf.NoDefaultConstructorTemplateEngineCustomizer", e.getCause().getMessage());
357+
// Since mybatis 3.5.1, exception is wrapped by InvocationTargetException
358+
Throwable cause = e.getCause() instanceof InvocationTargetException ? e.getCause().getCause() : e.getCause();
359+
Assertions.assertEquals("Cannot create an instance for class: class org.mybatis.scripting.thymeleaf.NoDefaultConstructorTemplateEngineCustomizer", cause.getMessage());
355360
}
356361
}
357362

0 commit comments

Comments
 (0)