Author: jfrederic.clere(a)jboss.com
Date: 2008-09-05 08:20:24 -0400 (Fri, 05 Sep 2008)
New Revision: 1776
Modified:
trunk/mod_cluster/test/java/org/jboss/mod_cluster/JBossWeb.java
trunk/mod_cluster/test/java/org/jboss/mod_cluster/ServerThread.java
trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestJBWEB_117.java
Log:
Also test native...
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/JBossWeb.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/JBossWeb.java 2008-09-05 09:04:28
UTC (rev 1775)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/JBossWeb.java 2008-09-05 12:20:24
UTC (rev 1776)
@@ -64,9 +64,53 @@
fos.close();
}
+ private static void copyFiles(File src, File dest) throws IOException {
+ if (src.isDirectory()) {
+ if (!dest.exists())
+ dest.mkdirs();
- public JBossWeb(String route, String host) throws IOException {
+ String list[] = src.list();
+ for (int i = 0; i < list.length; i++) {
+ File dest1 = new File(dest, list[i]);
+ File src1 = new File(src, list[i]);
+ copyFiles(src1 , dest1);
+ }
+ } else {
+ //This was not a directory, so lets just copy the file
+ FileInputStream fin = null;
+ FileOutputStream fout = null;
+ byte[] buffer = new byte[4096]; //Buffer 4K at a time (you can change this).
+ int bytesRead;
+ //open the files for input and output
+ fin = new FileInputStream(src);
+ fout = new FileOutputStream (dest);
+ //while bytesRead indicates a successful read, lets write...
+ while ((bytesRead = fin.read(buffer)) >= 0) {
+ fout.write(buffer,0,bytesRead);
+ }
+ fout.close();
+ fin.close();
+ }
+ }
+ private void copyNativeDir(String route) throws IOException {
+ File in = new File("bin/");
+ if (!in.exists()) {
+ return;
+ }
+ File ou = new File("node1/bin");
+ if (!ou.exists()) {
+ ou.mkdirs();
+ }
+ copyFiles(in, ou);
+ }
+ public JBossWeb(String route, String host, boolean nat) throws IOException {
+
+ // Copy native tree...
+ if (nat) {
+ copyNativeDir(route);
+ }
+
setCatalinaBase(route);
setCatalinaHome(route);
@@ -113,6 +157,10 @@
baseEngine.setService(this);
}
+ public JBossWeb(String route, String host) throws IOException {
+ this(route, host, false);
+ }
+
public void addWAR(String file, String route) throws IOException {
File fd = new File ( route + "/" + route + "/webapps");
fd.mkdirs();
@@ -131,9 +179,13 @@
}
public void addConnector(int port, String scheme) throws IOException {
+ addConnector(port, scheme, null);
+ }
+
+ public void addConnector(int port, String scheme, String address) throws IOException
{
- Connector connector = createConnector( (java.net.InetAddress) null,
+ Connector connector = createConnector( address,
port, scheme);
// Look in StandardService to see why it works ;-)
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/ServerThread.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/ServerThread.java 2008-09-05
09:04:28 UTC (rev 1775)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/ServerThread.java 2008-09-05
12:20:24 UTC (rev 1776)
@@ -50,6 +50,7 @@
}
public void run() {
try {
+ server.init();
server.start();
while (ok) {
Thread.sleep(delay);
@@ -59,6 +60,8 @@
} catch (InterruptedException e) {
} catch (LifecycleException ex) {
ex.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
}
}
public void stopit() {
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestJBWEB_117.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestJBWEB_117.java 2008-09-05
09:04:28 UTC (rev 1775)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestJBWEB_117.java 2008-09-05
12:20:24 UTC (rev 1776)
@@ -41,6 +41,8 @@
import org.jboss.web.cluster.ClusterListener;
+import org.apache.catalina.core.AprLifecycleListener;
+
public class TestJBWEB_117 extends TestCase {
/* Test for JBWEB-117 */
@@ -53,8 +55,8 @@
try {
// server = (StandardServer) ServerFactory.getServer();
- service = new JBossWeb("node1", "localhost");
- service.addConnector(8009, "ajp");
+ service = new JBossWeb("node1", "localhost", true);
+ service.addConnector(8009,
"org.apache.coyote.ajp.AjpAprProtocol");
service.addWAR("JBWEB-117.war", "node1");
server.addService(service);
@@ -65,6 +67,10 @@
// SSL ?
server.addLifecycleListener((LifecycleListener) cluster);
+ // Add AprLifecycleListener.
+ AprLifecycleListener listener = new AprLifecycleListener();
+ server.addLifecycleListener((LifecycleListener) listener);
+
// Debug Stuff
Maintest.listServices();