001: /* ====================================================================
002: The Jicarilla Software License
003:
004: Copyright (c) 2003 Leo Simons.
005: All rights reserved.
006:
007: Permission is hereby granted, free of charge, to any person obtaining
008: a copy of this software and associated documentation files (the
009: "Software"), to deal in the Software without restriction, including
010: without limitation the rights to use, copy, modify, merge, publish,
011: distribute, sublicense, and/or sell copies of the Software, and to
012: permit persons to whom the Software is furnished to do so, subject to
013: the following conditions:
014:
015: The above copyright notice and this permission notice shall be
016: included in all copies or substantial portions of the Software.
017:
018: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
019: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
020: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
021: IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
022: CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
023: TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
024: SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
025: ==================================================================== */
026: package org.jicarilla.container.test;
027:
028: import org.jicarilla.container.Container;
029: import org.jicarilla.container.Resolver;
030: import org.jicarilla.container.adapters.SingletonAdapter;
031: import org.jicarilla.container.factories.Type25Factory;
032: import org.jicarilla.container.factories.Type2Factory;
033: import org.jicarilla.container.factories.Type35Factory;
034: import org.jicarilla.container.factories.Type3Factory;
035: import org.jicarilla.container.selectors.ClassSelector;
036: import org.jicarilla.container.tck.AbstractAllInTheFamilyTestCase;
037: import org.jicarilla.container.tck.components.interfaces.Bart;
038: import org.jicarilla.container.tck.components.interfaces.Homer;
039: import org.jicarilla.container.tck.components.interfaces.Lisa;
040: import org.jicarilla.container.tck.components.interfaces.Maggie;
041: import org.jicarilla.container.tck.components.interfaces.Marge;
042: import org.jicarilla.container.tck.components.interfaces.Script;
043: import org.jicarilla.container.tck.components.type3.rich.AllInTheFamilyScript;
044: import org.jicarilla.container.tck.components.type3.rich.BartImpl;
045: import org.jicarilla.container.tck.components.type3.rich.HomerImpl;
046: import org.jicarilla.container.tck.components.type3.rich.LisaImpl;
047: import org.jicarilla.container.tck.components.type3.rich.MaggieImpl;
048: import org.jicarilla.container.tck.components.type3.rich.MargeImpl;
049:
050: /**
051: *
052: *
053: * @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
054: * @version $Id: AbstractJicarillaAllInTheFamilyTestCase.java,v 1.3 2004/04/03 12:09:19 lsimons Exp $
055: */
056: public abstract class AbstractJicarillaAllInTheFamilyTestCase extends
057: AbstractAllInTheFamilyTestCase {
058: protected Container jc;// = new DefaultContainer();
059: protected Resolver r;// = pc.getResolver();
060:
061: protected abstract Container getContainer();
062:
063: public void setUp() throws Exception {
064: jc = getContainer();
065: r = jc.getResolver();
066:
067: doPopulate();
068:
069: super .setUp();
070: }
071:
072: protected void doPopulate() {
073: jc.registerAdapter(new ClassSelector(Marge.class),
074: new SingletonAdapter(new Type3Factory(r,
075: MargeImpl.class.getName())));
076: jc.registerAdapter(new ClassSelector(Homer.class),
077: new SingletonAdapter(new Type25Factory(r,
078: HomerImpl.class.getName())));
079: jc.registerAdapter(new ClassSelector(Bart.class),
080: new SingletonAdapter(new Type2Factory(r, BartImpl.class
081: .getName())));
082: jc.registerAdapter(new ClassSelector(Lisa.class),
083: new SingletonAdapter(new Type3Factory(r, LisaImpl.class
084: .getName())));
085: jc.registerAdapter(new ClassSelector(Maggie.class),
086: new SingletonAdapter(new Type2Factory(r,
087: MaggieImpl.class.getName())));
088: jc.registerAdapter(new ClassSelector(Script.class),
089: new SingletonAdapter(new Type35Factory(r,
090: AllInTheFamilyScript.class.getName())));
091: }
092:
093: protected Script getAllInTheFamilyScript() {
094: return (AllInTheFamilyScript) r.get(Script.class);
095: }
096:
097: protected Homer getHomer() {
098: return (Homer) r.get(Homer.class);
099: }
100:
101: protected Marge getMarge() {
102: return (Marge) r.get(Marge.class);
103: }
104:
105: protected Bart getBart() {
106: return (Bart) r.get(Bart.class);
107: }
108:
109: protected Lisa getLisa() {
110: return (Lisa) r.get(Lisa.class);
111: }
112:
113: protected Maggie getMaggie() {
114: return (Maggie) r.get(Maggie.class);
115: }
116: }
|