empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From franci...@apache.org
Subject svn commit: r1199672 - in /incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire: DBResource.java db/mssql/ db/mssql/DBDatabaseDriverMSSqlTest.java
Date Wed, 09 Nov 2011 09:31:08 GMT
Author: francisdb
Date: Wed Nov  9 09:31:08 2011
New Revision: 1199672

URL: http://svn.apache.org/viewvc?rev=1199672&view=rev
Log:
Added test for chinese characters on mssql

Added:
    incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/mssql/
    incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/mssql/DBDatabaseDriverMSSqlTest.java
Modified:
    incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/DBResource.java

Modified: incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/DBResource.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/DBResource.java?rev=1199672&r1=1199671&r2=1199672&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/DBResource.java (original)
+++ incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/DBResource.java Wed
Nov  9 09:31:08 2011
@@ -28,6 +28,7 @@ import org.apache.empire.db.DBTools;
 import org.apache.empire.db.derby.DBDatabaseDriverDerby;
 import org.apache.empire.db.h2.DBDatabaseDriverH2;
 import org.apache.empire.db.hsql.DBDatabaseDriverHSql;
+import org.apache.empire.db.sqlserver.DBDatabaseDriverMSSQL;
 import org.junit.rules.ExternalResource;
 
 public class DBResource extends ExternalResource
@@ -102,9 +103,13 @@ public class DBResource extends External
               "jdbc:derby:memory:data/derby/test;create=true",
               DBDatabaseDriverDerby.class),
         H2(
-           "org.h2.Driver", 
-           "jdbc:h2:mem:data/h2/test",
-           DBDatabaseDriverH2.class);
+              "org.h2.Driver", 
+              "jdbc:h2:mem:data/h2/test",
+              DBDatabaseDriverH2.class),
+        MSSQL(
+              "com.microsoft.sqlserver.jdbc.SQLServerDriver", 
+              "jdbc:sqlserver://localhost:1433",
+              DBDatabaseDriverMSSQL.class);
         
         private final String jdbcClass;
         private final String jdbcURL;

Added: incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/mssql/DBDatabaseDriverMSSqlTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/mssql/DBDatabaseDriverMSSqlTest.java?rev=1199672&view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/mssql/DBDatabaseDriverMSSqlTest.java
(added)
+++ incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/mssql/DBDatabaseDriverMSSqlTest.java
Wed Nov  9 09:31:08 2011
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.mssql;
+
+import static org.junit.Assert.assertEquals;
+
+import java.sql.Connection;
+
+import org.apache.empire.DBResource;
+import org.apache.empire.DBResource.DB;
+import org.apache.empire.db.CompanyDB;
+import org.apache.empire.db.DBDatabaseDriver;
+import org.apache.empire.db.DBRecord;
+import org.apache.empire.db.DBSQLScript;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class DBDatabaseDriverMSSqlTest 
+{
+
+	@Rule
+	public DBResource dbResource = new DBResource(DB.MSSQL);
+
+	@Test
+	@Ignore
+	public void testChineseCharacters() 
+	{
+		Connection conn = dbResource.getConnection();
+
+		DBDatabaseDriver driver = dbResource.newDriver();
+		CompanyDB db = new CompanyDB();
+
+		// Encoding issue occur when prepared statement is disabled
+		// db.setPreparedStatementsEnabled(true);
+
+		db.open(driver, dbResource.getConnection());
+
+		DBSQLScript script = new DBSQLScript();
+		db.getCreateDDLScript(db.getDriver(), script);
+		System.out.println(script.toString());
+		script.run(db.getDriver(), dbResource.getConnection(), false);
+
+		DBRecord dep = new DBRecord();
+		dep.create(db.DEPARTMENT);
+		dep.setValue(db.DEPARTMENT.NAME, "junit");
+		dep.setValue(db.DEPARTMENT.BUSINESS_UNIT, "中文");
+		dep.update(conn);
+
+		int id = dep.getInt(db.DEPARTMENT.ID);
+
+		// Update an Employee
+		DBRecord depRead = new DBRecord();
+		depRead.read(db.DEPARTMENT, id, conn);
+
+		// You may see ?? in the DB record
+		assertEquals("中文", depRead.getString(db.DEPARTMENT.BUSINESS_UNIT));
+	}
+}



Mime
View raw message