Author: jfrederic.clere(a)jboss.com
Date: 2009-07-24 09:34:39 -0400 (Fri, 24 Jul 2009)
New Revision: 2506
Added:
trunk/mod_cluster/test/java/org/jboss/mod_cluster/Util.java
Modified:
trunk/mod_cluster/test/java/build.xml
trunk/mod_cluster/test/java/org/jboss/mod_cluster/Domaintest.java
Log:
Improve the logic to test the domain logic.
Modified: trunk/mod_cluster/test/java/build.xml
===================================================================
--- trunk/mod_cluster/test/java/build.xml 2009-07-24 10:12:48 UTC (rev 2505)
+++ trunk/mod_cluster/test/java/build.xml 2009-07-24 13:34:39 UTC (rev 2506)
@@ -208,28 +208,58 @@
</java>
<echo message="startjbossweb ${line}"/>
</target>
- <target name="domain" depends="compile">
- <copy file="conf/web.xml" todir="${test.classes}/conf"/>
- <!-- Create 4 server with a port to stop them -->
+ <target name="start4jbossweb" depends="compile">
<antcall target="startjbossweb">
- <param name="line" value="8009 node1 dom1 8005"/>
+ <param name="line" value="8009 ${basenode}1 dom1
8005"/>
</antcall>
<antcall target="startjbossweb">
- <param name="line" value="8010 node2 dom1 8006"/>
+ <param name="line" value="8010 ${basenode}2 dom1
8006"/>
</antcall>
<antcall target="startjbossweb">
- <param name="line" value="8011 node3 dom2 8007"/>
+ <param name="line" value="8011 ${basenode}3 dom2
8007"/>
</antcall>
<antcall target="startjbossweb">
- <param name="line" value="8012 node4 dom2 8008"/>
+ <param name="line" value="8012 ${basenode}4 dom2
8008"/>
</antcall>
+ </target>
+ <target name="startstop4jbossweb">
+ <antcall target="start4jbossweb">
+ <param name="basenode" value="${basenode}"/>
+ </antcall>
+ <java dir="${test.classes}"
classname="org.jboss.mod_cluster.Util" fork="yes"
failonerror="${test.failonerror}">
+ <classpath refid="tomcat.test.classpath"/>
+ </java>
+ </target>
+ <target name="domain20" depends="compile">
+ <!-- Create 4 server with a port to stop them -->
+ <antcall target="startstop4jbossweb">
+ <param name="basenode" value="aaaa"/>
+ </antcall>
+ <antcall target="startstop4jbossweb">
+ <param name="basenode" value="bbbb"/>
+ </antcall>
+ <antcall target="startstop4jbossweb">
+ <param name="basenode" value="cccc"/>
+ </antcall>
+ <antcall target="startstop4jbossweb">
+ <param name="basenode" value="dddd"/>
+ </antcall>
+ <antcall target="startstop4jbossweb">
+ <param name="basenode" value="eeee"/>
+ </antcall>
+ </target>
+ <target name="domain" depends="compile">
+ <copy file="conf/web.xml" todir="${test.classes}/conf"/>
+ <!-- Create 4 server for the test -->
+ <antcall target="start4jbossweb">
+ <param name="basenode" value="node"/>
+ </antcall>
<!-- Run a test : connect, get the node, stop it and check we stay on the domain
-->
<java dir="${test.classes}" classname="${test.runner}"
fork="yes" failonerror="${test.failonerror}">
<arg value="org.jboss.mod_cluster.Maintest"/>
<jvmarg line="-Dcluster=${cluster} -Dtest=Domaintest"/>
<classpath refid="tomcat.test.classpath"/>
</java>
-
</target>
<!-- Download and dependency building -->
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/Domaintest.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/Domaintest.java 2009-07-24 10:12:48
UTC (rev 2505)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/Domaintest.java 2009-07-24 13:34:39
UTC (rev 2506)
@@ -75,7 +75,7 @@
clienterror = true;
if (clienterror) {
- stopAll();
+ Util.stopAll();
fail("Client error");
}
@@ -93,7 +93,7 @@
stopport = 8008;
}
client.setnode(node);
- stopNode(stopport);
+ Util.stopNode(stopport);
try {
client.start();
client.join();
@@ -108,29 +108,7 @@
System.out.println("Test FAILED");
clienterror = true;
}
- stopAll();
+ Util.stopAll();
}
-
- public void stopNode(int port) {
- System.out.println("Stopping: " + port);
- try {
- Socket socket = new Socket("localhost", port);
- PrintWriter out = new PrintWriter(socket.getOutputStream());
- InputStream in = socket.getInputStream();
- out.print("SHUTDOWN");
- out.flush();
- in.read();
- socket.close();
- } catch (Exception ex) {
- ex.printStackTrace(System.out);
- }
- System.out.println("Stopped: " + port);
- }
- public void stopAll() {
- stopNode(8005);
- stopNode(8006);
- stopNode(8007);
- stopNode(8008);
- }
}
Added: trunk/mod_cluster/test/java/org/jboss/mod_cluster/Util.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/Util.java
(rev 0)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/Util.java 2009-07-24 13:34:39 UTC
(rev 2506)
@@ -0,0 +1,67 @@
+/*
+ * mod_cluster
+ *
+ * Copyright(c) 2009 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Jean-Frederic Clere
+ * @version $Revision$
+ */
+
+package org.jboss.mod_cluster;
+
+import java.lang.Exception;
+import java.net.Socket;
+import java.io.PrintWriter;
+import java.io.InputStream;
+
+public class Util {
+
+ public static void stopNode(int port) {
+ System.out.println("Stopping: " + port);
+ try {
+ Socket socket = new Socket("localhost", port);
+ PrintWriter out = new PrintWriter(socket.getOutputStream());
+ InputStream in = socket.getInputStream();
+ out.print("SHUTDOWN");
+ out.flush();
+ in.read();
+ socket.close();
+ } catch (Exception ex) {
+ ex.printStackTrace(System.out);
+ }
+ System.out.println("Stopped: " + port);
+ }
+ public static void stopAll() {
+ stopNode(8005);
+ stopNode(8006);
+ stopNode(8007);
+ stopNode(8008);
+ }
+ public static void main(String[] args) {
+ try {
+
+ Thread.currentThread().sleep(5000);
+ }
+ catch(InterruptedException ie){
+ }
+ stopAll();
+ }
+}
Show replies by date