[jboss-osgi-commits] JBoss-OSGI SVN: r91199 - in projects/jboss-osgi/trunk: reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky and 2 other directories.
jboss-osgi-commits at lists.jboss.org
jboss-osgi-commits at lists.jboss.org
Tue Jul 14 06:41:00 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-07-14 06:41:00 -0400 (Tue, 14 Jul 2009)
New Revision: 91199
Added:
projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/internal/BasicFailure.java
Modified:
projects/jboss-osgi/trunk/distribution/installer/
projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/Request.java
projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractConnector.java
projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractPackageListener.java
projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/internal/BasicRequest.java
projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnectorMBean.java
projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/SocketConnector.java
Log:
Relay husky socket exceptions back to client
Property changes on: projects/jboss-osgi/trunk/distribution/installer
___________________________________________________________________
Name: svn:ignore
+ target
Modified: projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/Request.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/Request.java 2009-07-14 10:05:14 UTC (rev 91198)
+++ projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/Request.java 2009-07-14 10:41:00 UTC (rev 91199)
@@ -36,10 +36,10 @@
/**
* Get the test case name
*/
- String getTestClass();
+ String getClassName();
/**
* Get the test method name
*/
- String getTestMethod();
+ String getMethodName();
}
Modified: projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractConnector.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractConnector.java 2009-07-14 10:05:14 UTC (rev 91198)
+++ projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractConnector.java 2009-07-14 10:41:00 UTC (rev 91199)
@@ -23,11 +23,6 @@
// $Id$
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;
@@ -58,7 +53,7 @@
public Response process(Request req) throws ClassNotFoundException
{
- String testClass = req.getTestClass();
+ String testClass = req.getClassName();
for (PackageListener listener : listeners)
{
if (listener.match(req))
@@ -68,35 +63,4 @@
}
throw new IllegalStateException("Cannot find listener to handle: " + testClass + ", we have " + listeners);
}
-
- public InputStream process(InputStream reqStream)
- {
- try
- {
- // Unmarshall the Request
- ObjectInputStream ois = new ObjectInputStream(reqStream);
- Request request = (Request)ois.readObject();
-
- // Field the request through the abstract connector
- Response response = process(request);
- if (response == null)
- throw new IllegalStateException("response cannot be null");
-
- // Marshall the Response
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(response);
- oos.close();
-
- return new ByteArrayInputStream(baos.toByteArray());
- }
- catch (RuntimeException rte)
- {
- throw rte;
- }
- catch (Exception ex)
- {
- throw new IllegalStateException("Cannot process request", ex);
- }
- }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractPackageListener.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractPackageListener.java 2009-07-14 10:05:14 UTC (rev 91198)
+++ projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractPackageListener.java 2009-07-14 10:41:00 UTC (rev 91199)
@@ -52,7 +52,7 @@
public boolean match(Request req)
{
- String testClass = req.getTestClass();
+ String testClass = req.getClassName();
for (String testPackage : testPackages)
{
if (testClass.startsWith(testPackage))
@@ -63,7 +63,7 @@
public Response runTests(Request request) throws ClassNotFoundException
{
- String testClass = request.getTestClass();
+ String testClass = request.getClassName();
return getRunner().runTests(getContext(), loadTestClass(testClass));
}
Added: projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/internal/BasicFailure.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/internal/BasicFailure.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/internal/BasicFailure.java 2009-07-14 10:41:00 UTC (rev 91199)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.husky.internal;
+
+// $Id: BasicResponse.java 91197 2009-07-14 09:48:24Z thomas.diesler at jboss.com $
+
+import org.jboss.osgi.husky.Failure;
+
+/**
+ * A basic {@link Failure} implementation.
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 16-May-2009
+ */
+public class BasicFailure implements Failure
+{
+ private static final long serialVersionUID = 1L;
+
+ private String message;
+ private Throwable exception;
+ private String className;
+ private String methodName;
+
+ public BasicFailure(String message, Throwable exception)
+ {
+ this.message = message;
+ this.exception = exception;
+ }
+
+ public Throwable getException()
+ {
+ return exception;
+ }
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ public String getClassName()
+ {
+ return className;
+ }
+
+ public void setClassName(String className)
+ {
+ this.className = className;
+ }
+
+ public String getMethodName()
+ {
+ return methodName;
+ }
+
+ public void setMethodName(String methodName)
+ {
+ this.methodName = methodName;
+ }
+}
Modified: projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/internal/BasicRequest.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/internal/BasicRequest.java 2009-07-14 10:05:14 UTC (rev 91198)
+++ projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/internal/BasicRequest.java 2009-07-14 10:41:00 UTC (rev 91199)
@@ -35,23 +35,23 @@
{
private static final long serialVersionUID = 1L;
- private String testClass;
- private String testMethod;
+ private String className;
+ private String methodName;
- public BasicRequest(String testClass, String testMethod)
+ public BasicRequest(String className, String methodName)
{
- this.testClass = testClass;
- this.testMethod = testMethod;
+ this.className = className;
+ this.methodName = methodName;
}
- public String getTestClass()
+ public String getClassName()
{
- return testClass;
+ return className;
}
- public String getTestMethod()
+ public String getMethodName()
{
- return testMethod;
+ return methodName;
}
}
Modified: projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnectorMBean.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnectorMBean.java 2009-07-14 10:05:14 UTC (rev 91198)
+++ projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnectorMBean.java 2009-07-14 10:41:00 UTC (rev 91199)
@@ -23,8 +23,6 @@
//$Id$
-import java.io.InputStream;
-
import org.jboss.osgi.husky.runtime.PackageListener;
/**
@@ -36,13 +34,6 @@
public interface JMXConnectorMBean
{
/*
- * Consumes the serialized version of an {@link Request} and return the the {@link Response} from the test run
- * @param reqStream the input stream to read the {@link Request} from
- * @return the input stream to read the {@link Response} from
- */
- InputStream process(InputStream reqStream);
-
- /*
* Add a {@link PackageListener} to this connector
*/
void addPackageListener(PackageListener listener);
Modified: projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/SocketConnector.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/SocketConnector.java 2009-07-14 10:05:14 UTC (rev 91198)
+++ projects/jboss-osgi/trunk/reactor/bundles/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/SocketConnector.java 2009-07-14 10:41:00 UTC (rev 91199)
@@ -23,14 +23,22 @@
// $Id$
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Properties;
+import org.jboss.osgi.husky.Request;
+import org.jboss.osgi.husky.Response;
import org.jboss.osgi.husky.internal.AbstractConnector;
+import org.jboss.osgi.husky.internal.BasicFailure;
+import org.jboss.osgi.husky.internal.BasicResponse;
import org.jboss.osgi.husky.internal.LogServiceTracker;
import org.jboss.osgi.husky.internal.Util;
import org.jboss.osgi.husky.runtime.Connector;
@@ -110,6 +118,47 @@
listenerThread.stopListener();
}
+ private InputStream process(InputStream reqStream)
+ {
+ Request request = null;
+ Response response = null;
+ try
+ {
+ // Unmarshall the Request
+ ObjectInputStream ois = new ObjectInputStream(reqStream);
+ request = (Request)ois.readObject();
+
+ // Field the request through the abstract connector
+ response = process(request);
+ }
+ catch (Exception ex)
+ {
+ response = new BasicResponse();
+ BasicFailure failure = new BasicFailure(ex.getMessage(), ex);
+ if (request != null)
+ {
+ failure.setClassName(request.getClassName());
+ failure.setMethodName(request.getMethodName());
+ }
+ response.addFailure(failure);
+ }
+
+ // Marshall the Response
+ try
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(response);
+ oos.close();
+
+ return new ByteArrayInputStream(baos.toByteArray());
+ }
+ catch (IOException ex)
+ {
+ throw new IllegalStateException("Cannot marshall response", ex);
+ }
+ }
+
class ListenerThread extends Thread
{
private ServerSocket serverSocket;
More information about the jboss-osgi-commits
mailing list