1 7 package org.jboss.test.remoting.interceptor; 8 9 import java.net.MalformedURLException ; 10 import org.jboss.aop.advice.Interceptor; 11 import org.jboss.aop.util.PayloadKey; 12 import org.jboss.aspects.remoting.interceptors.invoker.InvokerInterceptor; 13 import org.jboss.aspects.remoting.interceptors.invoker.RemotingInterceptorFactory; 14 import org.jboss.remoting.InvokerLocator; 15 import org.jboss.remoting.marshal.serializable.SerializableMarshaller; 16 17 import junit.framework.TestCase; 18 19 22 public class ClientInterceptorTest extends TestCase 23 { 24 private boolean passed = false; 25 26 public void runTest() throws MalformedURLException 27 { 28 Interceptor[] interceptorStack = new Interceptor[]{new InvokerInterceptor()}; 30 31 TestInvocation invocation = new TestInvocation(interceptorStack); 32 invocation.setArgument(new TestTarget()); 33 34 int port = 8081; 35 String transport = "socket"; 36 37 InvokerLocator locator = new InvokerLocator(transport + "://localhost:" + port + "/?" + 38 InvokerLocator.DATATYPE + "=" + SerializableMarshaller.DATATYPE); 39 invocation.getMetaData().addMetaData(RemotingInterceptorFactory.REMOTING, 40 RemotingInterceptorFactory.INVOKER_LOCATOR, locator, PayloadKey.TRANSIENT); 41 42 try 43 { 44 Object ret = invocation.invokeNext(); 45 if(ret instanceof Boolean && ((Boolean ) ret).booleanValue()) 46 { 47 assertTrue("Simple interceptor test passed. Value returned was not true.", true); 48 System.out.println("Test PASSED."); 49 passed = true; 50 } 51 else 52 { 53 assertTrue("Simple interceptor test passed. Value returned was not true.", false); 54 System.out.println("Test FAILED!!!"); 55 passed = false; 56 } 57 } 58 catch(Throwable throwable) 59 { 60 throwable.printStackTrace(); 61 } 62 } 63 64 public boolean isTestPassing() 65 { 66 return passed; 67 } 68 69 public static void main(String [] args) 70 { 71 try 72 { 73 new ClientInterceptorTest().runTest(); 74 } 75 catch(MalformedURLException e) 76 { 77 e.printStackTrace(); 78 } 79 } 80 81 } | Popular Tags |