Skip to content

Commit 9bfbfe4

Browse files
committed
add more test cases
1 parent 9cce295 commit 9bfbfe4

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/test/java/org/apache/ibatis/type/TypeAliasRegistryTest.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@
1515
*/
1616
package org.apache.ibatis.type;
1717

18-
import static org.junit.jupiter.api.Assertions.assertEquals;
19-
import static org.junit.jupiter.api.Assertions.assertNull;
20-
import static org.junit.jupiter.api.Assertions.assertThrows;
21-
2218
import java.math.BigDecimal;
2319

2420
import org.junit.jupiter.api.Test;
2521

22+
import static org.assertj.core.api.Assertions.*;
23+
import static org.junit.jupiter.api.Assertions.*;
24+
2625
class TypeAliasRegistryTest {
2726

2827
@Test
@@ -75,4 +74,21 @@ void shouldFetchCharType() {
7574
assertEquals(char[].class, typeAliasRegistry.resolveAlias("_char[]"));
7675
}
7776

77+
@Test
78+
void shouldNotBeAbleToRegisterAliasWithEmptyString() {
79+
TypeAliasRegistry typeAliasRegistry = new TypeAliasRegistry();
80+
81+
assertThatThrownBy(() -> typeAliasRegistry.registerAlias("foo", ""))
82+
.isInstanceOf(TypeException.class)
83+
.hasMessageContaining("Error registering type alias foo for");
84+
}
85+
86+
@Test
87+
void shouldNotBeAbleToResolveNotExistsAlias() {
88+
TypeAliasRegistry typeAliasRegistry = new TypeAliasRegistry();
89+
90+
assertThatThrownBy(() -> typeAliasRegistry.resolveAlias("abc"))
91+
.isInstanceOf(TypeException.class)
92+
.hasMessageContaining("Could not resolve type alias 'abc'. Cause: java.lang.ClassNotFoundException: Cannot find class: abc");
93+
}
7894
}

0 commit comments

Comments
 (0)