empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject empire-db git commit: EMPIREDB-257 fixed Unit-Test DBCommandTest
Date Fri, 30 Jun 2017 12:12:08 GMT
Repository: empire-db
Updated Branches:
  refs/heads/master 0c4337e2a -> 31cd18d44


EMPIREDB-257
fixed Unit-Test DBCommandTest


Project: http://git-wip-us.apache.org/repos/asf/empire-db/repo
Commit: http://git-wip-us.apache.org/repos/asf/empire-db/commit/31cd18d4
Tree: http://git-wip-us.apache.org/repos/asf/empire-db/tree/31cd18d4
Diff: http://git-wip-us.apache.org/repos/asf/empire-db/diff/31cd18d4

Branch: refs/heads/master
Commit: 31cd18d44549689d9204b9a21b9b425efaafa74e
Parents: 0c4337e
Author: Rainer Döbele <doebele@apache.org>
Authored: Fri Jun 30 14:12:04 2017 +0200
Committer: Rainer Döbele <doebele@apache.org>
Committed: Fri Jun 30 14:12:04 2017 +0200

----------------------------------------------------------------------
 .../java/org/apache/empire/db/DBCommand.java    |  2 +-
 .../org/apache/empire/db/DBCommandTest.java     | 96 ++++++--------------
 2 files changed, 30 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/empire-db/blob/31cd18d4/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
----------------------------------------------------------------------
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBCommand.java b/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
index b935e5e..712dc5c 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
@@ -1268,7 +1268,7 @@ public abstract class DBCommand extends DBCommandExpr
      
     protected void checkDatabase(DBExpr expr)
     {
-        if (expr.getDatabase().equals(this.getDatabase()))
+        if (getDatabase().equals(expr.getDatabase()))
             return;
         // not the same database
         throw new DatabaseMismatchException(this, expr);

http://git-wip-us.apache.org/repos/asf/empire-db/blob/31cd18d4/empire-db/src/test/java/org/apache/empire/db/DBCommandTest.java
----------------------------------------------------------------------
diff --git a/empire-db/src/test/java/org/apache/empire/db/DBCommandTest.java b/empire-db/src/test/java/org/apache/empire/db/DBCommandTest.java
index 9020aa1..2159013 100644
--- a/empire-db/src/test/java/org/apache/empire/db/DBCommandTest.java
+++ b/empire-db/src/test/java/org/apache/empire/db/DBCommandTest.java
@@ -18,15 +18,14 @@
  */
 package org.apache.empire.db;
 
-import org.apache.empire.data.DataType;
-import org.junit.Test;
-import org.w3c.dom.Element;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
 
 import java.util.ArrayList;
 import java.util.List;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import org.apache.empire.data.DataType;
+import org.junit.Test;
 
 /**
  * @author francisdb
@@ -40,9 +39,6 @@ public class DBCommandTest
 	{
 		MockDB mock = new MockDB();
 		mock.open(new MockDriver(), null);
-        DBColumn col = new MockDBColumn(null, "test");
-        DBColumn col2 = new MockDBColumn(null, "test2");
-        DBColumn col3 = new MockDBColumn(null, "test3");
 		
 		List<DBColumn> list = new ArrayList<DBColumn>();
 		DBCommand command = mock.createCommand();
@@ -50,76 +46,42 @@ public class DBCommandTest
 	    assertNull(command.getSelectExprList());
 	    
 		List<DBColumnExpr> list2 = new ArrayList<DBColumnExpr>();
-		list2.add(col);
-		list2.add(col2);
+		list2.add(mock.TABLE.COL1);
+		list2.add(mock.TABLE.COL3);
 		DBCommand command2 = mock.createCommand();
 		command2.select(list2);
 		assertEquals(2, command2.getSelectExprList().length);
 		
         DBCommand command3 = mock.createCommand();
-        command3.select(col, col2, col3);
-        command3.groupBy(col, col2, col2);
+        command3.select (mock.TABLE.getColumns());
+        command3.groupBy(mock.TABLE.COL1, mock.TABLE.COL2, mock.TABLE.COL2);
         assertEquals(3, command3.getSelectExprList().length);
         assertEquals(2, command3.groupBy.size());
 	}
 	
-	private class MockDB extends DBDatabase{
-        private static final long serialVersionUID = 1L;
-		
-	}
-	
-	
-	
-	private class MockDBColumn extends DBColumn{
-      private final static long serialVersionUID = 1L;
-
-	    public MockDBColumn(DBRowSet rowSet, String name)
-        {
-            super(rowSet, name);
-        }
+	private static class MockDB extends DBDatabase{
+        
+	    private static final long serialVersionUID = 1L;
 	    
-        @Override
-        public Element addXml(Element parent, long flags)
-        {
-            return null;
-        }
-
-        @Override
-        public Object validate(Object value)
-        {
-            return value;
-        }
-
-        @Override
-        public double getSize()
-        {
-            return 0;
-        }
-
-        @Override
-        public boolean isReadOnly()
-        {
-            return false;
-        }
-
-        @Override
-        public boolean isAutoGenerated()
-        {
-            return false;
-        }
-
-        @Override
-        public boolean isRequired()
-        {
-            return false;
-        }
+	    private final MockDBTable TABLE = new MockDBTable(this);
 
-        @Override
-        public DataType getDataType()
-        {
-            return null;
-        }
-	    
 	}
+	
+    private static class MockDBTable extends DBTable {
+        
+        private static final long serialVersionUID = 1L;
+        
+        private final DBColumn COL1; 
+        private final DBColumn COL2; 
+        private final DBColumn COL3; 
+        
+        public MockDBTable(MockDB db) {
+            super("MOCK_TABLE", db);
+            // add Columns
+            COL1 = addColumn("COL1", DataType.INTEGER,   0, true);
+            COL2 = addColumn("COL2", DataType.TEXT,     20, true);
+            COL3 = addColumn("COL3", DataType.DATETIME,  0, false);
+        }
+    }
 
 }


Mime
View raw message