001: // Copyright 2006, 2007 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.ioc.internal;
016:
017: import java.util.ArrayList;
018: import java.util.Collection;
019: import java.util.List;
020:
021: import org.apache.commons.logging.Log;
022: import org.apache.tapestry.ioc.ServiceResources;
023: import org.apache.tapestry.ioc.annotations.Inject;
024: import org.apache.tapestry.ioc.annotations.InjectService;
025: import org.apache.tapestry.ioc.annotations.Value;
026: import org.testng.Assert;
027:
028: /**
029: * Used by {@link org.apache.tapestry.ioc.internal.ServiceBuilderMethodInvokerTest}.
030: */
031: public class ServiceBuilderMethodFixture extends Assert {
032: FieService _fie;
033:
034: String _expectedServiceId;
035:
036: ServiceResources _expectedServiceResources;
037:
038: Class _expectedServiceInterface;
039:
040: Log _expectedLog;
041:
042: FoeService _expectedFoe;
043:
044: Object _expectedConfiguration;
045:
046: String _expectedString;
047:
048: public FieService buildWithUnorderedConfiguration(
049: Collection<Runnable> configuration) {
050: assertSame(configuration, _expectedConfiguration);
051:
052: return _fie;
053: }
054:
055: public FieService buildWithOrderedConfiguration(
056: List<Runnable> configuration) {
057: assertSame(configuration, _expectedConfiguration);
058:
059: return _fie;
060: }
061:
062: public void methodWithParameterizedList(List<Runnable> list) {
063: }
064:
065: public void methodWithList(List list) {
066: }
067:
068: public void methodWithWildcardList(List<? super ArrayList> list) {
069:
070: }
071:
072: public FieService build_noargs() {
073: return _fie;
074: }
075:
076: public FieService build_injected(@InjectService("Foe")
077: FoeService foe) {
078: assertSame(_expectedFoe, foe);
079:
080: return _fie;
081: }
082:
083: public FieService build_auto(FoeService foe) {
084: assertSame(_expectedFoe, foe);
085:
086: return _fie;
087: }
088:
089: public FieService build_fail() {
090: throw new RuntimeException("Method failed.");
091: }
092:
093: public FieService build_args(String serviceId,
094: ServiceResources resources, Class serviceInterface, Log log) {
095: assertEquals(serviceId, _expectedServiceId);
096: assertSame(resources, _expectedServiceResources);
097: assertSame(serviceInterface, _expectedServiceInterface);
098: assertSame(log, _expectedLog);
099:
100: return _fie;
101: }
102:
103: public FieService build_with_forced_injection(@Inject
104: @Value("Injected")
105: String string) {
106: assertEquals(string, _expectedString);
107:
108: return _fie;
109: }
110:
111: }
|