1 /* 2 * 3 * The Seasar Software License, Version 1.1 4 * 5 * Copyright (c) 2003-2004 The Seasar Project. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or 8 * without modification, are permitted provided that the following 9 * conditions are met: 10 * 11 * 1. Redistributions of source code must retain the above 12 * copyright notice, this list of conditions and the following 13 * disclaimer. 14 * 15 * 2. Redistributions in binary form must reproduce the above 16 * copyright notice, this list of conditions and the following 17 * disclaimer in the documentation and/or other materials provided 18 * with the distribution. 19 * 20 * 3. The end-user documentation included with the redistribution, 21 * if any, must include the following acknowledgement: 22 * "This product includes software developed by the 23 * Seasar Project (http://www.seasar.org/)." 24 * Alternately, this acknowledgement may appear in the software 25 * itself, if and wherever such third-party acknowledgements 26 * normally appear. 27 * 28 * 4. Neither the name "The Seasar Project" nor the names of its 29 * contributors may be used to endorse or promote products derived 30 * from this software without specific prior written permission of 31 * the Seasar Project. 32 * 33 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR 34 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 35 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 36 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE SEASAR PROJECT 37 * OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 38 * INCIDENTAL,SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 39 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 40 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 41 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 * WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING 43 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 44 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 */ 46 package org.seasar.remoting.common.interceptor; 47 48 import org.seasar.extension.unit.S2TestCase; 49 import org.seasar.framework.aop.interceptors.MockInterceptor; 50 51 /*** 52 * @author koichik 53 */ 54 public class RemotingInterceptorTest extends S2TestCase { 55 private MockInterceptor mockInterceptor; 56 57 public RemotingInterceptorTest(String name) { 58 super(name); 59 } 60 61 public void setUp() { 62 include("RemotingInterceptorTest.dicon"); 63 } 64 65 public void testInvoke() { 66 //call concrete method 67 Hoge hoge = (Hoge) getComponent(Hoge.class); 68 hoge.foo(); 69 assertFalse(mockInterceptor.isInvoked("invoke")); 70 71 //call abstract method 72 hoge.bar(); 73 assertTrue(mockInterceptor.isInvoked("invoke")); 74 } 75 76 public void testGetTargetName() { 77 //from name attribute of component 78 Hoge hoge = (Hoge) getComponent(Hoge.class); 79 hoge.bar(); 80 Object[] args = mockInterceptor.getArgs("invoke"); 81 assertEquals("hoge", args[0]); 82 83 //from class attribute of component 84 Foo foo = (Foo) getComponent(Foo.class); 85 foo.foo(); 86 args = mockInterceptor.getArgs("invoke"); 87 assertEquals("RemotingInterceptorTest$Foo", args[0]); 88 89 //from remoteName property 90 Bar bar = (Bar) getComponent(Bar.class); 91 bar.bar(); 92 args = mockInterceptor.getArgs("invoke"); 93 assertEquals("bar", args[0]); 94 } 95 96 public interface Hoge { 97 void foo(); 98 99 void bar(); 100 } 101 102 public static abstract class HogeImpl implements Hoge { 103 public void foo() { 104 } 105 } 106 107 public interface Foo { 108 void foo(); 109 } 110 111 public interface Bar { 112 void bar(); 113 } 114 }