Skip to content
Snippets Groups Projects
Commit 102abf04 authored by Christian Wulf's avatar Christian Wulf
Browse files

fixed StageTest

parent b010838d
No related branches found
No related tags found
No related merge requests found
package teetime.framework; package teetime.framework;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -12,8 +12,9 @@ import teetime.framework.validation.InvalidPortConnection; ...@@ -12,8 +12,9 @@ import teetime.framework.validation.InvalidPortConnection;
public abstract class Stage { // NOPMD (should not start with "Abstract") public abstract class Stage { // NOPMD (should not start with "Abstract")
private static final ConcurrentMap<String, Integer> INSTANCES_COUNTER = new ConcurrentHashMap<String, Integer>();
private final String id; private final String id;
private static final Map<String, Integer> INSTANCES_COUNTER = new ConcurrentHashMap<String, Integer>();
/** /**
* A unique logger instance per stage instance * A unique logger instance per stage instance
*/ */
...@@ -21,7 +22,7 @@ public abstract class Stage { // NOPMD (should not start with "Abstract") ...@@ -21,7 +22,7 @@ public abstract class Stage { // NOPMD (should not start with "Abstract")
protected Stage() { protected Stage() {
this.id = this.createId(); this.id = this.createId();
this.logger = LoggerFactory.getLogger(this.getClass().getName() + "-" + this.id); this.logger = LoggerFactory.getLogger(this.id);
} }
public String getId() { public String getId() {
...@@ -46,6 +47,10 @@ public abstract class Stage { // NOPMD (should not start with "Abstract") ...@@ -46,6 +47,10 @@ public abstract class Stage { // NOPMD (should not start with "Abstract")
return newId; return newId;
} }
static void clearInstanceCounters() { // NOPMD (package-private to clear map in tests)
INSTANCES_COUNTER.clear();
}
// public abstract Stage getParentStage(); // public abstract Stage getParentStage();
// //
// public abstract void setParentStage(Stage parentStage, int index); // public abstract void setParentStage(Stage parentStage, int index);
......
...@@ -10,6 +10,8 @@ public class StageTest { ...@@ -10,6 +10,8 @@ public class StageTest {
@Test @Test
public void testId() { public void testId() {
Stage.clearInstanceCounters();
Counter<Object> counter0 = new Counter<Object>(); Counter<Object> counter0 = new Counter<Object>();
Counter<Object> counter1 = new Counter<Object>(); Counter<Object> counter1 = new Counter<Object>();
Assert.assertEquals("Counter-0", counter0.getId()); Assert.assertEquals("Counter-0", counter0.getId());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment