Skip to content

Commit 6c3d713

Browse files
committed
Cleanup AsyncWaitStrategyFactoryConfigTest new tests + add one
1 parent 82c7910 commit 6c3d713

File tree

1 file changed

+27
-18
lines changed

1 file changed

+27
-18
lines changed

log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncWaitStrategyFactoryConfigTest.java

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ public class AsyncWaitStrategyFactoryConfigTest {
3939
@LoggerContextSource("AsyncWaitStrategyFactoryConfigTest.xml")
4040
public void testConfigWaitStrategyFactory(final LoggerContext context) throws Exception {
4141
final AsyncWaitStrategyFactory asyncWaitStrategyFactory =
42-
context.getConfiguration().getAsyncWaitStrategyFactory();
42+
context.getConfiguration().getAsyncWaitStrategyFactory();
4343
assertEquals(YieldingWaitStrategyFactory.class, asyncWaitStrategyFactory.getClass());
4444
assertThat(
45-
"factory is YieldingWaitStrategyFactory",
46-
asyncWaitStrategyFactory instanceof YieldingWaitStrategyFactory);
45+
"factory is YieldingWaitStrategyFactory",
46+
asyncWaitStrategyFactory instanceof YieldingWaitStrategyFactory);
4747
}
4848

4949
@Test
@@ -53,20 +53,20 @@ public void testWaitStrategy(final LoggerContext context) throws Exception {
5353
final org.apache.logging.log4j.Logger logger = context.getRootLogger();
5454

5555
final AsyncLoggerConfig loggerConfig =
56-
(AsyncLoggerConfig) ((org.apache.logging.log4j.core.Logger) logger).get();
56+
(AsyncLoggerConfig) ((org.apache.logging.log4j.core.Logger) logger).get();
5757
final AsyncLoggerConfigDisruptor delegate =
58-
(AsyncLoggerConfigDisruptor) loggerConfig.getAsyncLoggerConfigDelegate();
58+
(AsyncLoggerConfigDisruptor) loggerConfig.getAsyncLoggerConfigDelegate();
5959
assertEquals(YieldingWaitStrategy.class, delegate.getWaitStrategy().getClass());
6060
assertThat(
61-
"waitstrategy is YieldingWaitStrategy",
62-
delegate.getWaitStrategy() instanceof com.lmax.disruptor.YieldingWaitStrategy);
61+
"waitstrategy is YieldingWaitStrategy",
62+
delegate.getWaitStrategy() instanceof com.lmax.disruptor.YieldingWaitStrategy);
6363
}
6464

6565
@Test
6666
@LoggerContextSource("AsyncWaitStrategyIncorrectFactoryConfigTest.xml")
6767
public void testIncorrectConfigWaitStrategyFactory(final LoggerContext context) throws Exception {
6868
final AsyncWaitStrategyFactory asyncWaitStrategyFactory =
69-
context.getConfiguration().getAsyncWaitStrategyFactory();
69+
context.getConfiguration().getAsyncWaitStrategyFactory();
7070
assertNull(asyncWaitStrategyFactory);
7171
}
7272

@@ -81,41 +81,50 @@ void testInvalidBuilderConfiguration3159(final Configuration configuration) {
8181
assertNull(configuration.getAsyncWaitStrategyFactory(), "The AsyncWaitStrategyFactory should be null.");
8282
}
8383

84+
/**
85+
* Test that when programmatically building a {@link AsyncWaitStrategyFactoryConfig} not setting a valid
86+
* factory class-name throws an exception.
87+
*/
88+
@Test
89+
void testInvalidProgrammaticConfiguration3159WithFactoryClassNameNotSet() {
90+
Assertions.assertNull(AsyncWaitStrategyFactoryConfig.newBuilder().build());
91+
}
92+
8493
/**
8594
* Test that when programmatically building a {@link AsyncWaitStrategyFactoryConfig} a {@code null}
8695
* factory class-name throws an exception.
8796
*/
8897
@Test
89-
void testInvalidProgrammaticConfiguration3159WithNullFactoryClassName() {
98+
void testInvalidProgrammaticConfiguration3159WithFactoryClassNameNull() {
9099
Assertions.assertThrows(IllegalArgumentException.class, () -> AsyncWaitStrategyFactoryConfig.newBuilder()
91-
.withFactoryClassName(null));
100+
.withFactoryClassName(null));
92101
}
93102

94103
/**
95104
* Test that when programmatically building a {@link AsyncWaitStrategyFactoryConfig} a blank ({@code ""})
96105
* factory class-name throws an exception.
97106
*/
98107
@Test
99-
void testInvalidProgrammaticConfiguration3159WithEmptyFactoryClassName() {
108+
void testInvalidProgrammaticConfiguration3159WithFactoryClassNameEmpty() {
100109
Assertions.assertThrows(IllegalArgumentException.class, () -> AsyncWaitStrategyFactoryConfig.newBuilder()
101-
.withFactoryClassName(""));
110+
.withFactoryClassName(""));
102111
}
103112

104113
@Test
105114
@LoggerContextSource("AsyncWaitStrategyIncorrectFactoryConfigTest.xml")
106115
public void testIncorrectWaitStrategyFallsBackToDefault(
107-
@Named("WaitStrategyAppenderList") final ListAppender list1, final LoggerContext context) throws Exception {
116+
@Named("WaitStrategyAppenderList") final ListAppender list1, final LoggerContext context) throws Exception {
108117
final org.apache.logging.log4j.Logger logger = context.getRootLogger();
109118

110119
final AsyncLoggerConfig loggerConfig =
111-
(AsyncLoggerConfig) ((org.apache.logging.log4j.core.Logger) logger).get();
120+
(AsyncLoggerConfig) ((org.apache.logging.log4j.core.Logger) logger).get();
112121
final AsyncLoggerConfigDisruptor delegate =
113-
(AsyncLoggerConfigDisruptor) loggerConfig.getAsyncLoggerConfigDelegate();
122+
(AsyncLoggerConfigDisruptor) loggerConfig.getAsyncLoggerConfigDelegate();
114123
assertEquals(
115-
TimeoutBlockingWaitStrategy.class, delegate.getWaitStrategy().getClass());
124+
TimeoutBlockingWaitStrategy.class, delegate.getWaitStrategy().getClass());
116125
assertThat(
117-
"waitstrategy is TimeoutBlockingWaitStrategy",
118-
delegate.getWaitStrategy() instanceof TimeoutBlockingWaitStrategy);
126+
"waitstrategy is TimeoutBlockingWaitStrategy",
127+
delegate.getWaitStrategy() instanceof TimeoutBlockingWaitStrategy);
119128
}
120129

121130
public static class YieldingWaitStrategyFactory implements AsyncWaitStrategyFactory {

0 commit comments

Comments
 (0)