X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=system%2Fgeneral%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fsystem%2Fcontainer%2FApplication.java;h=b02f9357870e587b7557c578e5572adda003e48c;hb=49ce7cb8387601982d5e6ef186ce206d38f6e3d7;hp=9392974f38275c9cf1baa269c81b7d481b0b888f;hpb=e1975449f1bf16ccb441632d68e440f3e3704a79;p=utils diff --git a/system/general/src/test/java/org/wamblee/system/container/Application.java b/system/general/src/test/java/org/wamblee/system/container/Application.java index 9392974f..b02f9357 100644 --- a/system/general/src/test/java/org/wamblee/system/container/Application.java +++ b/system/general/src/test/java/org/wamblee/system/container/Application.java @@ -1,5 +1,5 @@ /* - * Copyright 2007 the original author or authors. + * Copyright 2005-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,81 +20,110 @@ import org.wamblee.system.core.DefaultRequiredInterface; import org.wamblee.system.core.ProvidedInterface; import org.wamblee.system.core.RequiredInterface; import org.wamblee.system.core.Scope; + import org.wamblee.test.EventTracker; +/** + * + * @author $author$ + * @version $Revision$ + */ public class Application extends AbstractComponent { - public static RequiredInterface[] required(boolean aOptional, - String aPrefix) { - return new RequiredInterface[] { - new DefaultRequiredInterface(aPrefix + "string", String.class, - aOptional), - new DefaultRequiredInterface(aPrefix + "integer", - Integer.class, aOptional) }; - } + private EventTracker tracker; - public static RequiredInterface[] required(boolean aOptional) { - return required(aOptional, ""); - } + private String string; - private EventTracker _tracker; - private String _string; - private Integer _integer; - private double _random; + private Integer integer; + private double random; + + /** + * Creates a new Application object. + */ public Application() { this("application"); } + /** + * Creates a new Application object. + * + */ public Application(String aName) { this(aName, ""); } + /** + * Creates a new Application object. + * + */ public Application(String aName, String aPrefix) { - super(aName, new ProvidedInterface[0], required(false, - aPrefix)); - _random = Math.random(); + super(aName, new ProvidedInterface[0], required(false, aPrefix)); + random = Math.random(); } + /** + * Creates a new Application object. + * + */ public Application(boolean aIsOptinal) { super("application", new ProvidedInterface[0], required(true, "")); } + /** + * Creates a new Application object. + * + */ public Application(EventTracker aTracker) { this(); - _tracker = aTracker; + tracker = aTracker; + } + + public static RequiredInterface[] required(boolean aOptional, String aPrefix) { + return new RequiredInterface[] { + new DefaultRequiredInterface(aPrefix + "string", String.class, + aOptional), + new DefaultRequiredInterface(aPrefix + "integer", Integer.class, + aOptional) }; + } + + public static RequiredInterface[] required(boolean aOptional) { + return required(aOptional, ""); } @Override public Object doStart(Scope aScope) { track("start." + getName()); - _string = aScope.getInterfaceImplementation(getRequiredInterfaces() - .get(0).getProvider(), String.class); - _integer = aScope.getInterfaceImplementation(getRequiredInterfaces() - .get(1).getProvider(), Integer.class); - return _random; + string = aScope.getInterfaceImplementation(getRequiredInterfaces().get( + 0).getProvider(), String.class); + integer = aScope.getInterfaceImplementation(getRequiredInterfaces() + .get(1).getProvider(), Integer.class); + + return random; } public String getString() { - return _string; + return string; } public Integer getInteger() { - return _integer; + return integer; } @Override public void doStop(Object aRuntime) { track("stop." + getName()); - if (_random != (Double) aRuntime) { - throw new IllegalArgumentException("Wrong runtime: expected " - + _random + " but got " + aRuntime); + + if (random != (Double) aRuntime) { + throw new IllegalArgumentException("Wrong runtime: expected " + + random + " but got " + aRuntime); } } private void track(String aString) { - if (_tracker == null) { + if (tracker == null) { return; } - _tracker.eventOccurred(aString); + + tracker.eventOccurred(aString); } }