Skip to content

Commit

Permalink
add more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
mawen12 committed Sep 29, 2024
1 parent 9cce295 commit 9bfbfe4
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/test/java/org/apache/ibatis/type/TypeAliasRegistryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
*/
package org.apache.ibatis.type;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;

import java.math.BigDecimal;

import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.*;

class TypeAliasRegistryTest {

@Test
Expand Down Expand Up @@ -75,4 +74,21 @@ void shouldFetchCharType() {
assertEquals(char[].class, typeAliasRegistry.resolveAlias("_char[]"));
}

@Test
void shouldNotBeAbleToRegisterAliasWithEmptyString() {
TypeAliasRegistry typeAliasRegistry = new TypeAliasRegistry();

assertThatThrownBy(() -> typeAliasRegistry.registerAlias("foo", ""))
.isInstanceOf(TypeException.class)
.hasMessageContaining("Error registering type alias foo for");
}

@Test
void shouldNotBeAbleToResolveNotExistsAlias() {
TypeAliasRegistry typeAliasRegistry = new TypeAliasRegistry();

assertThatThrownBy(() -> typeAliasRegistry.resolveAlias("abc"))
.isInstanceOf(TypeException.class)
.hasMessageContaining("Could not resolve type alias 'abc'. Cause: java.lang.ClassNotFoundException: Cannot find class: abc");
}
}

0 comments on commit 9bfbfe4

Please sign in to comment.