empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From der...@apache.org
Subject empire-db git commit: added tests for DBDatabaseDriverMySQL
Date Mon, 09 Oct 2017 08:59:55 GMT
Repository: empire-db
Updated Branches:
  refs/heads/master 76e28f968 -> f94e46389


added tests for DBDatabaseDriverMySQL


Project: http://git-wip-us.apache.org/repos/asf/empire-db/repo
Commit: http://git-wip-us.apache.org/repos/asf/empire-db/commit/f94e4638
Tree: http://git-wip-us.apache.org/repos/asf/empire-db/tree/f94e4638
Diff: http://git-wip-us.apache.org/repos/asf/empire-db/diff/f94e4638

Branch: refs/heads/master
Commit: f94e46389bb59388f411b9424d30d3aecba21675
Parents: 76e28f9
Author: Jan Glaubitz <jan@glaubitz.org>
Authored: Mon Oct 9 10:59:48 2017 +0200
Committer: Jan Glaubitz <jan@glaubitz.org>
Committed: Mon Oct 9 10:59:48 2017 +0200

----------------------------------------------------------------------
 .../db/mysql/DBDatabaseDriverMySQLTest.java     | 46 ++++++++++++++++++++
 1 file changed, 46 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/empire-db/blob/f94e4638/empire-db/src/test/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQLTest.java
----------------------------------------------------------------------
diff --git a/empire-db/src/test/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQLTest.java
b/empire-db/src/test/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQLTest.java
index 563ddbc..5d39f38 100644
--- a/empire-db/src/test/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQLTest.java
+++ b/empire-db/src/test/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQLTest.java
@@ -18,8 +18,10 @@
  */
 package org.apache.empire.db.mysql;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
+import org.apache.empire.data.DataType;
 import org.apache.empire.db.CompanyDB;
 import org.apache.empire.db.CompanyDB.Departments;
 import org.apache.empire.db.DBCommand;
@@ -61,4 +63,48 @@ public class DBDatabaseDriverMySQLTest {
 		
 	}
 	
+	@Test
+	public void testGetConvertPhrase()
+	{
+		
+        DBDatabaseDriver driver = new DBDatabaseDriverMySQL();
+
+        // BOOL
+        assertEquals("CAST(? AS UNSIGNED)", driver.getConvertPhrase(DataType.BOOL, null,
null));
+        assertEquals("CAST(? AS UNSIGNED)", driver.getConvertPhrase(DataType.BOOL, null,
"test"));
+        
+        // INTEGER
+        assertEquals("CAST(? AS SIGNED)", driver.getConvertPhrase(DataType.INTEGER, null,
null));
+        assertEquals("CAST(? AS SIGNED)", driver.getConvertPhrase(DataType.INTEGER, null,
"test"));
+
+        // DECIMAL
+        assertEquals("CAST(? AS DECIMAL)", driver.getConvertPhrase(DataType.DECIMAL, null,
null));
+        assertEquals("CAST(? AS DECIMAL)", driver.getConvertPhrase(DataType.DECIMAL, null,
"test"));
+        
+        // FLOAT
+        assertEquals("CAST(? AS DECIMAL)", driver.getConvertPhrase(DataType.FLOAT, null,
null));
+        assertEquals("CAST(? AS DECIMAL)", driver.getConvertPhrase(DataType.FLOAT, null,
"test"));
+        
+        // DATE
+        assertEquals("CAST(? AS DATE)", driver.getConvertPhrase(DataType.DATE, null, null));
+        assertEquals("CAST(? AS DATE)", driver.getConvertPhrase(DataType.DATE, null, "test"));
+        
+        // DATETIME
+        assertEquals("CAST(? AS DATETIME)", driver.getConvertPhrase(DataType.DATETIME, null,
null));
+        assertEquals("CAST(? AS DATETIME)", driver.getConvertPhrase(DataType.DATETIME, null,
"test"));
+        
+        // TEXT
+        assertEquals("CAST(? AS CHAR CHARACTER SET cp1250)", driver.getConvertPhrase(DataType.TEXT,
null, "CHARACTER SET cp1250"));
+        assertEquals("CAST(? AS CHAR)", driver.getConvertPhrase(DataType.TEXT, null, null));
+        
+        // BLOB
+        assertEquals("CAST(? AS BLOB)", driver.getConvertPhrase(DataType.BLOB, null, null));
+        assertEquals("CAST(? AS BLOB)", driver.getConvertPhrase(DataType.BLOB, null, "test"));
+        
+     // Unknown Type
+        assertEquals("?", driver.getConvertPhrase(DataType.AUTOINC, null, null));
+        assertEquals("?", driver.getConvertPhrase(DataType.AUTOINC, null, "test"));
+        
+	}
+	
 }


Mime
View raw message