001 /*****************************************************************************
002 * Copyright (C) NanoContainer Organization. All rights reserved. *
003 * ------------------------------------------------------------------------- *
004 * The software in this package is published under the terms of the BSD *
005 * style license a copy of which has been included with this distribution in *
006 * the LICENSE.txt file. *
007 * *
008 *****************************************************************************/
009 package org.nanocontainer.testmodel;
010
011 import junit.framework.Assert;
012 import org.picocontainer.Disposable;
013 import org.picocontainer.Startable;
014
015 /**
016 * An abstract component and three dependancies used for testing.
017 */
018 public abstract class Xxx implements Startable, Disposable {
019
020 public static String componentRecorder = "";
021
022 public static void reset() {
023 componentRecorder = "";
024 }
025
026 public void start() {
027 componentRecorder += "<" + code();
028 }
029
030 public void stop() {
031 componentRecorder += code() + ">";
032 }
033
034 public void dispose() {
035 componentRecorder += "!" + code();
036 }
037
038 private String code() {
039 String name = getClass().getName();
040 return name.substring(name.indexOf('$') + 1, name.length());
041 }
042
043 public static class A extends Xxx {
044 }
045
046 public static class B extends Xxx {
047 A a;
048
049 public B(A a) {
050 Assert.assertNotNull(a);
051 this.a = a;
052 }
053
054 public A getA() {
055 return a;
056 }
057 }
058
059 public static class C extends Xxx {
060 }
061 }