Search in sources :

Example 1 with ComponentRequestKey

use of alma.acs.manager.logparser.ManagerStdoutParser.ComponentRequestKey in project ACS by ACS-Community.

the class ManagerStdoutParserTest method testParseLine.

@Test
public void testParseLine() throws Exception {
    ManagerStdoutParser parser = new ManagerStdoutParser(logger);
    Map<ComponentRequestKey, List<ComponentRequest>> pendingRequests = new HashMap<ComponentRequestKey, List<ComponentRequest>>();
    List<ComponentRequest> finishedRequests = new ArrayList<ComponentRequest>();
    parser.parseLine("2011-09-30T21:34:20.084 INFO [Manager] 'Python Client' requested component 'curl:///CONTROL/DV15/Mount'.", pendingRequests, finishedRequests);
    parser.parseLine("2011-09-30T21:38:20.008 FINE [Manager] 'CCLSimpleClient' requested non-sticky component 'curl:///CONTROL/DA43/WVR'.", pendingRequests, finishedRequests);
    assertEquals(2, pendingRequests.keySet().size());
    assertEquals(0, finishedRequests.size());
    parser.parseLine("2011-09-30T21:34:20.085 INFO [Manager] Component 'curl:///CONTROL/DV15/Mount' provided to 'Python Client'.", pendingRequests, finishedRequests);
    assertEquals(1, pendingRequests.keySet().size());
    assertEquals(1, finishedRequests.size());
    ComponentRequest request = finishedRequests.get(0);
    assertEquals("Python Client", request.key.clientName);
    assertEquals("curl:///CONTROL/DV15/Mount", request.key.curl);
    assertEquals("2011-09-30T21:34:20.084", toISO(request.timeRequested));
    assertEquals("2011-09-30T21:34:20.085", toISO(request.timeProvided));
    logger.info("Got ComponentRequest as expected: " + request);
    pendingRequests.clear();
    finishedRequests.clear();
    // Unmatched 'provided to', should also log a WARNING which we currently don't check here
    parser.parseLine("2011-09-30T21:34:20.085 INFO [Manager] Component 'curl:///CONTROL/DV15/Mount' provided to 'Python Client'.", pendingRequests, finishedRequests);
    assertEquals(0, pendingRequests.keySet().size());
    assertEquals(0, finishedRequests.size());
}
Also used : ComponentRequestKey(alma.acs.manager.logparser.ManagerStdoutParser.ComponentRequestKey) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ComponentRequest(alma.acs.manager.logparser.ManagerStdoutParser.ComponentRequest) Test(org.junit.Test)

Aggregations

ComponentRequest (alma.acs.manager.logparser.ManagerStdoutParser.ComponentRequest)1 ComponentRequestKey (alma.acs.manager.logparser.ManagerStdoutParser.ComponentRequestKey)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Test (org.junit.Test)1