KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > picocontainer > gems > util > MulticasterTestCase


1 package org.picocontainer.gems.util;
2
3 import junit.framework.TestCase;
4
5 import org.picocontainer.Disposable;
6 import org.picocontainer.Startable;
7 import org.picocontainer.defaults.DefaultPicoContainer;
8 import org.picocontainer.testmodel.RecordingLifecycle;
9
10 import com.thoughtworks.proxy.ProxyFactory;
11 import com.thoughtworks.proxy.factory.StandardProxyFactory;
12
13 /**
14  * @author Aslak Hellesøy
15  * @version $Revision: 2234 $
16  */

17 public class MulticasterTestCase extends TestCase {
18     public void testOrderOfInstantiationShouldBeDependencyOrder() throws Exception JavaDoc {
19
20         DefaultPicoContainer pico = new DefaultPicoContainer();
21         pico.registerComponentImplementation("recording", StringBuffer JavaDoc.class);
22         pico.registerComponentImplementation(RecordingLifecycle.Four.class);
23         pico.registerComponentImplementation(RecordingLifecycle.Two.class);
24         pico.registerComponentImplementation(RecordingLifecycle.One.class);
25         pico.registerComponentImplementation(RecordingLifecycle.Three.class);
26
27         ProxyFactory proxyFactory = new StandardProxyFactory();
28         Startable startable = (Startable) Multicaster.object(pico, true, proxyFactory);
29         Startable stoppable = (Startable) Multicaster.object(pico, false, proxyFactory);
30         Disposable disposable = (Disposable) Multicaster.object(pico, false, proxyFactory);
31
32         startable.start();
33         stoppable.stop();
34         disposable.dispose();
35
36         assertEquals("<One<Two<Three<FourFour>Three>Two>One>!Four!Three!Two!One", pico.getComponentInstance("recording").toString());
37     }
38
39 }
Popular Tags