001 // Copyright 2005 The Apache Software Foundation 002 // 003 // Licensed under the Apache License, Version 2.0 (the "License"); 004 // you may not use this file except in compliance with the License. 005 // You may obtain a copy of the License at 006 // 007 // http://www.apache.org/licenses/LICENSE-2.0 008 // 009 // Unless required by applicable law or agreed to in writing, software 010 // distributed under the License is distributed on an "AS IS" BASIS, 011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 // See the License for the specific language governing permissions and 013 // limitations under the License. 014 015 package org.apache.tapestry.services.impl; 016 017 import org.apache.tapestry.IRequestCycle; 018 import org.apache.tapestry.engine.IEngineService; 019 import org.apache.tapestry.engine.ILink; 020 import org.testng.annotations.Test; 021 022 /** 023 * Tests for {@link org.apache.tapestry.services.impl.EngineServiceOuterProxy}. 024 * 025 * @author Howard M. Lewis Ship 026 * @since 4.0 027 */ 028 @Test(sequential = true) 029 public class EngineServiceOuterProxyTest extends AbstractEngineServiceProxyTestCase 030 { 031 public void testToString() 032 { 033 IEngineService s = new EngineServiceOuterProxy("fred"); 034 035 assertEquals("<OuterProxy for engine service 'fred'>", s.toString()); 036 } 037 038 public void testGetName() 039 { 040 EngineServiceOuterProxy proxy = new EngineServiceOuterProxy("Fred"); 041 042 assertEquals("Fred", proxy.getName()); 043 } 044 045 public void testService() throws Exception 046 { 047 IRequestCycle cycle = newCycle(); 048 IEngineService delegate = newEngineService(); 049 050 delegate.service(cycle); 051 052 replay(); 053 054 EngineServiceOuterProxy proxy = new EngineServiceOuterProxy("xxx"); 055 proxy.installDelegate(delegate); 056 057 assertSame(delegate, proxy.getDelegate()); 058 059 proxy.service(cycle); 060 061 verify(); 062 } 063 064 public void testGetLink() throws Exception 065 { 066 IEngineService delegate = newEngineService(); 067 ILink link = newLink(); 068 Object parameter = new Object(); 069 070 trainGetLink(delegate, false, parameter, link); 071 072 replay(); 073 074 EngineServiceOuterProxy proxy = new EngineServiceOuterProxy("xxx"); 075 proxy.installDelegate(delegate); 076 077 assertSame(link, proxy.getLink(false, parameter)); 078 079 verify(); 080 081 trainGetLink(delegate, true, parameter, link); 082 083 replay(); 084 085 assertSame(link, proxy.getLink(true, parameter)); 086 087 verify(); 088 } 089 }