X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=system%2Fgeneral%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fsystem%2Fcore%2FIntegerComponent.java;h=0c45c75ddb117796e72f1075bf15c1ad9d4d2317;hb=49ce7cb8387601982d5e6ef186ce206d38f6e3d7;hp=acf683fef8af7f74a83ea09001db52a0c22fd43a;hpb=32a8562695029cf13d915bc7941a61fe07ff0005;p=utils diff --git a/system/general/src/test/java/org/wamblee/system/core/IntegerComponent.java b/system/general/src/test/java/org/wamblee/system/core/IntegerComponent.java index acf683fe..0c45c75d 100644 --- a/system/general/src/test/java/org/wamblee/system/core/IntegerComponent.java +++ b/system/general/src/test/java/org/wamblee/system/core/IntegerComponent.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. @@ -15,68 +15,83 @@ */ package org.wamblee.system.core; -import javax.sql.DataSource; - -import org.wamblee.system.core.AbstractComponent; -import org.wamblee.system.core.DefaultProvidedInterface; -import org.wamblee.system.core.ProvidedInterface; -import org.wamblee.system.core.RequiredInterface; import org.wamblee.test.EventTracker; +/** + * + * @author $author$ + * @version $Revision$ + */ public class IntegerComponent extends AbstractComponent { + private EventTracker tracker; - private static final ProvidedInterface[] provided(String aPrefix) { - return new ProvidedInterface[] { - new DefaultProvidedInterface(aPrefix + "integer", Integer.class) }; - } + private double random; - private EventTracker _tracker; - private double _random; + /** + * Creates a new IntegerComponent object. + */ + public IntegerComponent() { + this("environment"); + } - public IntegerComponent() { - this("environment"); - } - - public IntegerComponent(String aName) { - this(aName, ""); + /** + * Creates a new IntegerComponent object. + * + */ + public IntegerComponent(String aName) { + this(aName, ""); } - - public IntegerComponent(String aName, String aPrefix) { + + /** + * Creates a new IntegerComponent object. + * + */ + public IntegerComponent(String aName, String aPrefix) { super(aName, provided(aPrefix), new RequiredInterface[0]); - _random = Math.random(); + random = Math.random(); } + /** + * Creates a new IntegerComponent object. + * + */ + public IntegerComponent(EventTracker aTracker) { + this(); + tracker = aTracker; + } + private static final ProvidedInterface[] provided(String aPrefix) { + return new ProvidedInterface[] { new DefaultProvidedInterface(aPrefix + + "integer", Integer.class) }; + } - public IntegerComponent(EventTracker aTracker) { - this(); - _tracker = aTracker; - } + public Integer getInteger() { + return 2; + } + + @Override + protected Object doStart(Scope aScope) { + addInterface(getProvidedInterfaces().get(1), getInteger(), aScope); + track("start." + getName()); + + return random; + } - public Integer getInteger() { - return 2; - } + @Override + protected void doStop(Object aRuntime) { + track("stop." + getName()); - @Override - protected Object doStart(Scope aScope) { - addInterface(getProvidedInterfaces().get(1), getInteger(), aScope); - track("start." + getName()); - return _random; - } + if (random != (Double) aRuntime) { + throw new IllegalArgumentException("Wrong runtime: expected " + + random + " but got " + aRuntime); + } + } - @Override - protected 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; + } - private void track(String aString) { - if (_tracker == null) { - return; - } - _tracker.eventOccurred(aString); - } + tracker.eventOccurred(aString); + } }