ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [10/10] incubator-ignite git commit: # IGNITE-32: Tests for db metadata parsing and XML generation.
Date Thu, 29 Jan 2015 03:51:30 GMT
# IGNITE-32: Tests for db metadata parsing and XML generation.


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

Branch: refs/heads/ignite-32
Commit: e716d82787d48016c4f620574b6ef6104611d221
Parents: e28ddd2
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Thu Jan 29 10:51:13 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Thu Jan 29 10:51:13 2015 +0700

----------------------------------------------------------------------
 .../ignite/schema/generator/XmlGenerator.java   |   4 +-
 .../apache/ignite/schema/model/PojoField.java   |   2 +-
 .../schema/load/BaseSchemaLoaderSelfTest.java   | 135 ++++++++
 .../load/generator/PojoGeneratorSelfTest.java   | 137 ++------
 .../load/generator/XmlGeneratorSelfTest.java    |  29 +-
 .../apache/ignite/schema/load/model/Ignite.xml  | 321 +++++++++++++++++++
 .../ignite/schema/load/model/Primitives.txt     |  10 +-
 .../load/parser/DbMetadataParserSelfTest.java   |  95 +++++-
 8 files changed, 606 insertions(+), 127 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e716d827/modules/schema-load/src/main/java/org/apache/ignite/schema/generator/XmlGenerator.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/generator/XmlGenerator.java
