Skip to content

Commit e66f730

Browse files
committed
simplify junit
1 parent e0f1978 commit e66f730

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ void shouldInsertAuthorWithSelectKeyAndDynamicParams() {
180180
Author author = new Author(-1, "cbegin", "******", "[email protected]", "N/A", Section.NEWS);
181181
int rows = mapper.insertAuthorDynamic(author);
182182
assertEquals(1, rows);
183-
assertFalse(-1 == author.getId()); // id must be autogenerated
183+
assertNotEquals(-1, author.getId()); // id must be autogenerated
184184
Author author2 = mapper.selectAuthor(author.getId());
185185
assertNotNull(author2);
186186
assertEquals(author.getEmail(), author2.getEmail());

src/test/java/org/apache/ibatis/cache/BaseCacheTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ class BaseCacheTest {
3232
@Test
3333
void shouldDemonstrateEqualsAndHashCodeForVariousCacheTypes() {
3434
PerpetualCache cache = new PerpetualCache("test_cache");
35-
assertTrue(cache.equals(cache));
36-
assertTrue(cache.equals(new SynchronizedCache(cache)));
37-
assertTrue(cache.equals(new SerializedCache(cache)));
38-
assertTrue(cache.equals(new LoggingCache(cache)));
39-
assertTrue(cache.equals(new ScheduledCache(cache)));
35+
assertEquals(cache, cache);
36+
assertEquals(cache, new SynchronizedCache(cache));
37+
assertEquals(cache, new SerializedCache(cache));
38+
assertEquals(cache, new LoggingCache(cache));
39+
assertEquals(cache, new ScheduledCache(cache));
4040

4141
assertEquals(cache.hashCode(), new SynchronizedCache(cache).hashCode());
4242
assertEquals(cache.hashCode(), new SerializedCache(cache).hashCode());

src/test/java/org/apache/ibatis/cache/CacheKeyTest.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,32 +34,32 @@ void shouldTestCacheKeysEqual() {
3434
Date date = new Date();
3535
CacheKey key1 = new CacheKey(new Object[] { 1, "hello", null, new Date(date.getTime()) });
3636
CacheKey key2 = new CacheKey(new Object[] { 1, "hello", null, new Date(date.getTime()) });
37-
assertTrue(key1.equals(key2));
38-
assertTrue(key2.equals(key1));
39-
assertTrue(key1.hashCode() == key2.hashCode());
40-
assertTrue(key1.toString().equals(key2.toString()));
37+
assertEquals(key1, key2);
38+
assertEquals(key2, key1);
39+
assertEquals(key1.hashCode(), key2.hashCode());
40+
assertEquals(key1.toString(), key2.toString());
4141
}
4242

4343
@Test
4444
void shouldTestCacheKeysNotEqualDueToDateDifference() throws Exception {
4545
CacheKey key1 = new CacheKey(new Object[] { 1, "hello", null, new Date() });
4646
Thread.sleep(1000);
4747
CacheKey key2 = new CacheKey(new Object[] { 1, "hello", null, new Date() });
48-
assertFalse(key1.equals(key2));
49-
assertFalse(key2.equals(key1));
50-
assertFalse(key1.hashCode() == key2.hashCode());
51-
assertFalse(key1.toString().equals(key2.toString()));
48+
assertNotEquals(key1, key2);
49+
assertNotEquals(key2, key1);
50+
assertNotEquals(key1.hashCode(), key2.hashCode());
51+
assertNotEquals(key1.toString(), key2.toString());
5252
}
5353

5454
@Test
5555
void shouldTestCacheKeysNotEqualDueToOrder() throws Exception {
5656
CacheKey key1 = new CacheKey(new Object[] { 1, "hello", null });
5757
Thread.sleep(1000);
5858
CacheKey key2 = new CacheKey(new Object[] { 1, null, "hello" });
59-
assertFalse(key1.equals(key2));
60-
assertFalse(key2.equals(key1));
61-
assertFalse(key1.hashCode() == key2.hashCode());
62-
assertFalse(key1.toString().equals(key2.toString()));
59+
assertNotEquals(key1, key2);
60+
assertNotEquals(key2, key1);
61+
assertNotEquals(key1.hashCode(), key2.hashCode());
62+
assertNotEquals(key1.toString(), key2.toString());
6363
}
6464

6565
@Test
@@ -84,7 +84,7 @@ void shouldTestCacheKeysWithBinaryArrays() {
8484
byte[] array2 = new byte[] { 1 };
8585
CacheKey key1 = new CacheKey(new Object[] { array1 });
8686
CacheKey key2 = new CacheKey(new Object[] { array2 });
87-
assertTrue(key1.equals(key2));
87+
assertEquals(key1, key2);
8888
}
8989

9090
@Test

src/test/java/org/apache/ibatis/submitted/lazy_immutable/ImmutablePOJOTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void testLoadLazyImmutablePOJO() {
5151

5252
assertEquals(POJO_ID, pojo.getId());
5353
assertNotNull(pojo.getDescription(), "Description should not be null.");
54-
assertFalse(pojo.getDescription().length() == 0, "Description should not be empty.");
54+
assertNotEquals(0, pojo.getDescription().length(), "Description should not be empty.");
5555
}
5656
}
5757

0 commit comments

Comments
 (0)