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.Context;
22: import javax.naming.InitialContext;
23: import java.util.ArrayList;
24: import java.util.List;
25: import java.util.Properties;
26:
27: import junit.framework.TestCase;
28:
29: /**
30: * @version $Rev: 609324 $ $Date: 2008-01-06 06:59:26 -0800 $
31: */
32: public class SecondStatelessInterceptedTest extends TestCase {
33:
34: private InitialContext initCtx;
35:
36: @Before
37: public void setUp() throws Exception {
38: Properties properties = new Properties();
39: properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
40: "org.apache.openejb.client.LocalInitialContextFactory");
41: properties.setProperty("openejb.deployments.classpath.include",
42: ".*interceptors/target/classes.*");
43:
44: initCtx = new InitialContext(properties);
45: }
46:
47: @Test
48: public void testMethodWithDefaultInterceptorsExcluded()
49: throws Exception {
50: SecondStatelessInterceptedLocal bean = (SecondStatelessInterceptedLocal) initCtx
51: .lookup("SecondStatelessInterceptedBeanLocal");
52:
53: assert bean != null;
54:
55: List<String> expected = new ArrayList<String>();
56: expected.add("ClassLevelInterceptorOne");
57: expected.add("ClassLevelInterceptorTwo");
58: expected.add("MethodLevelInterceptorOne");
59: expected.add("MethodLevelInterceptorTwo");
60: expected.add("SecondStatelessInterceptedBean");
61: expected.add("methodWithDefaultInterceptorsExcluded");
62:
63: List<String> actual = bean
64: .methodWithDefaultInterceptorsExcluded();
65: assert expected.equals(actual) : "Expected " + expected
66: + ", but got " + actual;
67: }
68: }
|