use of com.cosylab.logging.engine.log.ILogEntry in project ACS by ACS-Community.
the class LogDispatcherTest method testXMLDispatch.
/**
* Test the dispatching of XML logs
*
* @throws Exception
*/
public void testXMLDispatch() throws Exception {
// Add the name of the test in the additional data
for (ILogEntry log : logs) {
log.addData("TestType", "XML");
}
ACSListenersDispatcher listenerDispatcher = new ACSListenersDispatcher();
assertNotNull("Null listener dispatcher!", listenerDispatcher);
ACSLogRetrieval logDispatcher = new ACSLogRetrieval(listenerDispatcher);
assertNotNull("Null log dispatcher!", logDispatcher);
logDispatcher.start();
listenerDispatcher.addLogListener(logRecv);
listenerDispatcher.addRawLogListener(logRecv);
stopWatch.reset();
for (ILogEntry log : logs) {
logDispatcher.addLog(log.toXMLString());
}
waitProcessingComplete(logDispatcher, 300);
long xmlTime = stopWatch.getLapTimeMillis() / 1000;
//String str ="Time to publish "+LOGS_NUMBER+" XML logs: "+xmlTime + " seconds.\n";
//System.out.print(str);
assertEquals("XML case: logs sent and logs received differ", LOGS_NUMBER, logsReceived);
assertEquals("XML case: logs sent and raw logs received differ", LOGS_NUMBER, rawLogsReceived);
logDispatcher.close(true);
}
use of com.cosylab.logging.engine.log.ILogEntry in project ACS by ACS-Community.
the class LoadSaveTest method setUp.
/**
* @see junit.framework.TestCase#setUp()
*/
@Override
protected void setUp() throws Exception {
super.setUp();
bytesRead = 0;
bytesWritten = 0;
numOfLogsRead = 0;
logs = CacheUtils.generateLogs(NUMBER_OF_LOGS);
assertEquals(NUMBER_OF_LOGS, logs.size());
// Read the folder name and generate the file name
Properties props = System.getProperties();
assertNotNull(props);
folder = props.getProperty(USER_DIR);
assertNotNull(folder);
File folderFile = new File(folder);
String folderPath = folderFile.getAbsolutePath();
fileName = folderPath + "/logs.xml";
gzipFileName = fileName + ".gz";
// Check if folder is a writable directory
assertTrue(folderFile.isDirectory());
assertTrue(folderFile.canWrite());
logsRead = new Vector<ILogEntry>();
}
use of com.cosylab.logging.engine.log.ILogEntry in project ACS by ACS-Community.
the class LoadSaveTest method testSaveLoadCompressed.
/**
* Load and save a collection of logs in uncompressed files
* <P>
* The save is performed by passing the name of the file
*
* @throws Exception
*/
public void testSaveLoadCompressed() throws Exception {
IOHelper ioHelper = new IOHelper();
assertNotNull(ioHelper);
// Save the logs on file
ioHelper.saveLogs(gzipFileName, logs, this, false, true);
assertEquals(logs.size(), numOfLogsWritten);
// Read the logs
ioHelper.loadLogs(gzipFileName, this, null, this, this, true);
assertEquals(logs.size(), numOfLogsRead);
// Compare the 2 collections
assertEquals(logs.size(), logsRead.size());
// Compare the 2 collections
int t = 0;
for (ILogEntry log : logs) {
String logXML = log.toXMLString();
String logReadXML = logsRead.get(t++).toXMLString();
assertEquals(logXML, logReadXML);
}
}
use of com.cosylab.logging.engine.log.ILogEntry in project ACS by ACS-Community.
the class LoadSaveTest method testSaveLoadIterator.
/**
* Check the load and save of logs by passing an <code>Iterator</code>
*
* @throws Exception
*/
public void testSaveLoadIterator() throws Exception {
IOHelper ioHelper = new IOHelper();
assertNotNull(ioHelper);
Iterator<ILogEntry> iterator = logs.iterator();
long assumedLen = 0;
for (ILogEntry log : logs) {
char[] chars = (log.toXMLString() + "\n").toCharArray();
assumedLen += chars.length;
}
// Save the logs on file
ioHelper.saveLogs(fileName, iterator, this, false, false);
assertEquals(assumedLen, bytesWritten);
assertEquals(logs.size(), numOfLogsWritten);
// Read the logs
ioHelper.loadLogs(fileName, this, null, this, this, false);
assertEquals(logs.size(), numOfLogsRead);
}
use of com.cosylab.logging.engine.log.ILogEntry in project ACS by ACS-Community.
the class LoadSaveTest method testSaveLoad.
/**
* Load and save a collection of logs in uncompressed files
* <P>
* The save is performed by passing the name of the file
*
* @throws Exception
*/
public void testSaveLoad() throws Exception {
IOHelper ioHelper = new IOHelper();
assertNotNull(ioHelper);
long assumedLen = 0;
for (ILogEntry log : logs) {
char[] chars = (log.toXMLString() + "\n").toCharArray();
assumedLen += chars.length;
}
// Save the logs on file
ioHelper.saveLogs(fileName, logs, this, false, false);
assertEquals(assumedLen, bytesWritten);
assertEquals(logs.size(), numOfLogsWritten);
// Read the logs
ioHelper.loadLogs(fileName, this, null, this, this, false);
assertEquals(logs.size(), numOfLogsRead);
// bytes read includes the XML header
assertTrue(bytesRead > assumedLen);
// Compare the 2 collections
assertEquals(logs.size(), logsRead.size());
int t = 0;
for (ILogEntry log : logs) {
String logXML = log.toXMLString();
String logReadXML = logsRead.get(t++).toXMLString();
assertEquals(logXML, logReadXML);
}
}
Aggregations