2 * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 package org
.lttng
.ust
.agent
.integration
.events
;
21 import static org
.junit
.Assert
.assertEquals
;
22 import static org
.junit
.Assert
.assertTrue
;
24 import java
.util
.Arrays
;
25 import java
.util
.Collections
;
26 import java
.util
.List
;
28 import org
.junit
.After
;
29 import org
.junit
.Before
;
30 import org
.junit
.Test
;
31 import org
.lttng
.tools
.ILttngSession
;
34 * Base class for the list events command tests
36 public abstract class ListEventsITBase
{
38 protected static final String LOGGER_NAME_1
= "org.lttng.somecomponent";
39 protected static final String LOGGER_NAME_2
= "org.lttng.mycomponent";
40 protected static final String LOGGER_NAME_3
= "org.lttng.myothercomponent-àéç";
42 private ILttngSession session
;
48 public void testSetup() {
49 session
= ILttngSession
.createSession(null, getDomain());
53 * Common test teardown
56 public void testTeardown() {
60 protected abstract ILttngSession
.Domain
getDomain();
62 protected abstract void attachHandlerToLogger(int handlerIndex
, int loggerIndex
);
64 protected abstract void detachHandlerFromLogger(int handlerIndex
, int loggerIndex
);
67 * Test with many loggers existing, but none of them having a LTTng handler
71 public void testManyLoggersNoneAttached() {
72 /* Don't attach anything */
73 List
<String
> actualEvents
= session
.listEvents();
74 assertTrue(actualEvents
.isEmpty());
78 * Test with many loggers existing, but only a subset of them has a LTTng
82 public void testManyLoggersSomeAttached() {
83 attachHandlerToLogger(1, 1);
85 List
<String
> expectedEvents
= Arrays
.asList(LOGGER_NAME_1
);
86 List
<String
> actualEvents
= session
.listEvents();
88 Collections
.sort(expectedEvents
);
89 Collections
.sort(actualEvents
);
91 assertEquals(expectedEvents
, actualEvents
);
95 * Test with many loggers existing, and all of them having a LTTng handler
99 public void testManyLoggersAllAttached() {
100 attachHandlerToLogger(1, 1);
101 attachHandlerToLogger(2, 2);
102 attachHandlerToLogger(2, 3);
104 List
<String
> expectedEvents
= Arrays
.asList(LOGGER_NAME_1
, LOGGER_NAME_2
, LOGGER_NAME_3
);
105 List
<String
> actualEvents
= session
.listEvents();
107 Collections
.sort(expectedEvents
);
108 Collections
.sort(actualEvents
);
110 assertEquals(expectedEvents
, actualEvents
);
114 * Test with some loggers having had handlers attached but then detached.
117 public void testLoggersSomeDetached() {
118 attachHandlerToLogger(1, 1);
119 attachHandlerToLogger(2, 2);
121 attachHandlerToLogger(2, 3);
122 detachHandlerFromLogger(2, 3);
123 /* Only loggers 1 and 2 will be attached */
125 List
<String
> expectedEvents
= Arrays
.asList(LOGGER_NAME_1
, LOGGER_NAME_2
);
126 List
<String
> actualEvents
= session
.listEvents();
128 Collections
.sort(expectedEvents
);
129 Collections
.sort(actualEvents
);
131 assertEquals(expectedEvents
, actualEvents
);
135 * Test with all loggers having had handlers attached and then detached.
138 public void testLoggersAllDetached() {
139 attachHandlerToLogger(1, 1);
140 attachHandlerToLogger(2, 2);
141 attachHandlerToLogger(2, 3);
142 detachHandlerFromLogger(1, 1);
143 detachHandlerFromLogger(2, 2);
144 detachHandlerFromLogger(2, 3);
146 List
<String
> actualEvents
= session
.listEvents();
147 assertTrue(actualEvents
.isEmpty());
This page took 0.032623 seconds and 4 git commands to generate.