Skip to content

Commit 5dda40b

Browse files
authored
Merge pull request #1741 from kazuki43zoo/gh-1736
Bump catch-exception from 1.4.6 to 2.0
2 parents 58ef412 + 0a21ac2 commit 5dda40b

File tree

13 files changed

+41
-41
lines changed

13 files changed

+41
-41
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@
267267
<dependency>
268268
<groupId>eu.codearte.catch-exception</groupId>
269269
<artifactId>catch-exception</artifactId>
270-
<version>1.4.6</version>
270+
<version>2.0</version>
271271
<scope>test</scope>
272272
</dependency>
273273
<dependency>

src/test/java/org/apache/ibatis/binding/BindingTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ void verifyErrorMessageFromSelectKey() {
146146
try {
147147
BoundAuthorMapper mapper = session.getMapper(BoundAuthorMapper.class);
148148
Author author = new Author(-1, "cbegin", "******", "[email protected]", "N/A", Section.NEWS);
149-
when(mapper).insertAuthorInvalidSelectKey(author);
149+
when(() -> mapper.insertAuthorInvalidSelectKey(author));
150150
then(caughtException()).isInstanceOf(PersistenceException.class).hasMessageContaining(
151151
"### The error may exist in org/apache/ibatis/binding/BoundAuthorMapper.xml" + System.lineSeparator() +
152152
"### The error may involve org.apache.ibatis.binding.BoundAuthorMapper.insertAuthorInvalidSelectKey!selectKey" + System.lineSeparator() +
@@ -163,7 +163,7 @@ void verifyErrorMessageFromInsertAfterSelectKey() {
163163
try {
164164
BoundAuthorMapper mapper = session.getMapper(BoundAuthorMapper.class);
165165
Author author = new Author(-1, "cbegin", "******", "[email protected]", "N/A", Section.NEWS);
166-
when(mapper).insertAuthorInvalidInsert(author);
166+
when(() -> mapper.insertAuthorInvalidInsert(author));
167167
then(caughtException()).isInstanceOf(PersistenceException.class).hasMessageContaining(
168168
"### The error may exist in org/apache/ibatis/binding/BoundAuthorMapper.xml" + System.lineSeparator() +
169169
"### The error may involve org.apache.ibatis.binding.BoundAuthorMapper.insertAuthorInvalidInsert" + System.lineSeparator() +

src/test/java/org/apache/ibatis/builder/XmlConfigBuilderTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ void parseIsTwice() throws Exception {
250250
XMLConfigBuilder builder = new XMLConfigBuilder(inputStream);
251251
builder.parse();
252252

253-
when(builder).parse();
253+
when(builder::parse);
254254
then(caughtException()).isInstanceOf(BuilderException.class)
255255
.hasMessage("Each XMLConfigBuilder can only be used once.");
256256
}
@@ -267,7 +267,7 @@ void unknownSettings() {
267267
+ "</configuration>\n";
268268

269269
XMLConfigBuilder builder = new XMLConfigBuilder(new StringReader(MAPPER_CONFIG));
270-
when(builder).parse();
270+
when(builder::parse);
271271
then(caughtException()).isInstanceOf(BuilderException.class)
272272
.hasMessageContaining("The setting foo is not known. Make sure you spelled it correctly (case sensitive).");
273273
}
@@ -283,7 +283,7 @@ void unknownJavaTypeOnTypeHandler() {
283283
+ "</configuration>\n";
284284

285285
XMLConfigBuilder builder = new XMLConfigBuilder(new StringReader(MAPPER_CONFIG));
286-
when(builder).parse();
286+
when(builder::parse);
287287
then(caughtException()).isInstanceOf(BuilderException.class)
288288
.hasMessageContaining("Error registering typeAlias for 'null'. Cause: ");
289289
}
@@ -297,7 +297,7 @@ void propertiesSpecifyResourceAndUrlAtSameTime() {
297297
+ "</configuration>\n";
298298

299299
XMLConfigBuilder builder = new XMLConfigBuilder(new StringReader(MAPPER_CONFIG));
300-
when(builder).parse();
300+
when(builder::parse);
301301
then(caughtException()).isInstanceOf(BuilderException.class)
302302
.hasMessageContaining("The properties element cannot specify both a URL and a resource based property file reference. Please specify one or the other.");
303303
}

src/test/java/org/apache/ibatis/builder/XmlMapperBuilderTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void parseExpression() {
9595
@Test
9696
void resolveJdbcTypeWithUndefinedValue() {
9797
BaseBuilder builder = new BaseBuilder(new Configuration()){{}};
98-
when(builder).resolveJdbcType("aaa");
98+
when(() -> builder.resolveJdbcType("aaa"));
9999
then(caughtException())
100100
.isInstanceOf(BuilderException.class)
101101
.hasMessageStartingWith("Error resolving JdbcType. Cause: java.lang.IllegalArgumentException: No enum")
@@ -105,7 +105,7 @@ void resolveJdbcTypeWithUndefinedValue() {
105105
@Test
106106
void resolveResultSetTypeWithUndefinedValue() {
107107
BaseBuilder builder = new BaseBuilder(new Configuration()){{}};
108-
when(builder).resolveResultSetType("bbb");
108+
when(() -> builder.resolveResultSetType("bbb"));
109109
then(caughtException())
110110
.isInstanceOf(BuilderException.class)
111111
.hasMessageStartingWith("Error resolving ResultSetType. Cause: java.lang.IllegalArgumentException: No enum")
@@ -115,7 +115,7 @@ void resolveResultSetTypeWithUndefinedValue() {
115115
@Test
116116
void resolveParameterModeWithUndefinedValue() {
117117
BaseBuilder builder = new BaseBuilder(new Configuration()){{}};
118-
when(builder).resolveParameterMode("ccc");
118+
when(() -> builder.resolveParameterMode("ccc"));
119119
then(caughtException())
120120
.isInstanceOf(BuilderException.class)
121121
.hasMessageStartingWith("Error resolving ParameterMode. Cause: java.lang.IllegalArgumentException: No enum")
@@ -125,7 +125,7 @@ void resolveParameterModeWithUndefinedValue() {
125125
@Test
126126
void createInstanceWithAbstractClass() {
127127
BaseBuilder builder = new BaseBuilder(new Configuration()){{}};
128-
when(builder).createInstance("org.apache.ibatis.builder.BaseBuilder");
128+
when(() -> builder.createInstance("org.apache.ibatis.builder.BaseBuilder"));
129129
then(caughtException())
130130
.isInstanceOf(BuilderException.class)
131131
.hasMessage("Error creating instance. Cause: java.lang.NoSuchMethodException: org.apache.ibatis.builder.BaseBuilder.<init>()");
@@ -134,7 +134,7 @@ void createInstanceWithAbstractClass() {
134134
@Test
135135
void resolveClassWithNotFound() {
136136
BaseBuilder builder = new BaseBuilder(new Configuration()){{}};
137-
when(builder).resolveClass("ddd");
137+
when(() -> builder.resolveClass("ddd"));
138138
then(caughtException())
139139
.isInstanceOf(BuilderException.class)
140140
.hasMessage("Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'ddd'. Cause: java.lang.ClassNotFoundException: Cannot find class: ddd");
@@ -150,7 +150,7 @@ void resolveTypeHandlerTypeHandlerAliasIsNull() {
150150
@Test
151151
void resolveTypeHandlerNoAssignable() {
152152
BaseBuilder builder = new BaseBuilder(new Configuration()){{}};
153-
when(builder).resolveTypeHandler(String.class, "integer");
153+
when(() -> builder.resolveTypeHandler(String.class, "integer"));
154154
then(caughtException())
155155
.isInstanceOf(BuilderException.class)
156156
.hasMessage("Type java.lang.Integer is not a valid TypeHandler because it does not implement TypeHandler interface");
@@ -159,7 +159,7 @@ void resolveTypeHandlerNoAssignable() {
159159
@Test
160160
void setCurrentNamespaceValueIsNull() {
161161
MapperBuilderAssistant builder = new MapperBuilderAssistant(new Configuration(), "resource");
162-
when(builder).setCurrentNamespace(null);
162+
when(() -> builder.setCurrentNamespace(null));
163163
then(caughtException())
164164
.isInstanceOf(BuilderException.class)
165165
.hasMessage("The mapper element requires a namespace attribute to be specified.");
@@ -168,7 +168,7 @@ void setCurrentNamespaceValueIsNull() {
168168
@Test
169169
void useCacheRefNamespaceIsNull() {
170170
MapperBuilderAssistant builder = new MapperBuilderAssistant(new Configuration(), "resource");
171-
when(builder).useCacheRef(null);
171+
when(() -> builder.useCacheRef(null));
172172
then(caughtException())
173173
.isInstanceOf(BuilderException.class)
174174
.hasMessage("cache-ref element requires a namespace attribute.");
@@ -177,7 +177,7 @@ void useCacheRefNamespaceIsNull() {
177177
@Test
178178
void useCacheRefNamespaceIsUndefined() {
179179
MapperBuilderAssistant builder = new MapperBuilderAssistant(new Configuration(), "resource");
180-
when(builder).useCacheRef("eee");
180+
when(() -> builder.useCacheRef("eee"));
181181
then(caughtException())
182182
.hasMessage("No cache for namespace 'eee' could be found.");
183183
}

src/test/java/org/apache/ibatis/mapping/CacheBuilderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void testInitializing() {
3838

3939
@Test
4040
void testInitializingFailure() {
41-
when(new CacheBuilder("test").implementation(InitializingFailureCache.class)).build();
41+
when(() -> new CacheBuilder("test").implementation(InitializingFailureCache.class).build());
4242
then(caughtException()).isInstanceOf(CacheException.class)
4343
.hasMessage("Failed cache initialization for 'test' on 'org.apache.ibatis.mapping.CacheBuilderTest$InitializingFailureCache'");
4444
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public void setProp2(boolean arg) {}
217217

218218
Invoker ambiguousInvoker = reflector.getSetInvoker("prop2");
219219
Object[] param = String.class.equals(paramType)? new String[]{"x"} : new Integer[]{1};
220-
when(ambiguousInvoker).invoke(new BeanClass(), param);
220+
when(() -> ambiguousInvoker.invoke(new BeanClass(), param));
221221
then(caughtException()).isInstanceOf(ReflectionException.class)
222222
.hasMessageMatching(
223223
"Ambiguous setters defined for property 'prop2' in class '" + BeanClass.class.getName().replace("$", "\\$")
@@ -249,7 +249,7 @@ class BeanClass {
249249
assertEquals(int.class, paramType);
250250

251251
Invoker ambiguousInvoker = reflector.getGetInvoker("prop2");
252-
when(ambiguousInvoker).invoke(new BeanClass(), new Integer[] {1});
252+
when(() -> ambiguousInvoker.invoke(new BeanClass(), new Integer[] {1}));
253253
then(caughtException()).isInstanceOf(ReflectionException.class)
254254
.hasMessageContaining("Illegal overloaded getter method with ambiguous type for property 'prop2' in class '"
255255
+ BeanClass.class.getName()
@@ -281,7 +281,7 @@ class BeanClass {
281281
assertTrue(Integer.class.equals(returnType) || boolean.class.equals(returnType));
282282

283283
Invoker ambiguousInvoker = reflector.getGetInvoker("prop2");
284-
when(ambiguousInvoker).invoke(new BeanClass(), null);
284+
when(() -> ambiguousInvoker.invoke(new BeanClass(), null));
285285
then(caughtException()).isInstanceOf(ReflectionException.class)
286286
.hasMessageContaining("Illegal overloaded getter method with ambiguous type for property 'prop2' in class '"
287287
+ BeanClass.class.getName()
@@ -316,7 +316,7 @@ public void setBool(Integer bool) {}
316316
Class<?> paramType = reflector.getSetterType("bool");
317317
Object[] param = boolean.class.equals(paramType) ? new Boolean[] { true } : new Integer[] { 1 };
318318
Invoker ambiguousInvoker = reflector.getSetInvoker("bool");
319-
when(ambiguousInvoker).invoke(new Bean(), param);
319+
when(() -> ambiguousInvoker.invoke(new Bean(), param));
320320
then(caughtException()).isInstanceOf(ReflectionException.class)
321321
.hasMessageMatching(
322322
"Ambiguous setters defined for property 'bool' in class '" + Bean.class.getName().replace("$", "\\$")

src/test/java/org/apache/ibatis/scripting/LanguageDriverRegistryTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ void registerByTypeSameType() {
5656

5757
@Test
5858
void registerByTypeNull() {
59-
when(registry).register((Class<? extends LanguageDriver>) null);
59+
when(() -> registry.register((Class<? extends LanguageDriver>) null));
6060
then(caughtException()).isInstanceOf(IllegalArgumentException.class)
6161
.hasMessage("null is not a valid Language Driver");
6262
}
6363

6464
@Test
6565
void registerByTypeDoesNotCreateNewInstance() {
66-
when(registry).register(PrivateLanguageDriver.class);
66+
when(() -> registry.register(PrivateLanguageDriver.class));
6767
then(caughtException()).isInstanceOf(ScriptingException.class)
6868
.hasMessage("Failed to load language driver for org.apache.ibatis.scripting.LanguageDriverRegistryTest$PrivateLanguageDriver");
6969
}
@@ -88,7 +88,7 @@ void registerByInstanceSameType() {
8888

8989
@Test
9090
void registerByInstanceNull() {
91-
when(registry).register((LanguageDriver) null);
91+
when(() -> registry.register((LanguageDriver) null));
9292
then(caughtException()).isInstanceOf(IllegalArgumentException.class)
9393
.hasMessage("null is not a valid Language Driver");
9494
}

src/test/java/org/apache/ibatis/submitted/cache/CacheTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,23 +272,23 @@ void shouldApplyCustomCacheProperties() {
272272

273273
@Test
274274
void shouldErrorUnsupportedProperties() {
275-
when(sqlSessionFactory.getConfiguration()).addMapper(CustomCacheUnsupportedPropertyMapper.class);
275+
when(() -> sqlSessionFactory.getConfiguration().addMapper(CustomCacheUnsupportedPropertyMapper.class));
276276
then(caughtException()).isInstanceOf(CacheException.class)
277277
.hasMessage("Unsupported property type for cache: 'date' of type class java.util.Date");
278278
}
279279

280280
@Test
281281
void shouldErrorInvalidCacheNamespaceRefAttributesSpecifyBoth() {
282-
when(sqlSessionFactory.getConfiguration().getMapperRegistry())
283-
.addMapper(InvalidCacheNamespaceRefBothMapper.class);
282+
when(() -> sqlSessionFactory.getConfiguration().getMapperRegistry()
283+
.addMapper(InvalidCacheNamespaceRefBothMapper.class));
284284
then(caughtException()).isInstanceOf(BuilderException.class)
285285
.hasMessage("Cannot use both value() and name() attribute in the @CacheNamespaceRef");
286286
}
287287

288288
@Test
289289
void shouldErrorInvalidCacheNamespaceRefAttributesIsEmpty() {
290-
when(sqlSessionFactory.getConfiguration().getMapperRegistry())
291-
.addMapper(InvalidCacheNamespaceRefEmptyMapper.class);
290+
when(() -> sqlSessionFactory.getConfiguration().getMapperRegistry()
291+
.addMapper(InvalidCacheNamespaceRefEmptyMapper.class));
292292
then(caughtException()).isInstanceOf(BuilderException.class)
293293
.hasMessage("Should be specified either value() or name() attribute in the @CacheNamespaceRef");
294294
}

src/test/java/org/apache/ibatis/submitted/foreach/ForEachTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void nullItemInContext() {
115115
void shouldReportMissingPropertyName() {
116116
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
117117
Mapper mapper = sqlSession.getMapper(Mapper.class);
118-
when(mapper).typoInItemProperty(Collections.singletonList(new User()));
118+
when(() -> mapper.typoInItemProperty(Collections.singletonList(new User())));
119119
then(caughtException()).isInstanceOf(PersistenceException.class)
120120
.hasMessageContaining("There is no getter for property named 'idd' in 'class org.apache.ibatis.submitted.foreach.User'");
121121
}

src/test/java/org/apache/ibatis/submitted/keygen/Jdbc3KeyGeneratorTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ void shouldFailIfKeyPropertyIsInvalid_NoParamName() {
286286
try {
287287
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
288288
Country country = new Country("China", "CN");
289-
when(mapper).insertMultiParams_keyPropertyWithoutParamName(country, 1);
289+
when(() -> mapper.insertMultiParams_keyPropertyWithoutParamName(country, 1));
290290
then(caughtException()).isInstanceOf(PersistenceException.class).hasMessageContaining(
291291
"Could not determine which parameter to assign generated keys to. "
292292
+ "Note that when there are multiple parameters, 'keyProperty' must include the parameter name (e.g. 'param.id'). "
@@ -303,7 +303,7 @@ void shouldFailIfKeyPropertyIsInvalid_WrongParamName() {
303303
try {
304304
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
305305
Country country = new Country("China", "CN");
306-
when(mapper).insertMultiParams_keyPropertyWithWrongParamName(country, 1);
306+
when(() -> mapper.insertMultiParams_keyPropertyWithWrongParamName(country, 1));
307307
then(caughtException()).isInstanceOf(PersistenceException.class).hasMessageContaining(
308308
"Could not find parameter 'bogus'. "
309309
+ "Note that when there are multiple parameters, 'keyProperty' must include the parameter name (e.g. 'param.id'). "
@@ -504,7 +504,7 @@ void shouldErrorUndefineProperty() {
504504
try {
505505
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
506506

507-
when(mapper).insertUndefineKeyProperty(new Country("China", "CN"));
507+
when(() -> mapper.insertUndefineKeyProperty(new Country("China", "CN")));
508508
then(caughtException()).isInstanceOf(PersistenceException.class).hasMessageContaining(
509509
"### Error updating database. Cause: org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting result to parameter object. Cause: org.apache.ibatis.executor.ExecutorException: No setter found for the keyProperty 'country_id' in 'org.apache.ibatis.submitted.keygen.Country'.");
510510
} finally {
@@ -518,7 +518,7 @@ void shouldFailIfTooManyGeneratedKeys() {
518518
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
519519
try {
520520
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
521-
when(mapper).tooManyGeneratedKeys(new Country());
521+
when(() -> mapper.tooManyGeneratedKeys(new Country()));
522522
then(caughtException()).isInstanceOf(PersistenceException.class).hasMessageContaining(
523523
"Too many keys are generated. There are only 1 target objects.");
524524
} finally {
@@ -532,7 +532,7 @@ void shouldFailIfTooManyGeneratedKeys_ParamMap() {
532532
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
533533
try {
534534
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
535-
when(mapper).tooManyGeneratedKeysParamMap(new Country(), 1);
535+
when(() -> mapper.tooManyGeneratedKeysParamMap(new Country(), 1));
536536
then(caughtException()).isInstanceOf(PersistenceException.class).hasMessageContaining(
537537
"Too many keys are generated. There are only 1 target objects.");
538538
} finally {
@@ -548,7 +548,7 @@ void shouldFailIfTooManyGeneratedKeys_Batch() {
548548
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
549549
mapper.tooManyGeneratedKeysParamMap(new Country(), 1);
550550
mapper.tooManyGeneratedKeysParamMap(new Country(), 1);
551-
when(sqlSession).flushStatements();
551+
when(sqlSession::flushStatements);
552552
then(caughtException()).isInstanceOf(PersistenceException.class).hasMessageContaining(
553553
"Too many keys are generated. There are only 2 target objects.");
554554
} finally {

0 commit comments

Comments
 (0)