KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tctest > spring > integrationtests > tests > InterceptorAppliedViaPostprocessorTest


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tctest.spring.integrationtests.tests;
5
6 import com.tctest.spring.bean.FooService;
7 import com.tctest.spring.integrationtests.framework.AbstractTwoServerDeploymentTest;
8 import com.tctest.spring.integrationtests.framework.DeploymentBuilder;
9
10 import junit.extensions.TestSetup;
11 import junit.framework.Test;
12
13 /**
14  * Verify that an interceptor is applied via a postprocessor to a distributed bean
15  */

16 public class InterceptorAppliedViaPostprocessorTest extends AbstractTwoServerDeploymentTest {
17
18   private static final String JavaDoc REMOTE_SERVICE_NAME = "FooService";
19   private static final String JavaDoc BEAN_DEFINITION_FILE_FOR_TEST = "classpath:/com/tctest/spring/interceptor-via-postprocessor.xml";
20   private static final String JavaDoc CONFIG_FILE_FOR_TEST = "/tc-config-files/interceptor-via-postprocessor-tc-config.xml";
21
22   private static FooService singleton1;
23   private static FooService singleton2;
24
25   public void testInterceptor() throws Exception JavaDoc {
26
27     assertEquals("interceptorInvoked-rawValue-0", singleton1.serviceMethod());
28     assertEquals("interceptorInvoked-rawValue-1", singleton2.serviceMethod());
29
30   }
31
32   private static class TS extends TwoSvrSetup {
33     private TS() {
34       super(InterceptorAppliedViaPostprocessorTest.class, CONFIG_FILE_FOR_TEST, "test-interceptor");
35     }
36
37     protected void setUp() throws Exception JavaDoc {
38       super.setUp();
39
40       singleton1 = (FooService) server1.getProxy(FooService.class, REMOTE_SERVICE_NAME);
41       singleton2 = (FooService) server2.getProxy(FooService.class, REMOTE_SERVICE_NAME);
42     }
43
44     protected void configureWar(DeploymentBuilder builder) {
45       builder.addBeanDefinitionFile(BEAN_DEFINITION_FILE_FOR_TEST);
46       builder.addRemoteService(REMOTE_SERVICE_NAME, "service", FooService.class);
47     }
48
49   }
50
51   /**
52    * JUnit test loader entry point
53    */

54   public static Test suite() {
55     TestSetup setup = new TS();
56     return setup;
57   }
58
59 }
60
Popular Tags