3b3b0c658876c6d682800e3f762ad54a5ce95002
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.kernel.core.tests / src / org / eclipse / tracecompass / lttng2 / kernel / core / tests / event / matchandsync / MatchAndSyncTest.java
1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 École Polytechnique de Montréal
3 *
4 * All rights reserved. This program and the accompanying materials are made
5 * available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Geneviève Bastien - Initial implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.lttng2.kernel.core.tests.event.matchandsync;
14
15 import static org.junit.Assert.assertEquals;
16 import static org.junit.Assert.assertTrue;
17 import static org.junit.Assert.fail;
18
19 import java.lang.reflect.InvocationTargetException;
20 import java.lang.reflect.Method;
21 import java.util.LinkedList;
22 import java.util.List;
23
24 import org.eclipse.tracecompass.internal.lttng2.kernel.core.event.matching.TcpEventMatching;
25 import org.eclipse.tracecompass.internal.lttng2.kernel.core.event.matching.TcpLttngEventMatching;
26 import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
27 import org.eclipse.tracecompass.tmf.core.event.matching.IMatchProcessingUnit;
28 import org.eclipse.tracecompass.tmf.core.event.matching.TmfEventMatching;
29 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
30 import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils;
31 import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
32 import org.junit.Test;
33
34 /**
35 * Tests for {@link TcpEventMatching}
36 *
37 * @author Geneviève Bastien
38 */
39 @SuppressWarnings("nls")
40 public class MatchAndSyncTest {
41
42 /**
43 * Testing the packet matching
44 */
45 @Test
46 public void testMatching() {
47 CtfTmfTrace trace1 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.SYNC_SRC);
48 CtfTmfTrace trace2 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.SYNC_DEST);
49
50 List<ITmfTrace> tracearr = new LinkedList<>();
51 tracearr.add(trace1);
52 tracearr.add(trace2);
53
54 TmfEventMatching.registerMatchObject(new TcpEventMatching());
55 TmfEventMatching.registerMatchObject(new TcpLttngEventMatching());
56
57 TmfEventMatching twoTraceMatch = new TmfEventMatching(tracearr);
58 assertTrue(twoTraceMatch.matchEvents());
59
60 /* Set method and fields accessible to make sure the counts are ok */
61 try {
62 /* Verify number of matches */
63 Method method = TmfEventMatching.class.getDeclaredMethod("getProcessingUnit");
64 method.setAccessible(true);
65 IMatchProcessingUnit procUnit = (IMatchProcessingUnit) method.invoke(twoTraceMatch);
66 assertEquals(46, procUnit.countMatches());
67
68 } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
69 fail(e.getMessage());
70 } finally {
71 trace1.dispose();
72 trace2.dispose();
73 }
74 }
75
76 }
This page took 0.032717 seconds and 4 git commands to generate.