X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=system%2Fgeneral%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fsystem%2Fcontainer%2FApplication.java;h=58dcba6070348876b513792c2a08a7f850797e28;hb=9f620f398d323e1e385d28d6a9630d2c406a3a19;hp=56c267fed6d9f80a76adf1c09d8674317c452f50;hpb=2fd9075c122aaca3613fafd805b4c2fb8b794430;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 56c267fe..58dcba60 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 @@ -12,9 +12,13 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.system.container; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import org.wamblee.system.core.AbstractComponent; import org.wamblee.system.core.DefaultRequiredInterface; import org.wamblee.system.core.ProvidedInterface; @@ -22,76 +26,79 @@ import org.wamblee.system.core.RequiredInterface; import org.wamblee.system.core.Scope; import org.wamblee.test.EventTracker; -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) - }; - } - - public static RequiredInterface[] required(boolean aOptional) { +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) }; + } + + public static RequiredInterface[] required(boolean aOptional) { return required(aOptional, ""); } - - private EventTracker _tracker; - private String _string; - private Integer _integer; - private double _random; - - public Application() { - this("application"); - } - - public Application(String aName) { - this(aName, ""); + private EventTracker _tracker; + private String _string; + private Integer _integer; + private double _random; + + public Application() { + this("application"); + } + + public Application(String aName) { + this(aName, ""); } - - public Application(String aName, String aPrefix) { - super(aName, new ProvidedInterface[0], required(false, aPrefix)); + + public Application(String aName, String aPrefix) { + super(aName, new ProvidedInterface[0], required(false, + aPrefix)); _random = Math.random(); } - - public Application(boolean aIsOptinal) { - super("application", new ProvidedInterface[0], required(true, "")); - } - - public Application(EventTracker aTracker) { - this(); - _tracker = aTracker; - } - @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; - } - - public String getString() { - return _string; - } - - public Integer getInteger() { - 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); - } - } - - private void track(String aString) { - if ( _tracker == null ) { - return; - } - _tracker.eventOccurred(aString); - } + public Application(boolean aIsOptinal) { + super("application", new ProvidedInterface[0], required(true, "")); + } + + public Application(EventTracker aTracker) { + this(); + _tracker = aTracker; + } + + @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; + } + + public String getString() { + return _string; + } + + public Integer getInteger() { + 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); + } + } + + private void track(String aString) { + if (_tracker == null) { + return; + } + _tracker.eventOccurred(aString); + } }