(no commit message)
[utils] / system / general / src / test / java / org / wamblee / system / core / StringComponent.java
index c47112aa6c86ab8d50906157c836a196f4cc474e..1fa2f3521188373f59f71d502510b1d279025521 100644 (file)
@@ -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.
  */
 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 {
+/**
+ * 
+ * @author $author$
+ * @version $Revision$
+ */
+public class StringComponent extends AbstractComponent<Object> {
+    private EventTracker<String> tracker;
 
-       private static final ProvidedInterface[] provided(String aPrefix) {
-               return new ProvidedInterface[] {
-                               new DefaultProvidedInterface(aPrefix + "datasource", String.class) };
-       }
+    private double random;
 
-       private EventTracker<String> _tracker;
-       private double _random;
+    /**
+     * Creates a new StringComponent object.
+     */
+    public StringComponent() {
+        this("environment");
+    }
 
-       public StringComponent() {
-               this("environment");
-       }
-       
-       public StringComponent(String aName) {
-       this(aName, "");
+    /**
+     * Creates a new StringComponent object.
+     * 
+     */
+    public StringComponent(String aName) {
+        this(aName, "");
     }
-       
-       public StringComponent(String aName, String aPrefix) {
+
+    /**
+     * Creates a new StringComponent object.
+     * 
+     */
+    public StringComponent(String aName, String aPrefix) {
         super(aName, provided(aPrefix), new RequiredInterface[0]);
-        _random = Math.random();
+        random = Math.random();
     }
 
+    /**
+     * Creates a new StringComponent object.
+     * 
+     */
+    public StringComponent(EventTracker aTracker) {
+        this();
+        tracker = aTracker;
+    }
 
+    private static final ProvidedInterface[] provided(String aPrefix) {
+        return new ProvidedInterface[] { new DefaultProvidedInterface(aPrefix +
+            "datasource", String.class) };
+    }
 
-       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);
-       }
+    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);
+    }
 }