X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=system%2Fgeneral%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fsystem%2Fcore%2FStringComponent.java;h=54766f18dc517e1e950d9f160f48d3e13e2e17c8;hb=ddd261f331280640c5b53c7128230b629ebcd268;hp=c47112aa6c86ab8d50906157c836a196f4cc474e;hpb=1bfc42afcea288a918e8befe65fd8f87b99ba2e4;p=utils diff --git a/system/general/src/test/java/org/wamblee/system/core/StringComponent.java b/system/general/src/test/java/org/wamblee/system/core/StringComponent.java index c47112aa..54766f18 100644 --- a/system/general/src/test/java/org/wamblee/system/core/StringComponent.java +++ b/system/general/src/test/java/org/wamblee/system/core/StringComponent.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,72 +15,141 @@ */ 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; -public class StringComponent extends AbstractComponent { +import javax.sql.DataSource; + - private static final ProvidedInterface[] provided(String aPrefix) { - return new ProvidedInterface[] { - new DefaultProvidedInterface(aPrefix + "datasource", String.class) }; - } +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class StringComponent extends AbstractComponent { + /** + * DOCUMENT ME! + */ + private EventTracker tracker; - private EventTracker _tracker; - private double _random; + /** + * DOCUMENT ME! + */ + private double random; - public StringComponent() { - this("environment"); - } - - public StringComponent(String aName) { - this(aName, ""); + /** + * Creates a new StringComponent object. + */ + public StringComponent() { + this("environment"); } - - public StringComponent(String aName, String aPrefix) { + + /** + * Creates a new StringComponent object. + * + * @param aName DOCUMENT ME! + */ + public StringComponent(String aName) { + this(aName, ""); + } + + /** + * Creates a new StringComponent object. + * + * @param aName DOCUMENT ME! + * @param aPrefix DOCUMENT ME! + */ + public StringComponent(String aName, String aPrefix) { super(aName, provided(aPrefix), new RequiredInterface[0]); - _random = Math.random(); + random = Math.random(); + } + + /** + * Creates a new StringComponent object. + * + * @param aTracker DOCUMENT ME! + */ + public StringComponent(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 + "datasource", String.class) + }; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Integer getInteger() { + return 2; } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String getString() { + return getName() + ".hello"; + } + + /** + * DOCUMENT ME! + * + * @param aScope DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + @Override + protected Object doStart(Scope aScope) { + addInterface(getProvidedInterfaces().get(0), getString(), aScope); + track("start." + getName()); + return random; + } - public StringComponent(EventTracker aTracker) { - this(); - _tracker = aTracker; - } - - public Integer getInteger() { - return 2; - } - - public String getString() { - return getName() + ".hello"; - } - - @Override - protected Object doStart(Scope aScope) { - addInterface(getProvidedInterfaces().get(0), getString(), 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 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); + } + } + + /** + * DOCUMENT ME! + * + * @param aString DOCUMENT ME! + */ + private void track(String aString) { + if (tracker == null) { + return; + } + + tracker.eventOccurred(aString); + } }