You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2013/05/17 12:25:16 UTC
svn commit: r1483727 [2/3] - in
/db/derby/code/trunk/java/testing/org/apache/derbyTesting:
functionTests/harness/ functionTests/suites/
functionTests/tests/junitTests/compatibility/
functionTests/tests/junitTests/derbyNet/ functionTests/tests/lang/ fun...
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeadlockModeTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeadlockModeTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeadlockModeTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeadlockModeTest.java Fri May 17 10:25:14 2013
@@ -55,7 +55,7 @@ public class DeadlockModeTest extends Ba
private int startedCount = 0;
/* Exceptions thrown by threads (if any) */
- private LinkedList listExceptions = new LinkedList();
+ private LinkedList<Exception> listExceptions = new LinkedList<Exception>();
/**
* Creates a new instance of DeadlockModeTest
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DynamicLikeOptimizationTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DynamicLikeOptimizationTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DynamicLikeOptimizationTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DynamicLikeOptimizationTest.java Fri May 17 10:25:14 2013
@@ -26,7 +26,6 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -406,7 +405,8 @@ public class DynamicLikeOptimizationTest
"(name LIKE ? escape '\\') and (source like ? escape '\\') " +
"order by source asc, name asc");
- HashMap inputOutput = new HashMap();
+ HashMap<String[], Object[][]> inputOutput =
+ new HashMap<String[], Object[][]>();
inputOutput.put(
new String[] {"%", "%"},
new Object[][] {
@@ -447,10 +447,9 @@ public class DynamicLikeOptimizationTest
new Object[][] { CEI_ROWS[8] });
inputOutput.put(new String[] {"Bogus", "Name"}, new Object[][] {});
- for (Iterator it = inputOutput.entrySet().iterator(); it.hasNext(); ) {
- Map.Entry entry = (Map.Entry) it.next();
- String[] args = (String[]) entry.getKey();
- Object[][] rows = (Object[][]) entry.getValue();
+ for (Map.Entry<String[], Object[][]> entry : inputOutput.entrySet()) {
+ String[] args = entry.getKey();
+ Object[][] rows = entry.getValue();
ps.setObject(1, args[0]);
ps.setObject(2, args[1]);
JDBC.assertFullResultSet(ps.executeQuery(), rows, false);
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsHelper.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsHelper.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsHelper.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsHelper.java Fri May 17 10:25:14 2013
@@ -28,19 +28,9 @@ import java.sql.Connection;
import java.sql.Statement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
-import java.sql.DriverManager;
import java.util.ArrayList;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.apache.derby.iapi.util.StringUtil;
-import org.apache.derby.catalog.DefaultInfo;
+import java.util.Arrays;
import org.apache.derbyTesting.junit.BaseJDBCTestCase;
-import org.apache.derbyTesting.junit.JDBC;
-import org.apache.derbyTesting.junit.DatabasePropertyTestSetup;
-import org.apache.derbyTesting.junit.JDBC;
-import org.apache.derbyTesting.junit.TestConfiguration;
-import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
-import org.apache.derbyTesting.junit.JDBC;
import org.apache.derby.catalog.types.RoutineAliasInfo;
@@ -498,14 +488,9 @@ public class GeneratedColumnsHelper exte
* Fill an ArrayList from an array.
* </p>
*/
- protected ArrayList fill( Object[] raw )
+ protected <T> ArrayList<T> fill( T[] raw )
{
- ArrayList result = new ArrayList();
- int count = raw.length;
-
- for ( int i = 0; i < count; i++ ) { result.add( raw[ i ] ); }
-
- return result;
+ return new ArrayList<T>(Arrays.asList(raw));
}
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java Fri May 17 10:25:14 2013
@@ -67,7 +67,7 @@ public class GeneratedColumnsTest extend
private static int _minusCounter;
- private static ArrayList _triggerReports = new ArrayList();
+ private static ArrayList<String> _triggerReports = new ArrayList<String>();
private String _clearingProcName;
private String _triggerReportVTIName;
@@ -5714,7 +5714,7 @@ public class GeneratedColumnsTest extend
for ( int i = 0; i < count; i++ )
{
- rows[ i ] = new String[] { (String) _triggerReports.get( i ) };
+ rows[ i ] = new String[] { _triggerReports.get( i ) };
}
return new StringArrayVTI( new String[] { "contents" }, rows );
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeTest.java Fri May 17 10:25:14 2013
@@ -1582,14 +1582,14 @@ public class GrantRevokeTest extends Bas
String[] getAllColumns(String schema, String table) throws SQLException
{
DatabaseMetaData dbmd = getConnection().getMetaData();
- ArrayList columnList = new ArrayList();
+ ArrayList<String> columnList = new ArrayList<String>();
ResultSet rs = dbmd.getColumns( (String) null, schema, table, (String) null);
while(rs.next())
{
columnList.add(rs.getString(4));
}
- return (String[]) columnList.toArray(new String[0]);
+ return columnList.toArray(new String[columnList.size()]);
}
/**
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByTest.java Fri May 17 10:25:14 2013
@@ -2244,11 +2244,13 @@ public class GroupByTest extends BaseJDB
for (int i = 0; i < queries.length; i++) {
final String query1 = queries[i];
- final List rows1 = resultArrayToList(expectedResults[i]);
+ final List<List<String>> rows1 =
+ resultArrayToList(expectedResults[i]);
for (int j = 0; j < queries.length; j++) {
final String query2 = queries[j];
- final List rows2 = resultArrayToList(expectedResults[j]);
+ final List<List<String>> rows2 =
+ resultArrayToList(expectedResults[j]);
String query = query1 + " UNION " + query2;
String[][] rows = union(rows1, rows2, false);
@@ -2319,10 +2321,10 @@ public class GroupByTest extends BaseJDB
* @return the union of {@code rows1} and {@code rows2}, as a {@code
* String[][]}
*/
- private static String[][] union(Collection rows1,
- Collection rows2,
+ private static String[][] union(Collection<List<String>> rows1,
+ Collection<List<String>> rows2,
boolean all) {
- Collection bagOrSet = newBagOrSet(all);
+ Collection<List<String>> bagOrSet = newBagOrSet(all);
bagOrSet.addAll(rows1);
bagOrSet.addAll(rows2);
return toResultArray(bagOrSet);
@@ -2339,14 +2341,14 @@ public class GroupByTest extends BaseJDB
* @return the difference between {@code rows1} and {@code rows2}, as a
* {@code String[][]}
*/
- private static String[][] except(Collection rows1,
- Collection rows2,
+ private static String[][] except(Collection<List<String>> rows1,
+ Collection<List<String>> rows2,
boolean all) {
- Collection bagOrSet = newBagOrSet(all);
+ Collection<List<String>> bagOrSet = newBagOrSet(all);
bagOrSet.addAll(rows1);
// could use removeAll() for sets, but need other behaviour for bags
- for (Iterator it = rows2.iterator(); it.hasNext(); ) {
- bagOrSet.remove(it.next());
+ for (List<String> row : rows2) {
+ bagOrSet.remove(row);
}
return toResultArray(bagOrSet);
}
@@ -2362,14 +2364,13 @@ public class GroupByTest extends BaseJDB
* @return the intersection between {@code rows1} and {@code rows2}, as a
* {@code String[][]}
*/
- private static String[][] intersect(Collection rows1,
- Collection rows2,
+ private static String[][] intersect(Collection<List<String>> rows1,
+ Collection<List<String>> rows2,
boolean all) {
- Collection bagOrSet = newBagOrSet(all);
- List copyOfRows2 = new ArrayList(rows2);
+ Collection<List<String>> bagOrSet = newBagOrSet(all);
+ List<List<String>> copyOfRows2 = new ArrayList<List<String>>(rows2);
// could use retainAll() for sets, but need other behaviour for bags
- for (Iterator it = rows1.iterator(); it.hasNext(); ) {
- Object x = it.next();
+ for (List<String> x : rows1) {
if (copyOfRows2.remove(x)) {
// x is present in both of the collections, add it
bagOrSet.add(x);
@@ -2384,11 +2385,11 @@ public class GroupByTest extends BaseJDB
* @param bag tells whether or not the collection should be a bag
* @return a {@code List} if a bag is requested, or a {@code Set} otherwise
*/
- private static Collection newBagOrSet(boolean bag) {
+ private static Collection<List<String>> newBagOrSet(boolean bag) {
if (bag) {
- return new ArrayList();
+ return new ArrayList<List<String>>();
} else {
- return new HashSet();
+ return new HashSet<List<String>>();
}
}
@@ -2400,12 +2401,12 @@ public class GroupByTest extends BaseJDB
* @param rows a collection of rows, where each row is a list of strings
* @return a {@code String[][]} containing the same values as {@code rows}
*/
- private static String[][] toResultArray(Collection rows) {
+ private static String[][] toResultArray(Collection<List<String>> rows) {
String[][] results = new String[rows.size()][];
- Iterator it = rows.iterator();
+ Iterator<List<String>> it = rows.iterator();
for (int i = 0; i < results.length; i++) {
- List row = (List) it.next();
- results[i] = (String[]) row.toArray(new String[row.size()]);
+ List<String> row = it.next();
+ results[i] = row.toArray(new String[row.size()]);
}
return results;
}
@@ -2419,8 +2420,9 @@ public class GroupByTest extends BaseJDB
* results from a query}
* @return the values of {@code results} in a list of lists
*/
- private static List resultArrayToList(String[][] results) {
- ArrayList rows = new ArrayList(results.length);
+ private static List<List<String>> resultArrayToList(String[][] results) {
+ ArrayList<List<String>> rows =
+ new ArrayList<List<String>>(results.length);
for (int i = 0; i < results.length; i++) {
rows.add(Arrays.asList(results[i]));
}
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/InListMultiProbeTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/InListMultiProbeTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/InListMultiProbeTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/InListMultiProbeTest.java Fri May 17 10:25:14 2013
@@ -33,7 +33,6 @@ import java.util.BitSet;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.Set;
@@ -150,7 +149,7 @@ public class InListMultiProbeTest extend
* key id, that means an IN list with "N" values in it will return
* greater than N rows.
*/
- protected TreeMap foreignIdToRowsMap;
+ protected TreeMap<String, List<DataRow>> foreignIdToRowsMap;
/**
* Public constructor required for running test as standalone JUnit.
@@ -337,7 +336,7 @@ public class InListMultiProbeTest extend
*/
readAllRows(createStatement());
- List strategies = new ArrayList();
+ List<QueryStrategy> strategies = new ArrayList<QueryStrategy>();
Random ran = new Random(2);
Connection c = getConnection();
@@ -1425,16 +1424,15 @@ public class InListMultiProbeTest extend
* @param strategies Different query strategies to execute
* @param cnt Size of the IN list with which to query.
*/
- private void testOneSize(List strategies, int cnt) throws SQLException
+ private void testOneSize(List<QueryStrategy> strategies, int cnt)
+ throws SQLException
{
if (cnt > allIds.length)
return;
String failedStrategy = null;
Statement st = createStatement();
- for (Iterator iter = strategies.iterator(); iter.hasNext();)
- {
- QueryStrategy strategy = (QueryStrategy) iter.next();
+ for (QueryStrategy strategy : strategies) {
int numRows = strategy.testSize(cnt);
ResultSet rs = st.executeQuery(GET_RUNTIME_STATS_QUERY);
@@ -1475,14 +1473,14 @@ public class InListMultiProbeTest extend
throws SQLException
{
ResultSet rs = stmt.executeQuery(SELECT_ALL);
- foreignIdToRowsMap = new TreeMap();
+ foreignIdToRowsMap = new TreeMap<String, List<DataRow>>();
while (rs.next())
{
DataRow c = new DataRow(rs);
- List list = (List) foreignIdToRowsMap.get(c.foreign_key_uuid);
+ List<DataRow> list = foreignIdToRowsMap.get(c.foreign_key_uuid);
if (list == null)
{
- list = new ArrayList();
+ list = new ArrayList<DataRow>();
foreignIdToRowsMap.put(c.foreign_key_uuid, list);
}
list.add(c);
@@ -1711,22 +1709,17 @@ public class InListMultiProbeTest extend
* as well. This comparator object allows that sort to happen using
* the JVM's own sort algorithm.
*/
- Comparator rowComparator = new Comparator()
+ Comparator<String[]> rowComparator = new Comparator<String[]>()
{
- public int compare(Object o1, Object o2)
+ public int compare(String[] o1, String[] o2)
{
/* "6" here is the index of the "id" field w.r.t the array
* returned from DataRow.getColumns().
*/
- long id1 = Long.valueOf(((String[])o1)[6]).longValue();
- long id2 = Long.valueOf(((String[])o2)[6]).longValue();
+ Long id1 = Long.valueOf(o1[6]);
+ Long id2 = Long.valueOf(o2[6]);
- if (id1 < id2)
- return -1;
- else if (id1 == id2)
- return 0;
- else
- return 1;
+ return id1.compareTo(id2);
}
};
@@ -1750,7 +1743,7 @@ public class InListMultiProbeTest extend
public final int testSize(int size)
throws SQLException
{
- Set s = new HashSet();
+ Set<String> s = new HashSet<String>();
/* A Set contains no duplicate elements. So if we, in our
* randomness, try to insert a duplicate value, it will be
@@ -1799,14 +1792,15 @@ public class InListMultiProbeTest extend
throws SQLException
{
// This will be a list of String arrays.
- List expected = new ArrayList(foreignIdToRowsMap.size());
+ List<String[]> expected =
+ new ArrayList<String[]>(foreignIdToRowsMap.size());
// Search the in-memory map to find all expected rows.
for (int i = 0; i < foreignIds.length; i++)
{
- List list = (List)foreignIdToRowsMap.get(foreignIds[i]);
+ List<DataRow> list = foreignIdToRowsMap.get(foreignIds[i]);
for (int j = list.size() - 1; j >= 0; j--)
- expected.add(((DataRow)list.get(j)).getColumns());
+ expected.add(list.get(j).getColumns());
}
// Sort the rows.
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/PredicateTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/PredicateTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/PredicateTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/PredicateTest.java Fri May 17 10:25:14 2013
@@ -146,8 +146,8 @@ public class PredicateTest extends BaseJ
* @param stats the runtime statistics
* @return a list of all operators
*/
- private List extractOperators(String stats) throws IOException {
- ArrayList ops = new ArrayList();
+ private List<String> extractOperators(String stats) throws IOException {
+ ArrayList<String> ops = new ArrayList<String>();
BufferedReader r = new BufferedReader(new StringReader(stats));
String line;
while ((line = r.readLine()) != null) {
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RolesConferredPrivilegesTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RolesConferredPrivilegesTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RolesConferredPrivilegesTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RolesConferredPrivilegesTest.java Fri May 17 10:25:14 2013
@@ -2642,7 +2642,7 @@ public class RolesConferredPrivilegesTes
{
Connection c = getConnection();
DatabaseMetaData dbmd = c.getMetaData();
- ArrayList columnList = new ArrayList();
+ ArrayList<String> columnList = new ArrayList<String>();
ResultSet rs =
dbmd.getColumns( (String) null, schema, table, (String) null);
@@ -2651,7 +2651,7 @@ public class RolesConferredPrivilegesTes
columnList.add(rs.getString(4));
}
- return (String[]) columnList.toArray(new String[]{});
+ return columnList.toArray(new String[columnList.size()]);
}
/**
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SecurityPolicyReloadingTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SecurityPolicyReloadingTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SecurityPolicyReloadingTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SecurityPolicyReloadingTest.java Fri May 17 10:25:14 2013
@@ -23,8 +23,6 @@ package org.apache.derbyTesting.function
import java.io.File;
import java.security.AccessControlException;
-import java.security.AccessController;
-import java.security.PrivilegedExceptionAction;
import java.sql.Connection;
import java.sql.CallableStatement;
import java.sql.SQLException;
@@ -64,26 +62,6 @@ public class SecurityPolicyReloadingTest
//
///////////////////////////////////////////////////////////////////////////////////
- public static class PropReadingAction implements PrivilegedExceptionAction
- {
- private final String _propName;
-
- public PropReadingAction( String propName )
- {
- _propName = propName;
- }
-
- //
- // This will throw an AccessControlException if we don't have
- // privilege to read the property.
- //
- public Object run()
- throws Exception
- {
- return System.getProperty( _propName );
- }
- }
-
///////////////////////////////////////////////////////////////////////////////////
//
// STATE
@@ -312,25 +290,13 @@ public class SecurityPolicyReloadingTest
throws Exception
{
try {
- String propValue = readProperty( "SecurityPolicyReloadingTest.property" );
-
+ getSystemProperty("SecurityPolicyReloadingTest.property");
return true;
}
catch (AccessControlException ace) { return false; }
}
/**
- * Read a system property.
- */
- public static String readProperty( String propName )
- throws Exception
- {
- PropReadingAction action = new PropReadingAction( propName );
-
- return (String) AccessController.doPrivileged( action );
- }
-
- /**
* Try to change the policy file.
*/
private void changePolicyFile( Connection conn, String newPolicyFileName, boolean shouldSucceed, String expectedSQLState )
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java Fri May 17 10:25:14 2013
@@ -21,20 +21,15 @@ limitations under the License.
package org.apache.derbyTesting.functionTests.tests.lang;
-import java.lang.reflect.*;
import java.io.*;
import java.sql.*;
import java.text.NumberFormat;
import java.util.Arrays;
-import java.util.ArrayList;
import org.apache.derby.shared.common.reference.JDBC40Translation;
import org.apache.derbyTesting.junit.BaseJDBCTestCase;
-import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
-import org.apache.derbyTesting.junit.DatabasePropertyTestSetup;
import org.apache.derbyTesting.junit.Decorator;
import org.apache.derbyTesting.junit.JDBC;
-import org.apache.derbyTesting.junit.TestConfiguration;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -2682,50 +2677,19 @@ public class TableFunctionTest extends B
throws Exception
{
println( "\nExpecting correct function metadata from " + functionName );
- ResultSet rs = getFunctions( null, "APP", functionName );
+ ResultSet rs =
+ _databaseMetaData.getFunctions( null, "APP", functionName );
JDBC.assertFullResultSet( rs, expectedGetFunctionsResult, false );
rs.close();
println( "\nExpecting correct function column metadata from " + functionName );
- rs = getFunctionColumns( null, "APP", functionName, "%" );
+ rs = _databaseMetaData.getFunctionColumns( null, "APP", functionName, "%" );
//prettyPrint( getConnection(), getFunctionColumns( null, "APP", functionName, "%" ) );
JDBC.assertFullResultSet( rs, expectedGetFunctionColumnsResult, false );
rs.close();
}
/**
- * Call DatabaseMetaData.getFunctions(). We do this by reflection because
- * the calls exist in our JDBC3.0 implementations even though they don't
- * appear in the JDBC 3.0 java.sql.DatabaseMetaData api.
- */
- public ResultSet getFunctions( String catalog, String schemaPattern, String functionNamePattern )
- throws Exception
- {
- Class metadataClass = _databaseMetaData.getClass();
- Method method = metadataClass.getMethod( "getFunctions", new Class[] { String.class, String.class, String.class } );
- ResultSet result = (ResultSet) method.invoke( _databaseMetaData, new Object[] { catalog, schemaPattern, functionNamePattern } );
-
- return result;
- }
-
- /**
- * Call DatabaseMetaData.getFunctionColumnss(). We do this by reflection because
- * the calls exist in our JDBC3.0 implementations even though they don't
- * appear in the JDBC 3.0 java.sql.DatabaseMetaData api.
- */
- public ResultSet getFunctionColumns
- ( String catalog, String schemaPattern, String functionNamePattern, String columnNamePattern )
- throws Exception
- {
- Class metadataClass = _databaseMetaData.getClass();
- Method method = metadataClass.getMethod( "getFunctionColumns", new Class[] { String.class, String.class, String.class, String.class } );
- ResultSet result = (ResultSet) method.invoke
- ( _databaseMetaData, new Object[] { catalog, schemaPattern, functionNamePattern, columnNamePattern } );
-
- return result;
- }
-
- /**
* Drop the schema that we are going to use so that we can recreate it.
*/
private void dropSchema()
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java Fri May 17 10:25:14 2013
@@ -65,7 +65,8 @@ public class TriggerTest extends BaseJDB
* Thread local that a trigger can access to
* allow recording information about the firing.
*/
- private static ThreadLocal TRIGGER_INFO = new ThreadLocal();
+ private static ThreadLocal<List<String>> TRIGGER_INFO =
+ new ThreadLocal<List<String>>();
StringBuffer listOfCreatedTriggers = new StringBuffer();
@@ -314,7 +315,7 @@ public class TriggerTest extends BaseJDB
int triggerCount = createRandomTriggers()[0];
- List info = new ArrayList();
+ List<String> info = new ArrayList<String>();
TRIGGER_INFO.set(info);
// Check ordering with a single row.
@@ -469,7 +470,7 @@ public class TriggerTest extends BaseJDB
int beforeCount = createRandomTriggers()[1];
- List info = new ArrayList();
+ List<String> info = new ArrayList<String>();
TRIGGER_INFO.set(info);
// constraint violation on primary key
@@ -592,7 +593,7 @@ public class TriggerTest extends BaseJDB
*/
public static void logTriggerInfo(String info)
{
- ((List) TRIGGER_INFO.get()).add(info);
+ TRIGGER_INFO.get().add(info);
}
/**
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TruncateTableTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TruncateTableTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TruncateTableTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TruncateTableTest.java Fri May 17 10:25:14 2013
@@ -26,9 +26,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
import junit.framework.Test;
import org.apache.derbyTesting.junit.BaseJDBCTestCase;
import org.apache.derbyTesting.junit.DatabasePropertyTestSetup;
@@ -313,8 +311,8 @@ public class TruncateTableTest extends B
s.execute("create table d4275(x int)");
// Object used by the main thread to tell the helper thread to stop.
- // The helper thread stops once the list is non-empty.
- final List stop = Collections.synchronizedList(new ArrayList());
+ // The helper thread stops once the value is set to true.
+ final AtomicBoolean stop = new AtomicBoolean();
// Holder for anything thrown by the run() method in the helper thread.
final Throwable[] error = new Throwable[1];
@@ -327,7 +325,7 @@ public class TruncateTableTest extends B
Thread t = new Thread() {
public void run() {
try {
- while (stop.isEmpty()) {
+ while (!stop.get()) {
JDBC.assertEmpty(ps.executeQuery());
}
} catch (Throwable t) {
@@ -348,7 +346,7 @@ public class TruncateTableTest extends B
}
} finally {
// We're done, so tell the helper thread to stop.
- stop.add(Boolean.TRUE);
+ stop.set(true);
}
t.join();
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UDTTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UDTTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UDTTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UDTTest.java Fri May 17 10:25:14 2013
@@ -1237,7 +1237,8 @@ public class UDTTest extends GeneratedC
public static HashMap makeHashMap() { return new HashMap(); }
- public static HashMap putValue( HashMap map, String key, String value )
+ public static HashMap putValue(
+ HashMap<String, String> map, String key, String value)
{
map.put( key, value );
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XplainStatisticsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XplainStatisticsTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XplainStatisticsTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XplainStatisticsTest.java Fri May 17 10:25:14 2013
@@ -665,9 +665,9 @@ public class XplainStatisticsTest extend
DocumentBuilder builder = factory.newDocumentBuilder();
InputSource xml = new InputSource(
- (InputStream)AccessController.doPrivileged
- (new java.security.PrivilegedExceptionAction(){
- public Object run()throws Exception{
+ AccessController.doPrivileged
+ (new java.security.PrivilegedExceptionAction<InputStream>(){
+ public InputStream run()throws Exception{
return new FileInputStream(
SupportFilesSetup.getReadWriteURL(file+".xml").getPath()
);}})
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/build.xml?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/build.xml (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/build.xml Fri May 17 10:25:14 2013
@@ -84,6 +84,7 @@
<pathelement path="${junit}"/>
</classpath>
<include name="${this.dir}/*.java"/>
+ <compilerarg value="-Xlint"/>
</javac>
</target>
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/userDefMethods.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/userDefMethods.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/userDefMethods.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/userDefMethods.java Fri May 17 10:25:14 2013
@@ -34,10 +34,9 @@ public class userDefMethods
{
Connection con = DriverManager.getConnection("jdbc:default:connection");
PreparedStatement statement = null;
- String delStr = null;
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT c1 from new org.apache.derby.catalog.TriggerOldTransitionRows() AS EQ");
- Vector keys = new Vector();
+ Vector<Long> keys = new Vector<Long>();
while(rs.next()){
keys.addElement(new Long(rs.getLong(1)));
}
@@ -45,8 +44,7 @@ public class userDefMethods
statement =
con.prepareStatement("delete from t1 where c1 = ?");
- for(int i = 0; i < keys.size() ; i++){
- long key = ((Long)keys.elementAt(i)).longValue();
+ for (long key : keys) {
statement.setLong(1, key);
statement.executeUpdate();
}
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/wisconsin.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/wisconsin.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/wisconsin.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/wisconsin.java Fri May 17 10:25:14 2013
@@ -220,10 +220,10 @@ public class wisconsin {
protected static InputStream openTestResource(final URL url)
throws PrivilegedActionException
{
- return (InputStream)AccessController.doPrivileged
- (new java.security.PrivilegedExceptionAction(){
+ return AccessController.doPrivileged
+ (new java.security.PrivilegedExceptionAction<InputStream>(){
- public Object run() throws IOException{
+ public InputStream run() throws IOException {
return url.openStream();
}
@@ -241,10 +241,10 @@ public class wisconsin {
protected static URL getTestResource(final String name)
{
- return (URL)AccessController.doPrivileged
- (new java.security.PrivilegedAction(){
+ return AccessController.doPrivileged
+ (new java.security.PrivilegedAction<URL>(){
- public Object run(){
+ public URL run(){
return this.getClass().getClassLoader().
getResource(name);
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/BlobMemTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/BlobMemTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/BlobMemTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/BlobMemTest.java Fri May 17 10:25:14 2013
@@ -74,7 +74,7 @@ public class BlobMemTest extends BaseJDB
if (lengthless) {
Method m = null;
try {
- Class c = ps.getClass();
+ Class<?> c = ps.getClass();
m = c.getMethod("setBinaryStream",new Class[] {Integer.TYPE,
InputStream.class});
} catch (NoSuchMethodException e) {
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/ClobMemTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/ClobMemTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/ClobMemTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/ClobMemTest.java Fri May 17 10:25:14 2013
@@ -77,7 +77,7 @@ public class ClobMemTest extends BaseJDB
if (lengthless) {
Method m = null;
try {
- Class c = ps.getClass();
+ Class<?> c = ps.getClass();
m = c.getMethod("setCharacterStream",new Class[] {Integer.TYPE,
InputStream.class});
} catch (NoSuchMethodException e) {
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/ConnectionHandling.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/ConnectionHandling.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/ConnectionHandling.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/ConnectionHandling.java Fri May 17 10:25:14 2013
@@ -45,7 +45,7 @@ public class ConnectionHandling {
conn.close();
conn = null;
- ArrayList list = new ArrayList();
+ ArrayList<Connection> list = new ArrayList<Connection>();
list.ensureCapacity(30000);
Properties p = new Properties();
@@ -121,8 +121,7 @@ public class ConnectionHandling {
int alreadyClosed = 0;
for (int i = 0; i < list.size(); i++)
{
- Connection c = (Connection) list.get(i);
- list.set(i, null);
+ Connection c = list.set(i, null);
if (c.isClosed())
alreadyClosed++;
else
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/build.xml?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/build.xml (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/build.xml Fri May 17 10:25:14 2013
@@ -58,6 +58,7 @@
<pathelement path="${junit}"/>
</classpath>
<include name="${derby.testing.functest.dir}/tests/memory/*.java"/>
+ <compilerarg value="-Xlint"/>
</javac>
</target>
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java Fri May 17 10:25:14 2013
@@ -26,7 +26,6 @@ import org.apache.derby.drda.NetworkServ
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Iterator;
import java.util.Properties;
import java.sql.*;
@@ -160,7 +159,7 @@ public class ReplicationRun extends Base
* waited for. Wait for these to complete in {@link #tearDown()} so that
* they don't interfere with subsequent test cases.
*/
- private ArrayList helperThreads = new ArrayList();
+ private ArrayList<Thread> helperThreads = new ArrayList<Thread>();
private String db_uid = null;
private String db_passwd = null;
@@ -207,10 +206,7 @@ public class ReplicationRun extends Base
stopServer(jvmVersion, derbyVersion,
masterServerHost, masterServerPort);
-
- // Wait for all threads to complete.
- for (Iterator it = helperThreads.iterator(); it.hasNext(); ) {
- Thread t = (Thread) it.next();
+ for (Thread t : helperThreads) {
t.join();
}
helperThreads = null;
@@ -573,7 +569,7 @@ public class ReplicationRun extends Base
final boolean isRemote = !testClientHost.equals("localhost");
final boolean isIjTest = (replicationTest.indexOf(".sql") >= 0);
- ArrayList cmd = new ArrayList();
+ ArrayList<String> cmd = new ArrayList<String>();
// For remote tests, we need to specify the Java VM to use and the
// classpath. For local tests, we'll just use the JVM and the classpath
@@ -670,7 +666,7 @@ public class ReplicationRun extends Base
final boolean isRemote = !serverHost.equals("localhost");
final boolean isIjTest = (replicationTest.indexOf(".sql") >= 0);
- ArrayList cmd = new ArrayList();
+ ArrayList<String> cmd = new ArrayList<String>();
// For remote tests, we need to specify the Java VM to use and the
// classpath. For local tests, we'll just use the JVM and the classpath
@@ -764,7 +760,7 @@ public class ReplicationRun extends Base
util.DEBUG("load: " + load);
- ArrayList cmd = new ArrayList();
+ ArrayList<String> cmd = new ArrayList<String>();
// For remote tests, we need to specify the Java VM to use and the
// classpath. For local tests, we'll just use the JVM and the classpath
@@ -1917,7 +1913,7 @@ public class ReplicationRun extends Base
String workingDirName = masterDatabasePath +FS+ dbSubDirPath;
- ArrayList ceArray = new ArrayList();
+ ArrayList<String> ceArray = new ArrayList<String>();
// For remote tests, we need to specify the Java VM to use and the
// classpath. For local tests, we'll just use the JVM and the classpath
@@ -2046,7 +2042,7 @@ public class ReplicationRun extends Base
final boolean isRemote = !serverHost.equals("localhost");
- ArrayList ceArray = new ArrayList();
+ ArrayList<String> ceArray = new ArrayList<String>();
// For remote tests, we need to specify the Java VM to use and the
// classpath. For local tests, we'll just use the JVM and the classpath
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/Utils.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/Utils.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/Utils.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/Utils.java Fri May 17 10:25:14 2013
@@ -135,8 +135,8 @@ class Utils
/**
* Convert a list of strings to an array of strings.
*/
- String[] toStringArray(List list) {
- return (String[]) list.toArray(new String[list.size()]);
+ String[] toStringArray(List<String> list) {
+ return list.toArray(new String[list.size()]);
}
/**
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/build.xml?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/build.xml (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/build.xml Fri May 17 10:25:14 2013
@@ -84,6 +84,7 @@
<pathelement path="${junit}"/>
</classpath>
<include name="${this.dir}/*.java"/>
+ <compilerarg value="-Xlint"/>
</javac>
</target>
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/AutomaticIndexStatisticsMultiTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/AutomaticIndexStatisticsMultiTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/AutomaticIndexStatisticsMultiTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/AutomaticIndexStatisticsMultiTest.java Fri May 17 10:25:14 2013
@@ -80,7 +80,7 @@ public class AutomaticIndexStatisticsMul
int total = 0;
int totalError = 0;
- List errors = new ArrayList();
+ List<SQLException> errors = new ArrayList<SQLException>();
for (int i=0; i < threadCount; i++) {
MTCompileThread ct = compileThreads[i];
int count = ct.getCount();
@@ -95,9 +95,8 @@ public class AutomaticIndexStatisticsMul
StringWriter msg = new StringWriter();
PrintWriter out = new PrintWriter(msg);
out.println(totalError + " select/compile errors reported:");
- for (Iterator ei = errors.iterator(); ei.hasNext(); ) {
+ for (SQLException sqle : errors) {
out.println("------");
- SQLException sqle = (SQLException)ei.next();
sqle.printStackTrace(out);
}
out.close();
@@ -142,7 +141,7 @@ public class AutomaticIndexStatisticsMul
int total = 0;
int totalError = 0;
- List errors = new ArrayList();
+ List<SQLException> errors = new ArrayList<SQLException>();
for (int i=0; i < threadCount; i++) {
MTCompileThread ct = compileThreads[i];
int count = ct.getCount();
@@ -165,9 +164,8 @@ public class AutomaticIndexStatisticsMul
createThread.getError().printStackTrace(out);
}
out.println("select/compile errors:");
- for (Iterator ei = errors.iterator(); ei.hasNext(); ) {
+ for (SQLException sqle : errors) {
out.println("------");
- SQLException sqle = (SQLException)ei.next();
sqle.printStackTrace(out);
}
out.close();
@@ -255,7 +253,8 @@ public class AutomaticIndexStatisticsMul
private final Random rand = new Random();
private final Connection con;
private final long runTime;
- private final ArrayList errors = new ArrayList();
+ private final ArrayList<SQLException> errors =
+ new ArrayList<SQLException>();
private volatile int count;
public MTCompileThread(Connection con, long runTime)
@@ -289,8 +288,8 @@ public class AutomaticIndexStatisticsMul
return errors.size();
}
- public synchronized List getErrors() {
- return (List)errors.clone();
+ public synchronized List<SQLException> getErrors() {
+ return new ArrayList<SQLException>(errors);
}
}
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/AutomaticIndexStatisticsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/AutomaticIndexStatisticsTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/AutomaticIndexStatisticsTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/AutomaticIndexStatisticsTest.java Fri May 17 10:25:14 2013
@@ -536,9 +536,9 @@ public class AutomaticIndexStatisticsTes
// We expect the security manager to stop us from creating directories
// where we aren't supposed to.
if (!PrivilegedFileOpsForTests.exists(dest.getParentFile())) {
- AccessController.doPrivileged(new PrivilegedAction() {
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
- public Object run() {
+ public Void run() {
assertTrue(dest.getParentFile().mkdirs());
return null;
}
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BTreeMaxScanTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BTreeMaxScanTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BTreeMaxScanTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BTreeMaxScanTest.java Fri May 17 10:25:14 2013
@@ -24,7 +24,6 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import junit.framework.Test;
import org.apache.derby.iapi.services.sanity.SanityManager;
@@ -38,7 +37,7 @@ import org.apache.derbyTesting.junit.Tes
*/
public class BTreeMaxScanTest extends BaseJDBCTestCase {
/** List of SanityManager debug flags to reset on teardown. */
- private List traceFlags = new ArrayList();
+ private List<String> traceFlags = new ArrayList<String>();
public BTreeMaxScanTest(String name) {
super(name);
@@ -59,10 +58,7 @@ public class BTreeMaxScanTest extends Ba
protected void tearDown() throws Exception {
super.tearDown();
if (SanityManager.DEBUG) {
- // If we've enabled tracing for the test case, disable it now.
- Iterator it = traceFlags.iterator();
- while (it.hasNext()) {
- String flag = (String) it.next();
+ for (String flag : traceFlags) {
SanityManager.DEBUG_PRINT(
flag, "Disable tracing for " + getName());
SanityManager.DEBUG_CLEAR(flag);
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/ClassLoaderBootTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/ClassLoaderBootTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/ClassLoaderBootTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/ClassLoaderBootTest.java Fri May 17 10:25:14 2013
@@ -26,12 +26,8 @@ import java.net.URLClassLoader;
import java.net.URLStreamHandlerFactory;
import java.sql.*;
import java.security.AccessController;
-import java.security.AccessControlContext;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.io.File;
-import java.net.MalformedURLException;
import java.security.CodeSource;
+import java.security.PrivilegedAction;
import java.util.Properties;
import javax.sql.DataSource;
@@ -40,7 +36,6 @@ import junit.framework.TestSuite;
import junit.extensions.TestSetup;
import org.apache.derbyTesting.junit.BaseJDBCTestCase;
import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
-import org.apache.derbyTesting.junit.DatabasePropertyTestSetup;
import org.apache.derbyTesting.junit.JDBC;
import org.apache.derbyTesting.junit.JDBCDataSource;
import org.apache.derbyTesting.junit.SecurityManagerSetup;
@@ -141,10 +136,9 @@ public class ClassLoaderBootTest extends
private DerbyURLClassLoader createDerbyClassLoader(final URL[] urls)
throws Exception
{
- return (DerbyURLClassLoader)AccessController.doPrivileged
- (
- new java.security.PrivilegedExceptionAction(){
- public Object run()
+ return AccessController.doPrivileged(
+ new PrivilegedAction<DerbyURLClassLoader>(){
+ public DerbyURLClassLoader run()
{
return new DerbyURLClassLoader(urls);
}
@@ -218,11 +212,8 @@ public class ClassLoaderBootTest extends
}
private void setThreadLoader(final ClassLoader which) {
-
- AccessController.doPrivileged
- (new java.security.PrivilegedAction(){
-
- public Object run() {
+ AccessController.doPrivileged(new PrivilegedAction<Void>(){
+ public Void run() {
java.lang.Thread.currentThread().setContextClassLoader(which);
return null;
}
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/Derby4676Test.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/Derby4676Test.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/Derby4676Test.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/Derby4676Test.java Fri May 17 10:25:14 2013
@@ -34,7 +34,7 @@ import org.apache.derbyTesting.junit.Tes
*/
public class Derby4676Test extends BaseJDBCTestCase {
/** List of {@code HelperThread}s used in the test. */
- private List threads;
+ private List<HelperThread> threads;
public Derby4676Test(String name) {
super(name);
@@ -47,19 +47,19 @@ public class Derby4676Test extends BaseJ
/** Set up the test environment. */
protected void setUp() {
- threads = new ArrayList();
+ threads = new ArrayList<HelperThread>();
}
/** Tear down the test environment. */
protected void tearDown() throws Exception {
super.tearDown();
- List localThreads = threads;
+ List<HelperThread> localThreads = threads;
threads = null;
// First, wait for all threads to terminate and close all connections.
for (int i = 0; i < localThreads.size(); i++) {
- HelperThread t = (HelperThread) localThreads.get(i);
+ HelperThread t = localThreads.get(i);
t.join();
Connection c = t.conn;
if (c != null && !c.isClosed()) {
@@ -70,7 +70,7 @@ public class Derby4676Test extends BaseJ
// Then check if any of the helper threads failed.
for (int i = 0; i < localThreads.size(); i++) {
- HelperThread t = (HelperThread) localThreads.get(i);
+ HelperThread t = localThreads.get(i);
if (t.exception != null) {
fail("Helper thread failed", t.exception);
}
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/EncryptionAESTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/EncryptionAESTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/EncryptionAESTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/EncryptionAESTest.java Fri May 17 10:25:14 2013
@@ -31,21 +31,16 @@ import java.sql.SQLWarning;
import javax.sql.DataSource;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.apache.derbyTesting.functionTests.util.PrivilegedFileOpsForTests;
import org.apache.derbyTesting.junit.BaseJDBCTestCase;
import org.apache.derbyTesting.junit.JDBC;
-import org.apache.derbyTesting.junit.JDBCClient;
import org.apache.derbyTesting.junit.JDBCDataSource;
import org.apache.derbyTesting.junit.SupportFilesSetup;
import org.apache.derbyTesting.junit.TestConfiguration;
-import org.apache.derbyTesting.junit.Utilities;
/**
* <p>
@@ -308,15 +303,8 @@ extends BaseJDBCTestCase {
*/
private String obtainDbName(String dbName) {
File tmp = new File(dbName);
- final File db = tmp;
- return (String)AccessController.doPrivileged(
- new PrivilegedAction() {
- public Object run() {
- return new File(SupportFilesSetup.EXTINOUT,
- db.getPath()).getAbsolutePath();
- }
- }
- );
+ return PrivilegedFileOpsForTests.getAbsolutePath(
+ new File(SupportFilesSetup.EXTINOUT, tmp.getPath()));
}
/**
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/EncryptionKeyTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/EncryptionKeyTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/EncryptionKeyTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/EncryptionKeyTest.java Fri May 17 10:25:14 2013
@@ -31,8 +31,7 @@ import java.sql.SQLWarning;
import javax.sql.DataSource;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
+import org.apache.derbyTesting.functionTests.util.PrivilegedFileOpsForTests;
import org.apache.derbyTesting.junit.BaseJDBCTestCase;
import org.apache.derbyTesting.junit.JDBCDataSource;
@@ -444,20 +443,13 @@ public abstract class EncryptionKeyTest
* @return A string with the absolute path to the database.
* @see SupportFilesSetup
*/
- private String obtainDbName(String dbName, String subdirectory) {
+ String obtainDbName(String dbName, String subdirectory) {
File tmp = new File(dbName);
if (subdirectory != null) {
tmp = new File(subdirectory, dbName);
}
- final File db = tmp;
- return (String)AccessController.doPrivileged(
- new PrivilegedAction() {
- public Object run() {
- return new File(SupportFilesSetup.EXTINOUT,
- db.getPath()).getAbsolutePath();
- }
- }
- );
+ return PrivilegedFileOpsForTests.getAbsolutePath(
+ new File(SupportFilesSetup.EXTINOUT, tmp.getPath()));
}
/**
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/IndexSplitDeadlockTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/IndexSplitDeadlockTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/IndexSplitDeadlockTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/IndexSplitDeadlockTest.java Fri May 17 10:25:14 2013
@@ -25,7 +25,6 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import junit.framework.Test;
import org.apache.derbyTesting.functionTests.util.Barrier;
@@ -48,7 +47,7 @@ public class IndexSplitDeadlockTest exte
/**
* List of threads (AsyncThread objects) to wait for after running the test.
*/
- private List threads = new ArrayList();
+ private List<AsyncThread> threads = new ArrayList<AsyncThread>();
public IndexSplitDeadlockTest(String name) {
super(name);
@@ -71,11 +70,7 @@ public class IndexSplitDeadlockTest exte
// Rollback all uncommitted operations so that we don't hold any
// locks that may block the other threads.
rollback();
-
- // Go through all the threads and call waitFor() so that we
- // detect errors that happened in another thread.
- for (Iterator it = threads.iterator(); it.hasNext();) {
- AsyncThread thread = (AsyncThread) it.next();
+ for (AsyncThread thread : threads) {
thread.waitFor();
}
threads = null;
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/InterruptResilienceTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/InterruptResilienceTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/InterruptResilienceTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/InterruptResilienceTest.java Fri May 17 10:25:14 2013
@@ -242,9 +242,10 @@ public class InterruptResilienceTest ext
Connection c = DriverManager.getConnection("jdbc:default:connection");
- ArrayList workers = new ArrayList();
+ ArrayList<WorkerThread> workers = new ArrayList<WorkerThread>();
- ArrayList interruptors = new ArrayList();
+ ArrayList<InterruptorThread> interruptors =
+ new ArrayList<InterruptorThread>();
for (int i = 0; i < NO_OF_THREADS; i++) {
WorkerThread w = new WorkerThread(
@@ -266,7 +267,7 @@ public class InterruptResilienceTest ext
}
for (int i = 0; i < workers.size(); i++) {
- WorkerThread w = (WorkerThread)workers.get(i);
+ WorkerThread w = workers.get(i);
w.join();
if (w.e != null) {
@@ -277,7 +278,7 @@ public class InterruptResilienceTest ext
allDone = true;
for (int i = 0; i < interruptors.size(); i++) {
- ((Thread)interruptors.get(i)).join();
+ interruptors.get(i).join();
}
try {
@@ -325,11 +326,11 @@ public class InterruptResilienceTest ext
// Wait till here to start works, so interruptors don't get too late to
// the game
for (int i = 0; i < workers.size(); i++) {
- ((Thread)workers.get(i)).start();
+ workers.get(i).start();
}
for (int i = 0; i < workers.size(); i++) {
- WorkerThread w = (WorkerThread)workers.get(i);
+ WorkerThread w = workers.get(i);
w.join();
if (w.e != null) {
@@ -340,7 +341,7 @@ public class InterruptResilienceTest ext
allDone = true;
for (int i = 0; i < interruptors.size(); i++) {
- ((Thread)interruptors.get(i)).join();
+ interruptors.get(i).join();
}
c.close();
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/LiveLockTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/LiveLockTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/LiveLockTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/LiveLockTest.java Fri May 17 10:25:14 2013
@@ -23,7 +23,6 @@ import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
-import java.util.Iterator;
import java.util.LinkedList;
import junit.framework.Test;
@@ -40,7 +39,7 @@ import org.apache.derbyTesting.junit.Tes
*
*/
public class LiveLockTest extends BaseJDBCTestCase {
- private LinkedList listExceptions = new LinkedList();
+ private LinkedList<Exception> listExceptions = new LinkedList<Exception>();
private Object syncObject = new Object();
private boolean updateDone = false;
@@ -50,12 +49,11 @@ public class LiveLockTest extends BaseJD
}
/**
- * Start three threads. Two doing staggered selets and a third trying
+ * Start three threads. Two doing staggered selects and a third trying
* to do an update. The update should not be starved by the staggered
* selects.
- * @throws SQLException
*/
- public void testLiveLock() throws SQLException {
+ public void testLiveLock() throws Exception {
Thread[] t = createThreads();
waitForThreads(t);
@@ -65,16 +63,13 @@ public class LiveLockTest extends BaseJD
/**
* There should be no exceptions. The update should have gotten through
*
- * @throws SQLException
+ * @throws Exception
* if any occurred
*/
- private void checkExceptions() throws SQLException {
-
- for (Iterator i = listExceptions.iterator(); i.hasNext();) {
- SQLException e = (SQLException) i.next();
+ private void checkExceptions() throws Exception {
+ for (Exception e : listExceptions) {
throw e;
}
-
}
private void waitForThreads(Thread[] t) {
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OSReadOnlyTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OSReadOnlyTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OSReadOnlyTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OSReadOnlyTest.java Fri May 17 10:25:14 2013
@@ -179,45 +179,7 @@ public class OSReadOnlyTest extends Base
*/
private String getPhysicalDbName() {
String pdbName =TestConfiguration.getCurrent().getJDBCUrl();
- if (pdbName != null)
- pdbName=pdbName.substring(pdbName.lastIndexOf("oneuse"),pdbName.length());
- else {
- // with JSR169, we don't *have* a protocol, and so, no url, and so
- // we'll have had a null.
- // But we know the name of the db is something like system/singleUse/oneuse#
- // So, let's see if we can look it up, if everything's been properly
- // cleaned, there should be just 1...
- pdbName = (String) AccessController.doPrivileged(new java.security.PrivilegedAction() {
- String filesep = getSystemProperty("file.separator");
- public Object run() {
- File dbdir = new File("system" + filesep + "singleUse");
- String[] list = dbdir.list();
- // Some JVMs return null for File.list() when the directory is empty
- if( list != null)
- {
- if(list.length > 1)
- {
- for( int i = 0; i < list.length; i++ )
- {
- if(list[i].indexOf("oneuse")<0)
- continue;
- else
- {
- return list[i];
- }
- }
- // give up trying to be smart, assume it's 0
- return "oneuse0";
- }
- else
- return list[0];
- }
- return null;
- }
- });
-
- }
- return pdbName;
+ return pdbName.substring(pdbName.lastIndexOf("oneuse"));
}
private void shutdownDB(DataSource ds) throws SQLException {
@@ -306,9 +268,9 @@ public class OSReadOnlyTest extends Base
*/
private void createDummyLockFile(String dbDir) {
final File f = new File(constructDbPath(dbDir), "db.lck");
- AccessController.doPrivileged(new PrivilegedAction() {
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
- public Object run() {
+ public Void run() {
if (!f.exists()) {
try {
FileOutputStream fos = new FileOutputStream(f);
@@ -356,9 +318,9 @@ public class OSReadOnlyTest extends Base
return false;
final File sdirectory = directory;
- Boolean b = (Boolean)AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public Object run() {
+ return AccessController.doPrivileged(
+ new java.security.PrivilegedAction<Boolean>() {
+ public Boolean run() {
// set fail to true to start with; unless it works, we
// want to specifically set the value.
boolean success = true;
@@ -386,13 +348,8 @@ public class OSReadOnlyTest extends Base
// again, which means we cannot delete the directory and
// its content...
//success &= sdirectory.setReadOnly();
- return new Boolean(success);
+ return success;
}
});
- if (b.booleanValue())
- {
- return true;
- }
- else return false;
}
}
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/build.xml?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/build.xml (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/build.xml Fri May 17 10:25:14 2013
@@ -83,6 +83,7 @@
<pathelement path="${compile.classpath}"/>
</classpath>
<include name="${this.dir}/*.java"/>
+ <compilerarg value="-Xlint"/>
</javac>
</target>
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/CanonTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/CanonTestCase.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/CanonTestCase.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/CanonTestCase.java Fri May 17 10:25:14 2013
@@ -31,6 +31,7 @@ import java.io.OutputStream;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import org.apache.derbyTesting.junit.BaseJDBCTestCase;
@@ -143,10 +144,9 @@ abstract class CanonTestCase extends Bas
File folder = getFailureFolder();
final File outFile = new File(folder, getName() + ".out");
- OutputStream outStream = (OutputStream) AccessController
- .doPrivileged(new java.security.PrivilegedExceptionAction() {
-
- public Object run() throws IOException {
+ OutputStream outStream = AccessController
+ .doPrivileged(new PrivilegedExceptionAction<OutputStream>() {
+ public OutputStream run() throws IOException {
return new FileOutputStream(outFile);
}
});
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/FTFileUtil.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/FTFileUtil.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/FTFileUtil.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/FTFileUtil.java Fri May 17 10:25:14 2013
@@ -74,8 +74,8 @@ public class FTFileUtil
// called through a SQL statement and thus a generated
// class. The generated class on the stack has no permissions
// granted to it.
- AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws Exception {
+ AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
+ public Void run() throws Exception {
if(!src.renameTo(dst))
{
throw new Exception("unable to rename File: " +
@@ -98,10 +98,8 @@ public class FTFileUtil
* @param fileName the file's name.
* @return <tt>"true"</tt> if the given file exists
* <tt>"false"</tt> otherwise.
- * @exception Exception if any exception occurs
*/
public static String fileExists(String fileName)
- throws PrivilegedActionException
{
final File fl = new File(fileName);
@@ -110,17 +108,7 @@ public class FTFileUtil
// class. The generated class on the stack has no permissions
// granted to it.
- return (String)
- AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run()
- {
- if(fl.exists()) {
- return "true";
- }else {
- return "false";
- }
- }
- });
+ return Boolean.toString(PrivilegedFileOpsForTests.exists(fl));
}
@@ -183,9 +171,8 @@ public class FTFileUtil
// class. The generated class on the stack has no permissions
// granted to it.
- return (String)
- AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run()
+ return AccessController.doPrivileged(new PrivilegedAction<String>() {
+ public String run()
{
return (removeDirectory(
new File(directory)) ? "true" : "false");
@@ -194,6 +181,3 @@ public class FTFileUtil
}
}
-
-
-
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/HarnessJavaTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/HarnessJavaTest.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/HarnessJavaTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/HarnessJavaTest.java Fri May 17 10:25:14 2013
@@ -79,7 +79,7 @@ public abstract class HarnessJavaTest ex
false, outputEncoding);
setSystemOut(testOut);
- Class test = Class.forName(testClassName);
+ Class<?> test = Class.forName(testClassName);
Method main = test.getDeclaredMethod("main", MAIN_ARG_TYPE);
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/IjTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/IjTestCase.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/IjTestCase.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/IjTestCase.java Fri May 17 10:25:14 2013
@@ -85,8 +85,9 @@ public class IjTestCase extends ScriptTe
+ getName() + ".out";
final File out = outfile;
- FileInputStream fis = (FileInputStream) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ FileInputStream fis = AccessController.doPrivileged(
+ new PrivilegedAction<FileInputStream>() {
+ public FileInputStream run() {
FileInputStream fis = null;
try {
fis = new FileInputStream(out);
@@ -102,17 +103,12 @@ public class IjTestCase extends ScriptTe
os.write(b);
}
fis.close();
+
+ boolean deleted = PrivilegedFileOpsForTests.delete(outfile);
- Boolean deleted = (Boolean) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- boolean d = outfile.delete();
-
- return new Boolean(d);
- }
- });
-
- if (!deleted.booleanValue())
+ if (!deleted) {
println("Could not delete outfile for " + scriptName);
+ }
this.compareCanon(canon);
}
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/SampleVTI.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/SampleVTI.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/SampleVTI.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/SampleVTI.java Fri May 17 10:25:14 2013
@@ -269,11 +269,11 @@ public class SampleVTI
throw new UnsupportedOperationException("Not supported yet.");
}
- public Object getObject(int columnIndex, Class type) throws SQLException {
+ public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
throw new UnsupportedOperationException("Not supported yet.");
}
- public Object getObject(String columnLabel, Class type) throws SQLException {
+ public <T> T getObject(String columnLabel, Class<T> type) throws SQLException {
throw new UnsupportedOperationException("Not supported yet.");
}
}
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/ScriptTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/ScriptTestCase.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/ScriptTestCase.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/ScriptTestCase.java Fri May 17 10:25:14 2013
@@ -21,16 +21,15 @@ package org.apache.derbyTesting.function
import java.io.InputStream;
import java.net.URL;
-import java.security.AccessController;
import java.sql.Connection;
import java.util.Locale;
import org.apache.derby.iapi.tools.i18n.LocalizedResource;
-import org.apache.derbyTesting.junit.BaseTestCase;
import org.apache.derbyTesting.junit.Derby;
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.apache.derbyTesting.junit.LocaleTestSetup;
/**
* Run a .sql script as a test comparing it to
@@ -209,13 +208,7 @@ public abstract class ScriptTestCase ext
*/
protected void setUp() {
oldLocale = Locale.getDefault();
-
- AccessController.doPrivileged(new java.security.PrivilegedAction() {
- public Object run() {
- Locale.setDefault(Locale.US);
- return null;
- }
- });
+ LocaleTestSetup.setDefaultLocale(Locale.US);
// Reset IJ's locale to allow it to pick up the new locale from
// the environment.
@@ -228,12 +221,7 @@ public abstract class ScriptTestCase ext
protected void tearDown() throws Exception {
super.tearDown();
- AccessController.doPrivileged(new java.security.PrivilegedAction() {
- public Object run() {
- Locale.setDefault(oldLocale);
- return null;
- }
- });
+ LocaleTestSetup.setDefaultLocale(oldLocale);
// Forget the locale used by this test.
LocalizedResource.resetLocalizedResourceCache();
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/SecurityCheck.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/SecurityCheck.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/SecurityCheck.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/SecurityCheck.java Fri May 17 10:25:14 2013
@@ -25,7 +25,7 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.util.Iterator;
+import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
@@ -74,7 +74,8 @@ public class SecurityCheck {
* the class is being inspected. Otherwise the value is
* a String description of the risks.
*/
- private static final SortedMap allInspectedClasses = new TreeMap();
+ private static final SortedMap<String, String> allInspectedClasses =
+ new TreeMap<String, String>();
/**
* Perform security analysis of the public api for the embedded engine.
@@ -112,10 +113,10 @@ public class SecurityCheck {
{
synchronized (allInspectedClasses)
{
- for (Iterator it = allInspectedClasses.keySet().iterator(); it.hasNext(); )
+ for (Map.Entry<String, String> entry : allInspectedClasses.entrySet())
{
- Object key = it.next();
- Object value = allInspectedClasses.get(key);
+ String key = entry.getKey();
+ String value = entry.getValue();
if (value == null)
{
if (reportClear)
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestRoutines.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestRoutines.java?rev=1483727&r1=1483726&r2=1483727&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestRoutines.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestRoutines.java Fri May 17 10:25:14 2013
@@ -28,8 +28,6 @@ import java.security.PrivilegedException
import java.sql.*;
import java.io.*;
-import org.apache.derby.iapi.reference.JDBC30Translation;
-
/**
Utility methods for tests routines, in order to bring some consistency to test output.
@@ -85,8 +83,8 @@ public class TestRoutines {
// called through a SQL statement and thus a generated
// class. The generated class on the stack has no permissions
// granted to it.
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ public Void run() {
System.setProperty(key, value);
return null; // nothing to return
}
@@ -126,9 +124,9 @@ public class TestRoutines {
// called through a SQL statement and thus a generated
// class. The generated class on the stack has no permissions
// granted to it.
- FileInputStream fin = (FileInputStream)
- AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws FileNotFoundException {
+ FileInputStream fin = AccessController.doPrivileged(
+ new PrivilegedExceptionAction<FileInputStream>() {
+ public FileInputStream run() throws FileNotFoundException {
return new FileInputStream(fileName); // nothing to return
}
});