@Test
	public void canSeparateInterleavedEventsIntoEightRequests() throws IntraceException {
		/**
		 * Processing/events never happen in a tidy fashion, like this, but logically this situation must be handled.
		 * 8 threads trigger two events each.
		 * All 8 threads first process their first event (and in sequential order of thread id)
		 * Once those 8 events are fired, all 8 threads fire their second event.
		 */
		final String EVENTS_FROM_MULTIPLE_THREADS_INTERLEAVED_8 = 
			       "[08:36:43.885]:[413]:java.lang.Thread:run: {:682\n"
			     + "[08:36:43.885]:[414]:java.lang.Thread:run: {:682\n"
			     + "[08:36:43.885]:[412]:java.lang.Thread:run: {:682\n"
			     + "[08:36:43.885]:[415]:java.lang.Thread:run: {:682\n"
			     + "[08:36:43.885]:[417]:java.lang.Thread:run: {:682\n"
			     + "[08:36:43.885]:[418]:java.lang.Thread:run: {:682\n"
			     + "[08:36:43.885]:[416]:java.lang.Thread:run: {:682\n"
			     + "[08:36:43.885]:[419]:java.lang.Thread:run: {:682\n"
			     + "[08:36:43.885]:[412]:org.hsqldb.jdbc.jdbcConnection:prepareStatement: Arg: INSERT INTO Event (name, description, date, location) VALUES(?, ?, ?, ?)\n"
			     + "[08:36:43.885]:[413]:org.hsqldb.jdbc.jdbcConnection:prepareStatement: Arg: INSERT INTO Event (name, description, date, location) VALUES(?, ?, ?, ?)\n"
			     + "[08:36:43.885]:[414]:org.hsqldb.jdbc.jdbcConnection:prepareStatement: Arg: INSERT INTO Event (name, description, date, location) VALUES(?, ?, ?, ?)\n"
			     + "[08:36:43.885]:[415]:org.hsqldb.jdbc.jdbcConnection:prepareStatement: Arg: INSERT INTO Event (name, description, date, location) VALUES(?, ?, ?, ?)\n"
			     + "[08:36:43.885]:[416]:org.hsqldb.jdbc.jdbcConnection:prepareStatement: Arg: INSERT INTO Event (name, description, date, location) VALUES(?, ?, ?, ?)\n"
			     + "[08:36:43.885]:[417]:org.hsqldb.jdbc.jdbcConnection:prepareStatement: Arg: INSERT INTO Event (name, description, date, location) VALUES(?, ?, ?, ?)\n"
			     + "[08:36:43.885]:[418]:org.hsqldb.jdbc.jdbcConnection:prepareStatement: Arg: INSERT INTO Event (name, description, date, location) VALUES(?, ?, ?, ?)\n"
			     + "[08:36:43.885]:[419]:org.hsqldb.jdbc.jdbcConnection:prepareStatement: Arg: INSERT INTO Event (name, description, date, location) VALUES(?, ?, ?, ?)\n"
			     + "[08:36:43.885]:[413]:java.lang.Thread:run: }:682\n"
			     + "[08:36:43.885]:[414]:java.lang.Thread:run: }:682\n"
			     + "[08:36:43.885]:[412]:java.lang.Thread:run: }:682\n"
			     + "[08:36:43.885]:[415]:java.lang.Thread:run: }:682\n"
			     + "[08:36:43.885]:[417]:java.lang.Thread:run: }:682\n"
			     + "[08:36:43.885]:[418]:java.lang.Thread:run: }:682\n"
			     + "[08:36:43.885]:[416]:java.lang.Thread:run: }:682\n"
			     + "[08:36:43.885]:[419]:java.lang.Thread:run: }:682\n";
				
		List<ITraceEvent> events = TestUtil.createEvents(EVENTS_FROM_MULTIPLE_THREADS_INTERLEAVED_8);
		IRequestSeparator requestSeparator = DefaultFactory.getFactory().getRequestSeparator();
		
		//IncludeThisEventFilterExt methodFilter = new IncludeThisEventFilterExt();
		//methodFilter.setFilterCriteria(m_requestCompletionEvent);
		
		//requestSeparator.setRequestCompletionFilter(methodFilter);
		requestSeparator.setRequestCompletionFilter(new IncludeThisEventFilterExt(m_requestCompletionEvent));
		requestSeparator.setRequestStartFilter( new IncludeThisEventFilterExt(m_requestStartEvent));
		
				
//		requestSeparator.setRequestCompletionEvent(m_requestCompletionEvent);//Whenever this particular event first, that marks the end of a thread/request.
		
		m_completedRequests.clear();
		ICompletedRequestCallback requestCallback = new ICompletedRequestCallback() {
			
			@Override
			public void requestCompleted(IRequest events) {
				m_completedRequests.add(events);
			}
		};
		requestSeparator.setCompletedRequestCallback(requestCallback);
		
		//Simulate events from the InTrace server agent
		for(ITraceEvent e : events) {
			requestSeparator.add(e);
		}
		//We're expecting one event per request.  Each event will look like this:
		String rawEventText = "[08:36:43.885]:[419]:org.hsqldb.jdbc.jdbcConnection:prepareStatement: Arg: INSERT INTO Event (name, description, date, location) VALUES(?, ?, ?, ?)\n";
		ITraceEvent testEvent = 
				DefaultFactory.getFactory().getEventParser().createEvent(rawEventText, 0);
		IncludeThisEventFilterExt myTestFilter = new IncludeThisEventFilterExt();
		myTestFilter.setFilterCriteria(testEvent);
		
		assertEquals("Added eight requests, each with one events, but didn't get eight", 8 /* events.size() */, m_completedRequests.size());
		for(IRequest request : m_completedRequests) {
			assertEquals("Expected one event for each request", 1, request.getEvents().size());
			
			assertTrue("Expected a particular event type, class name and package", 
					myTestFilter.matches(request.getEvents().get(0)));
		}
		
		assertEquals("Whoops.  The RequestSeparator should have evicted all the requests, but some were left",0,requestSeparator.size());
	}