You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2017/07/06 09:18:25 UTC

kylin git commit: KYLIN-1351 Use different h2 instances in tests

Repository: kylin
Updated Branches:
  refs/heads/master ad47dc00e -> f8d3c0eed


KYLIN-1351 Use different h2 instances in tests

Signed-off-by: Li Yang <li...@apache.org>


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

Branch: refs/heads/master
Commit: f8d3c0eed2f04604abcb9e7972634755ac673e2d
Parents: ad47dc0
Author: auphyroc99 <45...@qq.com>
Authored: Thu Jul 6 16:32:15 2017 +0800
Committer: Li Yang <li...@apache.org>
Committed: Thu Jul 6 17:18:11 2017 +0800

----------------------------------------------------------------------
 .../jdbc/ITJdbcSourceTableLoaderTest.java       | 49 ++++++++------------
 .../source/jdbc/ITJdbcTableReaderTest.java      | 49 ++++++++------------
 2 files changed, 40 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/f8d3c0ee/kylin-it/src/test/java/org/apache/kylin/source/jdbc/ITJdbcSourceTableLoaderTest.java
----------------------------------------------------------------------
diff --git a/kylin-it/src/test/java/org/apache/kylin/source/jdbc/ITJdbcSourceTableLoaderTest.java b/kylin-it/src/test/java/org/apache/kylin/source/jdbc/ITJdbcSourceTableLoaderTest.java
index a84dca9..977c0f4 100644
--- a/kylin-it/src/test/java/org/apache/kylin/source/jdbc/ITJdbcSourceTableLoaderTest.java
+++ b/kylin-it/src/test/java/org/apache/kylin/source/jdbc/ITJdbcSourceTableLoaderTest.java
@@ -1,3 +1,21 @@
+/*
+ * 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.kylin.source.jdbc;
 
 import static org.junit.Assert.assertTrue;
@@ -5,7 +23,6 @@ import static org.junit.Assert.assertTrue;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.SQLException;
-import java.sql.Types;
 
 import org.apache.kylin.common.KylinConfig;
 import org.apache.kylin.common.util.LocalFileMetadataTestCase;
@@ -19,12 +36,6 @@ import org.apache.kylin.source.ISource;
 import org.apache.kylin.source.ISourceMetadataExplorer;
 import org.apache.kylin.source.SourceFactory;
 import org.apache.kylin.source.datagen.ModelDataGenerator;
-import org.dbunit.DatabaseUnitException;
-import org.dbunit.database.DatabaseConfig;
-import org.dbunit.dataset.datatype.DataType;
-import org.dbunit.dataset.datatype.DataTypeException;
-import org.dbunit.ext.h2.H2Connection;
-import org.dbunit.ext.h2.H2DataTypeFactory;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -39,14 +50,14 @@ public class ITJdbcSourceTableLoaderTest extends LocalFileMetadataTestCase imple
 
         super.createTestMetadata();
 
-        System.setProperty("kylin.source.jdbc.connection-url", "jdbc:h2:mem:db");
+        System.setProperty("kylin.source.jdbc.connection-url", "jdbc:h2:mem:db" + "_jdbc_source_table_loader");
         System.setProperty("kylin.source.jdbc.driver", "org.h2.Driver");
         System.setProperty("kylin.source.jdbc.user", "sa");
         System.setProperty("kylin.source.jdbc.pass", "");
 
         config = KylinConfig.getInstanceFromEnv();
 
-        h2Connection = DriverManager.getConnection("jdbc:h2:mem:db", "sa", "");
+        h2Connection = DriverManager.getConnection("jdbc:h2:mem:db" + "_jdbc_source_table_loader", "sa", "");
 
         H2Database h2DB = new H2Database(h2Connection, config);
 
@@ -98,24 +109,4 @@ public class ITJdbcSourceTableLoaderTest extends LocalFileMetadataTestCase imple
         return ISourceAware.ID_JDBC;
     }
 
-    @SuppressWarnings("deprecation")
-    protected static H2Connection newH2Connection() throws DatabaseUnitException {
-        H2Connection h2Conn = new H2Connection(h2Connection, null);
-        h2Conn.getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new TestH2DataTypeFactory());
-        h2Conn.getConfig().setFeature(DatabaseConfig.FEATURE_DATATYPE_WARNING, false);
-        return h2Conn;
-    }
-
-    public static class TestH2DataTypeFactory extends H2DataTypeFactory {
-        @Override
-        public DataType createDataType(int sqlType, String sqlTypeName, String tableName, String columnName)
-                throws DataTypeException {
-
-            if ((columnName.startsWith("COL") || columnName.startsWith("col")) && sqlType == Types.BIGINT) {
-                return DataType.INTEGER;
-            }
-            return super.createDataType(sqlType, sqlTypeName);
-        }
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/kylin/blob/f8d3c0ee/kylin-it/src/test/java/org/apache/kylin/source/jdbc/ITJdbcTableReaderTest.java
----------------------------------------------------------------------
diff --git a/kylin-it/src/test/java/org/apache/kylin/source/jdbc/ITJdbcTableReaderTest.java b/kylin-it/src/test/java/org/apache/kylin/source/jdbc/ITJdbcTableReaderTest.java
index 7850952..22e0b14 100644
--- a/kylin-it/src/test/java/org/apache/kylin/source/jdbc/ITJdbcTableReaderTest.java
+++ b/kylin-it/src/test/java/org/apache/kylin/source/jdbc/ITJdbcTableReaderTest.java
@@ -1,9 +1,26 @@
+/*
+ * 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.kylin.source.jdbc;
 
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.SQLException;
-import java.sql.Types;
 
 import org.apache.kylin.common.KylinConfig;
 import org.apache.kylin.common.util.LocalFileMetadataTestCase;
@@ -11,12 +28,6 @@ import org.apache.kylin.metadata.MetadataManager;
 import org.apache.kylin.metadata.model.ISourceAware;
 import org.apache.kylin.query.H2Database;
 import org.apache.kylin.source.datagen.ModelDataGenerator;
-import org.dbunit.DatabaseUnitException;
-import org.dbunit.database.DatabaseConfig;
-import org.dbunit.dataset.datatype.DataType;
-import org.dbunit.dataset.datatype.DataTypeException;
-import org.dbunit.ext.h2.H2Connection;
-import org.dbunit.ext.h2.H2DataTypeFactory;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -32,14 +43,14 @@ public class ITJdbcTableReaderTest extends LocalFileMetadataTestCase implements
 
         super.createTestMetadata();
 
-        System.setProperty("kylin.source.jdbc.connection-url", "jdbc:h2:mem:db");
+        System.setProperty("kylin.source.jdbc.connection-url", "jdbc:h2:mem:db" + "_jdbc_table_reader");
         System.setProperty("kylin.source.jdbc.driver", "org.h2.Driver");
         System.setProperty("kylin.source.jdbc.user", "sa");
         System.setProperty("kylin.source.jdbc.pass", "");
 
         config = KylinConfig.getInstanceFromEnv();
 
-        h2Connection = DriverManager.getConnection("jdbc:h2:mem:db", "sa", "");
+        h2Connection = DriverManager.getConnection("jdbc:h2:mem:db" + "_jdbc_table_reader", "sa", "");
 
         H2Database h2DB = new H2Database(h2Connection, config);
 
@@ -93,24 +104,4 @@ public class ITJdbcTableReaderTest extends LocalFileMetadataTestCase implements
         return ISourceAware.ID_JDBC;
     }
 
-    @SuppressWarnings("deprecation")
-    protected static H2Connection newH2Connection() throws DatabaseUnitException {
-        H2Connection h2Conn = new H2Connection(h2Connection, null);
-        h2Conn.getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new TestH2DataTypeFactory());
-        h2Conn.getConfig().setFeature(DatabaseConfig.FEATURE_DATATYPE_WARNING, false);
-        return h2Conn;
-    }
-
-    public static class TestH2DataTypeFactory extends H2DataTypeFactory {
-        @Override
-        public DataType createDataType(int sqlType, String sqlTypeName, String tableName, String columnName)
-                throws DataTypeException {
-
-            if ((columnName.startsWith("COL") || columnName.startsWith("col")) && sqlType == Types.BIGINT) {
-                return DataType.INTEGER;
-            }
-            return super.createDataType(sqlType, sqlTypeName);
-        }
-    }
-
 }