KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Testing the following features
15  * 1. proxy is correctly invoked
16  * 2. The shared bean is cached in the mixin cache
17  *
18  * @author Liyu Yi
19  */

20 /**
21  * Testing Singleton works and also
22  */

23 public class SingletonReferencingProxiedBeanTest extends AbstractTwoServerDeploymentTest {
24
25   private static final String JavaDoc FOO_SERVICE_NAME = "FooService";
26   private static final String JavaDoc BAR_SERVICE_NAME = "BarService";
27   private static final String JavaDoc BEAN_DEFINITION_FILE_FOR_TEST = "classpath:/com/tctest/spring/beanfactory-proxiedbean.xml";
28   private static final String JavaDoc CONFIG_FILE_FOR_TEST = "/tc-config-files/proxiedbean-tc-config.xml";
29
30   private static FooService bar1;
31   private static FooService bar2;
32
33   public void testProxiedBean() throws Exception JavaDoc {
34     logger.debug("testing proxied bean");
35     assertEquals("0-barAndinterceptorInvoked-rawValue-0", bar1.serviceMethod());
36     assertEquals("1-barAndinterceptorInvoked-rawValue-0", bar2.serviceMethod());
37   }
38
39   private static class InnerTestSetup extends TwoSvrSetup {
40
41     private InnerTestSetup() {
42       super(SingletonReferencingProxiedBeanTest.class, CONFIG_FILE_FOR_TEST, "test-proxiedbean");
43     }
44
45     protected void setUp() throws Exception JavaDoc {
46       super.setUp();
47       bar1 = (FooService) server1.getProxy(FooService.class, BAR_SERVICE_NAME);
48       bar2 = (FooService) server2.getProxy(FooService.class, BAR_SERVICE_NAME);
49     }
50
51     protected void configureWar(DeploymentBuilder builder) {
52       builder.addBeanDefinitionFile(BEAN_DEFINITION_FILE_FOR_TEST);
53       builder.addRemoteService(BAR_SERVICE_NAME, "service", FooService.class);
54       builder.addRemoteService(FOO_SERVICE_NAME, "innerService", FooService.class);
55     }
56   }
57
58   /**
59    * JUnit test loader entry point
60    */

61   public static Test suite() {
62     TestSetup setup = new InnerTestSetup();
63     return setup;
64   }
65
66 }
67
Popular Tags