Skip to content

Commit 6839f23

Browse files
committed
migrate to logger
1 parent 6a99568 commit 6839f23

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

dubbo-plugin/dubbo-qos/src/test/java/org/apache/dubbo/qos/command/impl/DiscoveryTimelineCommandTest.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import org.apache.dubbo.common.URL;
2020
import org.apache.dubbo.common.beans.factory.ScopeBeanFactory;
21+
import org.apache.dubbo.common.logger.Logger;
22+
import org.apache.dubbo.common.logger.LoggerFactory;
2123
import org.apache.dubbo.qos.api.CommandContext;
2224
import org.apache.dubbo.registry.client.DefaultServiceInstance;
2325
import org.apache.dubbo.registry.client.ServiceDiscovery;
@@ -40,6 +42,7 @@
4042

4143
public class DiscoveryTimelineCommandTest {
4244

45+
private static final Logger logger = LoggerFactory.getLogger(DiscoveryTimelineCommandTest.class);
4346
private DiscoveryTimelineCommand command;
4447
private FrameworkModel frameworkModel;
4548
private ApplicationModel applicationModel;
@@ -82,7 +85,7 @@ void testExecuteWithTimestamps() {
8285
Mockito.when(serviceInstance.getMetadata()).thenReturn(metadata);
8386

8487
String output = command.execute(new CommandContext("discovery-timeline"), null);
85-
System.out.println("testExecuteWithTimestamps Output:\n" + output);
88+
logger.info("testExecuteWithTimestamps Output:\n{}", output);
8689

8790
assertTrue(output.contains("Discovery Timeline"));
8891
assertTrue(output.contains("127.0.0.1:2181"));
@@ -98,7 +101,7 @@ void testExecuteWithoutMetadata() {
98101
Mockito.when(serviceInstance.getMetadata()).thenReturn(null);
99102

100103
String output = command.execute(new CommandContext("discovery-timeline"), null);
101-
System.out.println("testExecuteWithoutMetadata Output:\n" + output);
104+
logger.info("testExecuteWithoutMetadata Output:\n{}", output);
102105

103106
assertTrue(output.contains("Unknown"));
104107
assertTrue(output.contains("Discovered: org.apache.dubbo.demo.DemoService"));
@@ -120,13 +123,13 @@ void testExecuteWithPagination() {
120123
Mockito.when(serviceInstance.getMetadata()).thenReturn(metadata);
121124

122125
String output = command.execute(new CommandContext("discovery-timeline"), new String[] {"limit=5", "page=2"});
123-
System.out.println("testExecuteWithPagination Output:\n" + output);
124-
System.out.println("Providers mocked: "
125-
+ providers.stream().map(ProviderModel::getServiceKey).collect(Collectors.toList()));
126-
System.out.println("Output characters:");
126+
logger.info("testExecuteWithPagination Output:\n{}", output);
127+
logger.info("Providers mocked: {}", providers.stream().map(ProviderModel::getServiceKey).collect(Collectors.toList()));
128+
StringBuilder charLog = new StringBuilder("Output characters:\n");
127129
for (int i = 0; i < output.length(); i++) {
128-
System.out.printf("Index %d: %c (ASCII %d)%n", i, output.charAt(i), (int) output.charAt(i));
130+
charLog.append(String.format("Index %d: %c (ASCII %d)%n", i, output.charAt(i), (int) output.charAt(i)));
129131
}
132+
logger.info("{}", charLog.toString());
130133

131134
assertTrue(output.contains("Discovery Timeline"));
132135
assertTrue(output.contains("Discovered: Service6"));
@@ -141,7 +144,7 @@ void testExecuteWithServiceFilter() {
141144
Mockito.when(serviceInstance.getMetadata()).thenReturn(new HashMap<>());
142145

143146
String output = command.execute(new CommandContext("discovery-timeline"), new String[] {"service=MyService"});
144-
System.out.println("testExecuteWithServiceFilter Output:\n" + output);
147+
logger.info("testExecuteWithServiceFilter Output:\n{}", output);
145148

146149
assertTrue(output.contains("Discovered: org.apache.dubbo.MyService"));
147150
}
@@ -154,7 +157,7 @@ void testExecuteWithRegistryFilterMismatch() {
154157
Mockito.when(serviceInstance.getMetadata()).thenReturn(new HashMap<>());
155158

156159
String output = command.execute(new CommandContext("discovery-timeline"), new String[] {"registry=nacos"});
157-
System.out.println("testExecuteWithRegistryFilterMismatch Output:\n" + output);
160+
logger.info("testExecuteWithRegistryFilterMismatch Output:\n{}", output);
158161

159162
assertTrue(output.contains("Error: No services discovered."));
160163
}

0 commit comments

Comments
 (0)