This is an automated email from the ASF dual-hosted git repository.
chengzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere-elasticjob.git
The following commit(s) were added to refs/heads/master by this push:
new 1485887c8 Refactor test cases to reduce useless log (#2349)
1485887c8 is described below
commit 1485887c8aeb71f4fa1dd0c0841f069a8a698bf5
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Oct 31 15:50:34 2023 +0800
Refactor test cases to reduce useless log (#2349)
* Update log config file to ignore regular log
* Refactor RDBTracingListenerConfigurationTest
* Refactor JobTracingEventBusTest
* Refactor HttpJobExecutorTest
---
ecosystem/executor/http/pom.xml | 6 ------
.../http}/src/test/resources/logback-test.xml | 0
.../rdb/listener/RDBTracingListenerConfigurationTest.java | 12 ++++++++++--
ecosystem/tracing/rdb/src/test/resources/logback-test.xml | 2 ++
kernel/src/test/resources/logback-test.xml | 1 +
5 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/ecosystem/executor/http/pom.xml b/ecosystem/executor/http/pom.xml
index d3d7015c2..c1af6c9de 100644
--- a/ecosystem/executor/http/pom.xml
+++ b/ecosystem/executor/http/pom.xml
@@ -40,12 +40,6 @@
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-jdk14</artifactId>
- <scope>test</scope>
- <optional>true</optional>
- </dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
diff --git a/ecosystem/tracing/rdb/src/test/resources/logback-test.xml
b/ecosystem/executor/http/src/test/resources/logback-test.xml
similarity index 100%
copy from ecosystem/tracing/rdb/src/test/resources/logback-test.xml
copy to ecosystem/executor/http/src/test/resources/logback-test.xml
diff --git
a/ecosystem/tracing/rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/listener/RDBTracingListenerConfigurationTest.java
b/ecosystem/tracing/rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/listener/RDBTracingListenerConfigurationTest.java
index ec572b2bc..2b03d7977 100644
---
a/ecosystem/tracing/rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/listener/RDBTracingListenerConfigurationTest.java
+++
b/ecosystem/tracing/rdb/src/test/java/org/apache/shardingsphere/elasticjob/tracing/rdb/listener/RDBTracingListenerConfigurationTest.java
@@ -21,9 +21,15 @@ import org.apache.commons.dbcp2.BasicDataSource;
import
org.apache.shardingsphere.elasticjob.kernel.tracing.exception.TracingConfigurationException;
import org.junit.jupiter.api.Test;
+import javax.sql.DataSource;
+
+import java.sql.SQLException;
+
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
class RDBTracingListenerConfigurationTest {
@@ -38,7 +44,9 @@ class RDBTracingListenerConfigurationTest {
}
@Test
- void assertCreateTracingListenerFailure() {
- assertThrows(TracingConfigurationException.class, () -> new
RDBTracingListenerConfiguration().createTracingListener(new BasicDataSource()));
+ void assertCreateTracingListenerFailure() throws SQLException {
+ DataSource dataSource = mock(DataSource.class);
+ when(dataSource.getConnection()).thenThrow(new SQLException());
+ assertThrows(TracingConfigurationException.class, () -> new
RDBTracingListenerConfiguration().createTracingListener(dataSource));
}
}
diff --git a/ecosystem/tracing/rdb/src/test/resources/logback-test.xml
b/ecosystem/tracing/rdb/src/test/resources/logback-test.xml
index 74a43319c..9ba216d49 100644
--- a/ecosystem/tracing/rdb/src/test/resources/logback-test.xml
+++ b/ecosystem/tracing/rdb/src/test/resources/logback-test.xml
@@ -37,4 +37,6 @@
<root>
<appender-ref ref="STDOUT" />
</root>
+
+ <logger
name="org.apache.shardingsphere.elasticjob.tracing.rdb.datasource.DataSourceTracingStorageConverter"
level="OFF" />
</configuration>
diff --git a/kernel/src/test/resources/logback-test.xml
b/kernel/src/test/resources/logback-test.xml
index 1db232de7..ea8aa3706 100644
--- a/kernel/src/test/resources/logback-test.xml
+++ b/kernel/src/test/resources/logback-test.xml
@@ -39,5 +39,6 @@
</root>
<logger
name="org.apache.shardingsphere.elasticjob.kernel.internal.snapshot.SnapshotService"
level="OFF" />
+ <logger
name="org.apache.shardingsphere.elasticjob.kernel.tracing.JobTracingEventBus"
level="OFF" />
<logger name="org.apache.curator.framework.listen.MappingListenerManager"
level="OFF" />
</configuration>