|
1 | 1 | package io.javaoperatorsdk.operator.config.runtime; |
2 | 2 |
|
3 | | -import org.apache.logging.log4j.Level; |
4 | | -import org.apache.logging.log4j.core.LoggerContext; |
5 | | -import org.apache.logging.log4j.core.config.AppenderRef; |
6 | | -import org.apache.logging.log4j.core.config.LoggerConfig; |
7 | | -import org.apache.logging.log4j.core.layout.PatternLayout; |
8 | | -import org.apache.logging.log4j.test.appender.ListAppender; |
9 | 3 | import org.junit.jupiter.api.Test; |
10 | 4 |
|
11 | 5 | import io.fabric8.kubernetes.client.CustomResource; |
|
17 | 11 | import io.javaoperatorsdk.operator.api.reconciler.Reconciler; |
18 | 12 | import io.javaoperatorsdk.operator.api.reconciler.UpdateControl; |
19 | 13 |
|
20 | | -import static org.assertj.core.api.Assertions.assertThat; |
21 | | -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; |
22 | | -import static org.junit.jupiter.api.Assertions.assertEquals; |
23 | | -import static org.junit.jupiter.api.Assertions.assertFalse; |
| 14 | +import static org.junit.jupiter.api.Assertions.*; |
24 | 15 |
|
25 | 16 | class DefaultConfigurationServiceTest { |
26 | 17 |
|
27 | 18 | public static final String CUSTOM_FINALIZER_NAME = "a.custom/finalizer"; |
28 | 19 | final DefaultConfigurationService configurationService = DefaultConfigurationService.instance(); |
29 | 20 |
|
30 | | - @Test |
31 | | - void attemptingToRetrieveAnUnknownControllerShouldLogWarning() { |
32 | | - final LoggerContext context = LoggerContext.getContext(false); |
33 | | - final PatternLayout layout = PatternLayout.createDefaultLayout(context.getConfiguration()); |
34 | | - final ListAppender appender = new ListAppender("list", null, layout, false, false); |
35 | | - |
36 | | - appender.start(); |
37 | | - |
38 | | - context.getConfiguration().addAppender(appender); |
39 | | - |
40 | | - AppenderRef ref = AppenderRef.createAppenderRef("list", null, null); |
41 | | - final var loggerName = configurationService.getLoggerName(); |
42 | | - LoggerConfig loggerConfig = |
43 | | - LoggerConfig.createLogger( |
44 | | - false, |
45 | | - Level.valueOf("info"), |
46 | | - loggerName, |
47 | | - "false", |
48 | | - new AppenderRef[] {ref}, |
49 | | - null, |
50 | | - context.getConfiguration(), |
51 | | - null); |
52 | | - loggerConfig.addAppender(appender, null, null); |
53 | | - |
54 | | - context.getConfiguration().addLogger(loggerName, loggerConfig); |
55 | | - context.updateLoggers(); |
56 | | - |
57 | | - try { |
58 | | - final var config = |
59 | | - configurationService |
60 | | - .getConfigurationFor(new NotAutomaticallyCreated(), false); |
61 | | - |
62 | | - assertThat(config).isNull(); |
63 | | - assertThat(appender.getMessages()) |
64 | | - .hasSize(1) |
65 | | - .allMatch(m -> m.contains(NotAutomaticallyCreated.NAME) && m.contains("not found")); |
66 | | - } finally { |
67 | | - appender.stop(); |
68 | | - |
69 | | - context.getConfiguration().removeLogger(loggerName); |
70 | | - context.updateLoggers(); |
71 | | - } |
72 | | - } |
73 | | - |
74 | 21 | @Test |
75 | 22 | void returnsValuesFromControllerAnnotationFinalizer() { |
76 | 23 | final var reconciler = new TestCustomReconciler(); |
|
0 commit comments