Commit e0af085c authored by Christian Wulf's avatar Christian Wulf

refactoring

parent 38b71dbe
......@@ -47,7 +47,7 @@ public abstract class AbstractStage {
private static final Marker ON_STATE_CHANGE_MARKER = MarkerFactory.getMarker("ON_STATE_CHANGE_MARKER");
private static final boolean performanceLoggingEnabled = Boolean.getBoolean("performance.logging.enabled");
private static final boolean PERFORMANCE_LOGGING_ENABLED = Boolean.getBoolean("performance.logging.enabled");
/** This stage's unique logger */
@SuppressWarnings("PMD.LoggerIsNotStaticFinal")
......@@ -188,7 +188,7 @@ public abstract class AbstractStage {
* @throws TerminateException
*/
public final void executeByFramework() throws TerminateException {
if (performanceLoggingEnabled) {
if (PERFORMANCE_LOGGING_ENABLED) {
beforeExecuteTime = System.nanoTime();
executeWithCatchedExceptions();
if (lastState.getStageActivationState() == StageActivationState.ACTIVE) {
......@@ -728,7 +728,7 @@ public abstract class AbstractStage {
}
private boolean newStateRequired(final StageActivationState state) {
if (!performanceLoggingEnabled) {
if (!PERFORMANCE_LOGGING_ENABLED) {
return false;
}
return (this.lastState.getStageActivationState() != state);
......@@ -780,4 +780,11 @@ public abstract class AbstractStage {
this.stateless = stateless;
}
/**
* Only for testing purposes.
*/
static boolean isPerformanceLoggingEnabled() {
return PERFORMANCE_LOGGING_ENABLED;
}
}
......@@ -249,4 +249,28 @@ public class AbstractStageTest {
new Counter<>().workCompleted();
}
// @Test
// public void testActivedPerformanceLogging() throws Exception {
// System.setProperty("performance.logging.enabled", "true");
// assertThat(AbstractStage.isPerformanceLoggingEnabled(), is(true));
// }
//
// @Test
// public void testDeactivedPerformanceLogging() throws Exception {
// System.setProperty("performance.logging.enabled", "false");
// assertThat(AbstractStage.isPerformanceLoggingEnabled(), is(false));
// }
//
// @Test
// public void testInvalidPerformanceLogging() throws Exception {
// System.setProperty("performance.logging.enabled", "");
// assertThat(AbstractStage.isPerformanceLoggingEnabled(), is(false));
// }
//
// @Test
// public void testClearedPerformanceLogging() throws Exception {
// System.clearProperty("performance.logging.enabled");
// assertThat(AbstractStage.isPerformanceLoggingEnabled(), is(false));
// }
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment