01: /*****************************************************************************
02: * Copyright (C) NanoContainer Organization. All rights reserved. *
03: * ------------------------------------------------------------------------- *
04: * The software in this package is published under the terms of the BSD *
05: * style license a copy of which has been included with this distribution in *
06: * the LICENSE.txt file. *
07: * *
08: *****************************************************************************/package org.nanocontainer.testmodel;
09:
10: import junit.framework.Assert;
11: import org.picocontainer.Disposable;
12: import org.picocontainer.Startable;
13:
14: /**
15: * An abstract component and three dependancies used for testing.
16: */
17: public abstract class Xxx implements Startable, Disposable {
18:
19: public static String componentRecorder = "";
20:
21: public static void reset() {
22: componentRecorder = "";
23: }
24:
25: public void start() {
26: componentRecorder += "<" + code();
27: }
28:
29: public void stop() {
30: componentRecorder += code() + ">";
31: }
32:
33: public void dispose() {
34: componentRecorder += "!" + code();
35: }
36:
37: private String code() {
38: String name = getClass().getName();
39: return name.substring(name.indexOf('$') + 1, name.length());
40: }
41:
42: public static class A extends Xxx {
43: }
44:
45: public static class B extends Xxx {
46: A a;
47:
48: public B(A a) {
49: Assert.assertNotNull(a);
50: this .a = a;
51: }
52:
53: public A getA() {
54: return a;
55: }
56: }
57:
58: public static class C extends Xxx {
59: }
60: }
|