You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2020/10/24 04:31:21 UTC

[shardingsphere] branch master updated: new OracleDatabaseMetaDataDialectHandlerTest and complete to add assertGetSchema(), assertFormatTableNamePattern() , assertGetQuoteCharacter() (#7902)

This is an automated email from the ASF dual-hosted git repository.

zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 712fbee   new OracleDatabaseMetaDataDialectHandlerTest and complete to add assertGetSchema(), assertFormatTableNamePattern() ,assertGetQuoteCharacter() (#7902)
712fbee is described below

commit 712fbee392c3abde180e5c34ca14eb70ab7f99a4
Author: dos2002 <do...@qq.com>
AuthorDate: Sat Oct 24 12:30:51 2020 +0800

     new OracleDatabaseMetaDataDialectHandlerTest and complete to add assertGetSchema(), assertFormatTableNamePattern() ,assertGetQuoteCharacter() (#7902)
    
    Co-authored-by: dos2002 <we...@gmail.com>
---
 ...AbstractDatabaseMetaDataDialectHandlerTest.java |  2 +
 .../OracleDatabaseMetaDataDialectHandlerTest.java  | 52 ++++++++++++++++++++++
 2 files changed, 54 insertions(+)

diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/model/physical/jdbc/handler/AbstractDatabaseMetaDataDialectHandlerTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/model/physical/jdbc/handler/AbstractDatabaseMetaDataDialectHandlerTest.java
index 322ef6a..93543e6 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/model/physical/jdbc/handler/AbstractDatabaseMetaDataDialectHandlerTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/model/physical/jdbc/handler/AbstractDatabaseMetaDataDialectHandlerTest.java
@@ -35,6 +35,8 @@ public abstract class AbstractDatabaseMetaDataDialectHandlerTest {
     
     protected static final String TABLE_NAME_PATTERN = "t_order_0";
     
+    protected static final String USER_NAME = "demo_user";
+
     @Mock
     private Connection connection;
     
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/model/physical/jdbc/handler/OracleDatabaseMetaDataDialectHandlerTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/model/physical/jdbc/handler/OracleDatabaseMetaDataDialectHandlerTest.java
new file mode 100644
index 0000000..7cfa3e1
--- /dev/null
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/model/physical/jdbc/handler/OracleDatabaseMetaDataDialectHandlerTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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.shardingsphere.infra.metadata.model.physical.jdbc.handler;
+
+import org.apache.shardingsphere.infra.database.type.dialect.OracleDatabaseType;
+import org.apache.shardingsphere.sql.parser.sql.common.constant.QuoteCharacter;
+import org.junit.Test;
+
+import java.sql.SQLException;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.when;
+
+public final class OracleDatabaseMetaDataDialectHandlerTest extends AbstractDatabaseMetaDataDialectHandlerTest {
+    
+    @Test
+    public void assertGetSchema() throws SQLException {
+        when(getConnection().getSchema()).thenReturn(USER_NAME);
+        when(getConnection().getMetaData()).thenReturn(getDatabaseMetaData());
+        String oracleSchema = getSchema(new OracleDatabaseType());
+        assertThat(oracleSchema, is(USER_NAME));
+    }
+    
+    @Test
+    public void assertFormatTableNamePattern() {
+        String oracleTableNamePattern = formatTableNamePattern(new OracleDatabaseType());
+        assertThat(oracleTableNamePattern, is(TABLE_NAME_PATTERN.toUpperCase()));
+    }
+    
+    @Test
+    public void assertGetQuoteCharacter() {
+        QuoteCharacter oracleQuoteCharacter = getQuoteCharacter(new OracleDatabaseType());
+        assertThat(oracleQuoteCharacter.getStartDelimiter(), is("\""));
+        assertThat(oracleQuoteCharacter.getEndDelimiter(), is("\""));
+    }
+}