DebugRotationTest.java revision 59dd4e51b41d4317eab7eed8962531c1bb5c0676
/**
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2014-2015 ForgeRock AS.
*/
public class DebugRotationTest extends DebugTestTemplate {
@Test
//initialize a scenario
//Accelerate the test timeservice
//2s <=> 12 min = 720sec = 360x
int testDurationMs = 2000;
int factor = 360;
//In order to have an effective and short in time test, we accelerate the time
//Log history is to avoid the possibility of preemption due to the accelerate time
// check debugFiles.properties to see the mapping
// We will print on logs from threads, for testing the synchronized
PrintLogRunnable printLogRunnableTest1 = new PrintLogRunnable(debugTest1MergeToDebugMerge, initTime,
PrintLogRunnable printLogRunnableTest2 = new PrintLogRunnable(debugTest2MergeToDebugMerge, initTime,
PrintLogRunnable printLogRunnableTest3 = new PrintLogRunnable(debugTest3MergeToDebugMerge, initTime,
}
//The first writing initialize the log file. So we test that a swift of 1 minute doesn't
//create a new file
//Start threads
}
//Wait threads
}
//Check if any thread had a exception
}
//Merge Log dates history
//NB : we merge the log dates history from each thread instead of directly insert
//to a global set in order to not reduce the performance of each thread by
//inserting in a concurrent set.
//Check files creation
//It's possible that we stored the init time just before the next minute
}
/*
Before each file exist = true, we will check if there is a log in the history
if not, it means that the unit test has been preempted at the checked time.
*/
continue;
}
}
}
/**
* Runnable for printing in a log file
*/
public static class PrintLogRunnable implements Runnable {
private long initTime;
private int testDuration;
private TimeService accelerateClock;
//Date formats for helping the debugging
private SimpleDateFormat dateFormat;
private SimpleDateFormat dateFormatWithMs;
public PrintLogRunnable(IDebug debug, long initTime, int testDurationMS, TimeService accelerateClock) {
this.testDuration = testDurationMS;
this.accelerateClock = accelerateClock;
}
public void run() {
try {
}
} catch (Exception e) {
this.ex = e;
}
}
return logDatesHistory;
}
}
}