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 my...@apache.org on 2010/05/18 05:25:45 UTC
svn commit: r945472 - in
/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests:
master/ master/ibm15/ master/j9_13/ tests/derbynet/ tests/tools/
Author: myrnavl
Date: Tue May 18 03:25:45 2010
New Revision: 945472
URL: http://svn.apache.org/viewvc?rev=945472&view=rev
Log:
DERBY-4536; backporting fixes of DERBY-858 from 10.5 to 10.4 so
tests are not affected by hash table ordering changes. Merge command:
svn -c merge 835482 https://svn.apache.org/repos/asf/db/derby/code/branches/10.5
Added:
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ijConnName_sed.properties
- copied unchanged from r835482, db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ijConnName_sed.properties
Removed:
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/master/ibm15/ijConnName.out
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/master/j9_13/ij5.out
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/master/j9_13/ijConnName.out
Modified:
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/master/ij5.out
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/master/ijConnName.out
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SysinfoTest.java
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij5.sql
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij5_app.properties
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ijConnName.sql
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ijConnName_app.properties
Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/master/ij5.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/master/ij5.out?rev=945472&r1=945471&r2=945472&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/master/ij5.out (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/master/ij5.out Tue May 18 03:25:45 2010
@@ -1,7 +1,6 @@
CONNONE* - jdbc:derby:wombat
-CONNTWO - jdbc:derby:lemming
* = current connection
-ij(CONNONE)> --
+ij> --
-- Licensed to the Apache Software Foundation (ASF) under one or more
-- contributor license agreements. See the NOTICE file distributed with
-- this work for additional information regarding copyright ownership.
@@ -17,7 +16,7 @@ ij(CONNONE)> --
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--- assumes the connections connOne, connTwo are set up already
+-- assumes the connection connOne is set up already
-- 1)at the startup time, it will list all the connections
-- 2)select will now display number of rows selected
select count(*) from sys.systables where 1=0;
@@ -25,4 +24,4 @@ select count(*) from sys.systables where
-----------
0
1 row selected
-ij(CONNONE)>
+ij>
Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/master/ijConnName.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/master/ijConnName.out?rev=945472&r1=945471&r2=945472&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/master/ijConnName.out (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/master/ijConnName.out Tue May 18 03:25:45 2010
@@ -1,6 +1,4 @@
-ERROR XJ004: Database 'nevercreated' not found.
-ERROR 08001: No suitable driver
-ij(CONNONE)> --
+ij> --
-- Licensed to the Apache Software Foundation (ASF) under one or more
-- contributor license agreements. See the NOTICE file distributed with
-- this work for additional information regarding copyright ownership.
@@ -16,14 +14,14 @@ ij(CONNONE)> --
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--- assumes the connections connOne, connTwo are set up already
+-- assumes the connection connOne is set up already
-- and that connThree, connFour failed to be setup correctly (bad URLs)
-- expect connOne to be active
show connections;
CONNONE* - jdbc:derby:wombat
-CONNTWO - jdbc:derby:lemming
* = current connection
-ij(CONNONE)> set connection connOne;
+ij> connect 'jdbc:derby:lemming;create=true' as connTwo;
+ij(CONNTWO)> set connection connOne;
ij(CONNONE)> values 1;
1
-----------
Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java?rev=945472&r1=945471&r2=945472&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java Tue May 18 03:25:45 2010
@@ -215,8 +215,8 @@ public class ServerPropertiesTest exten
);
return test;
}
-
- private static void verifyProperties(String[] expectedValues) {
+
+ private static Properties getTheProperties() {
Properties p;
try {
p = NetworkServerTestSetup.getNetworkServerControl().getCurrentProperties();
@@ -226,23 +226,46 @@ public class ServerPropertiesTest exten
e.printStackTrace();
fail("unexpected exception getting properties from server");
}
-
- Enumeration e = p.propertyNames();
+ return p;
+ }
+
+ // check for 1 Property/Value pair, passing in expected as a String
+ // "<propertyName>=<expectedPropertyValue>"
+ private static void verifyProperties(String expectedPropAndValue) {
+ Properties p = getTheProperties();
+ assertPropertyValueCorrect(p, expectedPropAndValue);
+ p=null;
+ }
+
+ // check for an array of Property/Value pairs, passing each expected pair
+ // in as a String "<propertyName>=<expectedPropertyValue>"
+ private static void verifyProperties(String[] expectedValues) {
+ Properties p = getTheProperties();
// for debugging:
for (int i=0 ; i<expectedValues.length; i++){
println("expV: " + expectedValues[i]);
}
assertEquals(expectedValues.length , p.size());
- for ( int i = 0 ; i < p.size() ; i++)
+ for ( int i = 0 ; i < expectedValues.length ; i++)
{
- String propName = (String)e.nextElement();
- // next line for debugging
- println("propName: " + propName);
- String propval = (String)p.get(propName);
- assertEquals(expectedValues[i], propval);
+ assertPropertyValueCorrect(p, expectedValues[i]);
}
p = null;
}
+
+ private static void assertPropertyValueCorrect(Properties p, String expectedPropAndValue) {
+ String[] expPropValueString = expectedPropAndValue.split("=");
+ try {
+ // for debugging
+ String actualPropertyValue = p.getProperty(expPropValueString[0]);
+ println("exppropName: " + expPropValueString[0]);
+ println("exppropValue: " + expPropValueString[1]);
+ println("actualpropValue: " + actualPropertyValue);
+ assertEquals(expPropValueString[1],actualPropertyValue);
+ } catch(Exception e) {
+ fail("could not find property " + expPropValueString[0]);
+ }
+ }
public int getAlternativePort() throws SQLException {
@@ -538,14 +561,18 @@ public class ServerPropertiesTest exten
{
//check that default properties are used
verifyProperties(new String[] {
- // getProperties returns properties in sequence:
- // maxThreads; sslMode; keepAlive; minThreads; portNumber;
- // logConnections; timeSlice; startNetworkServer; host; traceAll
- "0", "off", "true", "0",
- String.valueOf(TestConfiguration.getCurrent().getPort()),
- "false", "0", "false",
- String.valueOf(TestConfiguration.getCurrent().getHostName()),
- "false"});
+ "derby.drda.maxThreads=0",
+ "derby.drda.sslMode=off",
+ "derby.drda.keepAlive=true",
+ "derby.drda.minThreads=0",
+ "derby.drda.portNumber=" +
+ String.valueOf(TestConfiguration.getCurrent().getPort()),
+ "derby.drda.logConnections=false",
+ "derby.drda.timeSlice=0",
+ "derby.drda.startNetworkServer=false",
+ "derby.drda.host=" +
+ String.valueOf(TestConfiguration.getCurrent().getHostName()),
+ "derby.drda.traceAll=false"});
}
/**
@@ -554,31 +581,10 @@ public class ServerPropertiesTest exten
public void testToggleTrace()
throws SQLException, IOException, InterruptedException
{
- String[] expectedTraceOff = new String[] {
- // getProperties returns properties in sequence:
- // traceDirectory; maxThreads; sslMode; keepAlive; minThreads;
- // portNumber; logConnections; timeSlice; startNetworkServer;
- // host; traceAll
- getSystemProperty("derby.system.home"),
- "0", "off", "true", "0",
- String.valueOf(TestConfiguration.getCurrent().getPort()),
- "false", "0", "false",
- //String.valueOf(TestConfiguration.getCurrent().getHostName()),
- "127.0.0.1",
- "false"};
- String[] expectedTraceOn = new String[] {
- // getProperties returns properties in sequence:
- // traceDirectory; maxThreads; sslMode; keepAlive; minThreads;
- // portNumber; logConnections; timeSlice; startNetworkServer;
- // host; traceAll
- getSystemProperty("derby.system.home"),
- "0", "off", "true", "0",
- String.valueOf(TestConfiguration.getCurrent().getPort()),
- "false", "0", "false",
- //String.valueOf(TestConfiguration.getCurrent().getHostName()),
- "127.0.0.1",
- "true"};
-
+ // we only care about the traceAll property, the rest will be unchanged
+ String expectedTraceOff = "derby.drda.traceAll=false";
+ String expectedTraceOn = "derby.drda.traceAll=true";
+
verifyProperties(expectedTraceOff);
String[] traceCmd = new String[] {
@@ -599,31 +605,10 @@ public class ServerPropertiesTest exten
public void testToggleLogConnections()
throws SQLException, IOException, InterruptedException
{
- String[] expectedLogConnectionsOff = new String[] {
- // getProperties returns properties in sequence:
- // traceDirectory; maxThreads; sslMode; keepAlive; minThreads;
- // portNumber; logConnections; timeSlice; startNetworkServer;
- // host; traceAll
- getSystemProperty("derby.system.home"),
- "0", "off", "true", "0",
- String.valueOf(TestConfiguration.getCurrent().getPort()),
- "false", "0", "false",
- //String.valueOf(TestConfiguration.getCurrent().getHostName()),
- "127.0.0.1",
- "false"};
- String[] expectedLogConnectionsOn = new String[] {
- // getProperties returns properties in sequence:
- // traceDirectory; maxThreads; sslMode; keepAlive; minThreads;
- // portNumber; logConnections; timeSlice; startNetworkServer;
- // host; traceAll
- getSystemProperty("derby.system.home"),
- "0", "off", "true", "0",
- String.valueOf(TestConfiguration.getCurrent().getPort()),
- "true", "0", "false",
- //String.valueOf(TestConfiguration.getCurrent().getHostName()),
- "127.0.0.1",
- "false"};
-
+ // only care about the LogConnections property; the rest is unchanged
+ String expectedLogConnectionsOff = "derby.drda.logConnections=false";
+ String expectedLogConnectionsOn = "derby.drda.logConnections=true";
+
verifyProperties(expectedLogConnectionsOff);
String[] cmd = new String[] {
Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SysinfoTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SysinfoTest.java?rev=945472&r1=945471&r2=945472&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SysinfoTest.java (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SysinfoTest.java Tue May 18 03:25:45 2010
@@ -45,7 +45,7 @@ import org.apache.derbyTesting.junit.Tes
public class SysinfoTest extends BaseJDBCTestCase {
private static String TARGET_POLICY_FILE_NAME="sysinfo.policy";
- private String OUTPUT;
+ private String [] OUTPUT;
/**
* Set to true before adding a test to the suite to add some extra properties.
@@ -62,41 +62,41 @@ public class SysinfoTest extends BaseJDB
/**
* Output from sysinfo without the extra properties.
*/
- String OUTPUT1 =
- "--------- Derby Network Server Information --------\n" +
- "derby.drda.maxThreads=0\n" +
- "derby.drda.sslMode=off\n" +
- "derby.drda.keepAlive=true\n" +
- "derby.drda.minThreads=0\n" +
- "derby.drda.portNumber=1527\n" +
- "derby.drda.logConnections=false\n" +
- "derby.drda.timeSlice=0\n" +
- "derby.drda.startNetworkServer=false\n" +
- "derby.drda.traceAll=false\n" +
- "--------- Derby Information --------\n" +
- "------------------------------------------------------\n" +
- "----------------- Locale Information -----------------\n" +
- "------------------------------------------------------";
+ String [] OUTPUT1 = {
+ "--------- Derby Network Server Information --------" ,
+ "derby.drda.maxThreads=0" ,
+ "derby.drda.sslMode=off" ,
+ "derby.drda.keepAlive=true" ,
+ "derby.drda.minThreads=0" ,
+ "derby.drda.portNumber=1527" ,
+ "derby.drda.logConnections=false" ,
+ "derby.drda.timeSlice=0" ,
+ "derby.drda.startNetworkServer=false" ,
+ "derby.drda.traceAll=false" ,
+ "--------- Derby Information --------" ,
+ "------------------------------------------------------" ,
+ "----------------- Locale Information -----------------" ,
+ "------------------------------------------------------"};
/**
* Output by sysinfo with the extra properties.
*/
- String OUTPUT2 =
- "--------- Derby Network Server Information --------\n" +
- "derby.drda.securityMechanism=USER_ONLY_SECURITY\n" +
- "derby.drda.maxThreads=0\n" +
- "derby.drda.sslMode=off\n" +
- "derby.drda.keepAlive=true\n" +
- "derby.drda.minThreads=0\n" +
- "derby.drda.portNumber=1527\n" +
- "derby.drda.logConnections=false\n" +
- "derby.drda.timeSlice=0\n" +
- "derby.drda.startNetworkServer=false\n" +
- "derby.drda.traceAll=false\n" +
- "--------- Derby Information --------\n" +
- "------------------------------------------------------\n" +
- "----------------- Locale Information -----------------\n" +
- "------------------------------------------------------";
+ String [] OUTPUT2 = {
+ "--------- Derby Network Server Information --------" ,
+ "derby.drda.securityMechanism=USER_ONLY_SECURITY" ,
+ "derby.drda.maxThreads=0" ,
+ "derby.drda.sslMode=off" ,
+ "derby.drda.keepAlive=true" ,
+ "derby.drda.minThreads=0" ,
+ "derby.drda.portNumber=1527" ,
+ "derby.drda.logConnections=false" ,
+ "derby.drda.timeSlice=0" ,
+ "derby.drda.startNetworkServer=false" ,
+ "derby.drda.traceAll=false" ,
+ "--------- Derby Information --------" ,
+ "------------------------------------------------------" ,
+ "----------------- Locale Information -----------------" ,
+ "------------------------------------------------------"};
if (useProperties)
OUTPUT = OUTPUT2;
@@ -203,7 +203,8 @@ public class SysinfoTest extends BaseJDB
*/
public void testSysinfo() throws Exception {
String[] SysInfoCmd =
- new String[] {"org.apache.derby.drda.NetworkServerControl", "sysinfo"};
+ new String[] {"org.apache.derby.drda.NetworkServerControl", "sysinfo",
+ "-p", String.valueOf(TestConfiguration.getCurrent().getPort())};
Process p = execJavaCmd(SysInfoCmd);
String s = readProcessOutput(p);
@@ -211,8 +212,7 @@ public class SysinfoTest extends BaseJDB
s = sed(s);
print("testSysinfo", s);
- assertEquals(OUTPUT,s);
-
+ assertMatchingStringExists(s);
}
/**
@@ -223,11 +223,11 @@ public class SysinfoTest extends BaseJDB
public void testSysinfoMethod() throws Exception {
String s = NetworkServerTestSetup.
- getNetworkServerControlDefault().getSysinfo();
+ getNetworkServerControl(TestConfiguration.getCurrent().getPort()).getSysinfo();
s = sed(s);
print("testSysinfoMethod", s);
- assertEquals(OUTPUT, s);
+ assertMatchingStringExists(s);
}
/**
@@ -239,13 +239,14 @@ public class SysinfoTest extends BaseJDB
String[] SysInfoLocaleCmd =
new String[] {"-Duser.language=de", "-Duser.country=DE",
- "org.apache.derby.drda.NetworkServerControl", "sysinfo"};
+ "org.apache.derby.drda.NetworkServerControl", "sysinfo",
+ "-p", String.valueOf(TestConfiguration.getCurrent().getPort())};
Process p = execJavaCmd(SysInfoLocaleCmd);
String s = readProcessOutput(p);
s = sed(s);
print("testSysinfoLocale", s);
- assertEquals(OUTPUT, s);
+ assertMatchingStringExists(s);
}
/**
@@ -261,7 +262,7 @@ public class SysinfoTest extends BaseJDB
* asserting that output is correct.
*/
String[] sed = {"Version", "version", "Java", "OS",
- "[0-9*].[0-9*].[0-9*]","JRE - JDBC","derby.drda.traceDirectory",
+ "[0-9*]\\.[0-9*]\\.[0-9*]","JRE - JDBC","derby.drda.traceDirectory",
"Unable to access Protection Domain","listing properties",
"Current Locale", //Remove these because locale info is
"Found support for locale:" //not printed when running from jars..
@@ -313,4 +314,33 @@ public class SysinfoTest extends BaseJDB
}
return url.getPath();
}
+
+ private void assertMatchingStringExists(String actualOutput) {
+ String delimiter = "\n";
+ String [] actualOutputArray = actualOutput.split(delimiter);
+ int lineCount = actualOutputArray.length;
+ assertEquals(OUTPUT.length, lineCount);
+ for (int i=0 ; i<lineCount ; i++)
+ {
+ String fullExpOutput="";
+ for (int j=0 ; j < OUTPUT.length; j++) {
+ fullExpOutput=fullExpOutput + OUTPUT[j] + "\n";
+ }
+ String ns = actualOutputArray[i];
+ assertTrue("Output string: " + ns +
+ "\ndoesn't match any of the expected strings: \n" +
+ fullExpOutput,
+ searchMatchingString(ns));
+ }
+ }
+
+ private boolean searchMatchingString(String substring){
+ for (int i=0; i<OUTPUT.length;i++)
+ {
+ if (!substring.equals(OUTPUT[i]))
+ continue;
+ else return true;
+ }
+ return false;
+ }
}
Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij5.sql
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij5.sql?rev=945472&r1=945471&r2=945472&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij5.sql (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij5.sql Tue May 18 03:25:45 2010
@@ -14,7 +14,7 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--- assumes the connections connOne, connTwo are set up already
+-- assumes the connection connOne is set up already
-- 1)at the startup time, it will list all the connections
-- 2)select will now display number of rows selected
Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij5_app.properties
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij5_app.properties?rev=945472&r1=945471&r2=945472&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij5_app.properties (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij5_app.properties Tue May 18 03:25:45 2010
@@ -14,10 +14,9 @@
# limitations under the License.
ij.connection.connOne=jdbc:derby:wombat;create=true
-ij.connection.connTwo=jdbc:derby:lemming;create=true
ij.showNoConnectionsAtStart=false
ij.showNoCountForSelect=false
#Exclude for J2ME/Foundation - test requires java.sql.Driver
-runwithfoundation=false
\ No newline at end of file
+runwithfoundation=false
Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ijConnName.sql
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ijConnName.sql?rev=945472&r1=945471&r2=945472&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ijConnName.sql (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ijConnName.sql Tue May 18 03:25:45 2010
@@ -14,11 +14,12 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--- assumes the connections connOne, connTwo are set up already
+-- assumes the connection connOne is set up already
-- and that connThree, connFour failed to be setup correctly (bad URLs)
-- expect connOne to be active
show connections;
+connect 'jdbc:derby:lemming;create=true' as connTwo;
set connection connOne;
values 1;
set connection connTwo;
Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ijConnName_app.properties
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ijConnName_app.properties?rev=945472&r1=945471&r2=945472&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ijConnName_app.properties (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ijConnName_app.properties Tue May 18 03:25:45 2010
@@ -14,7 +14,6 @@
# limitations under the License.
ij.connection.connOne=jdbc:derby:wombat;create=true
-ij.connection.connTwo=jdbc:derby:lemming;create=true
ij.connection.connThree=jdbc:noone:fruitfly;create=true
ij.connection.connFour=jdbc:derby:nevercreated
@@ -25,4 +24,4 @@ ij.showNoCountForSelect=true
runwithfoundation=false
# disable security manager for now - need investigating
-noSecurityManager=true
\ No newline at end of file
+noSecurityManager=true