[openjpa] branch master updated: move tests to junit4 style

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[openjpa] branch master updated: move tests to junit4 style

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 73582cc  move tests to junit4 style
73582cc is described below

commit 73582cc780d3c72af7a227890dde5180028edfd0
Author: Mark Struberg <[hidden email]>
AuthorDate: Mon Oct 22 13:24:51 2018 +0200

    move tests to junit4 style
---
 .../kernel/TestSQLStoreParamsSubstitution.java     |  10 +-
 .../kernel/TestUpdateManagerFlushException.java    | 137 +++++++++++++++++++--
 .../openjpa/jdbc/meta/TestMappingDefaultsImpl.java |  10 +-
 .../jdbc/sql/TestBooleanRepresentation.java        |   6 +-
 .../openjpa/jdbc/sql/TestDictionaryFactory.java    |  10 +-
 .../jdbc/sql/identifier/TestDBIdentifiers.java     |  10 +-
 6 files changed, 158 insertions(+), 25 deletions(-)

diff --git a/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/kernel/TestSQLStoreParamsSubstitution.java b/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/kernel/TestSQLStoreParamsSubstitution.java
index 06a9b33..8506e69 100644
--- a/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/kernel/TestSQLStoreParamsSubstitution.java
+++ b/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/kernel/TestSQLStoreParamsSubstitution.java
@@ -22,7 +22,10 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
 
 /**
  * <p>
@@ -30,12 +33,13 @@ import junit.framework.TestCase;
  * </p>
  */
 
