mirror of https://github.com/apache/openjpa.git
move tests to junit4 style
This commit is contained in:
parent
b3edd42ee8
commit
73582cc780
|
@ -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]"
|
||||
},
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue