01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tctest.spring.integrationtests.tests;
05:
06: import com.tc.test.server.appserver.deployment.AbstractTwoServerDeploymentTest;
07: import com.tc.test.server.appserver.deployment.DeploymentBuilder;
08: import com.tctest.spring.bean.FooService;
09: import com.tctest.spring.integrationtests.SpringTwoServerTestSetup;
10:
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: public class SingletonReferencingProxiedBeanTest extends
21: AbstractTwoServerDeploymentTest {
22:
23: private static final String FOO_SERVICE_NAME = "FooService";
24: private static final String BAR_SERVICE_NAME = "BarService";
25: private static final String BEAN_DEFINITION_FILE_FOR_TEST = "classpath:/com/tctest/spring/beanfactory-proxiedbean.xml";
26: private static final String CONFIG_FILE_FOR_TEST = "/tc-config-files/proxiedbean-tc-config.xml";
27:
28: private FooService bar1;
29: private FooService bar2;
30:
31: protected void setUp() throws Exception {
32: super .setUp();
33:
34: bar1 = (FooService) server0.getProxy(FooService.class,
35: BAR_SERVICE_NAME);
36: bar2 = (FooService) server1.getProxy(FooService.class,
37: BAR_SERVICE_NAME);
38: }
39:
40: public void testProxiedBean() throws Exception {
41: logger.debug("testing proxied bean");
42: assertEquals("0-barAndinterceptorInvoked-rawValue-0", bar1
43: .serviceMethod());
44: assertEquals("1-barAndinterceptorInvoked-rawValue-0", bar2
45: .serviceMethod());
46: }
47:
48: private static class InnerTestSetup extends
49: SpringTwoServerTestSetup {
50:
51: private InnerTestSetup() {
52: super (SingletonReferencingProxiedBeanTest.class,
53: CONFIG_FILE_FOR_TEST, "test-proxiedbean");
54: }
55:
56: protected void configureWar(DeploymentBuilder builder) {
57: builder
58: .addBeanDefinitionFile(BEAN_DEFINITION_FILE_FOR_TEST);
59: builder.addRemoteService(BAR_SERVICE_NAME, "service",
60: FooService.class);
61: builder.addRemoteService(FOO_SERVICE_NAME, "innerService",
62: FooService.class);
63: }
64: }
65:
66: public static Test suite() {
67: return new InnerTestSetup();
68: }
69:
70: }
|