[jboss-remoting-commits] JBoss Remoting SVN: r6104 - remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test.
jboss-remoting-commits at lists.jboss.org
jboss-remoting-commits at lists.jboss.org
Wed Sep 15 18:10:10 EDT 2010
Author: ron.sigal at jboss.com
Date: 2010-09-15 18:10:10 -0400 (Wed, 15 Sep 2010)
New Revision: 6104
Added:
remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/TestRequestListener.java
remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/TypedRequestObject.java
Log:
JBREM-1228: Classes used in tests.
Added: remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/TestRequestListener.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/TestRequestListener.java (rev 0)
+++ remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/TestRequestListener.java 2010-09-15 22:10:10 UTC (rev 6104)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @author tags. 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.remoting3.test;
+
+import java.io.IOException;
+
+import org.jboss.remoting3.RemoteExecutionException;
+import org.jboss.remoting3.RequestContext;
+import org.jboss.remoting3.RequestListener;
+import org.jboss.xnio.log.Logger;
+
+/**
+ * @author <a href="ron.sigal at jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ *
+ * Copyright Aug 28, 2010
+ */
+public class TestRequestListener implements RequestListener<InvocationTestObject, InvocationTestObject> {
+
+ private static final Logger log = Logger.getLogger(TestRequestListener.class);
+
+ private InvocationTestObject replyObject;
+
+ public TestRequestListener(InvocationTestObject replyObject) {
+ this.replyObject = replyObject;
+ }
+
+ public void handleRequest(final RequestContext<InvocationTestObject> objectRequestContext, final InvocationTestObject request) throws RemoteExecutionException {
+ try {
+ if (request.getAction().equals(InvocationTestObject.REPLY)) {
+ log.debug("Got request %s, sending reply %s", request, replyObject);
+ objectRequestContext.sendReply(replyObject);
+ } else if (request.getAction().equals(InvocationTestObject.FAILURE)) {
+ log.debug("Got request %s, sending failure", request);
+ objectRequestContext.sendFailure("failure", new TestRequestException());
+ } else if (request.getAction().equals(InvocationTestObject.CANCEL)) {
+ log.debug("Got request %s, sending cancel", request);
+ objectRequestContext.sendCancelled();
+ } else {
+ throw new RuntimeException("unexpected action: " + request.getAction());
+ }
+ } catch (IOException e) {
+ log.error(e, "reply");
+ throw new RemoteExecutionException(e);
+ }
+ }
+
+ public static class TestRequestException extends Exception {
+ private static final long serialVersionUID = 1L;
+ TestRequestException() {
+ super("", null);
+ }
+ }
+}
Added: remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/TypedRequestObject.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/TypedRequestObject.java (rev 0)
+++ remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/TypedRequestObject.java 2010-09-15 22:10:10 UTC (rev 6104)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.remoting3.test;
+
+import java.io.Serializable;
+
+import org.jboss.remoting3.TypedRequest;
+
+/**
+ * @author <a href="ron.sigal at jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright August 27, 2010
+ */
+public class TypedRequestObject implements TypedRequest<TypedRequestObject, InvocationTestObject>, Serializable {
+
+ private static final long serialVersionUID = 1L;
+ private InvocationTestObject payload;
+
+ public TypedRequestObject(InvocationTestObject payload) {
+ this.payload = payload;
+ }
+
+ public InvocationTestObject castReply(Object reply) throws ClassCastException {
+ return InvocationTestObject.class.cast(reply);
+ }
+
+ public InvocationTestObject getPayload() {
+ return payload;
+ }
+}
More information about the jboss-remoting-commits
mailing list