X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=system%2Fgeneral%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fsystem%2Fcore%2FIntegerComponent.java;h=83616744a8b2df02d2cfe71a55875f495136b767;hb=f4d446b84fa1a38ed83cd157f79fdb8233822145;hp=23685e4e4a1f5adebc2475b3b9c9b93756433e2c;hpb=246a6a94ac725ea202a79591a69530014bf1da5f;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 23685e4e..83616744 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,12 +1,12 @@ /* * Copyright 2007 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. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,68 +15,132 @@ */ 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; +import javax.sql.DataSource; + + +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ public class IntegerComponent extends AbstractComponent { + /** + * DOCUMENT ME! + */ + private EventTracker tracker; - private static final ProvidedInterface[] provided(String aPrefix) { - return new ProvidedInterface[] { - new DefaultProvidedInterface(aPrefix + "integer", Integer.class) }; - } + /** + * DOCUMENT ME! + */ + 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. + * + * @param aName DOCUMENT ME! + */ + public IntegerComponent(String aName) { + this(aName, ""); } - - public IntegerComponent(String aName, String aPrefix) { + + /** + * Creates a new IntegerComponent object. + * + * @param aName DOCUMENT ME! + * @param aPrefix DOCUMENT ME! + */ + public IntegerComponent(String aName, String aPrefix) { super(aName, provided(aPrefix), new RequiredInterface[0]); random = Math.random(); } + /** + * Creates a new IntegerComponent object. + * + * @param aTracker DOCUMENT ME! + */ + public IntegerComponent(EventTracker aTracker) { + this(); + tracker = aTracker; + } + + /** + * DOCUMENT ME! + * + * @param aPrefix DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + private static final ProvidedInterface[] provided(String aPrefix) { + return new ProvidedInterface[] { + new DefaultProvidedInterface(aPrefix + "integer", Integer.class) + }; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Integer getInteger() { + return 2; + } + + /** + * DOCUMENT ME! + * + * @param aScope DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + @Override + protected Object doStart(Scope aScope) { + addInterface(getProvidedInterfaces().get(1), getInteger(), aScope); + track("start." + getName()); + + return random; + } + + /** + * DOCUMENT ME! + * + * @param aRuntime DOCUMENT ME! + */ + @Override + protected void doStop(Object aRuntime) { + track("stop." + getName()); + if (random != (Double) aRuntime) { + throw new IllegalArgumentException("Wrong runtime: expected " + + random + " but got " + aRuntime); + } + } - 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; - } - - @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; - } - tracker.eventOccurred(aString); - } + /** + * DOCUMENT ME! + * + * @param aString DOCUMENT ME! + */ + private void track(String aString) { + if (tracker == null) { + return; + } + + tracker.eventOccurred(aString); + } }