5551db8f21f9faee4b583c5b2af02983025a3518
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
.jupiter
.api
.Assertions
.assertEquals
;
22 import static org
.junit
.jupiter
.api
.Assertions
.assertTrue
;
24 import java
.util
.Arrays
;
25 import java
.util
.Collections
;
26 import java
.util
.List
;
28 import org
.junit
.jupiter
.api
.AfterEach
;
29 import org
.junit
.jupiter
.api
.BeforeEach
;
30 import org
.junit
.jupiter
.api
.Test
;
31 import org
.junit
.jupiter
.api
.extension
.ExtendWith
;
32 import org
.lttng
.tools
.ILttngSession
;
33 import org
.lttng
.ust
.agent
.utils
.TestPrintExtension
;
36 * Base class for the list events command tests
38 @ExtendWith(TestPrintExtension
.class)
39 public abstract class ListEventsITBase
{
41 protected static final String LOGGER_NAME_1
= "org.lttng.somecomponent";
42 protected static final String LOGGER_NAME_2
= "org.lttng.mycomponent";
43 protected static final String LOGGER_NAME_3
= "org.lttng.myothercomponent-àéç";
45 private ILttngSession session
;
51 public void testSetup() {
52 session
= ILttngSession
.createSession(null, getDomain());
56 * Common test teardown
59 public void testTeardown() {
63 protected abstract ILttngSession
.Domain
getDomain();
65 protected abstract void attachHandlerToLogger(int handlerIndex
, int loggerIndex
);
67 protected abstract void detachHandlerFromLogger(int handlerIndex
, int loggerIndex
);
70 * Test with many loggers existing, but none of them having a LTTng handler
74 public void testManyLoggersNoneAttached() {
75 /* Don't attach anything */
76 List
<String
> actualEvents
= session
.listEvents();
77 assertTrue(actualEvents
.isEmpty());
81 * Test with many loggers existing, but only a subset of them has a LTTng
85 public void testManyLoggersSomeAttached() {
86 attachHandlerToLogger(1, 1);
88 List
<String
> expectedEvents
= Arrays
.asList(LOGGER_NAME_1
);
89 List
<String
> actualEvents
= session
.listEvents();
91 Collections
.sort(expectedEvents
);
92 Collections
.sort(actualEvents
);
94 assertEquals(expectedEvents
, actualEvents
);
98 * Test with many loggers existing, and all of them having a LTTng handler
102 public void testManyLoggersAllAttached() {
103 attachHandlerToLogger(1, 1);
104 attachHandlerToLogger(2, 2);
105 attachHandlerToLogger(2, 3);
107 List
<String
> expectedEvents
= Arrays
.asList(LOGGER_NAME_1
, LOGGER_NAME_2
, LOGGER_NAME_3
);
108 List
<String
> actualEvents
= session
.listEvents();
110 Collections
.sort(expectedEvents
);
111 Collections
.sort(actualEvents
);
113 assertEquals(expectedEvents
, actualEvents
);
117 * Test with some loggers having had handlers attached but then detached.
120 public void testLoggersSomeDetached() {
121 attachHandlerToLogger(1, 1);
122 attachHandlerToLogger(2, 2);
124 attachHandlerToLogger(2, 3);
125 detachHandlerFromLogger(2, 3);
126 /* Only loggers 1 and 2 will be attached */
128 List
<String
> expectedEvents
= Arrays
.asList(LOGGER_NAME_1
, LOGGER_NAME_2
);
129 List
<String
> actualEvents
= session
.listEvents();
131 Collections
.sort(expectedEvents
);
132 Collections
.sort(actualEvents
);
134 assertEquals(expectedEvents
, actualEvents
);
138 * Test with all loggers having had handlers attached and then detached.
141 public void testLoggersAllDetached() {
142 attachHandlerToLogger(1, 1);
143 attachHandlerToLogger(2, 2);
144 attachHandlerToLogger(2, 3);
145 detachHandlerFromLogger(1, 1);
146 detachHandlerFromLogger(2, 2);
147 detachHandlerFromLogger(2, 3);
149 List
<String
> actualEvents
= session
.listEvents();
150 assertTrue(actualEvents
.isEmpty());
This page took 0.035924 seconds and 4 git commands to generate.