Copyright header update, 2015 edition
[deliverable/tracecompass.git] / 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 import static org.junit.Assume.assumeTrue;
19
20 import java.lang.reflect.InvocationTargetException;
21 import java.lang.reflect.Method;
22 import java.util.LinkedList;
23 import java.util.List;
24
25 import org.eclipse.tracecompass.internal.lttng2.kernel.core.event.matching.TcpEventMatching;
26 import org.eclipse.tracecompass.internal.lttng2.kernel.core.event.matching.TcpLttngEventMatching;
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.event.matching.TmfNetworkEventMatching;
30 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
31 import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTrace;
32 import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
33 import org.junit.Test;
34
35 /**
36 * Tests for {@link TcpEventMatching}
37 *
38 * @author Geneviève Bastien
39 */
40 @SuppressWarnings("nls")
41 public class MatchAndSyncTest {
42
43 /**
44 * Testing the packet matching
45 */
46 @Test
47 public void testMatching() {
48 assumeTrue(CtfTmfTestTrace.SYNC_SRC.exists());
49 assumeTrue(CtfTmfTestTrace.SYNC_DEST.exists());
50 try (CtfTmfTrace trace1 = CtfTmfTestTrace.SYNC_SRC.getTrace();
51 CtfTmfTrace trace2 = CtfTmfTestTrace.SYNC_DEST.getTrace();) {
52
53 List<ITmfTrace> tracearr = new LinkedList<>();
54 tracearr.add(trace1);
55 tracearr.add(trace2);
56
57 TmfEventMatching.registerMatchObject(new TcpEventMatching());
58 TmfEventMatching.registerMatchObject(new TcpLttngEventMatching());
59
60 TmfNetworkEventMatching twoTraceMatch = new TmfNetworkEventMatching(tracearr);
61 assertTrue(twoTraceMatch.matchEvents());
62
63 /* Set method and fields accessible to make sure the counts are ok */
64 try {
65 /* Verify number of matches */
66 Method method = TmfEventMatching.class.getDeclaredMethod("getProcessingUnit");
67 method.setAccessible(true);
68 IMatchProcessingUnit procUnit = (IMatchProcessingUnit) method.invoke(twoTraceMatch);
69 assertEquals(46, procUnit.countMatches());
70
71 } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
72 fail(e.getMessage());
73 }
74
75 }
76 }
77
78 }
This page took 0.033293 seconds and 5 git commands to generate.