You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by zh...@apache.org on 2019/03/04 19:32:19 UTC

[geode] branch feature/GEODE-6481 created (now eb8836c)

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

zhouxj pushed a change to branch feature/GEODE-6481
in repository https://gitbox.apache.org/repos/asf/geode.git.


      at eb8836c  GEODE-6481: add tests to verify create jdbc mapping should get correct field type

This branch includes the following new commits:

     new eb8836c  GEODE-6481: add tests to verify create jdbc mapping should get correct field type

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[geode] 01/01: GEODE-6481: add tests to verify create jdbc mapping should get correct field type

Posted by zh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

zhouxj pushed a commit to branch feature/GEODE-6481
in repository https://gitbox.apache.org/repos/asf/geode.git

commit eb8836c8d58aa3001056f4d49ad914f182b071b6
Author: zhouxh <gz...@pivotal.io>
AuthorDate: Mon Mar 4 11:31:27 2019 -0800

    GEODE-6481: add tests to verify create jdbc mapping should get correct field type
---
 .../cli/CreateMappingCommandDUnitTest.java         | 80 ++++++++++++++++++++++
 1 file changed, 80 insertions(+)

diff --git a/geode-connectors/src/distributedTest/java/org/apache/geode/connectors/jdbc/internal/cli/CreateMappingCommandDUnitTest.java b/geode-connectors/src/distributedTest/java/org/apache/geode/connectors/jdbc/internal/cli/CreateMappingCommandDUnitTest.java
index 1e3e782..b3e514c 100644
--- a/geode-connectors/src/distributedTest/java/org/apache/geode/connectors/jdbc/internal/cli/CreateMappingCommandDUnitTest.java
+++ b/geode-connectors/src/distributedTest/java/org/apache/geode/connectors/jdbc/internal/cli/CreateMappingCommandDUnitTest.java
@@ -28,6 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import java.io.File;
 import java.io.IOException;
+import java.io.Serializable;
 import java.net.URISyntaxException;
 import java.sql.Connection;
 import java.sql.JDBCType;
@@ -50,6 +51,7 @@ import org.apache.geode.cache.configuration.CacheConfig;
 import org.apache.geode.cache.configuration.RegionAttributesType;
 import org.apache.geode.cache.configuration.RegionConfig;
 import org.apache.geode.connectors.jdbc.JdbcAsyncWriter;
+import org.apache.geode.connectors.jdbc.JdbcConnectorException;
 import org.apache.geode.connectors.jdbc.JdbcLoader;
 import org.apache.geode.connectors.jdbc.JdbcWriter;
 import org.apache.geode.connectors.jdbc.internal.JdbcConnectorService;
@@ -69,6 +71,7 @@ import org.apache.geode.test.compiler.JarBuilder;
 import org.apache.geode.test.dunit.IgnoredException;
 import org.apache.geode.test.dunit.rules.ClusterStartupRule;
 import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.junit.assertions.CommandResultAssert;
 import org.apache.geode.test.junit.categories.JDBCConnectorTest;
 import org.apache.geode.test.junit.rules.GfshCommandRule;
 import org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder;
@@ -82,6 +85,7 @@ public class CreateMappingCommandDUnitTest {
   private static final String EMPLOYEE_REGION = "employeeRegion";
   private static final String EMPLOYEE_LOWER = "employee";
   private static final String EMPLOYEE_UPPER = "EMPLOYEE";
+  private static final String EMPLOYEE_NUMERIC = "employeeNumeric";
   private static final String GROUP1_REGION = "group1Region";
   private static final String GROUP2_REGION = "group2Region";
   private static final String GROUP1_GROUP2_REGION = "group1Group2Region";
@@ -137,12 +141,16 @@ public class CreateMappingCommandDUnitTest {
     executeSql(
         "create table mySchema." + EMPLOYEE_UPPER
             + "(ID varchar(10) primary key, name varchar(10), AGE int)");
+    executeSql(
+        "create table mySchema." + EMPLOYEE_NUMERIC
+            + "(ID varchar(10) primary key, name varchar(10), AGE int, income real, refid bigint)");
   }
 
   private void teardownDatabase() {
     executeSql("drop table mySchema.myTable");
     executeSql("drop table mySchema." + EMPLOYEE_REGION);
     executeSql("drop table mySchema." + EMPLOYEE_UPPER);
+    executeSql("drop table mySchema." + EMPLOYEE_NUMERIC);
   }
 
   private void executeSql(String sql) {
@@ -775,6 +783,54 @@ public class CreateMappingCommandDUnitTest {
     }
   }
 
+  public static class EmployeeNumeric implements Serializable {
+    private String id;
+    private String name;
+    private int age;
+    private float income;
+    private long refid;
+
+    public EmployeeNumeric() {
+      // nothing
+    }
+
+    EmployeeNumeric(String id, String name, int age, float income, long refid) {
+      this.id = id;
+      this.name = name;
+      this.age = age;
+      this.income = income;
+      this.refid = refid;
+    }
+
+    String getId() {
+      return id;
+    }
+
+    String getName() {
+      return name;
+    }
+
+    int getAge() {
+      return age;
+    }
+
+    float getIncome() {
+      return income;
+    }
+
+    void setIncome(float income) {
+      this.income = income;
+    }
+
+    long getRefid() {
+      return refid;
+    }
+
+    void setRefid(long refid) {
+      this.refid = refid;
+    }
+  }
+
   public static class IdAndName implements PdxSerializable {
     private String id;
     private String name;
@@ -834,6 +890,30 @@ public class CreateMappingCommandDUnitTest {
       assertValidEmployeeMappingOnLocator(regionMapping, region1Name, null, false, false,
           "employeeRegion");
     });
+
+    csb = new CommandStringBuilder(DESCRIBE_MAPPING).addOption(REGION_NAME,
+        region1Name);
+    CommandResultAssert commandResultAssert = gfsh.executeAndAssertThat(csb.toString());
+    commandResultAssert.containsOutput("age       | INT      | AGE         | INTEGER   | true");
+  }
+
+  @Test
+  public void createMappingsWithoutPdxSerializableShouldFail() {
+    String region1Name = "region1";
+    setupReplicate(region1Name);
+
+    CommandStringBuilder csb = new CommandStringBuilder(CREATE_MAPPING);
+    csb.addOption(REGION_NAME, region1Name);
+    csb.addOption(DATA_SOURCE_NAME, "connection");
+    csb.addOption(TABLE_NAME, "employeeNumeric");
+    csb.addOption(PDX_NAME, EmployeeNumeric.class.getName());
+    csb.addOption(ID_NAME, "id");
+    csb.addOption(SCHEMA_NAME, "mySchema");
+    IgnoredException.addIgnoredException(JdbcConnectorException.class);
+
+    gfsh.executeAndAssertThat(csb.toString()).statusIsError()
+        .containsOutput(
+            "failing to register pdx metadata due to The instance is not PDX serializable");
   }
 
   @Test