diff --git a/pom.xml b/pom.xml index 7f504f2b29e4b6968de3222aea51c2967b07352c..6b79fedd925705c3d816b1f51a54934cdb5e3569 100644 --- a/pom.xml +++ b/pom.xml @@ -299,6 +299,18 @@ ${spring-boot.version} test + + org.powermock + powermock-module-junit4 + ${powermock.version} + test + + + org.powermock + powermock-api-mockito2 + ${powermock.version} + test + diff --git a/sharding-opentracing/.travis.yml b/sharding-opentracing/.travis.yml deleted file mode 100644 index 28cb653592fbbfc4c3758b93167ae8f3b2cb416d..0000000000000000000000000000000000000000 --- a/sharding-opentracing/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: java -jdk: - - oraclejdk8 -before_script: - - echo "MAVEN_OPTS='-Xmx1024m -XX:MaxPermSize=256m'" > ~/.mavenrc -after_success: - - mvn clean cobertura:cobertura coveralls:report \ No newline at end of file diff --git a/sharding-opentracing/pom.xml b/sharding-opentracing/pom.xml index 4753408003a6d57b8a20871bceb308ed697415fd..a62a0b2b1a70890fdd226cccaf0c81b7a02a2cfa 100644 --- a/sharding-opentracing/pom.xml +++ b/sharding-opentracing/pom.xml @@ -39,13 +39,11 @@ org.powermock powermock-module-junit4 - ${powermock.version} test org.powermock powermock-api-mockito2 - ${powermock.version} test @@ -53,17 +51,6 @@ - - org.apache.maven.plugins - maven-compiler-plugin - - ${java.version} - ${java.version} - ${java.version} - ${java.version} - - ${maven-compiler-plugin.version} - org.apache.maven.plugins maven-resources-plugin @@ -240,22 +227,6 @@ coveralls-maven-plugin ${coveralls-maven-plugin.version} - diff --git a/sharding-opentracing/src/main/java/io/shardingjdbc/opentracing/ShardingJDBCTracer.java b/sharding-opentracing/src/main/java/io/shardingjdbc/opentracing/ShardingJDBCTracer.java index 3796866322088e601addcc43168d33aff09ee5f3..3d1c050c3d9f38d22544cc3312280b89c7fb02e5 100644 --- a/sharding-opentracing/src/main/java/io/shardingjdbc/opentracing/ShardingJDBCTracer.java +++ b/sharding-opentracing/src/main/java/io/shardingjdbc/opentracing/ShardingJDBCTracer.java @@ -21,7 +21,7 @@ import io.opentracing.Tracer; import io.opentracing.util.GlobalTracer; import io.shardingjdbc.core.exception.ShardingJdbcException; import io.shardingjdbc.core.util.EventBusInstance; -import io.shardingjdbc.opentracing.config.ConfigLoader; +import io.shardingjdbc.opentracing.config.ConfigurationLoader; import lombok.AccessLevel; import lombok.NoArgsConstructor; @@ -41,7 +41,7 @@ public final class ShardingJDBCTracer { if (GlobalTracer.isRegistered()) { return; } - String tracerClassName = new ConfigLoader().getTracerClassName(); + String tracerClassName = new ConfigurationLoader().getTracerClassName(); try { init((Tracer) Class.forName(tracerClassName).newInstance()); } catch (final InstantiationException | IllegalAccessException | ClassNotFoundException ex) { diff --git a/sharding-opentracing/src/main/java/io/shardingjdbc/opentracing/config/ConfigLoader.java b/sharding-opentracing/src/main/java/io/shardingjdbc/opentracing/config/ConfigurationLoader.java similarity index 84% rename from sharding-opentracing/src/main/java/io/shardingjdbc/opentracing/config/ConfigLoader.java rename to sharding-opentracing/src/main/java/io/shardingjdbc/opentracing/config/ConfigurationLoader.java index 70d71acf6718d9baba044779dd2d92fac93407ac..d78d64528ec59ef1310cce1ab37b83ab037ba1f1 100644 --- a/sharding-opentracing/src/main/java/io/shardingjdbc/opentracing/config/ConfigLoader.java +++ b/sharding-opentracing/src/main/java/io/shardingjdbc/opentracing/config/ConfigurationLoader.java @@ -27,16 +27,16 @@ import lombok.Getter; * @author gaohongtao * @author wangkai */ -public class ConfigLoader { +public class ConfigurationLoader { - private static final ConfigParser[] PARSERS = new ConfigParser[]{new OptsConfigParser()}; + private static final ConfigurationParser[] PARSERS = new ConfigurationParser[]{new OpentracingConfigurationParser()}; @Getter private final String tracerClassName; - public ConfigLoader() { + public ConfigurationLoader() { String tracerClassName = null; - for (ConfigParser each : PARSERS) { + for (ConfigurationParser each : PARSERS) { Optional tracerClassOptional = each.parse("tracer.class"); if (tracerClassOptional.isPresent()) { tracerClassName = tracerClassOptional.get(); diff --git a/sharding-opentracing/src/main/java/io/shardingjdbc/opentracing/config/ConfigParser.java b/sharding-opentracing/src/main/java/io/shardingjdbc/opentracing/config/ConfigurationParser.java similarity index 96% rename from sharding-opentracing/src/main/java/io/shardingjdbc/opentracing/config/ConfigParser.java rename to sharding-opentracing/src/main/java/io/shardingjdbc/opentracing/config/ConfigurationParser.java index a9e5ea9ea166d212b3147eeb31e71a60059529ba..2047fe1a190bc192908548ed9c0c81a61d79198e 100644 --- a/sharding-opentracing/src/main/java/io/shardingjdbc/opentracing/config/ConfigParser.java +++ b/sharding-opentracing/src/main/java/io/shardingjdbc/opentracing/config/ConfigurationParser.java @@ -25,7 +25,7 @@ import com.google.common.base.Optional; * @author gaohongtao * @author wangkai */ -interface ConfigParser { +interface ConfigurationParser { /** * Parse config item to config value. diff --git a/sharding-opentracing/src/main/java/io/shardingjdbc/opentracing/config/OptsConfigParser.java b/sharding-opentracing/src/main/java/io/shardingjdbc/opentracing/config/OpentracingConfigurationParser.java similarity index 93% rename from sharding-opentracing/src/main/java/io/shardingjdbc/opentracing/config/OptsConfigParser.java rename to sharding-opentracing/src/main/java/io/shardingjdbc/opentracing/config/OpentracingConfigurationParser.java index ffba06d885e3b0dc3a12eef23aa6f5e63bc800f1..00f8618396aa9e72f0adb19b6ec0b9687e9cb865 100644 --- a/sharding-opentracing/src/main/java/io/shardingjdbc/opentracing/config/OptsConfigParser.java +++ b/sharding-opentracing/src/main/java/io/shardingjdbc/opentracing/config/OpentracingConfigurationParser.java @@ -25,7 +25,7 @@ import com.google.common.base.Optional; * @author gaohongtao * @author wangkai */ -public class OptsConfigParser implements ConfigParser { +public class OpentracingConfigurationParser implements ConfigurationParser { private static final String PREFIX = "shardingjdbc.opentracing"; diff --git a/sharding-opentracing/src/test/java/io/shardingjdbc/opentracing/AllTests.java b/sharding-opentracing/src/test/java/io/shardingjdbc/opentracing/AllTests.java index e37e01a499aab1e7414a7bdc723cb1ad94f38f3c..c7690241cca0ec391985638b29e603352fcf8169 100644 --- a/sharding-opentracing/src/test/java/io/shardingjdbc/opentracing/AllTests.java +++ b/sharding-opentracing/src/test/java/io/shardingjdbc/opentracing/AllTests.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -17,12 +17,12 @@ package io.shardingjdbc.opentracing; -import io.shardingjdbc.opentracing.config.ConfigLoaderTest; +import io.shardingjdbc.opentracing.config.ConfigurationLoaderTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; @RunWith(Suite.class) -@Suite.SuiteClasses({ConfigLoaderTest.class, +@Suite.SuiteClasses({ConfigurationLoaderTest.class, ExecuteEventListenerTest.class, ShardingJDBCTracerTest.class }) diff --git a/sharding-opentracing/src/test/java/io/shardingjdbc/opentracing/ExecuteEventListenerTest.java b/sharding-opentracing/src/test/java/io/shardingjdbc/opentracing/ExecuteEventListenerTest.java index 73858e6ef000ac8e66e9656f28a58899fbab5e1d..95181c6d08dbde457c9673aa43162ca95fee47d3 100644 --- a/sharding-opentracing/src/test/java/io/shardingjdbc/opentracing/ExecuteEventListenerTest.java +++ b/sharding-opentracing/src/test/java/io/shardingjdbc/opentracing/ExecuteEventListenerTest.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -54,7 +54,7 @@ public class ExecuteEventListenerTest { } @Before - public void before() throws NoSuchFieldException, IllegalAccessException { + public void before() { TRACER.reset(); } diff --git a/sharding-opentracing/src/test/java/io/shardingjdbc/opentracing/ShardingJDBCTracerTest.java b/sharding-opentracing/src/test/java/io/shardingjdbc/opentracing/ShardingJDBCTracerTest.java index d61dc9abd297e1f0d15d95b4b6bb4c27a8b72ff8..b196b6205f811f6aa169062b21268a205a469b1e 100644 --- a/sharding-opentracing/src/test/java/io/shardingjdbc/opentracing/ShardingJDBCTracerTest.java +++ b/sharding-opentracing/src/test/java/io/shardingjdbc/opentracing/ShardingJDBCTracerTest.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -21,8 +21,7 @@ import io.opentracing.NoopTracerFactory; import io.opentracing.Tracer; import io.opentracing.util.GlobalTracer; import io.shardingjdbc.core.exception.ShardingJdbcException; -import io.shardingjdbc.opentracing.config.OptsConfigParser; -import org.apache.commons.lang3.builder.ToStringExclude; +import io.shardingjdbc.opentracing.config.OpentracingConfigurationParser; import org.hamcrest.core.Is; import org.junit.Before; import org.junit.Test; @@ -40,7 +39,7 @@ import static org.powermock.api.mockito.PowerMockito.mockStatic; import static org.powermock.api.mockito.PowerMockito.when; @RunWith(PowerMockRunner.class) -@PrepareForTest(OptsConfigParser.class) +@PrepareForTest(OpentracingConfigurationParser.class) public class ShardingJDBCTracerTest { @Before diff --git a/sharding-opentracing/src/test/java/io/shardingjdbc/opentracing/config/ConfigLoaderTest.java b/sharding-opentracing/src/test/java/io/shardingjdbc/opentracing/config/ConfigurationLoaderTest.java similarity index 83% rename from sharding-opentracing/src/test/java/io/shardingjdbc/opentracing/config/ConfigLoaderTest.java rename to sharding-opentracing/src/test/java/io/shardingjdbc/opentracing/config/ConfigurationLoaderTest.java index 68c389901a98d0f168d6c1a7e3ecd2580872bbc9..6a64ca28420bbf7defbb149d19bc73fa4352ffca 100644 --- a/sharding-opentracing/src/test/java/io/shardingjdbc/opentracing/config/ConfigLoaderTest.java +++ b/sharding-opentracing/src/test/java/io/shardingjdbc/opentracing/config/ConfigurationLoaderTest.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -29,18 +29,18 @@ import static org.powermock.api.mockito.PowerMockito.mockStatic; import static org.powermock.api.mockito.PowerMockito.when; @RunWith(PowerMockRunner.class) -@PrepareForTest(OptsConfigParser.class) -public class ConfigLoaderTest { +@PrepareForTest(OpentracingConfigurationParser.class) +public class ConfigurationLoaderTest { @Before - public void setUp() throws Exception { + public void setUp() { mockStatic(System.class); } @Test public void assertLoadConfigFromProperty() { when(System.getProperty("shardingjdbc.opentracing.tracer.class")).thenReturn("com.foo.fooClass"); - assertThat(new ConfigLoader().getTracerClassName(), is("com.foo.fooClass")); + assertThat(new ConfigurationLoader().getTracerClassName(), is("com.foo.fooClass")); } } diff --git a/sharding-opentracing/src/test/java/io/shardingjdbc/opentracing/fixture/FooTracer.java b/sharding-opentracing/src/test/java/io/shardingjdbc/opentracing/fixture/FooTracer.java index fdab04a098f5b960e39a9f0d8d51694e84a3132a..3995ee8e1ccd5102771ef7b78627a2e512bdfe86 100644 --- a/sharding-opentracing/src/test/java/io/shardingjdbc/opentracing/fixture/FooTracer.java +++ b/sharding-opentracing/src/test/java/io/shardingjdbc/opentracing/fixture/FooTracer.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -31,9 +31,7 @@ public class FooTracer implements Tracer { } @Override - public void inject(final SpanContext spanContext, final Format format, final C c) { - - } + public void inject(final SpanContext spanContext, final Format format, final C c) {} @Override public SpanContext extract(final Format format, final C c) {