1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 École Polytechnique de Montréal
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
10 * Geneviève Bastien - Initial implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.lttng2
.kernel
.core
.tests
.event
.matchandsync
;
15 import static org
.junit
.Assert
.assertEquals
;
16 import static org
.junit
.Assert
.assertTrue
;
17 import static org
.junit
.Assert
.fail
;
19 import java
.lang
.reflect
.InvocationTargetException
;
20 import java
.lang
.reflect
.Method
;
21 import java
.util
.LinkedList
;
22 import java
.util
.List
;
24 import org
.eclipse
.jdt
.annotation
.NonNull
;
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
.testtraces
.ctf
.CtfTestTrace
;
28 import org
.eclipse
.tracecompass
.tmf
.core
.event
.matching
.IMatchProcessingUnit
;
29 import org
.eclipse
.tracecompass
.tmf
.core
.event
.matching
.TmfEventMatching
;
30 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
31 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.tests
.shared
.CtfTmfTestTraceUtils
;
32 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.trace
.CtfTmfTrace
;
33 import org
.junit
.Test
;
36 * Tests for {@link TcpEventMatching}
38 * @author Geneviève Bastien
40 @SuppressWarnings("nls")
41 public class MatchAndSyncTest
{
44 * Testing the packet matching
47 public void testMatching() {
48 CtfTmfTrace trace1
= CtfTmfTestTraceUtils
.getTrace(CtfTestTrace
.SYNC_SRC
);
49 CtfTmfTrace trace2
= CtfTmfTestTraceUtils
.getTrace(CtfTestTrace
.SYNC_DEST
);
51 List
<@NonNull ITmfTrace
> tracearr
= new LinkedList
<>();
55 TmfEventMatching
.registerMatchObject(new TcpEventMatching());
56 TmfEventMatching
.registerMatchObject(new TcpLttngEventMatching());
58 TmfEventMatching twoTraceMatch
= new TmfEventMatching(tracearr
);
59 assertTrue(twoTraceMatch
.matchEvents());
61 /* Set method and fields accessible to make sure the counts are ok */
63 /* Verify number of matches */
64 Method method
= TmfEventMatching
.class.getDeclaredMethod("getProcessingUnit");
65 method
.setAccessible(true);
66 IMatchProcessingUnit procUnit
= (IMatchProcessingUnit
) method
.invoke(twoTraceMatch
);
67 assertEquals(46, procUnit
.countMatches());
69 } catch (NoSuchMethodException
| SecurityException
| IllegalAccessException
| IllegalArgumentException
| InvocationTargetException e
) {