-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#21 Exception when hibernate returns oracle varchar2(n char)
- Loading branch information
Showing
2 changed files
with
64 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/test/java/liquibase/ext/hibernate/snapshot/TableSnapshotGeneratorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package liquibase.ext.hibernate.snapshot; | ||
|
||
import junit.framework.Assert; | ||
import liquibase.exception.DatabaseException; | ||
import liquibase.structure.core.DataType; | ||
import org.junit.Test; | ||
|
||
import java.sql.Types; | ||
|
||
import static junit.framework.Assert.assertEquals; | ||
import static junit.framework.TestCase.assertNull; | ||
|
||
public class TableSnapshotGeneratorTest { | ||
|
||
@Test | ||
public void toDataType() throws DatabaseException { | ||
TableSnapshotGenerator tableSnapshotGenerator = new TableSnapshotGenerator(); | ||
DataType varchar = tableSnapshotGenerator.toDataType("varchar(255)", Types.VARCHAR); | ||
assertEquals("varchar", varchar.getTypeName()); | ||
assertEquals(255, varchar.getColumnSize().intValue()); | ||
assertEquals(Types.VARCHAR, varchar.getDataTypeId().intValue()); | ||
assertNull(varchar.getColumnSizeUnit()); | ||
|
||
DataType intType = tableSnapshotGenerator.toDataType("integer", Types.INTEGER); | ||
assertEquals("integer", intType.getTypeName()); | ||
|
||
DataType varcharChar = tableSnapshotGenerator.toDataType("varchar2(30 char)", Types.INTEGER); | ||
assertEquals("varchar2", varcharChar.getTypeName()); | ||
assertEquals(30, varcharChar.getColumnSize().intValue()); | ||
assertEquals(DataType.ColumnSizeUnit.CHAR, varcharChar.getColumnSizeUnit()); | ||
|
||
} | ||
} |