db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From myrn...@apache.org
Subject svn commit: r985400 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/ tests/derbynet/
Date Fri, 13 Aug 2010 23:11:56 GMT
Author: myrnavl
Date: Fri Aug 13 23:11:55 2010
New Revision: 985400

URL: http://svn.apache.org/viewvc?rev=985400&view=rev
Log:
DERBY-4765; convert "org.apache.derbyTesting.functionTests.tests.derbynet.DerbyNetNewServer"
to junit
  patch contributed by Yun Lee (yun dot lee dot bj at gmail dot com)

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/DerbyNetNewServerTest.java
  (with props)
Removed:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetNewServer.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/DerbyNetNewServer.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/DerbyNetNewServer_app.properties
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetHarnessJavaTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/_Suite.java

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/DerbyNetNewServerTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/DerbyNetNewServerTest.java?rev=985400&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/DerbyNetNewServerTest.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/DerbyNetNewServerTest.java
Fri Aug 13 23:11:55 2010
@@ -0,0 +1,106 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.functionTests.tests.derbynet.DerbyNetNewServerTest
+
+   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.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.derby.drda.NetworkServerControl;
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.JDBC;
+import org.apache.derbyTesting.junit.NetworkServerTestSetup;
+import org.apache.derbyTesting.junit.TestConfiguration;
+
+/**
+ * Test NetworkServerControl.start(PrintWriter) writes to the print Writer
+ *
+ * test:
+ *<ul>
+ *<li> start( printWriter)
+ *<li> start( (PrintWriter) null)
+ *</ul>
+ */
+public class DerbyNetNewServerTest extends BaseJDBCTestCase {
+
+    public DerbyNetNewServerTest(String name) {
+        super(name);    
+    }    
+
+    public static Test suite() {
+        // Test does not run on J2ME
+        if (JDBC.vmSupportsJDBC3()) {
+            return new TestSuite(DerbyNetNewServerTest.class);
+        } else {
+            return new TestSuite("DerbyNetNewServerTest.empty");
+        }
+    }
+        
+    public void testStartWithPrintWriter()
+            throws UnknownHostException,
+            Exception {
+        ByteArrayOutputStream bos = new ByteArrayOutputStream(10240);
+        // DERBY-1466, Test that messages are flushed to the
+        // writer irrespective of whether the user's writer is
+        // set to autoflush true.
+        PrintWriter writer = new PrintWriter(bos);
+
+        NetworkServerControl server = new NetworkServerControl(InetAddress
+                .getByName(TestConfiguration.getCurrent().getHostName()),
+                TestConfiguration.getCurrent().getPort());
+
+        assertEquals("No log initially", 0, bos.size());
+        server.start(writer);
+        
+        NetworkServerTestSetup.waitForServerStart(server);
+        int sizeAfterPing = bos.size();
+        assertTrue("Create log with start message", 0 < sizeAfterPing);        
+        
+        server.shutdown();
+        int sizeAfterShutDown = bos.size();
+        bos.close();
+        bos = null;
+        writer.close();
+        assertTrue("Num of log item should add", 
+                sizeAfterShutDown > sizeAfterPing);
+    }
+    
+    public void testStartWithoutPrintWriter()
+            throws UnknownHostException,
+            Exception {
+        NetworkServerControl server = new NetworkServerControl(InetAddress
+                .getByName(TestConfiguration.getCurrent().getHostName()),
+                TestConfiguration.getCurrent().getPort());
+
+        server.start(null);
+        NetworkServerTestSetup.waitForServerStart(server);
+        server.shutdown();
+
+        //to show this is a right workflow.
+        assertTrue(true);
+    }
+
+}

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

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetHarnessJavaTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetHarnessJavaTest.java?rev=985400&r1=985399&r2=985400&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetHarnessJavaTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetHarnessJavaTest.java
Fri Aug 13 23:11:55 2010
@@ -86,12 +86,6 @@ public class NetHarnessJavaTest extends 
         //		         SecurityManagerSetup.noSecurityManager(
         //		             decorate(new NetHarnessJavaTest("testProtocol")))));
 
-        // Server does not run on J2ME
-        if (JDBC.vmSupportsJDBC3()) {
-            suite.addTest(SecurityManagerSetup.noSecurityManager(
-        		         decorate(new NetHarnessJavaTest("DerbyNetNewServer"))));
-        }
-        
         return new SupportFilesSetup(suite,
         	           new String[] {
 	                       "functionTests/tests/derbynet/protocol.tests",

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=985400&r1=985399&r2=985400&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
Fri Aug 13 23:11:55 2010
@@ -72,11 +72,14 @@ public class _Suite extends BaseTestCase
         //  in the nightly tests with JDK 1.6 and jar files.
         //suite.addTest(CheckSecurityManager.suite());
 
-        // this test refers to ConnectionPooledDataSource class
-        // thus causing class not found exceptions with JSR169
+ 
         if (JDBC.vmSupportsJDBC3())
         {
+            // this test refers to ConnectionPooledDataSource class
+            // thus causing class not found exceptions with JSR169
             suite.addTest(NSSecurityMechanismTest.suite());
+            // Test does not run on J2ME    
+            suite.addTest(DerbyNetNewServerTest.suite());
         }
 
         // These tests references a client class directly



Mime
View raw message