db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From myrn...@apache.org
Subject svn commit: r597456 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: functionTests/tests/derbynet/NSinSameJVMTest.java functionTests/tests/derbynet/_Suite.java junit/TestConfiguration.java
Date Thu, 22 Nov 2007 17:17:56 GMT
Author: myrnavl
Date: Thu Nov 22 09:17:50 2007
New Revision: 597456

URL: http://svn.apache.org/viewvc?rev=597456&view=rev
Log:
DERBY-3211 ; convert NSinSameJVM to junit
  patch contributed by Manjula Kutty

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSinSameJVMTest.java
  (with props)
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/_Suite.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSinSameJVMTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSinSameJVMTest.java?rev=597456&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSinSameJVMTest.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSinSameJVMTest.java
Thu Nov 22 09:17:50 2007
@@ -0,0 +1,72 @@
+/*
+
+ Derby - Class org.apache.derbyTesting.functionTests.tests.derbynet.DRDAProtocolTest
+
+ 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.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+package org.apache.derbyTesting.functionTests.tests.derbynet;
+
+import java.net.InetAddress;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import junit.framework.Test;
+import org.apache.derby.drda.NetworkServerControl;
+import org.apache.derbyTesting.junit.JDBC;
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.TestConfiguration;
+
+public class NSinSameJVMTest extends BaseJDBCTestCase {
+	public NSinSameJVMTest(String name) {
+		super(name);
+	}
+
+	protected void tearDown() throws Exception {
+		super.tearDown();
+	}
+	/** Test NetworkServer start and shutdown on a different port 
+	 * other than 1527 in the same jvm
+	 * @throws Exception
+	 **/
+	public void testShutdown() throws Exception {
+		final int NETWORKSERVER_PORT = 20000; //port to start the server
+		NetworkServerControl serverControl = null;
+		try {
+			serverControl = new NetworkServerControl(InetAddress
+					.getByName("localhost"), NETWORKSERVER_PORT);//initialized for the shutdown.
+			Connection connection = null;
+			// Just connect, do something and close the connection
+			connection = getConnection();
+			Statement stmt = connection.createStatement();
+			ResultSet rs = stmt.executeQuery("Select  tablename   from  sys.systables");	
+			JDBC.assertDrainResults(rs);
+			serverControl.shutdown();
+			Thread.sleep(5000);
+		} catch (Exception e) {
+			System.out.print("FAIL: Unexpected exception" + e.getMessage());
+			e.printStackTrace();
+		}
+	}
+	 /**
+     * Construct the name of the server policy file.
+     */
+	public static Test suite() {
+        Test test;
+        test = TestConfiguration.clientServerSuite(NSinSameJVMTest.class,20000);
+        return test;
+    }
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSinSameJVMTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/_Suite.java?rev=597456&r1=597455&r2=597456&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/_Suite.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/_Suite.java
Thu Nov 22 09:17:50 2007
@@ -55,6 +55,7 @@
         suite.addTest(SecureServerTest.suite());
         suite.addTest(SSLTest.suite());
         suite.addTest(NetIjTest.suite());
+        suite.addTest(NSinSameJVMTest.suite());
         
         
         // Disabled due to "java.sql.SQLSyntaxErrorException: The class

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java?rev=597456&r1=597455&r2=597456&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
Thu Nov 22 09:17:50 2007
@@ -306,6 +306,18 @@
                 suiteName(testClass)+":client");
         return clientServerDecorator(suite);
     }
+    /**
+     * Create a suite for the passed test class that includes
+     * all the default fixtures from the class, wrapped in
+     * a derbyClientServerDecorator with a given port.
+     * 
+     */
+    public static Test clientServerSuite(Class testClass, int port)
+    {           
+        TestSuite suite = new TestSuite(testClass,
+                suiteName(testClass)+":client");
+        return clientServerDecorator(suite,port);
+    }
 
     /**
      * Return a decorator for the passed in tests that sets the
@@ -325,6 +337,15 @@
             
         return defaultServerDecorator(test);
     }
+    /**
+     * Wrapper ot use the given port number.
+     */
+    public static Test clientServerDecorator(Test suite,int port)
+    {
+        Test test = new NetworkServerTestSetup(suite, false);
+            
+        return defaultServerDecorator(test,port);
+    }
    
     /**
      * Decorate a test to use suite's default host and port.
@@ -344,7 +365,24 @@
         //
         return new ServerSetup(test, DEFAULT_HOSTNAME, DEFAULT_PORT);
     }
-   
+    /**
+     * Decorate a test to use suite's default host and given port.
+     */
+    public static Test defaultServerDecorator(Test test, int port)
+    {
+        // Need to have network server and client and not
+        // running in J2ME (JSR169).
+        if (!(Derby.hasClient() && Derby.hasServer())
+                || JDBC.vmSupportsJSR169())
+            return new TestSuite("empty: no network server support");
+
+        //
+        // This looks bogus to me. Shouldn't this get the hostname and port
+        // which are specific to this test run (perhaps overridden on the
+        // command line)?
+        //
+        return new ServerSetup(test, DEFAULT_HOSTNAME, port);
+    }
 
     /**
      * Generate the unique database name for single use.



Mime
View raw message