diff --git a/pom.xml b/pom.xml index c6416d3a5..72ad887e9 100644 --- a/pom.xml +++ b/pom.xml @@ -255,7 +255,7 @@ org.mockito mockito-core - 1.10.19 + 4.3.0 test diff --git a/sofa-tracer-plugins/sofa-tracer-datasource-plugin/pom.xml b/sofa-tracer-plugins/sofa-tracer-datasource-plugin/pom.xml index b57203872..11c282e80 100644 --- a/sofa-tracer-plugins/sofa-tracer-datasource-plugin/pom.xml +++ b/sofa-tracer-plugins/sofa-tracer-datasource-plugin/pom.xml @@ -37,7 +37,6 @@ org.mockito mockito-core - 2.10.0 test diff --git a/sofa-tracer-plugins/sofa-tracer-datasource-plugin/src/test/java/com/sofa/tracer/plugins/datasource/base/BaseTest.java b/sofa-tracer-plugins/sofa-tracer-datasource-plugin/src/test/java/com/sofa/tracer/plugins/datasource/base/BaseTest.java index ca9a63c54..d7ea30047 100644 --- a/sofa-tracer-plugins/sofa-tracer-datasource-plugin/src/test/java/com/sofa/tracer/plugins/datasource/base/BaseTest.java +++ b/sofa-tracer-plugins/sofa-tracer-datasource-plugin/src/test/java/com/sofa/tracer/plugins/datasource/base/BaseTest.java @@ -31,7 +31,7 @@ import org.junit.runner.RunWith; import org.junit.runners.MethodSorters; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import javax.sql.DataSource; import java.io.File; diff --git a/sofa-tracer-plugins/sofa-tracer-kafkamq-plugin/pom.xml b/sofa-tracer-plugins/sofa-tracer-kafkamq-plugin/pom.xml index 4884f8c23..eadba6183 100644 --- a/sofa-tracer-plugins/sofa-tracer-kafkamq-plugin/pom.xml +++ b/sofa-tracer-plugins/sofa-tracer-kafkamq-plugin/pom.xml @@ -45,7 +45,6 @@ org.mockito mockito-core - 2.10.0 test diff --git a/sofa-tracer-plugins/sofa-tracer-rabbitmq-plugin/pom.xml b/sofa-tracer-plugins/sofa-tracer-rabbitmq-plugin/pom.xml index 6ab9312d8..01922658f 100644 --- a/sofa-tracer-plugins/sofa-tracer-rabbitmq-plugin/pom.xml +++ b/sofa-tracer-plugins/sofa-tracer-rabbitmq-plugin/pom.xml @@ -45,7 +45,6 @@ org.mockito mockito-core - 2.10.0 test diff --git a/tracer-core/src/test/java/com/alipay/common/tracer/core/benchmark/CountBenchmark.java b/tracer-core/src/test/java/com/alipay/common/tracer/core/benchmark/CountBenchmark.java index cc88b3ada..debf44b16 100644 --- a/tracer-core/src/test/java/com/alipay/common/tracer/core/benchmark/CountBenchmark.java +++ b/tracer-core/src/test/java/com/alipay/common/tracer/core/benchmark/CountBenchmark.java @@ -17,7 +17,6 @@ package com.alipay.common.tracer.core.benchmark; import com.alipay.common.tracer.core.utils.StringUtils; -import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; @@ -77,7 +76,6 @@ public void countUseCountMatches(Blackhole blackhole) { blackhole.consume(StringUtils.countMatches(RPC_ID, '.')); } - @Test public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder().include(CountBenchmark.class.getSimpleName()).forks(1) .build(); diff --git a/tracer-sofa-boot-starter/pom.xml b/tracer-sofa-boot-starter/pom.xml index 4c9a7d44f..5b98d1601 100644 --- a/tracer-sofa-boot-starter/pom.xml +++ b/tracer-sofa-boot-starter/pom.xml @@ -17,6 +17,10 @@ + + com.alipay.sofa + sofa-boot + com.alipay.sofa tracer-core @@ -259,13 +263,18 @@ de.flapdoodle.embed de.flapdoodle.embed.mongo - 2.2.0 test cz.jirutka.spring embedmongo-spring 1.3.1 + true + + + + junit + junit test diff --git a/tracer-sofa-boot-starter/src/main/java/com/alipay/sofa/tracer/boot/listener/SofaTracerConfigurationListener.java b/tracer-sofa-boot-starter/src/main/java/com/alipay/sofa/tracer/boot/listener/SofaTracerConfigurationListener.java index 2719849f9..a8ef67b35 100644 --- a/tracer-sofa-boot-starter/src/main/java/com/alipay/sofa/tracer/boot/listener/SofaTracerConfigurationListener.java +++ b/tracer-sofa-boot-starter/src/main/java/com/alipay/sofa/tracer/boot/listener/SofaTracerConfigurationListener.java @@ -18,6 +18,7 @@ import com.alipay.common.tracer.core.configuration.SofaTracerConfiguration; import com.alipay.common.tracer.core.utils.StringUtils; +import com.alipay.sofa.boot.util.SofaBootEnvUtils; import com.alipay.sofa.tracer.boot.properties.SofaTracerProperties; import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -27,9 +28,7 @@ import org.springframework.core.Ordered; import org.springframework.core.annotation.AnnotationUtils; import org.springframework.core.env.ConfigurableEnvironment; -import org.springframework.core.env.Environment; import org.springframework.util.Assert; -import org.springframework.util.ClassUtils; /** * Parse SOFATracer Configuration in early stage. @@ -46,7 +45,7 @@ public class SofaTracerConfigurationListener public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) { ConfigurableEnvironment environment = event.getEnvironment(); - if (isSpringCloudBootstrapEnvironment(environment)) { + if (SofaBootEnvUtils.isSpringCloudBootstrapEnvironment(environment)) { return; } @@ -112,19 +111,4 @@ public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) { public int getOrder() { return HIGHEST_PRECEDENCE + 30; } - - private boolean isSpringCloudBootstrapEnvironment(Environment environment) { - if (!(environment instanceof ConfigurableEnvironment)) { - return false; - } else { - return !((ConfigurableEnvironment) environment).getPropertySources().contains( - "sofaBootstrap") - && isSpringCloud(); - } - } - - private boolean isSpringCloud() { - return ClassUtils.isPresent("org.springframework.cloud.bootstrap.BootstrapConfiguration", - null); - } } \ No newline at end of file diff --git a/tracer-sofa-boot-starter/src/test/java/com/alipay/sofa/tracer/boot/base/AbstractTestBase.java b/tracer-sofa-boot-starter/src/test/java/com/alipay/sofa/tracer/boot/base/AbstractTestBase.java index 355f1e887..068686ab4 100644 --- a/tracer-sofa-boot-starter/src/test/java/com/alipay/sofa/tracer/boot/base/AbstractTestBase.java +++ b/tracer-sofa-boot-starter/src/test/java/com/alipay/sofa/tracer/boot/base/AbstractTestBase.java @@ -21,7 +21,7 @@ import com.alipay.common.tracer.core.reporter.digest.manager.SofaTracerDigestReporterAsyncManager; import com.alipay.common.tracer.core.reporter.stat.manager.SofaTracerStatisticReporterCycleTimesManager; import com.alipay.common.tracer.core.reporter.stat.manager.SofaTracerStatisticReporterManager; -import com.alipay.sofa.infra.listener.SofaBootstrapRunListener; +import com.alipay.sofa.boot.listener.SofaBootstrapRunListener; import com.alipay.sofa.tracer.plugins.springmvc.SpringMvcTracer; import org.apache.commons.io.FileUtils; import org.junit.AfterClass; diff --git a/tracer-sofa-boot-starter/src/test/java/com/alipay/sofa/tracer/boot/base/AbstractTestCloudBase.java b/tracer-sofa-boot-starter/src/test/java/com/alipay/sofa/tracer/boot/base/AbstractTestCloudBase.java index f3d00dd78..5f624c7be 100644 --- a/tracer-sofa-boot-starter/src/test/java/com/alipay/sofa/tracer/boot/base/AbstractTestCloudBase.java +++ b/tracer-sofa-boot-starter/src/test/java/com/alipay/sofa/tracer/boot/base/AbstractTestCloudBase.java @@ -18,7 +18,7 @@ import com.alipay.common.tracer.core.appender.TracerLogRootDaemon; import com.alipay.common.tracer.core.configuration.SofaTracerConfiguration; -import com.alipay.sofa.infra.listener.SofaBootstrapRunListener; +import com.alipay.sofa.boot.listener.SofaBootstrapRunListener; import org.apache.commons.io.FileUtils; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -41,7 +41,7 @@ @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = SpringBootWebApplication.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) @TestPropertySource(locations = "classpath:application.properties") -public class AbstractTestCloudBase { +public abstract class AbstractTestCloudBase { protected static String logDirectoryPath = TracerLogRootDaemon.LOG_FILE_DIR; @BeforeClass diff --git a/tracer-sofa-boot-starter/src/test/java/com/alipay/sofa/tracer/boot/base/ConfigurationHolderListener.java b/tracer-sofa-boot-starter/src/test/java/com/alipay/sofa/tracer/boot/base/ConfigurationHolderListener.java index 43da3bf8c..a110bd4ae 100644 --- a/tracer-sofa-boot-starter/src/test/java/com/alipay/sofa/tracer/boot/base/ConfigurationHolderListener.java +++ b/tracer-sofa-boot-starter/src/test/java/com/alipay/sofa/tracer/boot/base/ConfigurationHolderListener.java @@ -18,7 +18,7 @@ import com.alipay.common.tracer.core.configuration.SofaTracerConfiguration; import com.alipay.common.tracer.core.utils.StringUtils; -import com.alipay.sofa.infra.utils.SOFABootEnvUtils; +import com.alipay.sofa.boot.util.SofaBootEnvUtils; import com.alipay.sofa.tracer.boot.properties.SofaTracerProperties; import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent; import org.springframework.context.ApplicationListener; @@ -33,7 +33,7 @@ public class ConfigurationHolderListener implements @Override public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) { ConfigurableEnvironment environment = event.getEnvironment(); - if (SOFABootEnvUtils.isSpringCloudBootstrapEnvironment(environment)) { + if (SofaBootEnvUtils.isSpringCloudBootstrapEnvironment(environment)) { return; } SofaTracerProperties sofaTracerProperties = new SofaTracerProperties(); diff --git a/tracer-sofa-boot-starter/src/test/java/com/alipay/sofa/tracer/boot/base/SpringBootWebApplication.java b/tracer-sofa-boot-starter/src/test/java/com/alipay/sofa/tracer/boot/base/SpringBootWebApplication.java index 9aba4822d..8493668c0 100644 --- a/tracer-sofa-boot-starter/src/test/java/com/alipay/sofa/tracer/boot/base/SpringBootWebApplication.java +++ b/tracer-sofa-boot-starter/src/test/java/com/alipay/sofa/tracer/boot/base/SpringBootWebApplication.java @@ -17,6 +17,7 @@ package com.alipay.sofa.tracer.boot.base; import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration; import org.springframework.cloud.client.loadbalancer.LoadBalanced; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ImportResource; @@ -28,7 +29,11 @@ * @author yangguanchao * @since 2018/04/30 */ -@org.springframework.boot.autoconfigure.SpringBootApplication +@org.springframework.boot.autoconfigure.SpringBootApplication( + exclude = { + EmbeddedMongoAutoConfiguration.class + } +) @ImportResource({ "classpath:hikariDataSource.xml" }) public class SpringBootWebApplication { diff --git a/tracer-sofa-boot-starter/src/test/java/com/alipay/sofa/tracer/boot/config/ConfigurationTest.java b/tracer-sofa-boot-starter/src/test/java/com/alipay/sofa/tracer/boot/config/ConfigurationTest.java index efdf65c4b..f307824a4 100644 --- a/tracer-sofa-boot-starter/src/test/java/com/alipay/sofa/tracer/boot/config/ConfigurationTest.java +++ b/tracer-sofa-boot-starter/src/test/java/com/alipay/sofa/tracer/boot/config/ConfigurationTest.java @@ -19,17 +19,12 @@ import com.alipay.common.tracer.core.appender.file.TimedRollingFileAppender; import com.alipay.sofa.tracer.boot.base.AbstractTestBase; import com.alipay.sofa.tracer.boot.base.ConfigurationHolder; -import com.alipay.sofa.tracer.boot.base.SpringBootWebApplication; import com.alipay.sofa.tracer.boot.properties.SofaTracerProperties; import org.apache.commons.io.FileUtils; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import java.io.File; import java.util.Map; diff --git a/tracer-test/core-test/pom.xml b/tracer-test/core-test/pom.xml index 8ede67005..d0ff7b760 100644 --- a/tracer-test/core-test/pom.xml +++ b/tracer-test/core-test/pom.xml @@ -26,7 +26,6 @@ org.mockito mockito-core - 2.3.0 test