empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1146996 - /incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenParserTest.java
Date Fri, 15 Jul 2011 07:49:09 GMT
Author: doebele
Date: Fri Jul 15 07:49:09 2011
New Revision: 1146996

URL: http://svn.apache.org/viewvc?rev=1146996&view=rev
Log:
EMPIREDB-110
patch submitted by Matt DeHoust

Added:
    incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenParserTest.java
  (with props)

Added: incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenParserTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenParserTest.java?rev=1146996&view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenParserTest.java
(added)
+++ incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenParserTest.java
Fri Jul 15 07:49:09 2011
@@ -0,0 +1,50 @@
+package org.apache.empire.db.codegen;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.List;
+
+import org.apache.empire.db.DBDatabase;
+import org.apache.empire.db.DBRelation;
+import org.apache.empire.db.DBTable;
+import org.apache.empire.db.DBRelation.DBReference;
+import org.junit.Before;
+import org.junit.Test;
+
+
+public class CodeGenParserTest {
+    private transient CodeGenParser parser;
+
+    @Before
+    public void setUp() throws Exception {
+        final CodeGenConfig config = new CodeGenConfig();
+        config.init("src/test/resources/testconfig.xml");
+        config.setDbSchema(null);
+        parser = new CodeGenParser(config);
+    }
+
+    @Test
+    public void testLoadDbModel() {
+        final DBDatabase db = parser.loadDbModel();
+
+        final DBTable departments = db.getTable("DEPARTMENTS");
+        final DBTable employees = db.getTable("EMPLOYEES");
+
+        assertNotNull("Expected DEPARTMENTS table.", departments);
+		assertNotNull("Expected EMPLOYEES table.", employees);
+
+        final List<DBRelation> relations = db.getRelations();
+        assertEquals("Should have EMPLOYEES->DEPARTMENTS relation.", 1, relations.size());
+
+        final DBRelation dbRelation = relations.get(0);
+        assertEquals("EMPLOYEES_DEPARTMENT_I_FK", dbRelation.getName());
+
+        final DBReference[] references = dbRelation.getReferences();
+        assertEquals("Should reference one column.", 1, references.length);
+
+        final DBReference dbReference = references[0];
+		assertEquals(dbReference.getSourceColumn(), employees.getColumn("DEPARTMENT_ID"));
+        assertEquals(dbReference.getTargetColumn(), departments.getColumn("DEPARTMENT_ID"));
+    }
+}

Propchange: incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenParserTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message