Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 94381 invoked from network); 18 Aug 2006 02:44:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 18 Aug 2006 02:44:10 -0000 Received: (qmail 9959 invoked by uid 500); 18 Aug 2006 02:44:10 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 9930 invoked by uid 500); 18 Aug 2006 02:44:10 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 9919 invoked by uid 99); 18 Aug 2006 02:44:10 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Aug 2006 19:44:10 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Aug 2006 19:44:09 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 7C0071A981C; Thu, 17 Aug 2006 19:43:49 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r432468 - in /db/derby/code/trunk: java/testing/ java/testing/org/apache/derbyTesting/junit/ tools/ant/properties/ Date: Fri, 18 Aug 2006 02:43:48 -0000 To: derby-commits@db.apache.org From: djd@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060818024349.7C0071A981C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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 @@ + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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