b/modules/schema-load/src/main/java/org/apache/ignite/schema/generator/XmlGenerator.java
index 340bee1..c372ad2 100644
--- a/modules/schema-load/src/main/java/org/apache/ignite/schema/generator/XmlGenerator.java
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/generator/XmlGenerator.java
@@ -49,9 +49,9 @@ public class XmlGenerator {
             "    contributor license agreements.  See the NOTICE file distributed with\n"
+
             "    this work for additional information regarding copyright ownership.\n" +
             "    The ASF licenses this file to You under the Apache License, Version 2.0\n"
+
-            "    (the \"License\" + you may not use this file except in compliance with\n"
+
+            "    (the \"License\"); you may not use this file except in compliance with\n"
+
             "    the License.  You may obtain a copy of the License at\n\n" +
-            "         http://www.apache.org/licenses/LICENSE-2.0\n\n" +
+            "        http://www.apache.org/licenses/LICENSE-2.0\n\n" +
             "    Unless required by applicable law or agreed to in writing, software\n" +
             "    distributed under the License is distributed on an \"AS IS\" BASIS,\n" +
             "    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
+

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e716d827/modules/schema-load/src/main/java/org/apache/ignite/schema/model/PojoField.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/model/PojoField.java
b/modules/schema-load/src/main/java/org/apache/ignite/schema/model/PojoField.java
index 4768dfb..89c0647 100644
--- a/modules/schema-load/src/main/java/org/apache/ignite/schema/model/PojoField.java
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/model/PojoField.java
@@ -375,7 +375,7 @@ public class PojoField {
     }
 
     /**
-     * @return {@code true}
+     * @return {@code true} if type of field is primitive type.
      */
     public boolean primitive() {
         return PRIMITIVES.contains(javaTypeName());

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e716d827/modules/schema-load/src/test/java/org/apache/ignite/schema/load/BaseSchemaLoaderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/test/java/org/apache/ignite/schema/load/BaseSchemaLoaderSelfTest.java
b/modules/schema-load/src/test/java/org/apache/ignite/schema/load/BaseSchemaLoaderSelfTest.java
new file mode 100644
index 0000000..b074093
--- /dev/null
+++ b/modules/schema-load/src/test/java/org/apache/ignite/schema/load/BaseSchemaLoaderSelfTest.java
@@ -0,0 +1,135 @@
+/*
+ * 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.ignite.schema.load;
+
+import junit.framework.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.schema.model.PojoDescriptor;
+import org.apache.ignite.schema.parser.DatabaseMetadataParser;
+import org.apache.ignite.schema.ui.*;
+
+import java.io.*;
+import java.sql.*;
+import java.util.List;
+
+import static org.apache.ignite.schema.ui.MessageBox.Result.*;
+
+/**
+ * Base functional for ignite-schema-loader tests.
+ */
+public class BaseSchemaLoaderSelfTest extends TestCase {
+    /** Default connection URL (value is <tt>jdbc:h2:mem:jdbcCacheStore;DB_CLOSE_DELAY=-1</tt>).
*/
+    private static final String DFLT_CONN_URL = "jdbc:h2:mem:autoCacheStore;DB_CLOSE_DELAY=-1";
+
+    /** Path to temp folder where generated POJOs will be saved. */
+    protected static final String OUT_DIR_PATH =
+        String.format("%s/ignite-schema-loader/out", System.getProperty("java.io.tmpdir"));
+
+    /** Auto confirmation of file conflicts. */
+    protected ConfirmCallable askOverwrite = new ConfirmCallable(null, "") {
+        @Override public MessageBox.Result confirm(String msg) {
+            return YES_TO_ALL;
+        }
+    };
+
+    /** List of generated for test database POJO objects. */
+    protected List<PojoDescriptor> pojoLst;
+
+    /** {@inheritDoc} */
+    @Override public void setUp() throws Exception {
+        Class.forName("org.h2.Driver");
+
+        Connection conn = DriverManager.getConnection(DFLT_CONN_URL, "sa", "");
+
+        Statement stmt = conn.createStatement();
+
+        stmt.executeUpdate("CREATE TABLE PRIMITIVES (pk INTEGER PRIMARY KEY, " +
+            " boolCol BOOLEAN NOT NULL," +
+            " byteCol TINYINT NOT NULL," +
+            " shortCol SMALLINT NOT NULL," +
+            " intCol INTEGER NOT NULL, " +
+            " longCol BIGINT NOT NULL," +
+            " floatCol REAL NOT NULL," +
+            " doubleCol DOUBLE NOT NULL," +
+            " doubleCol2 DOUBLE NOT NULL, " +
+            " bigDecimalCol DECIMAL(10, 0)," +
+            " strCol VARCHAR(10)," +
+            " dateCol DATE," +
+            " timeCol TIME," +
+            " tsCol TIMESTAMP, " +
+            " arrCol BINARY(10))");
+
+        stmt.executeUpdate("CREATE TABLE OBJECTS (pk INTEGER PRIMARY KEY, " +
+            " boolCol BOOLEAN," +
+            " byteCol TINYINT," +
+            " shortCol SMALLINT," +
+            " intCol INTEGER," +
+            " longCol BIGINT," +
+            " floatCol REAL," +
+            " doubleCol DOUBLE," +
+            " doubleCol2 DOUBLE," +
+            " bigDecimalCol DECIMAL(10, 0)," +
+            " strCol VARCHAR(10), " +
+            " dateCol DATE," +
+            " timeCol TIME," +
+            " tsCol TIMESTAMP," +
+            " arrCol BINARY(10))");
+
+        conn.commit();
+
+        U.closeQuiet(stmt);
+
+        pojoLst = DatabaseMetadataParser.parse(conn, false);
+
+        U.closeQuiet(conn);
+    }
+
+    /**
+     * Compare files by lines.
+     *
+     * @param exp Stream to read of expected file from test resources.
+     * @param generated Generated file instance.
+     * @param excludePtrn Marker string to exclude lines from comparing.
+     * @return true if generated file correspond to expected.
+     */
+    protected boolean compareFilesInt(InputStream exp, File generated, String excludePtrn)
{
+        try (BufferedReader baseReader = new BufferedReader(new InputStreamReader(exp)))
{
+            try (BufferedReader generatedReader = new BufferedReader(new FileReader(generated)))
{
+                String baseLine;
+
+                while ((baseLine = baseReader.readLine()) != null) {
+                    String generatedLine = generatedReader.readLine();
+
+                    if (!baseLine.equals(generatedLine) && !baseLine.contains(excludePtrn)
+                            && !generatedLine.contains(excludePtrn)) {
+                        System.out.println("Expected: " + baseLine);
+                        System.out.println("Generated: " + generatedLine);
+
+                        return false;
+                    }
+                }
+
+                return true;
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+
+            return false;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e716d827/modules/schema-load/src/test/java/org/apache/ignite/schema/load/generator/PojoGeneratorSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/test/java/org/apache/ignite/schema/load/generator/PojoGeneratorSelfTest.java
b/modules/schema-load/src/test/java/org/apache/ignite/schema/load/generator/PojoGeneratorSelfTest.java
index 5984641..310f885 100644
--- a/modules/schema-load/src/test/java/org/apache/ignite/schema/load/generator/PojoGeneratorSelfTest.java
+++ b/modules/schema-load/src/test/java/org/apache/ignite/schema/load/generator/PojoGeneratorSelfTest.java
@@ -17,118 +17,43 @@
 
 package org.apache.ignite.schema.load.generator;
 
-import junit.framework.TestCase;
-import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.schema.generator.PojoGenerator;
+import org.apache.ignite.schema.load.BaseSchemaLoaderSelfTest;
 import org.apache.ignite.schema.model.PojoDescriptor;
-import org.apache.ignite.schema.parser.DatabaseMetadataParser;
-import org.apache.ignite.schema.ui.ConfirmCallable;
-import org.apache.ignite.schema.ui.MessageBox;
 
-import java.io.*;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.Statement;
-import java.util.List;
-
-import static org.apache.ignite.schema.ui.MessageBox.Result.YES_TO_ALL;
+import java.io.File;
 
 /**
  * Tests for POJO generator.
  */
-public class PojoGeneratorSelfTest extends TestCase {
-    /** Default connection URL (value is <tt>jdbc:h2:mem:jdbcCacheStore;DB_CLOSE_DELAY=-1</tt>).
*/
-    protected static final String DFLT_CONN_URL = "jdbc:h2:mem:autoCacheStore;DB_CLOSE_DELAY=-1";
-
-    /** File separator. */
-    private static final String PS = File.separator;
-
-    /** Path to temp folder where generated POJOs will be saved. */
-    private static final String OUT_DIR_PATH = System.getProperty("java.io.tmpdir") + PS
+
-        "ignite-schema-loader" + PS + "out";
-
+public class PojoGeneratorSelfTest extends BaseSchemaLoaderSelfTest {
     /** Marker string to skip date generation while comparing.*/
     private static final String GEN_PTRN = "Code generated by Apache Ignite Schema Load utility";
 
-    /** Connection to in-memory H2 database. */
-    private Connection conn;
-
-    /** {@inheritDoc} */
-    @Override public void setUp() throws Exception {
-        Class.forName("org.h2.Driver");
-
-        conn = DriverManager.getConnection(DFLT_CONN_URL, "sa", "");
-
-        Statement stmt = conn.createStatement();
-
-        stmt.executeUpdate("CREATE TABLE PRIMITIVES (pk INTEGER PRIMARY KEY, " +
-            " boolCol BOOLEAN NOT NULL," +
-            " byteCol TINYINT NOT NULL," +
-            " shortCol SMALLINT NOT NULL," +
-            " intCol INTEGER NOT NULL, " +
-            " longCol BIGINT NOT NULL," +
-            " floatCol REAL NOT NULL," +
-            " doubleCol DOUBLE NOT NULL," +
-            " doubleCol2 DOUBLE NOT NULL, " +
-            " bigDecimalCol DECIMAL(10, 0)," +
-            " strCol VARCHAR(10)," +
-            " dateCol DATE," +
-            " timeCol TIME," +
-            " tsCol TIMESTAMP, " +
-            " arrCol BINARY(10))");
-
-        stmt.executeUpdate("CREATE TABLE OBJECTS (pk INTEGER PRIMARY KEY, " +
-            " boolCol BOOLEAN," +
-            " byteCol TINYINT," +
-            " shortCol SMALLINT," +
-            " intCol INTEGER," +
-            " longCol BIGINT," +
-            " floatCol REAL," +
-            " doubleCol DOUBLE," +
-            " doubleCol2 DOUBLE," +
-            " bigDecimalCol DECIMAL(10, 0)," +
-            " strCol VARCHAR(10), " +
-            " dateCol DATE," +
-            " timeCol TIME," +
-            " tsCol TIMESTAMP," +
-            " arrCol BINARY(10))");
-
-        conn.commit();
-
-        U.closeQuiet(stmt);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void tearDown() throws Exception {
-        U.closeQuiet(conn);
-    }
-
     /**
      * Test that POJOs generated correctly.
      */
     public void testPojoGeneration() throws Exception {
-        List<PojoDescriptor> pojos = DatabaseMetadataParser.parse(conn, true);
-
-        ConfirmCallable askOverwrite = new ConfirmCallable(null, "") {
-            @Override public MessageBox.Result confirm(String msg) {
-                return YES_TO_ALL;
-            }
-        };
-
         String pkg = "org.apache.ignite.schema.load.model";
-        String intPath = "org" + PS + "apache" + PS + "ignite" + PS + "schema" + PS + "load"
+ PS + "model";
+        String intPath = "org/apache/ignite/schema/load/model";
 
-        for (PojoDescriptor pojo : pojos) {
-            if (!pojo.valueClassName().isEmpty()) {
+        Boolean containsSchema = false;
+
+        for (PojoDescriptor pojo : pojoLst) {
+            if (pojo.valueClassName().isEmpty())
+                containsSchema = true;
+            else {
                 PojoGenerator.generate(pojo, OUT_DIR_PATH, pkg, true, true, askOverwrite);
 
-                assertTrue("Generated POJO files does not accordance to predefined for type
" + pojo.keyClassName(),
-                        compareFiles(pojo.keyClassName(), intPath));
+                assertTrue("Generated key class POJO content is differ from expected for
type " + pojo.keyClassName(),
+                        compareFiles(pojo.keyClassName(), intPath, GEN_PTRN));
 
-                assertTrue("Generated POJO files does not accordance to predefined for type
" + pojo.valueClassName(),
-                        compareFiles(pojo.valueClassName(), intPath));
+                assertTrue("Generated value class POJO content is differ from expected for
type " + pojo.valueClassName(),
+                        compareFiles(pojo.valueClassName(), intPath, GEN_PTRN));
             }
         }
+
+        assertTrue("Generated POJOs does not contains schema.", containsSchema);
     }
 
     /**
@@ -136,32 +61,10 @@ public class PojoGeneratorSelfTest extends TestCase {
      * @param intPath Int path.
      * @return {@code true} if generated POJO as expected.
      */
-    private boolean compareFiles(String typeName, String intPath) {
-        String relPath = intPath + PS + typeName;
-
-        try (BufferedReader baseReader = new BufferedReader(new InputStreamReader(
-                getClass().getResourceAsStream("/" + relPath + ".txt")))) {
-            try (BufferedReader generatedReader = new BufferedReader(new FileReader(OUT_DIR_PATH
+ PS + relPath + ".java"))) {
-                String baseLine;
-
-                while ((baseLine = baseReader.readLine()) != null) {
-                    String generatedLine = generatedReader.readLine();
-
-                    if (!baseLine.equals(generatedLine) && !baseLine.contains(GEN_PTRN)
-                        && !generatedLine.contains(GEN_PTRN)) {
-                        System.out.println("Expected: " + baseLine);
-                        System.out.println("Generated: " + generatedLine);
-
-                        return false;
-                    }
-                }
-
-                return true;
-            }
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
+    private boolean compareFiles(String typeName, String intPath, String excludePtrn) {
+        String relPath = intPath + "/" + typeName;
 
-        return false;
+        return compareFilesInt(getClass().getResourceAsStream("/" + relPath + ".txt"),
+                new File(OUT_DIR_PATH + "/" + relPath + ".java"), excludePtrn);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e716d827/modules/schema-load/src/test/java/org/apache/ignite/schema/load/generator/XmlGeneratorSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/test/java/org/apache/ignite/schema/load/generator/XmlGeneratorSelfTest.java
b/modules/schema-load/src/test/java/org/apache/ignite/schema/load/generator/XmlGeneratorSelfTest.java
index d0b1af5..6722a34 100644
--- a/modules/schema-load/src/test/java/org/apache/ignite/schema/load/generator/XmlGeneratorSelfTest.java
+++ b/modules/schema-load/src/test/java/org/apache/ignite/schema/load/generator/XmlGeneratorSelfTest.java
@@ -17,9 +17,36 @@
 
 package org.apache.ignite.schema.load.generator;
 
+import org.apache.ignite.cache.query.*;
+import org.apache.ignite.schema.generator.*;
+import org.apache.ignite.schema.load.*;
+import org.apache.ignite.schema.model.*;
+
+import java.io.*;
+import java.util.*;
+
 /**
  * Tests for XML generator.
  */
-public class XmlGeneratorSelfTest {
+public class XmlGeneratorSelfTest extends BaseSchemaLoaderSelfTest {
+    /**
+     * Test that XML generated correctly.
+     */
+    public void testXmlGeneration() throws Exception {
+        Collection<CacheQueryTypeMetadata> all = new ArrayList<>();
+
+        // Generate XML.
+        for (PojoDescriptor pojo : pojoLst)
+            if (!pojo.valueClassName().isEmpty())
+                all.add(pojo.metadata(true));
+
+        String fileName = "Ignite.xml";
+
+        XmlGenerator.generate("org.apache.ignite.schema.load.model", all, new File(OUT_DIR_PATH,
fileName),
+            askOverwrite);
 
+        assertTrue("Generated XML file content is differ from expected one",
+            compareFilesInt(getClass().getResourceAsStream("/org/apache/ignite/schema/load/model/"
+ fileName),
+                new File(OUT_DIR_PATH + "/" + fileName), "XML generated by Apache Ignite
Schema Load utility"));
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e716d827/modules/schema-load/src/test/java/org/apache/ignite/schema/load/model/Ignite.xml
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/test/java/org/apache/ignite/schema/load/model/Ignite.xml
b/modules/schema-load/src/test/java/org/apache/ignite/schema/load/model/Ignite.xml
new file mode 100644
index 0000000..27d30ce
--- /dev/null
+++ b/modules/schema-load/src/test/java/org/apache/ignite/schema/load/model/Ignite.xml
@@ -0,0 +1,321 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<!--
+    XML generated by Apache Ignite Schema Load utility: 01/28/2015
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans 
+                           http://www.springframework.org/schema/beans/spring-beans.xsd">
+    <bean class="org.apache.ignite.cache.query.CacheQueryTypeMetadata">
+        <property name="type" value="org.apache.ignite.schema.load.model.Objects"/>
+        <property name="keyType" value="org.apache.ignite.schema.load.model.ObjectsKey"/>
+        <property name="schema" value="PUBLIC"/>
+        <property name="tableName" value="OBJECTS"/>
+        <property name="keyDescriptors">
+            <list>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="pk"/>
+                    <property name="javaType" value="int"/>
+                    <property name="dbName" value="PK"/>
+                    <property name="dbType" value="4"/>
+                </bean>
+            </list>
+        </property>
+        <property name="valueDescriptors">
+            <list>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="pk"/>
+                    <property name="javaType" value="int"/>
+                    <property name="dbName" value="PK"/>
+                    <property name="dbType" value="4"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="boolcol"/>
+                    <property name="javaType" value="java.lang.Boolean"/>
+                    <property name="dbName" value="BOOLCOL"/>
+                    <property name="dbType" value="16"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="bytecol"/>
+                    <property name="javaType" value="java.lang.Byte"/>
+                    <property name="dbName" value="BYTECOL"/>
+                    <property name="dbType" value="-6"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="shortcol"/>
+                    <property name="javaType" value="java.lang.Short"/>
+                    <property name="dbName" value="SHORTCOL"/>
+                    <property name="dbType" value="5"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="intcol"/>
+                    <property name="javaType" value="java.lang.Integer"/>
+                    <property name="dbName" value="INTCOL"/>
+                    <property name="dbType" value="4"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="longcol"/>
+                    <property name="javaType" value="java.lang.Long"/>
+                    <property name="dbName" value="LONGCOL"/>
+                    <property name="dbType" value="-5"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="floatcol"/>
+                    <property name="javaType" value="java.lang.Float"/>
+                    <property name="dbName" value="FLOATCOL"/>
+                    <property name="dbType" value="7"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="doublecol"/>
+                    <property name="javaType" value="java.lang.Double"/>
+                    <property name="dbName" value="DOUBLECOL"/>
+                    <property name="dbType" value="8"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="doublecol2"/>
+                    <property name="javaType" value="java.lang.Double"/>
+                    <property name="dbName" value="DOUBLECOL2"/>
+                    <property name="dbType" value="8"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="bigdecimalcol"/>
+                    <property name="javaType" value="java.math.BigDecimal"/>
+                    <property name="dbName" value="BIGDECIMALCOL"/>
+                    <property name="dbType" value="3"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="strcol"/>
+                    <property name="javaType" value="java.lang.String"/>
+                    <property name="dbName" value="STRCOL"/>
+                    <property name="dbType" value="12"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="datecol"/>
+                    <property name="javaType" value="java.sql.Date"/>
+                    <property name="dbName" value="DATECOL"/>
+                    <property name="dbType" value="91"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="timecol"/>
+                    <property name="javaType" value="java.sql.Time"/>
+                    <property name="dbName" value="TIMECOL"/>
+                    <property name="dbType" value="92"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="tscol"/>
+                    <property name="javaType" value="java.sql.Timestamp"/>
+                    <property name="dbName" value="TSCOL"/>
+                    <property name="dbType" value="93"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="arrcol"/>
+                    <property name="javaType" value="java.lang.Object"/>
+                    <property name="dbName" value="ARRCOL"/>
+                    <property name="dbType" value="-3"/>
+                </bean>
+            </list>
+        </property>
+        <property name="queryFields">
+            <map>
+                <entry key="pk" value="int"/>
+                <entry key="boolcol" value="java.lang.Boolean"/>
+                <entry key="bytecol" value="java.lang.Byte"/>
+                <entry key="shortcol" value="java.lang.Short"/>
+                <entry key="intcol" value="java.lang.Integer"/>
+                <entry key="longcol" value="java.lang.Long"/>
+                <entry key="floatcol" value="java.lang.Float"/>
+                <entry key="doublecol" value="java.lang.Double"/>
+                <entry key="doublecol2" value="java.lang.Double"/>
+                <entry key="bigdecimalcol" value="java.math.BigDecimal"/>
+                <entry key="strcol" value="java.lang.String"/>
+                <entry key="datecol" value="java.sql.Date"/>
+                <entry key="timecol" value="java.sql.Time"/>
+                <entry key="tscol" value="java.sql.Timestamp"/>
+                <entry key="arrcol" value="java.lang.Object"/>
+            </map>
+        </property>
+        <property name="ascendingFields">
+            <map>
+                <entry key="pk" value="int"/>
+            </map>
+        </property>
+        <property name="groups">
+            <map>
+                <entry key="primaryKeyC">
+                    <map>
+                        <entry key="pk">
+                            <bean class="org.apache.ignite.lang.IgniteBiTuple">
+                                <constructor-arg value="int"/>
+                                <constructor-arg value="false"/>
+                            </bean>
+                        </entry>
+                    </map>
+                </entry>
+            </map>
+        </property>
+    </bean>
+    <bean class="org.apache.ignite.cache.query.CacheQueryTypeMetadata">
+        <property name="type" value="org.apache.ignite.schema.load.model.Primitives"/>
+        <property name="keyType" value="org.apache.ignite.schema.load.model.PrimitivesKey"/>
+        <property name="schema" value="PUBLIC"/>
+        <property name="tableName" value="PRIMITIVES"/>
+        <property name="keyDescriptors">
+            <list>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="pk"/>
+                    <property name="javaType" value="int"/>
+                    <property name="dbName" value="PK"/>
+                    <property name="dbType" value="4"/>
+                </bean>
+            </list>
+        </property>
+        <property name="valueDescriptors">
+            <list>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="pk"/>
+                    <property name="javaType" value="int"/>
+                    <property name="dbName" value="PK"/>
+                    <property name="dbType" value="4"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="boolcol"/>
+                    <property name="javaType" value="boolean"/>
+                    <property name="dbName" value="BOOLCOL"/>
+                    <property name="dbType" value="16"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="bytecol"/>
+                    <property name="javaType" value="byte"/>
+                    <property name="dbName" value="BYTECOL"/>
+                    <property name="dbType" value="-6"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="shortcol"/>
+                    <property name="javaType" value="short"/>
+                    <property name="dbName" value="SHORTCOL"/>
+                    <property name="dbType" value="5"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="intcol"/>
+                    <property name="javaType" value="int"/>
+                    <property name="dbName" value="INTCOL"/>
+                    <property name="dbType" value="4"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="longcol"/>
+                    <property name="javaType" value="long"/>
+                    <property name="dbName" value="LONGCOL"/>
+                    <property name="dbType" value="-5"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="floatcol"/>
+                    <property name="javaType" value="float"/>
+                    <property name="dbName" value="FLOATCOL"/>
+                    <property name="dbType" value="7"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="doublecol"/>
+                    <property name="javaType" value="double"/>
+                    <property name="dbName" value="DOUBLECOL"/>
+                    <property name="dbType" value="8"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="doublecol2"/>
+                    <property name="javaType" value="double"/>
+                    <property name="dbName" value="DOUBLECOL2"/>
+                    <property name="dbType" value="8"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="bigdecimalcol"/>
+                    <property name="javaType" value="java.math.BigDecimal"/>
+                    <property name="dbName" value="BIGDECIMALCOL"/>
+                    <property name="dbType" value="3"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="strcol"/>
+                    <property name="javaType" value="java.lang.String"/>
+                    <property name="dbName" value="STRCOL"/>
+                    <property name="dbType" value="12"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="datecol"/>
+                    <property name="javaType" value="java.sql.Date"/>
+                    <property name="dbName" value="DATECOL"/>
+                    <property name="dbType" value="91"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="timecol"/>
+                    <property name="javaType" value="java.sql.Time"/>
+                    <property name="dbName" value="TIMECOL"/>
+                    <property name="dbType" value="92"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="tscol"/>
+                    <property name="javaType" value="java.sql.Timestamp"/>
+                    <property name="dbName" value="TSCOL"/>
+                    <property name="dbType" value="93"/>
+                </bean>
+                <bean class="org.apache.ignite.cache.query.CacheQueryTypeDescriptor">
+                    <property name="javaName" value="arrcol"/>
+                    <property name="javaType" value="java.lang.Object"/>
+                    <property name="dbName" value="ARRCOL"/>
+                    <property name="dbType" value="-3"/>
+                </bean>
+            </list>
+        </property>
+        <property name="queryFields">
+            <map>
+                <entry key="pk" value="int"/>
+                <entry key="boolcol" value="boolean"/>
+                <entry key="bytecol" value="byte"/>
+                <entry key="shortcol" value="short"/>
+                <entry key="intcol" value="int"/>
+                <entry key="longcol" value="long"/>
+                <entry key="floatcol" value="float"/>
+                <entry key="doublecol" value="double"/>
+                <entry key="doublecol2" value="double"/>
+                <entry key="bigdecimalcol" value="java.math.BigDecimal"/>
+                <entry key="strcol" value="java.lang.String"/>
+                <entry key="datecol" value="java.sql.Date"/>
+                <entry key="timecol" value="java.sql.Time"/>
+                <entry key="tscol" value="java.sql.Timestamp"/>
+                <entry key="arrcol" value="java.lang.Object"/>
+            </map>
+        </property>
+        <property name="ascendingFields">
+            <map>
+                <entry key="pk" value="int"/>
+            </map>
+        </property>
+        <property name="groups">
+            <map>
+                <entry key="primaryKeyD">
+                    <map>
+                        <entry key="pk">
+                            <bean class="org.apache.ignite.lang.IgniteBiTuple">
+                                <constructor-arg value="int"/>
+                                <constructor-arg value="false"/>
+                            </bean>
+                        </entry>
+                    </map>
+                </entry>
+            </map>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e716d827/modules/schema-load/src/test/java/org/apache/ignite/schema/load/model/Primitives.txt
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/test/java/org/apache/ignite/schema/load/model/Primitives.txt
b/modules/schema-load/src/test/java/org/apache/ignite/schema/load/model/Primitives.txt
index 3a2a5d2..e4f0a79 100644
--- a/modules/schema-load/src/test/java/org/apache/ignite/schema/load/model/Primitives.txt
+++ b/modules/schema-load/src/test/java/org/apache/ignite/schema/load/model/Primitives.txt
@@ -44,7 +44,7 @@ public class Primitives implements Serializable {
     private int intcol;
 
     /** Value for longcol. */
-    private int longcol;
+    private long longcol;
 
     /** Value for floatcol. */
     private float floatcol;
@@ -89,7 +89,7 @@ public class Primitives implements Serializable {
         byte bytecol,
         short shortcol,
         int intcol,
-        int longcol,
+        long longcol,
         float floatcol,
         double doublecol,
         double doublecol2,
@@ -212,7 +212,7 @@ public class Primitives implements Serializable {
      *
      * @return Value for longcol.
      */
-    public int getLongcol() {
+    public long getLongcol() {
         return longcol;
     }
 
@@ -221,7 +221,7 @@ public class Primitives implements Serializable {
      *
      * @param longcol New value for longcol.
      */
-    public void setLongcol(int longcol) {
+    public void setLongcol(long longcol) {
         this.longcol = longcol;
     }
 
@@ -457,7 +457,7 @@ public class Primitives implements Serializable {
 
         res = 31 * res + intcol;
 
-        res = 31 * res + longcol;
+        res = 31 * res + (int)(longcol ^ (longcol >>> 32));
 
         res = 31 * res + (floatcol != +0.0f ? Float.floatToIntBits(floatcol) : 0);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e716d827/modules/schema-load/src/test/java/org/apache/ignite/schema/load/parser/DbMetadataParserSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/test/java/org/apache/ignite/schema/load/parser/DbMetadataParserSelfTest.java
b/modules/schema-load/src/test/java/org/apache/ignite/schema/load/parser/DbMetadataParserSelfTest.java
index 5c4dc23..eafb55f 100644
--- a/modules/schema-load/src/test/java/org/apache/ignite/schema/load/parser/DbMetadataParserSelfTest.java
+++ b/modules/schema-load/src/test/java/org/apache/ignite/schema/load/parser/DbMetadataParserSelfTest.java
@@ -17,9 +17,102 @@
 
 package org.apache.ignite.schema.load.parser;
 
+import org.apache.ignite.schema.load.*;
+import org.apache.ignite.schema.model.*;
+
+import java.math.*;
+import java.sql.Date;
+import java.sql.*;
+import java.util.*;
+
 /**
  * Tests for metadata parsing.
  */
-public class DbMetadataParserSelfTest {
+public class DbMetadataParserSelfTest extends BaseSchemaLoaderSelfTest {
+    /**
+     * Check that field is correspond to expected.
+     *
+     * @param field Field descriptor.
+     * @param name Expected field name.
+     * @param primitive Expected field primitive type.
+     * @param cls Expected field type.
+     */
+    private void checkField(PojoField field, String name, boolean primitive, Class<?>
cls) {
+        assertEquals("Name of field should be " + name, name, field.javaName());
+
+        assertEquals("Type of field should be " + cls.getName(), cls.getName(), field.javaTypeName());
+
+        assertEquals("Field primitive should be " + primitive, primitive, field.primitive());
+    }
+
+    /**
+     * Check that type is correspond to expected.
+     *
+     * @param type Type descriptor.
+     */
+    private void checkType(PojoDescriptor type) {
+        assertFalse("Type key class name should be defined", type.keyClassName().isEmpty());
+
+        assertFalse("Type value class name should be defined", type.valueClassName().isEmpty());
+
+        Collection<PojoField> keyFields = type.keyFields();
+
+        assertEquals("Key type should have 1 field", 1, keyFields.size());
+
+        checkField(keyFields.iterator().next(), "pk", true, int.class);
+
+        List<PojoField> fields = type.fields();
+
+        assertEquals("Value type should have 15 fields", 15, fields.size());
+
+        Iterator<PojoField> fieldsIt = fields.iterator();
+
+        checkField(fieldsIt.next(), "pk", true, int.class);
+
+        if ("Objects".equals(type.valueClassName())) {
+            checkField(fieldsIt.next(), "boolcol", false, Boolean.class);
+            checkField(fieldsIt.next(), "bytecol", false, Byte.class);
+            checkField(fieldsIt.next(), "shortcol", false, Short.class);
+            checkField(fieldsIt.next(), "intcol", false, Integer.class);
+            checkField(fieldsIt.next(), "longcol", false, Long.class);
+            checkField(fieldsIt.next(), "floatcol", false, Float.class);
+            checkField(fieldsIt.next(), "doublecol", false, Double.class);
+            checkField(fieldsIt.next(), "doublecol2", false, Double.class);
+        }
+        else {
+            checkField(fieldsIt.next(), "boolcol", true, boolean.class);
+            checkField(fieldsIt.next(), "bytecol", true, byte.class);
+            checkField(fieldsIt.next(), "shortcol", true, short.class);
+            checkField(fieldsIt.next(), "intcol", true, int.class);
+            checkField(fieldsIt.next(), "longcol", true, long.class);
+            checkField(fieldsIt.next(), "floatcol", true, float.class);
+            checkField(fieldsIt.next(), "doublecol", true, double.class);
+            checkField(fieldsIt.next(), "doublecol2", true, double.class);
+        }
+
+        checkField(fieldsIt.next(), "bigdecimalcol", false, BigDecimal.class);
+        checkField(fieldsIt.next(), "strcol", false, String.class);
+        checkField(fieldsIt.next(), "datecol", false, Date.class);
+        checkField(fieldsIt.next(), "timecol", false, Time.class);
+        checkField(fieldsIt.next(), "tscol", false, Timestamp.class);
+        checkField(fieldsIt.next(), "arrcol", false, Object.class);
+    }
+
+    /**
+     * Test that metadata generated correctly.
+     */
+    public void testCheckMetadata() {
+        assertEquals("Metadata should contain 3 element", 3, pojoLst.size());
+
+        Iterator<PojoDescriptor> it = pojoLst.iterator();
+
+        PojoDescriptor schema = it.next();
+
+        assertTrue("First element is schema description. Its class name should be empty",
+                schema.valueClassName().isEmpty());
+
+        checkType(it.next());
 
+        checkType(it.next());
+    }
 }


Mime
View raw message