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 dj...@apache.org on 2006/08/18 04:43:48 UTC
svn commit: r432468 - in /db/derby/code/trunk: java/testing/
java/testing/org/apache/derbyTesting/junit/ tools/ant/properties/
Author: djd
Date: Thu Aug 17 19:43:47 2006
New Revision: 432468
URL: http://svn.apache.org/viewvc?rev=432468&view=rev
Log:
The patch (DERBY-1712.diff) has a new class NetworkServerTestSetup. This class is put into a new package for junit components, called org.apache.derbyTesting.junit, and the patch therefore also contains a new build file.
TestConfiguration had to be modified so that the new class could use DERBY_TEST_CONFIG attribute.
patch contributed by Andreas Korneliusse nandreas.korneliussen@sun.com
Added:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/
db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/build.xml (with props)
Modified:
db/derby/code/trunk/java/testing/build.xml
db/derby/code/trunk/tools/ant/properties/dirs.properties
Modified: db/derby/code/trunk/java/testing/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/build.xml?rev=432468&r1=432467&r2=432468&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/build.xml (original)
+++ db/derby/code/trunk/java/testing/build.xml Thu Aug 17 19:43:47 2006
@@ -60,6 +60,7 @@
<ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/testData"/>
<ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/util"/>
<ant dir="${derby.testing.src.dir}/${derby.testing.unittest.dir}"/>
+ <ant dir="${derby.testing.src.dir}/${derby.testing.junit.dir}"/>
<ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/tests/junitTests/compatibility"/>
<ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/tests/junitTests/derbyNet"/>
<ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/tests/jdbcapi"/>
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java?rev=432468&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java Thu Aug 17 19:43:47 2006
@@ -0,0 +1,103 @@
+/*
+ *
+ * Derby - Class org.apache.derbyTesting.junit.NetworkServerTestSetup
+ *
+ * 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.junit;
+
+import java.net.InetAddress;
+import java.io.PrintWriter;
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import org.apache.derby.drda.NetworkServerControl;
+
+// This import can be removed once junit classes are moved to this
+// package:
+import org.apache.derbyTesting.functionTests.util.*;
+
+/**
+ * Test decorator that starts the network server on startup
+ * and stops it on teardown.
+ *
+ * It does not start it if the test is configured to run in
+ * embedded mode.
+ *
+ * Currently it will start the network server in the same VM
+ * as, and it does not support starting it from a remote
+ * machine.
+ */
+final public class NetworkServerTestSetup extends TestSetup {
+
+ /**
+ * Decorator this test with the NetworkServerTestSetup
+ */
+ public NetworkServerTestSetup(Test test) {
+ super(test);
+
+ this.config = TestConfiguration.DERBY_TEST_CONFIG;
+ this.networkServerController = null;
+ }
+
+ /**
+ * Start the network server.
+ */
+ protected void setUp() throws Exception {
+
+ if (config.getJDBCClient().isEmbedded()) {
+ BaseTestCase.println("Starting network server:");
+ networkServerController = new NetworkServerControl
+ (InetAddress.getByName(config.getHostName()), config.getPort());
+
+ networkServerController.start(new PrintWriter(System.out));
+
+ final long startTime = System.currentTimeMillis();
+ while (true) {
+ Thread.sleep(SLEEP_TIME);
+ try {
+ networkServerController.ping();
+ break;
+ } catch (Exception e) {
+ if (System.currentTimeMillis() - startTime > WAIT_TIME) {
+ e.printStackTrace();
+ fail("Timed out waiting for network server to start");
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Stop the network server.
+ */
+ protected void tearDown() throws Exception {
+ if (networkServerController != null) {
+ networkServerController.shutdown();
+ }
+ }
+
+ /* Network Server Control */
+ private NetworkServerControl networkServerController;
+
+ /* Configuration of test */
+ private final TestConfiguration config;
+
+ /** Wait maximum 1 minute for server to start */
+ private static final int WAIT_TIME = 60000;
+
+ /** Sleep for 50 ms before pinging the network server (again) */
+ private static final int SLEEP_TIME = 50;
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/build.xml?rev=432468&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/build.xml (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/build.xml Thu Aug 17 19:43:47 2006
@@ -0,0 +1,83 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+
+<!-- ==================================================================== -->
+<!-- Derby build file -->
+<!-- ==================================================================== -->
+
+<project default="junitcomponents" basedir="../../../../../..">
+
+<!-- ==================================================================== -->
+<!-- Set properties -->
+<!-- ==================================================================== -->
+
+ <property name="properties.dir" value="tools/ant/properties"/>
+
+ <!-- User settings -->
+ <property file="${user.home}/ant.properties"/>
+
+ <!-- Significant dirs -->
+ <property file="${properties.dir}/dirs.properties"/>
+ <property file="${properties.dir}/derbytesting.properties"/>
+
+ <!-- Compiler settings -->
+ <property file="${properties.dir}/defaultcompiler.properties"/>
+ <property file="${properties.dir}/${build.compiler}.properties"/>
+
+ <!-- Parser properties -->
+ <property file="${properties.dir}/parser.properties"/>
+
+ <!-- Compile-time classpath properties files -->
+ <property file="${properties.dir}/extrapath.properties"/>
+ <property file="${properties.dir}/compilepath.properties"/>
+ <property file="${user.home}/properties/derbytesting.properties"/>
+ <property file="${ant.home}/properties/derbytesting.properties"/>
+
+ <!-- Release and Version info -->
+ <property file="${properties.dir}/release.properties"/>
+
+<!-- ============ Begin Targets ============== -->
+
+ <target name="junitcomponents"
+ description="Build Derby JUnit test components">
+ <javac
+ source="1.3"
+ target="1.3"
+ bootclasspath="${empty}"
+ nowarn="on"
+ debug="${debug}"
+ depend="${depend}"
+ deprecation="${deprecation}"
+ optimize="${optimize}"
+ proceed="${proceed}"
+ verbose="${verbose}"
+ srcdir="${derby.testing.src.dir}"
+ destdir="${out.dir}">
+ <classpath>
+ <pathelement path="${compile.classpath}"/>
+ <pathelement path="${junit}"/>
+ </classpath>
+ <include name="${derby.testing.junit.dir}/**/*.java"/>
+ </javac>
+ </target>
+
+<!-- ============= End Targets ============== -->
+
+<!-- ============= End Project ============== -->
+
+</project>
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/build.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/trunk/tools/ant/properties/dirs.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/tools/ant/properties/dirs.properties?rev=432468&r1=432467&r2=432468&view=diff
==============================================================================
--- db/derby/code/trunk/tools/ant/properties/dirs.properties (original)
+++ db/derby/code/trunk/tools/ant/properties/dirs.properties Thu Aug 17 19:43:47 2006
@@ -60,4 +60,5 @@
derby.testing.out.dir=${out.dir}/${derby.testing.dir}
derby.testing.functest.dir=${derby.testing.dir}/functionTests
derby.testing.unittest.dir=${derby.testing.dir}/unitTests
+derby.testing.junit.dir=${derby.testing.dir}/junit
derby.testing.suites.dir=${derby.testing.functest.dir}/suites