-public class TestSQLStoreParamsSubstitution extends TestCase {
+public class TestSQLStoreParamsSubstitution {
 
     /**
      * Tests parameter substitution algorithm to make sure the input sql is NOT transformed
      * especially escape characters.
      */
+    @Test
     public void testParamSubstitute() {
 
         String sqlNrtns[][] = {
@@ -48,7 +52,7 @@ public class TestSQLStoreParamsSubstitution extends TestCase {
 //                    "[1]"
 //                },
                 {
-             "SELECT 'TRUE' AS VAL FROM DUAL WHERE '\\' = ? AND 'Y' = 'Y'",
+                    "SELECT 'TRUE' AS VAL FROM DUAL WHERE '\\' = ? AND 'Y' = 'Y'",
                     "[1]"
                 },
                 {
diff --git a/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/kernel/TestUpdateManagerFlushException.java b/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/kernel/TestUpdateManagerFlushException.java
index 1172699..b080639 100644
--- a/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/kernel/TestUpdateManagerFlushException.java
+++ b/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/kernel/TestUpdateManagerFlushException.java
@@ -20,19 +20,28 @@ package org.apache.openjpa.jdbc.kernel;
 
 import java.io.IOException;
 import java.io.ObjectOutput;
+import java.sql.Array;
+import java.sql.Blob;
 import java.sql.CallableStatement;
+import java.sql.Clob;
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
+import java.sql.NClob;
 import java.sql.PreparedStatement;
+import java.sql.SQLClientInfoException;
 import java.sql.SQLException;
 import java.sql.SQLWarning;
+import java.sql.SQLXML;
 import java.sql.Savepoint;
 import java.sql.Statement;
+import java.sql.Struct;
 import java.util.ArrayList;
 import java.util.BitSet;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.Executor;
 
 import org.apache.openjpa.enhance.PersistenceCapable;
 import org.apache.openjpa.enhance.StateManager;
@@ -50,7 +59,10 @@ import org.apache.openjpa.kernel.StoreContext;
 import org.apache.openjpa.meta.ClassMetaData;
 import org.apache.openjpa.util.Id;
 
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
 
 /**
  * <p>
@@ -65,24 +77,22 @@ import junit.framework.TestCase;
  * @author Albert Lee
  */
 
-public class TestUpdateManagerFlushException extends /* Abstract */TestCase {
+public class TestUpdateManagerFlushException {
 
     private TestUpdateManager updMgr;
 
-    @Override
+    @Before
     public void setUp() {
         updMgr = new TestUpdateManager();
     }
 
-    public void testDummy() {
-
-    }
 
     /**
      * Tests exception collection returns from UpdateManager flush method is in
      * the order the original exceptions are thrown.
      */
-    public void xtestAddRetrieve() {
+    @Test
+    public void testAddRetrieve() {
 
         Collection states = new ArrayList<OpenJPAStateManager>();
         states.add(new TestOpenJPAStateManager());
@@ -862,7 +872,115 @@ public class TestUpdateManagerFlushException extends /* Abstract */TestCase {
     /*
      * Scaffolding test connection.
      */
-    abstract class TestConnection implements Connection {
+    class TestConnection implements Connection {
+
+        @Override
+        public boolean isWrapperFor(Class<?> aClass) throws SQLException
+        {
+            return false;
+        }
+
+        @Override
+        public Clob createClob() throws SQLException
+        {
+            return null;
+        }
+
+        @Override
+        public Blob createBlob() throws SQLException
+        {
+            return null;
+        }
+
+        @Override
+        public NClob createNClob() throws SQLException
+        {
+            return null;
+        }
+
+        @Override
+        public SQLXML createSQLXML() throws SQLException
+        {
+            return null;
+        }
+
+        @Override
+        public boolean isValid(int i) throws SQLException
+        {
+            return false;
+        }
+
+        @Override
+        public void setClientInfo(String s, String s1) throws SQLClientInfoException
+        {
+
+        }
+
+        @Override
+        public void setClientInfo(Properties properties) throws SQLClientInfoException
+        {
+
+        }
+
+        @Override
+        public String getClientInfo(String s) throws SQLException
+        {
+            return null;
+        }
+
+        @Override
+        public Properties getClientInfo() throws SQLException
+        {
+            return null;
+        }
+
+        @Override
+        public Array createArrayOf(String s, Object[] objects) throws SQLException
+        {
+            return null;
+        }
+
+        @Override
+        public Struct createStruct(String s, Object[] objects) throws SQLException
+        {
+            return null;
+        }
+
+        @Override
+        public void setSchema(String s) throws SQLException
+        {
+
+        }
+
+        @Override
+        public String getSchema() throws SQLException
+        {
+            return null;
+        }
+
+        @Override
+        public void abort(Executor executor) throws SQLException
+        {
+
+        }
+
+        @Override
+        public void setNetworkTimeout(Executor executor, int i) throws SQLException
+        {
+
+        }
+
+        @Override
+        public int getNetworkTimeout() throws SQLException
+        {
+            return 0;
+        }
+
+        @Override
+        public <T> T unwrap(Class<T> aClass) throws SQLException
+        {
+            return null;
+        }
 
         @Override
         public void clearWarnings() throws SQLException {
@@ -1064,8 +1182,7 @@ public class TestUpdateManagerFlushException extends /* Abstract */TestCase {
 
         @Override
         public Connection getConnection() {
-            throw new RuntimeException("TestConnection is abstract for JDK6");
-//            return new TestConnection();
+            return new TestConnection();
         }
 
         @Override
diff --git a/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestMappingDefaultsImpl.java b/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestMappingDefaultsImpl.java
index dd3ab8a..f779a04 100644
--- a/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestMappingDefaultsImpl.java
+++ b/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestMappingDefaultsImpl.java
@@ -23,18 +23,18 @@ import org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl;
 import org.apache.openjpa.jdbc.schema.Column;
 import org.apache.openjpa.jdbc.schema.Table;
 
-import junit.framework.TestCase;
+import org.junit.Test;
 
-public class TestMappingDefaultsImpl extends TestCase {
+import static org.junit.Assert.assertFalse;
+
+public class TestMappingDefaultsImpl {
 
-    @Override
-    public void setUp() {
-    }
 
     /**
      * For databases that accept only short column names, test avoidance of
      * duplicate column names when populating the table with long column names.
      */
+    @Test
     public void testPopulateWithLongColumnNames() {
         MappingDefaultsImpl mapping = new MappingDefaultsImpl();
         JDBCConfiguration conf = new JDBCConfigurationImpl(false, false);
diff --git a/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/TestBooleanRepresentation.java b/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/TestBooleanRepresentation.java
index 1a1df91..90a44b4 100644
--- a/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/TestBooleanRepresentation.java
+++ b/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/TestBooleanRepresentation.java
@@ -28,14 +28,15 @@ import java.sql.SQLException;
 import org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement;
 
 import junit.framework.Assert;
-import junit.framework.TestCase;
+import org.junit.Test;
 
 /**
  * Test for the {@link org.apache.openjpa.jdbc.sql.BooleanRepresentation} factory and default impls
  */
-public class TestBooleanRepresentation  extends TestCase {
+public class TestBooleanRepresentation {
 
 
+    @Test
     public void testBooleanRepresentation() throws Exception {
 
         checkBooleanRepresentation("BOOLEAN", Boolean.class, Boolean.TRUE, Boolean.FALSE);
@@ -145,6 +146,7 @@ public class TestBooleanRepresentation  extends TestCase {
         }
     }
 
+    @SuppressWarnings("unused") // used via configuration
     public static class DummyTestBooleanRepresentation implements BooleanRepresentation<String> {
         @Override
         public void setBoolean(PreparedStatement stmnt, int columnIndex, boolean val) throws SQLException {
diff --git a/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/TestDictionaryFactory.java b/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/TestDictionaryFactory.java
index c5ed791..625a68a 100644
--- a/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/TestDictionaryFactory.java
+++ b/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/TestDictionaryFactory.java
@@ -20,9 +20,12 @@ package org.apache.openjpa.jdbc.sql;
 
 import java.lang.reflect.Method;
 
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
 
-public class TestDictionaryFactory extends TestCase {
+import static org.junit.Assert.*;
+
+public class TestDictionaryFactory {
 
     private String[][] testMatrix =  {
         // Generic url
@@ -172,7 +175,7 @@ public class TestDictionaryFactory extends TestCase {
 
     private static Method getProtocol;
 
-    @Override
+    @Before
     public void setUp() {
         try {
             getProtocol = DBDictionaryFactory.class.getDeclaredMethod(
@@ -190,6 +193,7 @@ public class TestDictionaryFactory extends TestCase {
      *
      * @author Albert Lee
      */
+    @Test
     public void testUrl2Dictionary() {
         for (int i = 0; i < testMatrix.length; ++i) {
             try {
diff --git a/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/identifier/TestDBIdentifiers.java b/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/identifier/TestDBIdentifiers.java
index a95f900..66fb1d2 100644
--- a/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/identifier/TestDBIdentifiers.java
+++ b/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/identifier/TestDBIdentifiers.java
@@ -21,15 +21,17 @@ package org.apache.openjpa.jdbc.sql.identifier;
 import org.apache.openjpa.jdbc.identifier.DBIdentifier;
 import org.apache.openjpa.jdbc.identifier.DBIdentifier.DBIdentifierType;
 import org.apache.openjpa.jdbc.identifier.QualifiedDBIdentifier;
+import org.junit.Test;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
 
 /**
  * Test operations on DBIdentifier and QualifiedDBIdentifier.
  *
  */
-public class TestDBIdentifiers extends TestCase {
+public class TestDBIdentifiers {
 
+    @Test
     public void testSchemaOps() {
         // Use a schema name with punctuation.  It will get normalized with
         // delimiters.
@@ -53,6 +55,7 @@ public class TestDBIdentifiers extends TestCase {
         assertFalse(s2 instanceof QualifiedDBIdentifier);
     }
 
+    @Test
     public void testTableOps() {
         DBIdentifier name = DBIdentifier.newTable("table");
         assertEquals("table", name.getName());
@@ -105,6 +108,7 @@ public class TestDBIdentifiers extends TestCase {
         assertFalse(p1.equals(DBIdentifier.NULL));
     }
 
+    @Test
     public void testColumnOps() {
 
         DBIdentifier c0 = DBIdentifier.newColumn("\"col.1\"");
@@ -129,6 +133,7 @@ public class TestDBIdentifiers extends TestCase {
 
     }
 
+    @Test
     public void testDBIdentifierOps() {
 
         // Test truncate
@@ -187,6 +192,7 @@ public class TestDBIdentifiers extends TestCase {
 
     }
 
+    @Test
     public void testPathOps() {
 
         // Test equals operator with case insensitive names