01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.superbiz.interceptors;
17:
18: import org.junit.Before;
19: import org.junit.Test;
20:
21: import javax.naming.InitialContext;
22: import javax.naming.Context;
23: import java.util.Properties;
24: import java.util.List;
25: import java.util.ArrayList;
26:
27: import junit.framework.TestCase;
28:
29: /**
30: * @version $Rev: 609324 $ $Date: 2008-01-06 06:59:26 -0800 $
31: */
32: public class ThirdSLSBeanTest extends TestCase {
33: private InitialContext initCtx;
34:
35: @Before
36: public void setUp() throws Exception {
37: Properties properties = new Properties();
38: properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
39: "org.apache.openejb.client.LocalInitialContextFactory");
40: properties.setProperty("openejb.deployments.classpath.include",
41: ".*interceptors/target/classes.*");
42:
43: initCtx = new InitialContext(properties);
44: }
45:
46: @Test
47: public void testMethodWithDefaultInterceptorsExcluded()
48: throws Exception {
49: ThirdSLSBeanLocal bean = (ThirdSLSBeanLocal) initCtx
50: .lookup("ThirdSLSBeanLocal");
51:
52: assert bean != null;
53:
54: List<String> expected = new ArrayList<String>();
55: expected.add("ClassLevelInterceptorOne");
56: expected.add("ClassLevelInterceptorTwo");
57: expected.add("MethodLevelInterceptorOne");
58: expected.add("MethodLevelInterceptorTwo");
59: expected.add("ThirdSLSBean");
60: expected.add("businessMethod");
61:
62: List<String> actual = bean.businessMethod();
63: assert expected.equals(actual) : "Expected " + expected
64: + ", but got " + actual;
65: }
66:
67: @Test
68: public void testMethodWithDefaultAndClassInterceptorsExcluded()
69: throws Exception {
70: ThirdSLSBeanLocal bean = (ThirdSLSBeanLocal) initCtx
71: .lookup("ThirdSLSBeanLocal");
72:
73: assert bean != null;
74:
75: List<String> expected = new ArrayList<String>();
76: expected.add("MethodLevelInterceptorOne");
77: expected.add("MethodLevelInterceptorTwo");
78: expected.add("ThirdSLSBean");
79: expected.add("anotherBusinessMethod");
80:
81: List<String> actual = bean.anotherBusinessMethod();
82: assert expected.equals(actual) : "Expected " + expected
83: + ", but got " + actual;
84: }
85: }
|