Skip to content
This repository was archived by the owner on Jan 6, 2023. It is now read-only.

Commit bfa8f13

Browse files
committed
add some config tests
1 parent 5163549 commit bfa8f13

File tree

5 files changed

+98
-1
lines changed

5 files changed

+98
-1
lines changed

pom.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,18 @@
121121
<version>12.2.1-3-0</version>
122122
<scope>provided</scope>
123123
</dependency>
124+
<dependency>
125+
<groupId>com.oracle.weblogic</groupId>
126+
<artifactId>com.bea.core.logging.debug</artifactId>
127+
<version>12.2.1-3-0</version>
128+
<scope>provided</scope>
129+
</dependency>
130+
<dependency>
131+
<groupId>com.oracle.weblogic</groupId>
132+
<artifactId>com.bea.core.diagnostics.core</artifactId>
133+
<version>12.2.1-3-0</version>
134+
<scope>provided</scope>
135+
</dependency>
124136
<dependency>
125137
<groupId>com.oracle.weblogic</groupId>
126138
<artifactId>com.bea.core.diagnostics.logging</artifactId>
@@ -133,6 +145,12 @@
133145
<version>12.2.1-3-0</version>
134146
<scope>provided</scope>
135147
</dependency>
148+
<dependency>
149+
<groupId>com.oracle.weblogic</groupId>
150+
<artifactId>com.bea.core.repackaged.asm</artifactId>
151+
<version>12.2.1-3-0</version>
152+
<scope>provided</scope>
153+
</dependency>
136154
<dependency>
137155
<groupId>com.oracle.weblogic</groupId>
138156
<artifactId>com.bea.core.diagnostics.query</artifactId>
@@ -162,5 +180,10 @@
162180
<artifactId>snakeyaml</artifactId>
163181
<version>1.23</version>
164182
</dependency>
183+
<dependency>
184+
<groupId>org.antlr</groupId>
185+
<artifactId>antlr-complete</artifactId>
186+
<version>3.5.2</version>
187+
</dependency>
165188
</dependencies>
166189
</project>

src/test/java/weblogic/logging/exporter/FirstTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
55
*/
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
3+
*
4+
* Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
5+
*/
6+
7+
package weblogic.logging.exporter.config;
8+
9+
import static org.junit.jupiter.api.Assertions.*;
10+
11+
import java.io.File;
12+
import java.util.ArrayList;
13+
import org.junit.jupiter.api.DisplayName;
14+
import org.junit.jupiter.api.Test;
15+
16+
@DisplayName("Test the Config class")
17+
public class ConfigTest {
18+
19+
@DisplayName("Create the default config from an empty file")
20+
@Test
21+
public void createDefaultConfigFromEmptyFile() {
22+
// create config by loading an empty file
23+
Config config = Config.loadConfig(new File("src/test/resources/emptyConfig.yaml"));
24+
25+
// now check that the config contains the expected default values
26+
assertAll(
27+
"config",
28+
() -> assertEquals("localhost", config.getHost()),
29+
() -> assertEquals(9200, config.getPort()),
30+
() -> assertEquals(true, config.getEnabled()),
31+
() -> assertEquals("wls", config.getIndexName()),
32+
() -> assertEquals(null, config.getSeverity()),
33+
() -> assertTrue(config.getFilterConfigs() instanceof ArrayList),
34+
() -> assertEquals(0, config.getFilterConfigs().size()),
35+
() -> assertEquals(1, config.getBulkSize()),
36+
() -> assertEquals("unknown", config.getDomainUID()));
37+
}
38+
39+
@DisplayName("Create config from file")
40+
@Test
41+
public void createConfigFromFile() {
42+
// create config by loading an empty file
43+
Config config = Config.loadConfig(new File("src/test/resources/config1.yaml"));
44+
45+
// now check that the config contains the expected default values
46+
assertAll(
47+
"config",
48+
() -> assertEquals("host1", config.getHost()),
49+
() -> assertEquals(1234, config.getPort()),
50+
() -> assertEquals(false, config.getEnabled()),
51+
() -> assertEquals("index1", config.getIndexName()),
52+
() -> assertEquals("Warning", config.getSeverity()),
53+
() -> assertTrue(config.getFilterConfigs() instanceof ArrayList),
54+
() -> assertEquals(1, config.getFilterConfigs().size()),
55+
() ->
56+
assertEquals(
57+
"FilterConfig{expression='MSGID != 'BEA-000449'', servers=[]}",
58+
config.getFilterConfigs().get(0).toString()),
59+
() -> assertEquals(2, config.getBulkSize()),
60+
() -> assertEquals("domain1", config.getDomainUID()));
61+
}
62+
}

src/test/resources/config1.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Test config file
2+
3+
publishHost: host1
4+
publishPort: 1234
5+
weblogicLoggingExporterFilters:
6+
- FilterExpression: MSGID != 'BEA-000449'
7+
weblogicLoggingExporterEnabled: false
8+
weblogicLoggingExporterSeverity: Warning
9+
weblogicLoggingExporterBulkSize: 2
10+
weblogicLoggingIndexName: index1
11+
domainUID: domain1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# I am empty

0 commit comments

Comments
 (0)