Fix some null warnings
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.kernel.core.tests / src / org / eclipse / tracecompass / lttng2 / kernel / core / tests / event / matchandsync / MatchAndSyncTest.java
CommitLineData
e73a4ba5 1/*******************************************************************************
ed902a2b 2 * Copyright (c) 2013, 2014 École Polytechnique de Montréal
e73a4ba5
GB
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
9bc60be7 13package org.eclipse.tracecompass.lttng2.kernel.core.tests.event.matchandsync;
e73a4ba5
GB
14
15import static org.junit.Assert.assertEquals;
16import static org.junit.Assert.assertTrue;
4d2a4a2c 17import static org.junit.Assert.fail;
e73a4ba5 18
4d2a4a2c
GB
19import java.lang.reflect.InvocationTargetException;
20import java.lang.reflect.Method;
27213c57
AM
21import java.util.LinkedList;
22import java.util.List;
23
aa353506 24import org.eclipse.jdt.annotation.NonNull;
dc327459
GB
25import org.eclipse.tracecompass.internal.lttng2.kernel.core.event.matching.TcpEventMatching;
26import org.eclipse.tracecompass.internal.lttng2.kernel.core.event.matching.TcpLttngEventMatching;
c4d57ac1 27import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
4d2a4a2c 28import org.eclipse.tracecompass.tmf.core.event.matching.IMatchProcessingUnit;
2bdf0193 29import org.eclipse.tracecompass.tmf.core.event.matching.TmfEventMatching;
2bdf0193 30import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
c4d57ac1 31import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils;
9722e5d7 32import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
e73a4ba5
GB
33import org.junit.Test;
34
35/**
36 * Tests for {@link TcpEventMatching}
37 *
38 * @author Geneviève Bastien
39 */
40@SuppressWarnings("nls")
41public class MatchAndSyncTest {
42
43 /**
44 * Testing the packet matching
45 */
46 @Test
47 public void testMatching() {
c4d57ac1
AM
48 CtfTmfTrace trace1 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.SYNC_SRC);
49 CtfTmfTrace trace2 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.SYNC_DEST);
e73a4ba5 50
aa353506 51 List<@NonNull ITmfTrace> tracearr = new LinkedList<>();
0ff9e595
AM
52 tracearr.add(trace1);
53 tracearr.add(trace2);
e73a4ba5 54
0ff9e595
AM
55 TmfEventMatching.registerMatchObject(new TcpEventMatching());
56 TmfEventMatching.registerMatchObject(new TcpLttngEventMatching());
e73a4ba5 57
0ff9e595
AM
58 TmfEventMatching twoTraceMatch = new TmfEventMatching(tracearr);
59 assertTrue(twoTraceMatch.matchEvents());
e73a4ba5 60
0ff9e595
AM
61 /* Set method and fields accessible to make sure the counts are ok */
62 try {
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());
75b7c1bc 68
0ff9e595
AM
69 } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
70 fail(e.getMessage());
71 } finally {
72 trace1.dispose();
73 trace2.dispose();
090c006e 74 }
e73a4ba5
GB
75 }
76
77}
This page took 0.086741 seconds and 5 git commands to generate.