[SCB-2475] migrate to junit5 core part 1 (#2829)
diff --git a/core/src/test/java/org/apache/servicecomb/core/TestConfig.java b/core/src/test/java/org/apache/servicecomb/core/TestConfig.java
index 5162e89..dafb46c 100644
--- a/core/src/test/java/org/apache/servicecomb/core/TestConfig.java
+++ b/core/src/test/java/org/apache/servicecomb/core/TestConfig.java
@@ -29,17 +29,17 @@
import org.apache.servicecomb.swagger.invocation.context.HttpStatus;
import org.apache.servicecomb.swagger.invocation.context.InvocationContext;
import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
-import org.junit.Assert;
import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
public class TestConfig {
@Test
public void testConstants() {
- Assert.assertEquals("x-cse-context", Const.CSE_CONTEXT);
- Assert.assertEquals("rest", Const.RESTFUL);
- Assert.assertEquals("", Const.ANY_TRANSPORT);
- Assert.assertEquals("latest", Const.VERSION_RULE_LATEST);
- Assert.assertEquals("0.0.0.0+", Const.DEFAULT_VERSION_RULE);
+ Assertions.assertEquals("x-cse-context", Const.CSE_CONTEXT);
+ Assertions.assertEquals("rest", Const.RESTFUL);
+ Assertions.assertEquals("", Const.ANY_TRANSPORT);
+ Assertions.assertEquals("latest", Const.VERSION_RULE_LATEST);
+ Assertions.assertEquals("0.0.0.0+", Const.DEFAULT_VERSION_RULE);
}
@Test
@@ -47,69 +47,69 @@
String objectString = new String("Unit Testing");
Response oResponse = Response.success(objectString, Status.OK);
- Assert.assertEquals(true, oResponse.isSucceed());
+ Assertions.assertEquals(true, oResponse.isSucceed());
oResponse = Response.succResp(objectString);
- Assert.assertEquals(true, oResponse.isSucceed());
- Assert.assertEquals(200, oResponse.getStatusCode());
+ Assertions.assertEquals(true, oResponse.isSucceed());
+ Assertions.assertEquals(200, oResponse.getStatusCode());
Throwable oThrowable = new Throwable("Error");
oResponse = Response.consumerFailResp(oThrowable);
- Assert.assertEquals(true, oResponse.isFailed());
+ Assertions.assertEquals(true, oResponse.isFailed());
oResponse = Response.providerFailResp(oThrowable);
- Assert.assertEquals(true, oResponse.isFailed());
+ Assertions.assertEquals(true, oResponse.isFailed());
}
@Test
public void testHttpStatus() {
StatusType oStatus = new HttpStatus(204, "InternalServerError");
- Assert.assertEquals("InternalServerError", oStatus.getReasonPhrase());
+ Assertions.assertEquals("InternalServerError", oStatus.getReasonPhrase());
}
@Test
public void testContextUtils() {
ThreadLocal<InvocationContext> contextMgr = new ThreadLocal<>();
- Assert.assertEquals(contextMgr.get(), ContextUtils.getInvocationContext());
+ Assertions.assertEquals(contextMgr.get(), ContextUtils.getInvocationContext());
SwaggerInvocation invocation = new SwaggerInvocation();
invocation.addContext("test1", "testObject");
- Assert.assertEquals("testObject", invocation.getContext("test1"));
+ Assertions.assertEquals("testObject", invocation.getContext("test1"));
Map<String, String> context = new HashMap<>();
context.put("test2", new String("testObject"));
invocation.setContext(context);
- Assert.assertEquals(context, invocation.getContext());
+ Assertions.assertEquals(context, invocation.getContext());
invocation.setStatus(Status.OK);
- Assert.assertEquals(200, invocation.getStatus().getStatusCode());
+ Assertions.assertEquals(200, invocation.getStatus().getStatusCode());
invocation.setStatus(204);
- Assert.assertEquals(204, invocation.getStatus().getStatusCode());
+ Assertions.assertEquals(204, invocation.getStatus().getStatusCode());
invocation.setStatus(Status.OK);
- Assert.assertEquals((Status.OK).getStatusCode(), invocation.getStatus().getStatusCode());
+ Assertions.assertEquals((Status.OK).getStatusCode(), invocation.getStatus().getStatusCode());
invocation.setStatus(203, "Done");
- Assert.assertEquals(203, invocation.getStatus().getStatusCode());
+ Assertions.assertEquals(203, invocation.getStatus().getStatusCode());
ContextUtils.setInvocationContext(invocation);
- Assert.assertEquals(invocation, ContextUtils.getInvocationContext());
+ Assertions.assertEquals(invocation, ContextUtils.getInvocationContext());
ContextUtils.removeInvocationContext();
- Assert.assertEquals(null, ContextUtils.getInvocationContext());
+ Assertions.assertEquals(null, ContextUtils.getInvocationContext());
}
@Test
public void testResponse() {
Response response = Response.create(400, "test", null);
InvocationException exception = response.getResult();
- Assert.assertEquals(null, exception.getErrorData());
+ Assertions.assertEquals(null, exception.getErrorData());
response = Response.create(400, "test", "errorData");
exception = response.getResult();
- Assert.assertEquals("errorData", exception.getErrorData());
+ Assertions.assertEquals("errorData", exception.getErrorData());
}
}
diff --git a/core/src/test/java/org/apache/servicecomb/core/TestConfigurationSpringInitializer.java b/core/src/test/java/org/apache/servicecomb/core/TestConfigurationSpringInitializer.java
index 266274d..35a0aca 100644
--- a/core/src/test/java/org/apache/servicecomb/core/TestConfigurationSpringInitializer.java
+++ b/core/src/test/java/org/apache/servicecomb/core/TestConfigurationSpringInitializer.java
@@ -16,10 +16,6 @@
*/
package org.apache.servicecomb.core;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
import static org.mockito.Matchers.anyString;
import java.util.HashMap;
@@ -31,12 +27,11 @@
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.servicecomb.config.ConfigUtil;
-import org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader;
import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
import org.mockito.Matchers;
import org.mockito.Mockito;
import org.mockito.stubbing.Answer;
@@ -78,13 +73,13 @@
Object o = ConfigUtil.getProperty("zq");
@SuppressWarnings("unchecked")
List<Map<String, Object>> listO = (List<Map<String, Object>>) o;
- Assert.assertEquals(3, listO.size());
- Assert.assertNull(ConfigUtil.getProperty("notExist"));
+ Assertions.assertEquals(3, listO.size());
+ Assertions.assertNull(ConfigUtil.getProperty("notExist"));
Configuration instance = ConfigurationManager.getConfigInstance();
ConfigUtil.installDynamicConfig();
// must not reinstall
- Assert.assertEquals(instance, ConfigurationManager.getConfigInstance());
+ Assertions.assertEquals(instance, ConfigurationManager.getConfigInstance());
}
@Test
@@ -151,7 +146,7 @@
String value = propertyMap.get(propertyName);
if (null == value) {
- fail("get unexpected property name: " + propertyName);
+ Assertions.fail("get unexpected property name: " + propertyName);
}
return value;
}).when(environment).getProperty(anyString(), Matchers.eq(Object.class));
@@ -159,13 +154,13 @@
new ConfigurationSpringInitializer().setEnvironment(environment);
Map<String, Map<String, Object>> extraLocalConfig = getExtraConfigMapFromConfigUtil();
- assertFalse(extraLocalConfig.isEmpty());
+ Assertions.assertFalse(extraLocalConfig.isEmpty());
Map<String, Object> extraProperties = extraLocalConfig
.get(ConfigurationSpringInitializer.EXTRA_CONFIG_SOURCE_PREFIX + environment.getClass().getName() + "@"
+ environment.hashCode());
- assertNotNull(extraLocalConfig);
+ Assertions.assertNotNull(extraLocalConfig);
for (Entry<String, String> entry : propertyMap.entrySet()) {
- assertEquals(entry.getValue(), extraProperties.get(entry.getKey()));
+ Assertions.assertEquals(entry.getValue(), extraProperties.get(entry.getKey()));
}
}
@@ -207,22 +202,22 @@
configurationSpringInitializer.setEnvironment(environment2);
Map<String, Map<String, Object>> extraConfig = getExtraConfigMapFromConfigUtil();
- assertEquals(3, extraConfig.size());
+ Assertions.assertEquals(3, extraConfig.size());
Map<String, Object> extraProperties = extraConfig
.get(ConfigurationSpringInitializer.EXTRA_CONFIG_SOURCE_PREFIX + "application");
- assertEquals(1, extraProperties.size());
- assertEquals("application", extraProperties.get("spring.config.name"));
+ Assertions.assertEquals(1, extraProperties.size());
+ Assertions.assertEquals("application", extraProperties.get("spring.config.name"));
extraProperties = extraConfig.get(ConfigurationSpringInitializer.EXTRA_CONFIG_SOURCE_PREFIX + "bootstrap");
- assertEquals(1, extraProperties.size());
- assertEquals("bootstrap", extraProperties.get("spring.application.name"));
+ Assertions.assertEquals(1, extraProperties.size());
+ Assertions.assertEquals("bootstrap", extraProperties.get("spring.application.name"));
extraProperties = extraConfig.get(
ConfigurationSpringInitializer.EXTRA_CONFIG_SOURCE_PREFIX + environment2.getClass().getName() + "@"
+ environment2.hashCode());
- assertEquals(1, extraProperties.size());
- assertEquals("value2", extraProperties.get("key2"));
+ Assertions.assertEquals(1, extraProperties.size());
+ Assertions.assertEquals("value2", extraProperties.get("key2"));
}
@Test(expected = RuntimeException.class)
diff --git a/core/src/test/java/org/apache/servicecomb/core/TestConsumer.java b/core/src/test/java/org/apache/servicecomb/core/TestConsumer.java
deleted file mode 100644
index 885e831..0000000
--- a/core/src/test/java/org/apache/servicecomb/core/TestConsumer.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); 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
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.core;
-
-public class TestConsumer {
-//
-// @SuppressWarnings({"rawtypes", "unchecked"})
-// @Test
-// public void testConsumerProviderManager() {
-// ConsumerProviderManager oConsumerProviderManager = new ConsumerProviderManager();
-// RegisterManager oRegisterManager = new RegisterManager("cse consumer provider manager");
-// oRegisterManager.register("servicecomb.references.cse consumer provider manager",
-// "cse consumer provider manager");
-// boolean validAssert = true;
-// try {
-// oConsumerProviderManager.getReferenceConfig("consumer provider manager");
-// } catch (Throwable ee) {
-// Assert.assertNotEquals(null, ee);
-// validAssert = false;
-// }
-// Assert.assertFalse(validAssert);
-// }
-//
-// @Test
-// public void testReferenceConfig() throws InterruptedException {
-// Map<String, String> oMap = new ConcurrentHashMap<>();
-// oMap.put("test1", "value1");
-// RegisterManager<String, String> oManager = new RegisterManager<>("test");
-// oManager.register("test1", "value1");
-//
-// SyncResponseExecutor oExecutor = new SyncResponseExecutor();
-// oExecutor.execute(new Runnable() {
-//
-// @Override
-// public void run() {
-// oExecutor.setResponse(Response.succResp("success"));
-// }
-// });
-// Assert.assertEquals(true, oExecutor.waitResponse().isSuccessed());
-// }
-//
-// @Test
-// public void testInvocation() {
-// OperationMeta oOperationMeta = Mockito.mock(OperationMeta.class);
-// SchemaMeta oSchemaMeta = Mockito.mock(SchemaMeta.class);
-// AsyncResponse asyncResp = Mockito.mock(AsyncResponse.class);
-// List<Handler> oHandlerList = new ArrayList<>();
-//
-// Mockito.when(oSchemaMeta.getProviderHandlerChain()).thenReturn(oHandlerList);
-// Mockito.when(oSchemaMeta.getMicroserviceName()).thenReturn("TMK");
-// Mockito.when(oOperationMeta.getSchemaMeta()).thenReturn(oSchemaMeta);
-// Endpoint oEndpoint = Mockito.mock(Endpoint.class);
-// Transport oTransport = Mockito.mock(Transport.class);
-// Mockito.when(oEndpoint.getTransport()).thenReturn(oTransport);
-// Mockito.when(oOperationMeta.getOperationId()).thenReturn("TMK");
-//
-// Invocation oInvocation = new Invocation(oEndpoint, oOperationMeta, null);
-// Assert.assertNotNull(oInvocation.getTransport());
-// Assert.assertNotNull(oInvocation.getInvocationType());
-// oInvocation.setResponseExecutor(Mockito.mock(Executor.class));
-// Assert.assertNotNull(oInvocation.getResponseExecutor());
-// Assert.assertNotNull(oInvocation.getSchemaMeta());
-// Assert.assertNotNull(oInvocation.getOperationMeta());
-// Assert.assertNull(oInvocation.getArgs());
-// Assert.assertNotNull(oInvocation.getEndpoint());
-// oInvocation.setEndpoint(null);
-// Map<String, String> map = oInvocation.getContext();
-// Assert.assertNotNull(map);
-// String str = oInvocation.getSchemaId();
-// Assert.assertEquals(null, str);
-// String str1 = oInvocation.getMicroserviceName();
-// Assert.assertEquals("TMK", str1);
-// Map<String, Object> mapp = oInvocation.getHandlerContext();
-// Assert.assertNotNull(mapp);
-// Assert.assertEquals(true, oInvocation.getHandlerIndex() >= 0);
-// oInvocation.setHandlerIndex(8);
-// Assert.assertEquals("TMK", oInvocation.getOperationName());
-// Assert.assertEquals("TMK", oInvocation.getMicroserviceName());
-//
-// boolean validAssert;
-//
-// try {
-//
-// validAssert = true;
-//
-// oInvocation.next(asyncResp);
-// } catch (Exception e) {
-// validAssert = false;
-// }
-// Assert.assertFalse(validAssert);
-// }
-}
diff --git a/core/src/test/java/org/apache/servicecomb/core/TestCseApplicationListener.java b/core/src/test/java/org/apache/servicecomb/core/TestCseApplicationListener.java
index aac398c..4059406 100644
--- a/core/src/test/java/org/apache/servicecomb/core/TestCseApplicationListener.java
+++ b/core/src/test/java/org/apache/servicecomb/core/TestCseApplicationListener.java
@@ -21,9 +21,9 @@
import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
import org.apache.servicecomb.registry.DiscoveryManager;
import org.junit.AfterClass;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
import org.springframework.context.event.ContextClosedEvent;
import mockit.Mocked;
@@ -48,7 +48,7 @@
CseApplicationListener listener = new CseApplicationListener();
listener.onApplicationEvent(contextClosedEvent);
- Assert.assertEquals(SCBStatus.DOWN, scbEngine.getStatus());
+ Assertions.assertEquals(SCBStatus.DOWN, scbEngine.getStatus());
scbEngine.destroy();
}
diff --git a/core/src/test/java/org/apache/servicecomb/core/TestDefinition.java b/core/src/test/java/org/apache/servicecomb/core/TestDefinition.java
deleted file mode 100644
index 3364e02..0000000
--- a/core/src/test/java/org/apache/servicecomb/core/TestDefinition.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); 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
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.core;
-
-public class TestDefinition {
-// @Test
-// public void testMicroServiceMeta() {
-// MicroserviceMeta oMicroMeta = new MicroserviceMeta("app:micro1");
-// Assert.assertEquals(0, oMicroMeta.getSchemaMetas().size());
-// Assert.assertEquals(0, oMicroMeta.getOperations().size());
-// Assert.assertEquals("micro1", oMicroMeta.getShortName());
-// Assert.assertEquals("app:micro1", oMicroMeta.getName());
-// try {
-// oMicroMeta.putExtData("key1", new String("value1"));
-// Assert.assertNotEquals(null, oMicroMeta.getExtData("key1"));
-// } catch (Exception e) {
-// Assert.assertNotNull(e);
-// }
-// }
-}
diff --git a/core/src/test/java/org/apache/servicecomb/core/TestEndpoint.java b/core/src/test/java/org/apache/servicecomb/core/TestEndpoint.java
index 9be7e1b..87cdc8f 100644
--- a/core/src/test/java/org/apache/servicecomb/core/TestEndpoint.java
+++ b/core/src/test/java/org/apache/servicecomb/core/TestEndpoint.java
@@ -18,11 +18,11 @@
package org.apache.servicecomb.core;
import org.apache.servicecomb.registry.api.registry.MicroserviceInstance;
-import org.junit.Assert;
import org.junit.Test;
import mockit.Expectations;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestEndpoint {
@Test
@@ -34,18 +34,18 @@
}
};
Endpoint endpoint = new Endpoint(transport, "rest://123.6.6.6:8080");
- Assert.assertEquals(endpoint.getAddress(), "rest://123.6.6.6:8080");
- Assert.assertEquals(endpoint.getEndpoint(), "rest://123.6.6.6:8080");
- Assert.assertEquals(endpoint.getTransport(), transport);
- Assert.assertEquals(endpoint.toString(), "rest://123.6.6.6:8080");
+ Assertions.assertEquals(endpoint.getAddress(), "rest://123.6.6.6:8080");
+ Assertions.assertEquals(endpoint.getEndpoint(), "rest://123.6.6.6:8080");
+ Assertions.assertEquals(endpoint.getTransport(), transport);
+ Assertions.assertEquals(endpoint.toString(), "rest://123.6.6.6:8080");
}
@Test
public void testEndpointAddressConstructor(@Mocked Transport transport, @Mocked MicroserviceInstance instance) {
Endpoint endpoint = new Endpoint(transport, "rest://123.6.6.6:8080", instance, "iot://123.6.6.6:8080");
- Assert.assertEquals(endpoint.getAddress(), "iot://123.6.6.6:8080");
- Assert.assertEquals(endpoint.getEndpoint(), "rest://123.6.6.6:8080");
- Assert.assertEquals(endpoint.getTransport(), transport);
- Assert.assertEquals(endpoint.toString(), "rest://123.6.6.6:8080");
+ Assertions.assertEquals(endpoint.getAddress(), "iot://123.6.6.6:8080");
+ Assertions.assertEquals(endpoint.getEndpoint(), "rest://123.6.6.6:8080");
+ Assertions.assertEquals(endpoint.getTransport(), transport);
+ Assertions.assertEquals(endpoint.toString(), "rest://123.6.6.6:8080");
}
}
diff --git a/core/src/test/java/org/apache/servicecomb/core/TestException.java b/core/src/test/java/org/apache/servicecomb/core/TestException.java
index e9646a1..d4739a5 100644
--- a/core/src/test/java/org/apache/servicecomb/core/TestException.java
+++ b/core/src/test/java/org/apache/servicecomb/core/TestException.java
@@ -19,38 +19,38 @@
import org.apache.servicecomb.core.exception.CseException;
import org.apache.servicecomb.core.exception.ExceptionUtils;
-import org.junit.Assert;
import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
public class TestException {
@Test
public void testCseException() {
CseException oExeception = new CseException("500", "InternalServerError");
- Assert.assertEquals("500", oExeception.getCode());
- Assert.assertEquals("ServiceDefinitionException Code:500, Message:InternalServerError",
+ Assertions.assertEquals("500", oExeception.getCode());
+ Assertions.assertEquals("ServiceDefinitionException Code:500, Message:InternalServerError",
oExeception.toString());
oExeception = new CseException("503", "OwnException", new Throwable());
- Assert.assertEquals("503", oExeception.getCode());
+ Assertions.assertEquals("503", oExeception.getCode());
}
@Test
public void testExceptionUtils() {
CseException oExeception = ExceptionUtils
.createCseException("servicecomb.handler.ref.not.exist", new String("test"));
- Assert.assertEquals("servicecomb.handler.ref.not.exist", oExeception.getCode());
+ Assertions.assertEquals("servicecomb.handler.ref.not.exist", oExeception.getCode());
oExeception =
ExceptionUtils.createCseException("servicecomb.handler.ref.not.exist", new Throwable(), new String("test"));
- Assert.assertEquals("servicecomb.handler.ref.not.exist", oExeception.getCode());
+ Assertions.assertEquals("servicecomb.handler.ref.not.exist", oExeception.getCode());
oExeception = ExceptionUtils.producerOperationNotExist("servicecomb.error", "unit-testing");
- Assert.assertEquals("servicecomb.producer.operation.not.exist", oExeception.getCode());
+ Assertions.assertEquals("servicecomb.producer.operation.not.exist", oExeception.getCode());
oExeception = ExceptionUtils.handlerRefNotExist("servicecomb.double.error");
- Assert.assertEquals("servicecomb.handler.ref.not.exist", oExeception.getCode());
+ Assertions.assertEquals("servicecomb.handler.ref.not.exist", oExeception.getCode());
oExeception = ExceptionUtils.lbAddressNotFound("microServiceName", "my rule my world", "transportChannel");
- Assert.assertEquals("servicecomb.lb.no.available.address", oExeception.getCode());
+ Assertions.assertEquals("servicecomb.lb.no.available.address", oExeception.getCode());
}
}
diff --git a/core/src/test/java/org/apache/servicecomb/core/TestHandler.java b/core/src/test/java/org/apache/servicecomb/core/TestHandler.java
deleted file mode 100644
index c9b67f4..0000000
--- a/core/src/test/java/org/apache/servicecomb/core/TestHandler.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); 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
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.core;
-
-public class TestHandler {
-//
-// @Test
-// public void testAbstractHandlerManager() throws Exception {
-// HandlerConfigUtils.init();
-// Assert.assertNotEquals(null, ConsumerHandlerManager.INSTANCE.getOrCreate("test"));
-// }
-}
diff --git a/core/src/test/java/org/apache/servicecomb/core/TestInvocation.java b/core/src/test/java/org/apache/servicecomb/core/TestInvocation.java
index 34b0330..6b22d5d 100644
--- a/core/src/test/java/org/apache/servicecomb/core/TestInvocation.java
+++ b/core/src/test/java/org/apache/servicecomb/core/TestInvocation.java
@@ -37,7 +37,6 @@
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.AfterClass;
-import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -48,6 +47,7 @@
import mockit.Mock;
import mockit.MockUp;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestInvocation {
Invocation invocation;
@@ -101,8 +101,8 @@
Invocation invocation = new Invocation(endpoint, operationMeta, arguments);
invocation.onStart(nanoTime);
- Assert.assertSame(invocation, result.value);
- Assert.assertEquals(nanoTime, invocation.getInvocationStageTrace().getStart());
+ Assertions.assertSame(invocation, result.value);
+ Assertions.assertEquals(nanoTime, invocation.getInvocationStageTrace().getStart());
EventManager.unregister(subscriber);
}
@@ -114,7 +114,7 @@
Invocation invocation = new Invocation(endpoint, operationMeta, arguments);
invocation.onExecuteStart();
- Assert.assertEquals(nanoTime, invocation.getInvocationStageTrace().getStartExecution());
+ Assertions.assertEquals(nanoTime, invocation.getInvocationStageTrace().getStartExecution());
}
@Test
@@ -131,19 +131,19 @@
EventManager.register(subscriber);
Invocation invocation = new Invocation(endpoint, operationMeta, arguments);
- Assert.assertFalse(invocation.isFinished());
+ Assertions.assertFalse(invocation.isFinished());
Response response = Response.succResp(null);
invocation.onFinish(response);
- Assert.assertEquals(nanoTime, result.value.getNanoCurrent());
- Assert.assertSame(invocation, result.value.getInvocation());
- Assert.assertSame(response, result.value.getResponse());
- Assert.assertTrue(invocation.isFinished());
+ Assertions.assertEquals(nanoTime, result.value.getNanoCurrent());
+ Assertions.assertSame(invocation, result.value.getInvocation());
+ Assertions.assertSame(response, result.value.getResponse());
+ Assertions.assertTrue(invocation.isFinished());
// should not post event again
InvocationFinishEvent oldEvent = result.value;
invocation.onFinish(null);
- Assert.assertSame(oldEvent, result.value);
+ Assertions.assertSame(oldEvent, result.value);
EventManager.unregister(subscriber);
}
@@ -151,13 +151,13 @@
@Test
public void isConsumer_yes() {
Invocation invocation = new Invocation(endpoint, operationMeta, arguments);
- Assert.assertFalse(invocation.isConsumer());
+ Assertions.assertFalse(invocation.isConsumer());
}
@Test
public void isConsumer_no(@Mocked ReferenceConfig referenceConfig) {
Invocation invocation = new Invocation(referenceConfig, operationMeta, invocationRuntimeType, arguments);
- Assert.assertTrue(invocation.isConsumer());
+ Assertions.assertTrue(invocation.isConsumer());
}
@Test
@@ -165,8 +165,8 @@
Invocation invocation = new Invocation(referenceConfig, operationMeta, invocationRuntimeType, arguments);
invocation.addLocalContext("k", 1);
- Assert.assertSame(invocation.getHandlerContext(), invocation.getLocalContext());
- Assert.assertEquals(1, (int) invocation.getLocalContext("k"));
+ Assertions.assertSame(invocation.getHandlerContext(), invocation.getLocalContext());
+ Assertions.assertEquals(1, (int) invocation.getLocalContext("k"));
}
@Test
@@ -176,8 +176,8 @@
invocation.onStart(0);
- Assert.assertEquals("abc", invocation.getTraceId());
- Assert.assertEquals("abc", invocation.getTraceId(Const.TRACE_ID_NAME));
+ Assertions.assertEquals("abc", invocation.getTraceId());
+ Assertions.assertEquals("abc", invocation.getTraceId(Const.TRACE_ID_NAME));
}
@Test
@@ -193,8 +193,8 @@
invocation.onStart(0);
- Assert.assertEquals("abc", invocation.getTraceId());
- Assert.assertEquals("abc", invocation.getTraceId(Const.TRACE_ID_NAME));
+ Assertions.assertEquals("abc", invocation.getTraceId());
+ Assertions.assertEquals("abc", invocation.getTraceId(Const.TRACE_ID_NAME));
}
@Test
@@ -209,8 +209,8 @@
invocation.onStart(requestEx, 0);
- Assert.assertEquals("abc", invocation.getTraceId());
- Assert.assertEquals("abc", invocation.getTraceId(Const.TRACE_ID_NAME));
+ Assertions.assertEquals("abc", invocation.getTraceId());
+ Assertions.assertEquals("abc", invocation.getTraceId(Const.TRACE_ID_NAME));
}
@Test
@@ -226,8 +226,8 @@
invocation.onStart(requestEx, 0);
- Assert.assertEquals("abc", invocation.getTraceId());
- Assert.assertEquals("abc", invocation.getTraceId(Const.TRACE_ID_NAME));
+ Assertions.assertEquals("abc", invocation.getTraceId());
+ Assertions.assertEquals("abc", invocation.getTraceId(Const.TRACE_ID_NAME));
}
@Test
@@ -271,8 +271,8 @@
invocation.onBusinessMethodStart();
EventManager.getEventBus().unregister(listener);
- Assert.assertSame(invocation, invocationBaseEvent.getInvocation());
- Assert.assertEquals(nanoTime, invocation.getInvocationStageTrace().getStartBusinessMethod());
+ Assertions.assertSame(invocation, invocationBaseEvent.getInvocation());
+ Assertions.assertEquals(nanoTime, invocation.getInvocationStageTrace().getStartBusinessMethod());
}
@Test
@@ -288,7 +288,7 @@
invocation.onBusinessMethodFinish();
EventManager.getEventBus().unregister(listener);
- Assert.assertSame(invocation, invocationBaseEvent.getInvocation());
+ Assertions.assertSame(invocation, invocationBaseEvent.getInvocation());
}
@Test
@@ -297,7 +297,7 @@
mockNonaTime();
invocation.onBusinessFinish();
- Assert.assertEquals(nanoTime, invocation.getInvocationStageTrace().getFinishBusiness());
+ Assertions.assertEquals(nanoTime, invocation.getInvocationStageTrace().getFinishBusiness());
}
@Test
@@ -307,18 +307,18 @@
Invocation invocation = new Invocation(referenceConfig, operationMeta, invocationRuntimeType, arguments);
invocation.addContext(Const.TRACE_ID_NAME, "abc");
invocation.onStart(0);
- Assert.assertEquals("abc-0", invocation.getTraceIdLogger().getName());
+ Assertions.assertEquals("abc-0", invocation.getTraceIdLogger().getName());
invocation = new Invocation(referenceConfig, operationMeta, invocationRuntimeType, arguments);
invocation.addContext(Const.TRACE_ID_NAME, "abc");
invocation.onStart(0);
- Assert.assertEquals("abc-1", invocation.getTraceIdLogger().getName());
+ Assertions.assertEquals("abc-1", invocation.getTraceIdLogger().getName());
}
@Test
public void isThirdPartyInvocation(@Mocked ReferenceConfig referenceConfig) {
Invocation invocation = new Invocation(referenceConfig, operationMeta, invocationRuntimeType, arguments);
- Assert.assertFalse(invocation.isThirdPartyInvocation());
+ Assertions.assertFalse(invocation.isThirdPartyInvocation());
new Expectations() {
{
@@ -326,6 +326,6 @@
result = true;
}
};
- Assert.assertTrue(invocation.isThirdPartyInvocation());
+ Assertions.assertTrue(invocation.isThirdPartyInvocation());
}
}
diff --git a/core/src/test/java/org/apache/servicecomb/core/TestInvocationFactory.java b/core/src/test/java/org/apache/servicecomb/core/TestInvocationFactory.java
deleted file mode 100644
index 0f4cf76..0000000
--- a/core/src/test/java/org/apache/servicecomb/core/TestInvocationFactory.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); 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
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.core;
-
-public class TestInvocationFactory {
-// @BeforeClass
-// public static void setUp() {
-// ServiceRegistry serviceRegistry = ServiceRegistryFactory.createLocal();
-// serviceRegistry.init();
-// RegistryUtils.setServiceRegistry(serviceRegistry);
-// SCBEngine.getInstance().setStatus(SCBStatus.UP);
-// }
-//
-// @Test
-// public void testInvocationFactoryforConsumer(@Injectable ReferenceConfig referenceConfig,
-// @Injectable OperationMeta operationMeta) {
-// Invocation invocation =
-// InvocationFactory.forConsumer(referenceConfig, operationMeta, new String[] {"a", "b"});
-// Assert.assertEquals("perfClient", invocation.getContext(Const.SRC_MICROSERVICE));
-// }
-//
-// @Test
-// public void testInvocationFactoryforConsumer(@Injectable ReferenceConfig referenceConfig,
-// @Injectable SchemaMeta schemaMeta) {
-// Invocation invocation =
-// InvocationFactory.forConsumer(referenceConfig, schemaMeta, "test", new String[] {"a", "b"});
-// Assert.assertEquals("perfClient", invocation.getContext(Const.SRC_MICROSERVICE));
-// }
-//
-// @Test
-// public void testInvocationFactoryforConsumer(@Injectable ReferenceConfig referenceConfig) {
-// Invocation invocation =
-// InvocationFactory.forConsumer(referenceConfig, "test", new String[] {"a", "b"});
-// Assert.assertEquals("perfClient", invocation.getContext(Const.SRC_MICROSERVICE));
-// }
-//
-// @Test
-// public void testInvocationFactoryforProvider(@Injectable Endpoint endpoint,
-// @Injectable OperationMeta operationMeta) {
-// Invocation invocation =
-// InvocationFactory.forProvider(endpoint, operationMeta, new String[] {"a", "b"});
-// Assert.assertEquals(invocation.getEndpoint(), endpoint);
-// }
-}
diff --git a/core/src/test/java/org/apache/servicecomb/core/TestTransport.java b/core/src/test/java/org/apache/servicecomb/core/TestTransport.java
index 065e411..e4e3203 100644
--- a/core/src/test/java/org/apache/servicecomb/core/TestTransport.java
+++ b/core/src/test/java/org/apache/servicecomb/core/TestTransport.java
@@ -17,12 +17,11 @@
package org.apache.servicecomb.core;
-import org.apache.servicecomb.core.bootstrap.SCBBootstrap;
import org.apache.servicecomb.swagger.invocation.AsyncResponse;
import org.junit.AfterClass;
-import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
public class TestTransport {
@BeforeClass
@@ -68,9 +67,9 @@
}
}, "rest://127.0.0.1:8080");
oEndpoint.getTransport().init();
- Assert.assertEquals("rest://127.0.0.1:8080", oEndpoint.getEndpoint());
- Assert.assertEquals("127.0.0.1", oEndpoint.getAddress());
- Assert.assertEquals("test", oEndpoint.getTransport().getName());
- Assert.assertEquals("rest://127.0.0.1:8080", oEndpoint.getEndpoint());
+ Assertions.assertEquals("rest://127.0.0.1:8080", oEndpoint.getEndpoint());
+ Assertions.assertEquals("127.0.0.1", oEndpoint.getAddress());
+ Assertions.assertEquals("test", oEndpoint.getTransport().getName());
+ Assertions.assertEquals("rest://127.0.0.1:8080", oEndpoint.getEndpoint());
}
}
diff --git a/core/src/test/java/org/apache/servicecomb/core/Utils.java b/core/src/test/java/org/apache/servicecomb/core/Utils.java
deleted file mode 100644
index f9b7e74..0000000
--- a/core/src/test/java/org/apache/servicecomb/core/Utils.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); 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
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.core;
-
-import java.lang.reflect.Method;
-
-import org.springframework.util.ReflectionUtils;
-
-import com.netflix.config.DynamicProperty;
-
-public class Utils {
- private static final Method updatePropertyMethod =
- ReflectionUtils.findMethod(DynamicProperty.class, "updateProperty", String.class, Object.class);
-
- static {
- updatePropertyMethod.setAccessible(true);
- }
-
- public static void updateProperty(String key, Object value) {
- ReflectionUtils.invokeMethod(updatePropertyMethod, null, key, value);
- }
-}
diff --git a/core/src/test/java/org/apache/servicecomb/core/consumer/TestReactiveResponseExecutor.java b/core/src/test/java/org/apache/servicecomb/core/consumer/TestReactiveResponseExecutor.java
index 4826982..cec56c0 100644
--- a/core/src/test/java/org/apache/servicecomb/core/consumer/TestReactiveResponseExecutor.java
+++ b/core/src/test/java/org/apache/servicecomb/core/consumer/TestReactiveResponseExecutor.java
@@ -18,8 +18,8 @@
package org.apache.servicecomb.core.consumer;
import org.apache.servicecomb.core.provider.consumer.ReactiveResponseExecutor;
-import org.junit.Assert;
import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
import org.mockito.Mockito;
public class TestReactiveResponseExecutor {
@@ -33,6 +33,6 @@
} catch (Exception e) {
validAssert = false;
}
- Assert.assertTrue(validAssert);
+ Assertions.assertTrue(validAssert);
}
}
diff --git a/core/src/test/java/org/apache/servicecomb/core/consumer/TestSyncResponseExecutor.java b/core/src/test/java/org/apache/servicecomb/core/consumer/TestSyncResponseExecutor.java
index 438e959..2ce9844 100644
--- a/core/src/test/java/org/apache/servicecomb/core/consumer/TestSyncResponseExecutor.java
+++ b/core/src/test/java/org/apache/servicecomb/core/consumer/TestSyncResponseExecutor.java
@@ -20,8 +20,8 @@
import org.apache.servicecomb.core.Invocation;
import org.apache.servicecomb.core.provider.consumer.SyncResponseExecutor;
import org.apache.servicecomb.swagger.invocation.Response;
-import org.junit.Assert;
import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
import org.mockito.Mockito;
public class TestSyncResponseExecutor {
@@ -36,9 +36,9 @@
try {
Response responseValue = executor.waitResponse(invocation);
- Assert.assertNotNull(responseValue);
+ Assertions.assertNotNull(responseValue);
} catch (Exception e) {
- Assert.assertNotNull(e);
+ Assertions.assertNotNull(e);
}
}
}
diff --git a/core/src/test/java/org/apache/servicecomb/core/definition/TestMicroserviceMetaManager.java b/core/src/test/java/org/apache/servicecomb/core/definition/TestMicroserviceMetaManager.java
index 55ea9b7..68c0c94 100644
--- a/core/src/test/java/org/apache/servicecomb/core/definition/TestMicroserviceMetaManager.java
+++ b/core/src/test/java/org/apache/servicecomb/core/definition/TestMicroserviceMetaManager.java
@@ -17,8 +17,8 @@
package org.apache.servicecomb.core.definition;
-import org.junit.Assert;
import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
import org.mockito.Mockito;
public class TestMicroserviceMetaManager {
@@ -28,6 +28,6 @@
SchemaMeta meta = Mockito.mock(SchemaMeta.class);
MicroserviceMeta microserviceMeta = Mockito.mock(MicroserviceMeta.class);
Mockito.when(microserviceMeta.ensureFindSchemaMeta("yhfghj")).thenReturn(meta);
- Assert.assertEquals(meta, microserviceMeta.ensureFindSchemaMeta("yhfghj"));
+ Assertions.assertEquals(meta, microserviceMeta.ensureFindSchemaMeta("yhfghj"));
}
}
diff --git a/core/src/test/java/org/apache/servicecomb/core/event/TestInvocationFinishEvent.java b/core/src/test/java/org/apache/servicecomb/core/event/TestInvocationFinishEvent.java
index daae2d6..6338036 100644
--- a/core/src/test/java/org/apache/servicecomb/core/event/TestInvocationFinishEvent.java
+++ b/core/src/test/java/org/apache/servicecomb/core/event/TestInvocationFinishEvent.java
@@ -19,13 +19,13 @@
import org.apache.servicecomb.core.Invocation;
import org.apache.servicecomb.core.invocation.InvocationStageTrace;
import org.apache.servicecomb.swagger.invocation.Response;
-import org.junit.Assert;
import org.junit.Test;
import mockit.Expectations;
import mockit.Mock;
import mockit.MockUp;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestInvocationFinishEvent {
InvocationFinishEvent event;
@@ -50,8 +50,8 @@
event = new InvocationFinishEvent(invocation, response);
- Assert.assertEquals(time, event.getNanoCurrent());
- Assert.assertSame(invocation, event.getInvocation());
- Assert.assertSame(response, event.getResponse());
+ Assertions.assertEquals(time, event.getNanoCurrent());
+ Assertions.assertSame(invocation, event.getInvocation());
+ Assertions.assertSame(response, event.getResponse());
}
}
diff --git a/core/src/test/java/org/apache/servicecomb/core/event/TestInvocationStartEvent.java b/core/src/test/java/org/apache/servicecomb/core/event/TestInvocationStartEvent.java
index 9181520..48e8521 100644
--- a/core/src/test/java/org/apache/servicecomb/core/event/TestInvocationStartEvent.java
+++ b/core/src/test/java/org/apache/servicecomb/core/event/TestInvocationStartEvent.java
@@ -17,10 +17,10 @@
package org.apache.servicecomb.core.event;
import org.apache.servicecomb.core.Invocation;
-import org.junit.Assert;
import org.junit.Test;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestInvocationStartEvent {
InvocationStartEvent event;
@@ -29,6 +29,6 @@
public void construct(@Mocked Invocation invocation) {
event = new InvocationStartEvent(invocation);
- Assert.assertSame(invocation, event.getInvocation());
+ Assertions.assertSame(invocation, event.getInvocation());
}
}
diff --git a/core/src/test/java/org/apache/servicecomb/core/executor/TestExecutorManager.java b/core/src/test/java/org/apache/servicecomb/core/executor/TestExecutorManager.java
index 3165d45..cb1db76 100644
--- a/core/src/test/java/org/apache/servicecomb/core/executor/TestExecutorManager.java
+++ b/core/src/test/java/org/apache/servicecomb/core/executor/TestExecutorManager.java
@@ -23,12 +23,12 @@
import org.apache.servicecomb.foundation.common.utils.BeanUtils;
import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import mockit.Expectations;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestExecutorManager {
@Mocked
@@ -53,7 +53,7 @@
}
};
- Assert.assertSame(executor, new ExecutorManager().findExecutor(operationMeta));
+ Assertions.assertSame(executor, new ExecutorManager().findExecutor(operationMeta));
}
@Test
@@ -72,7 +72,7 @@
}
};
- Assert.assertSame(executor, new ExecutorManager().findExecutor(operationMeta, null));
+ Assertions.assertSame(executor, new ExecutorManager().findExecutor(operationMeta, null));
}
@Test
@@ -91,13 +91,13 @@
}
};
- Assert.assertSame(executor, new ExecutorManager().findExecutor(operationMeta, defExecutor));
+ Assertions.assertSame(executor, new ExecutorManager().findExecutor(operationMeta, defExecutor));
}
@Test
public void findExecutor_twoParam_schemaCfg_withOpDef(@Mocked OperationMeta operationMeta,
@Mocked Executor defExecutor) {
- Assert.assertSame(defExecutor, new ExecutorManager().findExecutor(operationMeta, defExecutor));
+ Assertions.assertSame(defExecutor, new ExecutorManager().findExecutor(operationMeta, defExecutor));
}
@Test
@@ -117,7 +117,7 @@
result = executor;
}
};
- Assert.assertSame(executor, new ExecutorManager().findExecutor(operationMeta, null));
+ Assertions.assertSame(executor, new ExecutorManager().findExecutor(operationMeta, null));
}
@Test
@@ -133,6 +133,6 @@
}
};
- Assert.assertSame(executor, new ExecutorManager().findExecutor(operationMeta, null));
+ Assertions.assertSame(executor, new ExecutorManager().findExecutor(operationMeta, null));
}
}
diff --git a/core/src/test/java/org/apache/servicecomb/core/executor/TestGroupExecutor.java b/core/src/test/java/org/apache/servicecomb/core/executor/TestGroupExecutor.java
index f65693d..597ba7b 100644
--- a/core/src/test/java/org/apache/servicecomb/core/executor/TestGroupExecutor.java
+++ b/core/src/test/java/org/apache/servicecomb/core/executor/TestGroupExecutor.java
@@ -24,11 +24,11 @@
import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
import org.apache.servicecomb.foundation.test.scaffolding.log.LogCollector;
import org.junit.AfterClass;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import mockit.Deencapsulation;
+import org.junit.jupiter.api.Assertions;
public class TestGroupExecutor {
String strThreadTest = "default";
@@ -48,60 +48,60 @@
@Test
public void groupCount() {
groupExecutor.initConfig();
- Assert.assertEquals(2, groupExecutor.groupCount);
+ Assertions.assertEquals(2, groupExecutor.groupCount);
ArchaiusUtils.setProperty(GroupExecutor.KEY_GROUP, 4);
groupExecutor.initConfig();
- Assert.assertEquals(4, groupExecutor.groupCount);
+ Assertions.assertEquals(4, groupExecutor.groupCount);
}
@Test
public void coreThreads() {
groupExecutor.initConfig();
- Assert.assertEquals(25, groupExecutor.coreThreads);
+ Assertions.assertEquals(25, groupExecutor.coreThreads);
ArchaiusUtils.setProperty(GroupExecutor.KEY_CORE_THREADS, 100);
groupExecutor.initConfig();
- Assert.assertEquals(100, groupExecutor.coreThreads);
+ Assertions.assertEquals(100, groupExecutor.coreThreads);
}
@Test
public void maxIdleInSecond() {
groupExecutor.initConfig();
- Assert.assertEquals(60, groupExecutor.maxIdleInSecond);
+ Assertions.assertEquals(60, groupExecutor.maxIdleInSecond);
ArchaiusUtils.setProperty(GroupExecutor.KEY_MAX_IDLE_SECOND, 100);
groupExecutor.initConfig();
- Assert.assertEquals(100, groupExecutor.maxIdleInSecond);
+ Assertions.assertEquals(100, groupExecutor.maxIdleInSecond);
}
@Test
public void maxQueueSize() {
groupExecutor.initConfig();
- Assert.assertEquals(Integer.MAX_VALUE, groupExecutor.maxQueueSize);
+ Assertions.assertEquals(Integer.MAX_VALUE, groupExecutor.maxQueueSize);
ArchaiusUtils.setProperty(GroupExecutor.KEY_MAX_QUEUE_SIZE, 100);
groupExecutor.initConfig();
- Assert.assertEquals(100, groupExecutor.maxQueueSize);
+ Assertions.assertEquals(100, groupExecutor.maxQueueSize);
}
@Test
public void maxThreads() {
groupExecutor.initConfig();
- Assert.assertEquals(100, groupExecutor.maxThreads);
+ Assertions.assertEquals(100, groupExecutor.maxThreads);
LogCollector collector = new LogCollector();
ArchaiusUtils.setProperty(GroupExecutor.KEY_OLD_MAX_THREAD, 200);
groupExecutor.initConfig();
- Assert.assertEquals(200, groupExecutor.maxThreads);
- Assert.assertEquals(
+ Assertions.assertEquals(200, groupExecutor.maxThreads);
+ Assertions.assertEquals(
"servicecomb.executor.default.thread-per-group is deprecated, recommended to use servicecomb.executor.default.maxThreads-per-group.",
collector.getEvents().get(collector.getEvents().size() - 2).getMessage());
collector.teardown();
ArchaiusUtils.setProperty(GroupExecutor.KEY_MAX_THREADS, 300);
groupExecutor.initConfig();
- Assert.assertEquals(300, groupExecutor.maxThreads);
+ Assertions.assertEquals(300, groupExecutor.maxThreads);
}
@Test
@@ -110,8 +110,8 @@
LogCollector collector = new LogCollector();
groupExecutor.initConfig();
- Assert.assertEquals(10, groupExecutor.maxThreads);
- Assert.assertEquals(
+ Assertions.assertEquals(10, groupExecutor.maxThreads);
+ Assertions.assertEquals(
"coreThreads is bigger than maxThreads, change from 25 to 10.",
collector.getEvents().get(collector.getEvents().size() - 2).getMessage());
collector.teardown();
@@ -123,14 +123,14 @@
groupExecutor.execute(() -> {
});
Map<Long, Executor> threadExecutorMap = Deencapsulation.getField(groupExecutor, "threadExecutorMap");
- Assert.assertEquals(true, (threadExecutorMap.size() > 0));
+ Assertions.assertEquals(true, (threadExecutorMap.size() > 0));
List<Executor> executorList = Deencapsulation.getField(groupExecutor, "executorList");
- Assert.assertEquals(true, (executorList.size() > 1));
+ Assertions.assertEquals(true, (executorList.size() > 1));
ReactiveExecutor oReactiveExecutor = new ReactiveExecutor();
oReactiveExecutor.execute(() -> strThreadTest = "thread Ran");
oReactiveExecutor.close();
- Assert.assertEquals("thread Ran", strThreadTest);
+ Assertions.assertEquals("thread Ran", strThreadTest);
}
}
diff --git a/core/src/test/java/org/apache/servicecomb/core/executor/TestThreadPoolExecutorEx.java b/core/src/test/java/org/apache/servicecomb/core/executor/TestThreadPoolExecutorEx.java
index eaf4133..ddcf48d 100644
--- a/core/src/test/java/org/apache/servicecomb/core/executor/TestThreadPoolExecutorEx.java
+++ b/core/src/test/java/org/apache/servicecomb/core/executor/TestThreadPoolExecutorEx.java
@@ -24,8 +24,8 @@
import java.util.concurrent.TimeUnit;
import java.util.function.IntSupplier;
-import org.junit.Assert;
import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -64,49 +64,49 @@
@Test
public void schedule() throws ExecutionException, InterruptedException {
// init
- Assert.assertEquals(0, executorEx.getPoolSize());
- Assert.assertEquals(0, executorEx.getRejectedCount());
- Assert.assertEquals(0, executorEx.getNotFinished());
- Assert.assertEquals(0, executorEx.getQueue().size());
+ Assertions.assertEquals(0, executorEx.getPoolSize());
+ Assertions.assertEquals(0, executorEx.getRejectedCount());
+ Assertions.assertEquals(0, executorEx.getNotFinished());
+ Assertions.assertEquals(0, executorEx.getQueue().size());
// use core threads
TestTask t1 = submitTask();
- Assert.assertEquals(1, executorEx.getPoolSize());
- Assert.assertEquals(0, executorEx.getRejectedCount());
- Assert.assertEquals(1, executorEx.getNotFinished());
- Assert.assertEquals(0, executorEx.getQueue().size());
+ Assertions.assertEquals(1, executorEx.getPoolSize());
+ Assertions.assertEquals(0, executorEx.getRejectedCount());
+ Assertions.assertEquals(1, executorEx.getNotFinished());
+ Assertions.assertEquals(0, executorEx.getQueue().size());
TestTask t2 = submitTask();
- Assert.assertEquals(2, executorEx.getPoolSize());
- Assert.assertEquals(0, executorEx.getRejectedCount());
- Assert.assertEquals(2, executorEx.getNotFinished());
- Assert.assertEquals(0, executorEx.getQueue().size());
+ Assertions.assertEquals(2, executorEx.getPoolSize());
+ Assertions.assertEquals(0, executorEx.getRejectedCount());
+ Assertions.assertEquals(2, executorEx.getNotFinished());
+ Assertions.assertEquals(0, executorEx.getQueue().size());
// extend threads
TestTask t3 = submitTask();
- Assert.assertEquals(3, executorEx.getPoolSize());
- Assert.assertEquals(0, executorEx.getRejectedCount());
- Assert.assertEquals(3, executorEx.getNotFinished());
- Assert.assertEquals(0, executorEx.getQueue().size());
+ Assertions.assertEquals(3, executorEx.getPoolSize());
+ Assertions.assertEquals(0, executorEx.getRejectedCount());
+ Assertions.assertEquals(3, executorEx.getNotFinished());
+ Assertions.assertEquals(0, executorEx.getQueue().size());
TestTask t4 = submitTask();
- Assert.assertEquals(4, executorEx.getPoolSize());
- Assert.assertEquals(0, executorEx.getRejectedCount());
- Assert.assertEquals(4, executorEx.getNotFinished());
- Assert.assertEquals(0, executorEx.getQueue().size());
+ Assertions.assertEquals(4, executorEx.getPoolSize());
+ Assertions.assertEquals(0, executorEx.getRejectedCount());
+ Assertions.assertEquals(4, executorEx.getNotFinished());
+ Assertions.assertEquals(0, executorEx.getQueue().size());
// queue the tasks
TestTask t5 = submitTask();
- Assert.assertEquals(4, executorEx.getPoolSize());
- Assert.assertEquals(0, executorEx.getRejectedCount());
- Assert.assertEquals(5, executorEx.getNotFinished());
- Assert.assertEquals(1, executorEx.getQueue().size());
+ Assertions.assertEquals(4, executorEx.getPoolSize());
+ Assertions.assertEquals(0, executorEx.getRejectedCount());
+ Assertions.assertEquals(5, executorEx.getNotFinished());
+ Assertions.assertEquals(1, executorEx.getQueue().size());
TestTask t6 = submitTask();
- Assert.assertEquals(4, executorEx.getPoolSize());
- Assert.assertEquals(0, executorEx.getRejectedCount());
- Assert.assertEquals(6, executorEx.getNotFinished());
- Assert.assertEquals(2, executorEx.getQueue().size());
+ Assertions.assertEquals(4, executorEx.getPoolSize());
+ Assertions.assertEquals(0, executorEx.getRejectedCount());
+ Assertions.assertEquals(6, executorEx.getNotFinished());
+ Assertions.assertEquals(2, executorEx.getQueue().size());
// reject the task
try {
@@ -114,24 +114,24 @@
} catch (RejectedExecutionException e) {
}
- Assert.assertEquals(4, executorEx.getPoolSize());
- Assert.assertEquals(1, executorEx.getRejectedCount());
- Assert.assertEquals(6, executorEx.getNotFinished());
- Assert.assertEquals(2, executorEx.getQueue().size());
+ Assertions.assertEquals(4, executorEx.getPoolSize());
+ Assertions.assertEquals(1, executorEx.getRejectedCount());
+ Assertions.assertEquals(6, executorEx.getNotFinished());
+ Assertions.assertEquals(2, executorEx.getQueue().size());
// t1/t2/t3 finish
t1.quit();
t2.quit();
t3.quit();
- Assert.assertEquals(4, executorEx.getPoolSize());
- Assert.assertEquals(1, executorEx.getRejectedCount());
+ Assertions.assertEquals(4, executorEx.getPoolSize());
+ Assertions.assertEquals(1, executorEx.getRejectedCount());
waitForResult(3, executorEx::getNotFinished);
waitForResult(0, executorEx.getQueue()::size);
// reuse thread
t3 = submitTask();
- Assert.assertEquals(4, executorEx.getPoolSize());
- Assert.assertEquals(1, executorEx.getRejectedCount());
+ Assertions.assertEquals(4, executorEx.getPoolSize());
+ Assertions.assertEquals(1, executorEx.getRejectedCount());
waitForResult(4, executorEx::getNotFinished);
waitForResult(0, executorEx.getQueue()::size);
diff --git a/core/src/test/java/org/apache/servicecomb/core/handler/impl/TestProducerOperationHandler.java b/core/src/test/java/org/apache/servicecomb/core/handler/impl/TestProducerOperationHandler.java
index 104f57c..cafb890 100644
--- a/core/src/test/java/org/apache/servicecomb/core/handler/impl/TestProducerOperationHandler.java
+++ b/core/src/test/java/org/apache/servicecomb/core/handler/impl/TestProducerOperationHandler.java
@@ -23,10 +23,10 @@
import org.apache.servicecomb.swagger.invocation.Response;
import org.apache.servicecomb.swagger.invocation.SwaggerInvocation;
-import org.junit.Assert;
import org.junit.Test;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
// test cases copied from delete class, this test case tests ExceptionToProducerResponseConverter
public class TestProducerOperationHandler {
@@ -37,8 +37,8 @@
Error error = new Error("abc");
Response response = handler.processException(invocation, error);
- Assert.assertSame(Status.OK, response.getStatus());
- Assert.assertEquals("response from error: abc", response.getResult());
+ Assertions.assertSame(Status.OK, response.getStatus());
+ Assertions.assertEquals("response from error: abc", response.getResult());
}
@Test
@@ -47,7 +47,7 @@
InvocationTargetException targetException = new InvocationTargetException(error);
Response response = handler.processException(invocation, error);
- Assert.assertSame(Status.OK, response.getStatus());
- Assert.assertEquals("response from error: abc", response.getResult());
+ Assertions.assertSame(Status.OK, response.getStatus());
+ Assertions.assertEquals("response from error: abc", response.getResult());
}
}
diff --git a/core/src/test/java/org/apache/servicecomb/core/handler/impl/TestServiceProviderHandler.java b/core/src/test/java/org/apache/servicecomb/core/handler/impl/TestServiceProviderHandler.java
index 26cbf54..74ef4fd 100644
--- a/core/src/test/java/org/apache/servicecomb/core/handler/impl/TestServiceProviderHandler.java
+++ b/core/src/test/java/org/apache/servicecomb/core/handler/impl/TestServiceProviderHandler.java
@@ -21,9 +21,9 @@
import org.apache.servicecomb.core.definition.OperationMeta;
import org.apache.servicecomb.swagger.invocation.AsyncResponse;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
import org.mockito.Mockito;
public class TestServiceProviderHandler {
@@ -56,13 +56,13 @@
public void testHandle() {
boolean status = false;
try {
- Assert.assertNotNull(serviceProviderHandler);
+ Assertions.assertNotNull(serviceProviderHandler);
Mockito.when(invocation.getOperationMeta()).thenReturn(OperationMeta);
serviceProviderHandler.handle(invocation, asyncResp);
} catch (Exception e) {
e.printStackTrace();
status = true;
}
- Assert.assertFalse(status);
+ Assertions.assertFalse(status);
}
}
diff --git a/core/src/test/java/org/apache/servicecomb/core/handler/impl/TestSimpleLoadBalanceHandler.java b/core/src/test/java/org/apache/servicecomb/core/handler/impl/TestSimpleLoadBalanceHandler.java
index bcd2eec..67db40f 100644
--- a/core/src/test/java/org/apache/servicecomb/core/handler/impl/TestSimpleLoadBalanceHandler.java
+++ b/core/src/test/java/org/apache/servicecomb/core/handler/impl/TestSimpleLoadBalanceHandler.java
@@ -35,13 +35,13 @@
import org.apache.servicecomb.swagger.invocation.AsyncResponse;
import org.apache.servicecomb.swagger.invocation.Response;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import mockit.Deencapsulation;
import mockit.Expectations;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestSimpleLoadBalanceHandler {
SimpleLoadBalanceHandler handler;
@@ -96,10 +96,10 @@
handler.handle(invocation, ar);
Throwable result = response.getResult();
- Assert.assertEquals(
+ Assertions.assertEquals(
"InvocationException: code=490;msg=CommonExceptionData [message=Unexpected consumer error, please check logs for details]",
result.getMessage());
- Assert.assertEquals("No available address found. microserviceName=null, version=null, discoveryGroupName=parent/",
+ Assertions.assertEquals("No available address found. microserviceName=null, version=null, discoveryGroupName=parent/",
result.getCause().getMessage());
}
@@ -122,9 +122,9 @@
handler.handle(invocation, ar);
AtomicInteger idx = indexMap.values().iterator().next();
- Assert.assertEquals(1, idx.get());
+ Assertions.assertEquals(1, idx.get());
handler.handle(invocation, ar);
- Assert.assertEquals(2, idx.get());
+ Assertions.assertEquals(2, idx.get());
}
}
diff --git a/core/src/test/java/org/apache/servicecomb/core/invocation/TestInvocationStageTrace.java b/core/src/test/java/org/apache/servicecomb/core/invocation/TestInvocationStageTrace.java
index 91c7dd9..5d81bfe 100644
--- a/core/src/test/java/org/apache/servicecomb/core/invocation/TestInvocationStageTrace.java
+++ b/core/src/test/java/org/apache/servicecomb/core/invocation/TestInvocationStageTrace.java
@@ -24,13 +24,13 @@
import org.apache.servicecomb.core.definition.InvocationRuntimeType;
import org.apache.servicecomb.core.definition.OperationMeta;
import org.apache.servicecomb.core.provider.consumer.ReferenceConfig;
-import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import mockit.Mock;
import mockit.MockUp;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestInvocationStageTrace {
Invocation invocation;
@@ -90,29 +90,29 @@
nanoTime = 11;
stageTrace.finish();
- Assert.assertEquals(1, stageTrace.getStart());
- Assert.assertEquals(2, stageTrace.getStartHandlersRequest());
- Assert.assertEquals(3, stageTrace.getStartClientFiltersRequest());
- Assert.assertEquals(4, stageTrace.getStartSend());
- Assert.assertEquals(5, stageTrace.getFinishGetConnection());
- Assert.assertEquals(6, stageTrace.getFinishWriteToBuffer());
- Assert.assertEquals(7, stageTrace.getFinishReceiveResponse());
- Assert.assertEquals(8, stageTrace.getStartClientFiltersResponse());
- Assert.assertEquals(9, stageTrace.getFinishClientFiltersResponse());
- Assert.assertEquals(10, stageTrace.getFinishHandlersResponse());
- Assert.assertEquals(11, stageTrace.getFinish());
+ Assertions.assertEquals(1, stageTrace.getStart());
+ Assertions.assertEquals(2, stageTrace.getStartHandlersRequest());
+ Assertions.assertEquals(3, stageTrace.getStartClientFiltersRequest());
+ Assertions.assertEquals(4, stageTrace.getStartSend());
+ Assertions.assertEquals(5, stageTrace.getFinishGetConnection());
+ Assertions.assertEquals(6, stageTrace.getFinishWriteToBuffer());
+ Assertions.assertEquals(7, stageTrace.getFinishReceiveResponse());
+ Assertions.assertEquals(8, stageTrace.getStartClientFiltersResponse());
+ Assertions.assertEquals(9, stageTrace.getFinishClientFiltersResponse());
+ Assertions.assertEquals(10, stageTrace.getFinishHandlersResponse());
+ Assertions.assertEquals(11, stageTrace.getFinish());
- Assert.assertEquals(1f, stageTrace.calcInvocationPrepareTime(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcHandlersRequestTime(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcClientFiltersRequestTime(), 0.1f);
- Assert.assertEquals(2f, stageTrace.calcSendRequestTime(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcGetConnectionTime(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcWriteToBufferTime(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcReceiveResponseTime(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcWakeConsumer(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcClientFiltersResponseTime(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcHandlersResponseTime(), 0.1f);
- Assert.assertEquals(10f, stageTrace.calcTotalTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcInvocationPrepareTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcHandlersRequestTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcClientFiltersRequestTime(), 0.1f);
+ Assertions.assertEquals(2f, stageTrace.calcSendRequestTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcGetConnectionTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcWriteToBufferTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcReceiveResponseTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcWakeConsumer(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcClientFiltersResponseTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcHandlersResponseTime(), 0.1f);
+ Assertions.assertEquals(10f, stageTrace.calcTotalTime(), 0.1f);
}
@Test
@@ -140,26 +140,26 @@
nanoTime = 10;
stageTrace.finish();
- Assert.assertEquals(1, stageTrace.getStart());
- Assert.assertEquals(2, stageTrace.getStartSchedule());
- Assert.assertEquals(3, stageTrace.getStartExecution());
- Assert.assertEquals(4, stageTrace.getStartServerFiltersRequest());
- Assert.assertEquals(5, stageTrace.getStartHandlersRequest());
- Assert.assertEquals(6, stageTrace.getStartBusinessMethod());
- Assert.assertEquals(7, stageTrace.getFinishBusiness());
- Assert.assertEquals(8, stageTrace.getFinishHandlersResponse());
- Assert.assertEquals(9, stageTrace.getFinishServerFiltersResponse());
- Assert.assertEquals(10, stageTrace.getFinish());
+ Assertions.assertEquals(1, stageTrace.getStart());
+ Assertions.assertEquals(2, stageTrace.getStartSchedule());
+ Assertions.assertEquals(3, stageTrace.getStartExecution());
+ Assertions.assertEquals(4, stageTrace.getStartServerFiltersRequest());
+ Assertions.assertEquals(5, stageTrace.getStartHandlersRequest());
+ Assertions.assertEquals(6, stageTrace.getStartBusinessMethod());
+ Assertions.assertEquals(7, stageTrace.getFinishBusiness());
+ Assertions.assertEquals(8, stageTrace.getFinishHandlersResponse());
+ Assertions.assertEquals(9, stageTrace.getFinishServerFiltersResponse());
+ Assertions.assertEquals(10, stageTrace.getFinish());
- Assert.assertEquals(1f, stageTrace.calcInvocationPrepareTime(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcThreadPoolQueueTime(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcServerFiltersRequestTime(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcHandlersRequestTime(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcBusinessTime(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcHandlersResponseTime(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcServerFiltersResponseTime(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcSendResponseTime(), 0.1f);
- Assert.assertEquals(9f, stageTrace.calcTotalTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcInvocationPrepareTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcThreadPoolQueueTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcServerFiltersRequestTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcHandlersRequestTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcBusinessTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcHandlersResponseTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcServerFiltersResponseTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcSendResponseTime(), 0.1f);
+ Assertions.assertEquals(9f, stageTrace.calcTotalTime(), 0.1f);
}
@Test
@@ -198,38 +198,38 @@
nanoTime = 15;
stageTrace.finish();
- Assert.assertEquals(1, stageTrace.getStart());
- Assert.assertEquals(2, stageTrace.getStartSchedule());
- Assert.assertEquals(3, stageTrace.getStartExecution());
- Assert.assertEquals(4, stageTrace.getStartServerFiltersRequest());
- Assert.assertEquals(5, stageTrace.getStartHandlersRequest());
- Assert.assertEquals(6, stageTrace.getStartClientFiltersRequest());
- Assert.assertEquals(7, stageTrace.getStartSend());
- Assert.assertEquals(8, stageTrace.getFinishGetConnection());
- Assert.assertEquals(9, stageTrace.getFinishWriteToBuffer());
- Assert.assertEquals(10, stageTrace.getFinishReceiveResponse());
- Assert.assertEquals(11, stageTrace.getStartClientFiltersResponse());
- Assert.assertEquals(12, stageTrace.getFinishClientFiltersResponse());
- Assert.assertEquals(13, stageTrace.getFinishHandlersResponse());
- Assert.assertEquals(14, stageTrace.getFinishServerFiltersResponse());
- Assert.assertEquals(15, stageTrace.getFinish());
+ Assertions.assertEquals(1, stageTrace.getStart());
+ Assertions.assertEquals(2, stageTrace.getStartSchedule());
+ Assertions.assertEquals(3, stageTrace.getStartExecution());
+ Assertions.assertEquals(4, stageTrace.getStartServerFiltersRequest());
+ Assertions.assertEquals(5, stageTrace.getStartHandlersRequest());
+ Assertions.assertEquals(6, stageTrace.getStartClientFiltersRequest());
+ Assertions.assertEquals(7, stageTrace.getStartSend());
+ Assertions.assertEquals(8, stageTrace.getFinishGetConnection());
+ Assertions.assertEquals(9, stageTrace.getFinishWriteToBuffer());
+ Assertions.assertEquals(10, stageTrace.getFinishReceiveResponse());
+ Assertions.assertEquals(11, stageTrace.getStartClientFiltersResponse());
+ Assertions.assertEquals(12, stageTrace.getFinishClientFiltersResponse());
+ Assertions.assertEquals(13, stageTrace.getFinishHandlersResponse());
+ Assertions.assertEquals(14, stageTrace.getFinishServerFiltersResponse());
+ Assertions.assertEquals(15, stageTrace.getFinish());
- Assert.assertEquals(1f, stageTrace.calcInvocationPrepareTime(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcThreadPoolQueueTime(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcServerFiltersRequestTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcInvocationPrepareTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcThreadPoolQueueTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcServerFiltersRequestTime(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcHandlersRequestTime(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcClientFiltersRequestTime(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcGetConnectionTime(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcWriteToBufferTime(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcReceiveResponseTime(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcWakeConsumer(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcClientFiltersResponseTime(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcHandlersResponseTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcHandlersRequestTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcClientFiltersRequestTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcGetConnectionTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcWriteToBufferTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcReceiveResponseTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcWakeConsumer(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcClientFiltersResponseTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcHandlersResponseTime(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcServerFiltersResponseTime(), 0.1f);
- Assert.assertEquals(1f, stageTrace.calcSendResponseTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcServerFiltersResponseTime(), 0.1f);
+ Assertions.assertEquals(1f, stageTrace.calcSendResponseTime(), 0.1f);
- Assert.assertEquals(14f, stageTrace.calcTotalTime(), 0.1f);
+ Assertions.assertEquals(14f, stageTrace.calcTotalTime(), 0.1f);
}
}
diff --git a/core/src/test/java/org/apache/servicecomb/core/provider/consumer/TestConsumerProviderManager.java b/core/src/test/java/org/apache/servicecomb/core/provider/consumer/TestConsumerProviderManager.java
deleted file mode 100644
index 2d877a6..0000000
--- a/core/src/test/java/org/apache/servicecomb/core/provider/consumer/TestConsumerProviderManager.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); 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
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.core.provider.consumer;
-
-public class TestConsumerProviderManager {
-// @Before
-// public void setUp() throws Exception {
-// ArchaiusUtils.resetConfig();
-// }
-//
-// @After
-// public void tearDown() throws Exception {
-// ArchaiusUtils.resetConfig();
-// }
-//
-// @Test
-// public void allowedNoProvider(@Mocked ConsumerSchemaFactory consumerSchemaFactory) {
-// AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
-// context.getBeanFactory().registerSingleton(consumerSchemaFactory.getClass().getName(), consumerSchemaFactory);
-// context.register(ConsumerProviderManager.class);
-// // must not throw exception
-// context.refresh();
-//
-// context.close();
-// }
-//
-// private ReferenceConfig mockCreateReferenceConfig() {
-// EventBus eventBus = new EventBus();
-// AppManager appManager = new AppManager(eventBus);
-//
-// ConsumerProviderManager consumerProviderManager = new ConsumerProviderManager();
-// consumerProviderManager.setAppManager(appManager);
-//
-// new Expectations(RegistryUtils.class) {
-// {
-// RegistryUtils.findServiceInstances(anyString, anyString, DefinitionConst.VERSION_RULE_ALL, null);
-// result = Collections.emptyList();
-// }
-// };
-//
-// new MockUp<MicroserviceVersionRule>() {
-// @Mock
-// MicroserviceVersion getLatestMicroserviceVersion() {
-// return Mockito.mock(MicroserviceVersion.class);
-// }
-// };
-// return consumerProviderManager.createReferenceConfig("app:ms");
-// }
-//
-// @Test
-// public void createReferenceConfig_default() {
-// ReferenceConfig referenceConfig = mockCreateReferenceConfig();
-//
-// Assert.assertEquals("app", referenceConfig.getMicroserviceVersionRule().getAppId());
-// Assert.assertEquals("app:ms", referenceConfig.getMicroserviceVersionRule().getMicroserviceName());
-// Assert.assertEquals("0.0.0.0+", referenceConfig.getMicroserviceVersionRule().getVersionRule().getVersionRule());
-// Assert.assertEquals(Const.ANY_TRANSPORT, referenceConfig.getTransport());
-// }
-//
-// @Test
-// public void createReferenceConfig_config() {
-// ArchaiusUtils.setProperty("servicecomb.references.app:ms.version-rule", "1.0.0+");
-// ArchaiusUtils.setProperty("servicecomb.references.app:ms.transport", Const.RESTFUL);
-//
-// ReferenceConfig referenceConfig = mockCreateReferenceConfig();
-//
-// Assert.assertEquals("app", referenceConfig.getMicroserviceVersionRule().getAppId());
-// Assert.assertEquals("app:ms", referenceConfig.getMicroserviceVersionRule().getMicroserviceName());
-// Assert.assertEquals("1.0.0.0+", referenceConfig.getMicroserviceVersionRule().getVersionRule().getVersionRule());
-// Assert.assertEquals(Const.RESTFUL, referenceConfig.getTransport());
-// }
-//
-// @Test
-// public void createReferenceConfig_ProviderNotFound() {
-// EventBus eventBus = new EventBus();
-// AppManager appManager = new AppManager(eventBus);
-//
-// ConsumerProviderManager consumerProviderManager = new ConsumerProviderManager();
-// consumerProviderManager.setAppManager(appManager);
-//
-// new Expectations(RegistryUtils.class) {
-// {
-// RegistryUtils.findServiceInstances(anyString, anyString, DefinitionConst.VERSION_RULE_ALL, null);
-// result = Collections.emptyList();
-// }
-// };
-//
-// new MockUp<MicroserviceVersionRule>() {
-// @Mock
-// String getAppId() {
-// return "aId";
-// }
-//
-// @Mock
-// String getMicroserviceName() {
-// return "ms";
-// }
-// };
-//
-// try {
-// consumerProviderManager.createReferenceConfig("app:ms");
-// fail("an IllegalStateException is expected!");
-// } catch (Exception e) {
-// Assert.assertEquals(IllegalStateException.class, e.getClass());
-// Assert.assertEquals(
-// "Probably invoke a service before it is registered, or no instance found for it, appId=aId, name=ms",
-// e.getMessage());
-// e.printStackTrace();
-// }
-// }
-}
diff --git a/core/src/test/java/org/apache/servicecomb/core/provider/consumer/TestInvokerUtils.java b/core/src/test/java/org/apache/servicecomb/core/provider/consumer/TestInvokerUtils.java
index 409fa7f..9eba671 100644
--- a/core/src/test/java/org/apache/servicecomb/core/provider/consumer/TestInvokerUtils.java
+++ b/core/src/test/java/org/apache/servicecomb/core/provider/consumer/TestInvokerUtils.java
@@ -19,14 +19,14 @@
import org.apache.servicecomb.swagger.invocation.Response;
import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
-import org.junit.Assert;
import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
public class TestInvokerUtils {
@Test
public void testRetryInvocation503() {
InvocationException root = new InvocationException(503, "Service Unavailable", "Error");
boolean canRetry = InvokerUtils.canRetryForStatusCode(Response.failResp(root));
- Assert.assertTrue(canRetry);
+ Assertions.assertTrue(canRetry);
}
}
diff --git a/core/src/test/java/org/apache/servicecomb/core/provider/consumer/TestReferenceConfig.java b/core/src/test/java/org/apache/servicecomb/core/provider/consumer/TestReferenceConfig.java
deleted file mode 100644
index 2504228..0000000
--- a/core/src/test/java/org/apache/servicecomb/core/provider/consumer/TestReferenceConfig.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); 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
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.core.provider.consumer;
-
-public class TestReferenceConfig {
-// @Test
-// public void constructNoParam(@Mocked MicroserviceMeta microserviceMeta,
-// @Mocked MicroserviceVersionMeta microserviceVersionMeta,
-// @Mocked MicroserviceVersionRule microserviceVersionRule) {
-// new Expectations() {
-// {
-// microserviceVersionMeta.getMicroserviceMeta();
-// result = microserviceMeta;
-// microserviceVersionRule.getLatestMicroserviceVersion();
-// result = microserviceVersionMeta;
-// }
-// };
-// String transport = Const.ANY_TRANSPORT;
-//
-// ReferenceConfig referenceConfig = new ReferenceConfig();
-// referenceConfig.setMicroserviceVersionRule(microserviceVersionRule);
-// referenceConfig.setTransport(transport);
-//
-// Assert.assertSame(microserviceMeta, referenceConfig.getMicroserviceMeta());
-// Assert.assertSame(microserviceVersionRule, referenceConfig.getMicroserviceVersionRule());
-// Assert.assertSame(transport, referenceConfig.getTransport());
-// }
-//
-// @Test
-// public void constructWithParam(@Mocked AppManager appManager,
-// @Mocked MicroserviceMeta microserviceMeta,
-// @Mocked MicroserviceVersionRule microserviceVersionRule,
-// @Mocked MicroserviceVersionMeta microserviceVersionMeta) {
-// String microserviceName = "ms";
-// String transport = Const.ANY_TRANSPORT;
-// new Expectations() {
-// {
-// appManager.getOrCreateMicroserviceVersionRule(anyString, anyString, anyString);
-// result = microserviceVersionRule;
-// microserviceVersionMeta.getMicroserviceMeta();
-// result = microserviceMeta;
-// microserviceVersionRule.getLatestMicroserviceVersion();
-// result = microserviceVersionMeta;
-// }
-// };
-//
-// ReferenceConfig referenceConfig = new ReferenceConfig(appManager, microserviceName,
-// DefinitionConst.VERSION_RULE_LATEST,
-// transport);
-// Assert.assertSame(microserviceMeta, referenceConfig.getMicroserviceMeta());
-// Assert.assertSame(microserviceVersionRule, referenceConfig.getMicroserviceVersionRule());
-// Assert.assertSame(transport, referenceConfig.getTransport());
-// }
-//
-// @Test
-// public void unifyVersionRule(@Mocked MicroserviceVersionMeta microserviceVersionMeta) {
-// String microserviceName = "app:ms";
-// String transport = Const.ANY_TRANSPORT;
-//
-// new Expectations(RegistryUtils.class) {
-// {
-// RegistryUtils.findServiceInstances(anyString, anyString, anyString, anyString);
-// result = Collections.emptyList();
-// }
-// };
-// AppManager appManager = new AppManager(new EventBus());
-//
-// ReferenceConfig referenceConfig = new ReferenceConfig(appManager, microserviceName,
-// "0+",
-// transport);
-// Assert.assertEquals("0.0.0.0+", referenceConfig.getVersionRule());
-//
-// referenceConfig = new ReferenceConfig(appManager, microserviceName,
-// "1.0.0+",
-// transport);
-// Assert.assertEquals("1.0.0.0+", referenceConfig.getVersionRule());
-// }
-}
diff --git a/core/src/test/java/org/apache/servicecomb/core/provider/producer/TestProducerBootListener.java b/core/src/test/java/org/apache/servicecomb/core/provider/producer/TestProducerBootListener.java
index a61b6f4..8df53a1 100644
--- a/core/src/test/java/org/apache/servicecomb/core/provider/producer/TestProducerBootListener.java
+++ b/core/src/test/java/org/apache/servicecomb/core/provider/producer/TestProducerBootListener.java
@@ -30,13 +30,13 @@
import org.apache.servicecomb.core.definition.OperationMeta;
import org.apache.servicecomb.core.executor.GroupExecutor;
import org.apache.servicecomb.foundation.test.scaffolding.log.LogCollector;
-import org.junit.Assert;
import org.junit.Test;
import mockit.Expectations;
import mockit.Mock;
import mockit.MockUp;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestProducerBootListener {
ProducerBootListener producerBootListener = new ProducerBootListener();
@@ -85,7 +85,7 @@
producerBootListener.onBootEvent(event);
- Assert.assertEquals(2, count.get());
+ Assertions.assertEquals(2, count.get());
}
@Test
@@ -110,7 +110,7 @@
producerBootListener.onBootEvent(event);
- Assert.assertEquals(
+ Assertions.assertEquals(
"Executor org.apache.servicecomb.core.provider.producer.TestProducerBootListener$UnCloseableExecutor "
+ "do not support close or shutdown, it may block service shutdown.",
logCollector.getLastEvents().getMessage());
diff --git a/core/src/test/java/org/apache/servicecomb/core/provider/producer/TestProducerMeta.java b/core/src/test/java/org/apache/servicecomb/core/provider/producer/TestProducerMeta.java
index 3d45871..1c481c7 100644
--- a/core/src/test/java/org/apache/servicecomb/core/provider/producer/TestProducerMeta.java
+++ b/core/src/test/java/org/apache/servicecomb/core/provider/producer/TestProducerMeta.java
@@ -16,25 +16,25 @@
*/
package org.apache.servicecomb.core.provider.producer;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestProducerMeta {
@Test
public void test1() {
Object instance = new Object();
ProducerMeta meta = new ProducerMeta("id", instance);
- Assert.assertEquals("id", meta.getSchemaId());
- Assert.assertEquals(instance, meta.getInstance());
+ Assertions.assertEquals("id", meta.getSchemaId());
+ Assertions.assertEquals(instance, meta.getInstance());
}
@Test
public void test2() {
ProducerMeta meta = new ProducerMeta();
meta.setSchemaId("id1");
- Assert.assertEquals("id1", meta.getSchemaId());
+ Assertions.assertEquals("id1", meta.getSchemaId());
meta.setInstance(1);
- Assert.assertEquals(1, meta.getInstance());
+ Assertions.assertEquals(1, meta.getInstance());
}
}
diff --git a/core/src/test/java/org/apache/servicecomb/core/registry/discovery/TestEndpointDiscoveryFilter.java b/core/src/test/java/org/apache/servicecomb/core/registry/discovery/TestEndpointDiscoveryFilter.java
index 9afa690..30a8bef 100644
--- a/core/src/test/java/org/apache/servicecomb/core/registry/discovery/TestEndpointDiscoveryFilter.java
+++ b/core/src/test/java/org/apache/servicecomb/core/registry/discovery/TestEndpointDiscoveryFilter.java
@@ -28,12 +28,12 @@
import org.apache.servicecomb.registry.api.registry.MicroserviceInstance;
import org.apache.servicecomb.registry.discovery.DiscoveryContext;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import mockit.Expectations;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestEndpointDiscoveryFilter {
EndpointDiscoveryFilter filter = new EndpointDiscoveryFilter();
@@ -61,7 +61,7 @@
@Test
public void getOrder() {
- Assert.assertEquals(Short.MAX_VALUE, filter.getOrder());
+ Assertions.assertEquals(Short.MAX_VALUE, filter.getOrder());
}
@Test
@@ -73,12 +73,12 @@
}
};
- Assert.assertEquals(Const.RESTFUL, filter.findTransportName(context, null));
+ Assertions.assertEquals(Const.RESTFUL, filter.findTransportName(context, null));
}
@Test
public void createEndpointNullTransport() {
- Assert.assertNull(filter.createEndpoint(null, Const.RESTFUL, "", null));
+ Assertions.assertNull(filter.createEndpoint(null, Const.RESTFUL, "", null));
}
@Test
@@ -96,9 +96,9 @@
};
Endpoint ep = (Endpoint) filter.createEndpoint(null, Const.RESTFUL, endpoint, instance);
- Assert.assertSame(transport, ep.getTransport());
- Assert.assertSame(address, ep.getAddress());
- Assert.assertSame(instance, ep.getMicroserviceInstance());
- Assert.assertEquals(endpoint, ep.getEndpoint());
+ Assertions.assertSame(transport, ep.getTransport());
+ Assertions.assertSame(address, ep.getAddress());
+ Assertions.assertSame(instance, ep.getMicroserviceInstance());
+ Assertions.assertEquals(endpoint, ep.getEndpoint());
}
}
diff --git a/core/src/test/java/org/apache/servicecomb/core/registry/discovery/TestOperationInstancesDiscoveryFilter.java b/core/src/test/java/org/apache/servicecomb/core/registry/discovery/TestOperationInstancesDiscoveryFilter.java
deleted file mode 100644
index 54cd21e..0000000
--- a/core/src/test/java/org/apache/servicecomb/core/registry/discovery/TestOperationInstancesDiscoveryFilter.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); 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
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.core.registry.discovery;
-
-public class TestOperationInstancesDiscoveryFilter {
-// @SwaggerDefinition(basePath = "/v1")
-// private static class V1_0_0 {
-// @ApiOperation(value = "", httpMethod = "GET")
-// public void add() {
-// }
-// }
-//
-// @SwaggerDefinition(basePath = "/v1")
-// private static class V1_1_0 {
-// @ApiOperation(value = "", httpMethod = "GET")
-// public void add() {
-// }
-//
-// @ApiOperation(value = "", httpMethod = "GET")
-// public void dec() {
-// }
-// }
-//
-// OperationInstancesDiscoveryFilter filter = new OperationInstancesDiscoveryFilter();
-//
-// DiscoveryContext context = new DiscoveryContext();
-//
-// EventBus eventBus = new EventBus();
-//
-// String appId = "app";
-//
-// String microserviceName = "ms";
-//
-// ServiceRegistry serviceRegistry =
-// new LocalServiceRegistry(eventBus, ServiceRegistryConfig.INSTANCE,
-// MicroserviceDefinition.create(appId, "self"));
-//
-// @Mocked
-// ApplicationContext applicationContext;
-//
-// @Mocked
-// Invocation invocation;
-//
-// OperationMeta latestOperationMeta;
-//
-// ConsumerSchemaFactory consumerSchemaFactory = new ConsumerSchemaFactory();
-//
-// DiscoveryTreeNode result;
-//
-// @Before
-// public void setup() {
-// serviceRegistry.init();
-// BeanUtils.setContext(applicationContext);
-//
-// RegistryUtils.setServiceRegistry(serviceRegistry);
-// }
-//
-// private void setupOnChange() {
-// new Expectations(RegistryUtils.class) {
-// {
-// invocation.getOperationMeta();
-// result = latestOperationMeta;
-// invocation.getMicroserviceQualifiedName();
-// result = latestOperationMeta.getMicroserviceQualifiedName();
-// }
-// };
-//
-// context.setInputParameters(invocation);
-// }
-//
-// @After
-// public void teardown() {
-// RegistryUtils.setServiceRegistry(null);
-// BeanUtils.setContext(null);
-// CseContext.getInstance().setConsumerSchemaFactory(null);
-// CseContext.getInstance().setSchemaListenerManager(null);
-// }
-//
-// private MicroserviceInstance createInstance(String serviceId) {
-// MicroserviceInstance instance = new MicroserviceInstance();
-// instance.setInstanceId(UUID.randomUUID().toString());
-// instance.setServiceId(serviceId);
-// return instance;
-// }
-//
-// private Microservice regMicroservice(String serviceId, String version, Class<?> schemaCls, int instanceCount) {
-// String schemaId = "sid";
-//
-// Microservice microservice = new Microservice();
-// microservice.setServiceId(serviceId);
-// microservice.setAppId(appId);
-// microservice.setServiceName(microserviceName);
-// microservice.setVersion(version);
-// microservice.setSchemas(Arrays.asList(schemaId));
-// serviceRegistry.getServiceRegistryClient().registerMicroservice(microservice);
-//
-// String schemaContent = SwaggerUtils.swaggerToString(SwaggerGenerator.generate(schemaCls));
-// serviceRegistry.getServiceRegistryClient().registerSchema(serviceId, schemaId, schemaContent);
-//
-// for (int idx = 0; idx < instanceCount; idx++) {
-// MicroserviceInstance instance = createInstance(serviceId);
-// serviceRegistry.getServiceRegistryClient().registerMicroserviceInstance(instance);
-// }
-//
-// return microservice;
-// }
-//
-// @Test
-// public void getOrder() {
-// Assert.assertEquals(-10000, filter.getOrder());
-// }
-//
-// @Test
-// public void isGroupingFilterAndEnabled() {
-// Assert.assertTrue(filter.isGroupingFilter());
-// Assert.assertTrue(filter.enabled());
-// }
-//
-// @Test
-// public void discovery_v1_0_0() {
-// regMicroservice("1", "1.0.0", V1_0_0.class, 2);
-//
-// MicroserviceVersions MicroserviceVersions =
-// serviceRegistry.getAppManager().getOrCreateMicroserviceVersions(appId, microserviceName);
-// MicroserviceVersions.submitPull();
-// MicroserviceVersionRule microserviceVersionRule =
-// MicroserviceVersions.getOrCreateMicroserviceVersionRule(DefinitionConst.VERSION_RULE_ALL);
-// MicroserviceVersionMeta latestMicroserviceVersionMeta = microserviceVersionRule.getLatestMicroserviceVersion();
-// latestOperationMeta = latestMicroserviceVersionMeta.getMicroserviceMeta().ensureFindOperation("sid.add");
-// DiscoveryTreeNode parent = new DiscoveryTreeNode().fromCache(microserviceVersionRule.getVersionedCache());
-//
-// setupOnChange();
-//
-// result = filter.discovery(context, parent);
-//
-// Assert.assertEquals(2, result.mapData().size());
-// result.mapData().values().forEach(instance -> {
-// Assert.assertEquals("1", ((MicroserviceInstance) instance).getServiceId());
-// });
-// }
-//
-// @Test
-// public void discovery_v1_1_0_add() {
-// regMicroservice("1", "1.0.0", V1_0_0.class, 2);
-// regMicroservice("2", "1.1.0", V1_1_0.class, 2);
-//
-// MicroserviceVersions MicroserviceVersions =
-// serviceRegistry.getAppManager().getOrCreateMicroserviceVersions(appId, microserviceName);
-// MicroserviceVersions.submitPull();
-// MicroserviceVersionRule microserviceVersionRule =
-// MicroserviceVersions.getOrCreateMicroserviceVersionRule(DefinitionConst.VERSION_RULE_ALL);
-// MicroserviceVersionMeta latestMicroserviceVersionMeta = microserviceVersionRule.getLatestMicroserviceVersion();
-// latestOperationMeta = latestMicroserviceVersionMeta.getMicroserviceMeta().ensureFindOperation("sid.add");
-// DiscoveryTreeNode parent = new DiscoveryTreeNode().fromCache(microserviceVersionRule.getVersionedCache());
-//
-// setupOnChange();
-//
-// result = filter.discovery(context, parent);
-//
-// Assert.assertEquals(4, result.mapData().size());
-// Set<String> ids = new HashSet<>();
-// result.mapData().values().forEach(instance -> {
-// ids.add(((MicroserviceInstance) instance).getServiceId());
-// });
-// Assert.assertThat(ids, Matchers.containsInAnyOrder("1", "2"));
-// }
-//
-// @Test
-// public void discovery_v1_1_0_dec() {
-// regMicroservice("1", "1.0.0", V1_0_0.class, 2);
-// regMicroservice("2", "1.1.0", V1_1_0.class, 2);
-//
-// MicroserviceVersions MicroserviceVersions =
-// serviceRegistry.getAppManager().getOrCreateMicroserviceVersions(appId, microserviceName);
-// MicroserviceVersions.submitPull();
-// MicroserviceVersionRule microserviceVersionRule =
-// MicroserviceVersions.getOrCreateMicroserviceVersionRule(DefinitionConst.VERSION_RULE_ALL);
-// MicroserviceVersionMeta latestMicroserviceVersionMeta = microserviceVersionRule.getLatestMicroserviceVersion();
-// latestOperationMeta = latestMicroserviceVersionMeta.getMicroserviceMeta().ensureFindOperation("sid.dec");
-// DiscoveryTreeNode parent = new DiscoveryTreeNode().fromCache(microserviceVersionRule.getVersionedCache());
-//
-// setupOnChange();
-//
-// result = filter.discovery(context, parent);
-//
-// Assert.assertEquals(2, result.mapData().size());
-// Set<String> ids = new HashSet<>();
-// result.mapData().values().forEach(instance -> {
-// ids.add(((MicroserviceInstance) instance).getServiceId());
-// });
-// Assert.assertThat(ids, Matchers.containsInAnyOrder("2"));
-// }
-}
diff --git a/core/src/test/java/org/apache/servicecomb/core/tracing/BraveTraceIdGeneratorTest.java b/core/src/test/java/org/apache/servicecomb/core/tracing/BraveTraceIdGeneratorTest.java
index 8963cd2..55fa453 100644
--- a/core/src/test/java/org/apache/servicecomb/core/tracing/BraveTraceIdGeneratorTest.java
+++ b/core/src/test/java/org/apache/servicecomb/core/tracing/BraveTraceIdGeneratorTest.java
@@ -17,23 +17,21 @@
package org.apache.servicecomb.core.tracing;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.fail;
-
import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
public class BraveTraceIdGeneratorTest {
@Test
public void generateStringId() {
TraceIdGenerator traceIdGenerator = new BraveTraceIdGenerator();
- assertNotEquals(traceIdGenerator.generate(), traceIdGenerator.generate());
+ Assertions.assertNotEquals(traceIdGenerator.generate(), traceIdGenerator.generate());
String traceId = traceIdGenerator.generate();
try {
Long.parseLong(traceId, 16);
} catch (NumberFormatException e) {
- fail("wrong traceId format: " + traceId);
+ Assertions.fail("wrong traceId format: " + traceId);
}
}
}
diff --git a/core/src/test/java/org/apache/servicecomb/core/transport/TestAbstractTransport.java b/core/src/test/java/org/apache/servicecomb/core/transport/TestAbstractTransport.java
index 7d270d2..adea616 100644
--- a/core/src/test/java/org/apache/servicecomb/core/transport/TestAbstractTransport.java
+++ b/core/src/test/java/org/apache/servicecomb/core/transport/TestAbstractTransport.java
@@ -29,8 +29,8 @@
import org.apache.servicecomb.registry.RegistrationManager;
import org.apache.servicecomb.swagger.invocation.AsyncResponse;
import org.junit.AfterClass;
-import org.junit.Assert;
import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
import org.springframework.util.ReflectionUtils;
import com.netflix.config.DynamicProperty;
@@ -79,7 +79,7 @@
MyAbstractTransport transport = new MyAbstractTransport();
transport.setListenAddressWithoutSchema("127.0.0.1:9090", Collections.singletonMap("country", "中 国"));
- Assert.assertEquals("my://127.0.0.1:9090?country=" + URLEncoder.encode("中 国", StandardCharsets.UTF_8.name()),
+ Assertions.assertEquals("my://127.0.0.1:9090?country=" + URLEncoder.encode("中 国", StandardCharsets.UTF_8.name()),
transport.getEndpoint().getEndpoint());
}
@@ -87,7 +87,7 @@
public void testSetListenAddressWithoutSchemaNormalNotEncode() {
MyAbstractTransport transport = new MyAbstractTransport();
transport.setListenAddressWithoutSchema("127.0.0.1:9090", Collections.singletonMap("country", "chinese"));
- Assert.assertEquals("my://127.0.0.1:9090?country=chinese", transport.getEndpoint().getEndpoint());
+ Assertions.assertEquals("my://127.0.0.1:9090?country=chinese", transport.getEndpoint().getEndpoint());
}
@Test
@@ -95,21 +95,21 @@
MyAbstractTransport transport = new MyAbstractTransport();
transport.setListenAddressWithoutSchema("127.0.0.1:9090?a=aValue",
Collections.singletonMap("country", "chinese"));
- Assert.assertEquals("my://127.0.0.1:9090?a=aValue&country=chinese", transport.getEndpoint().getEndpoint());
+ Assertions.assertEquals("my://127.0.0.1:9090?a=aValue&country=chinese", transport.getEndpoint().getEndpoint());
}
@Test
public void testMyAbstractTransport() {
MyAbstractTransport transport = new MyAbstractTransport();
transport.setListenAddressWithoutSchema("127.0.0.1:9090");
- Assert.assertEquals("my", transport.getName());
- Assert.assertEquals("my://127.0.0.1:9090", transport.getEndpoint().getEndpoint());
- Assert.assertEquals("127.0.0.1", ((IpPort) transport.parseAddress("my://127.0.0.1:9090")).getHostOrIp());
+ Assertions.assertEquals("my", transport.getName());
+ Assertions.assertEquals("my://127.0.0.1:9090", transport.getEndpoint().getEndpoint());
+ Assertions.assertEquals("127.0.0.1", ((IpPort) transport.parseAddress("my://127.0.0.1:9090")).getHostOrIp());
transport.setListenAddressWithoutSchema("0.0.0.0:9090");
- Assert.assertNotEquals("my://127.0.0.1:9090", transport.getEndpoint().getEndpoint());
+ Assertions.assertNotEquals("my://127.0.0.1:9090", transport.getEndpoint().getEndpoint());
transport.setListenAddressWithoutSchema(null);
- Assert.assertNull(transport.getEndpoint().getEndpoint());
- Assert.assertNull(transport.parseAddress(null));
+ Assertions.assertNull(transport.getEndpoint().getEndpoint());
+ Assertions.assertNull(transport.parseAddress(null));
}
@Test(expected = IllegalArgumentException.class)
diff --git a/core/src/test/java/org/apache/servicecomb/core/transport/TestTransportManager.java b/core/src/test/java/org/apache/servicecomb/core/transport/TestTransportManager.java
index ed78e2c..2082245 100644
--- a/core/src/test/java/org/apache/servicecomb/core/transport/TestTransportManager.java
+++ b/core/src/test/java/org/apache/servicecomb/core/transport/TestTransportManager.java
@@ -26,12 +26,12 @@
import org.apache.servicecomb.core.Transport;
import org.apache.servicecomb.foundation.common.exceptions.ServiceCombException;
import org.apache.servicecomb.registry.api.registry.MicroserviceInstance;
-import org.junit.Assert;
import org.junit.Test;
import mockit.Expectations;
import mockit.Injectable;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestTransportManager {
@Test
@@ -53,7 +53,7 @@
manager.addTransportsBeforeInit(transports);
manager.init(scbEngine);
- Assert.assertEquals(manager.findTransport("test"), transport);
+ Assertions.assertEquals(manager.findTransport("test"), transport);
}
@Test
@@ -77,7 +77,7 @@
manager.addTransportsBeforeInit(transports);
manager.init(scbEngine);
- Assert.assertEquals(manager.findTransport("test"), transport);
+ Assertions.assertEquals(manager.findTransport("test"), transport);
}
@Test
@@ -98,12 +98,12 @@
manager.addTransportsBeforeInit(Arrays.asList(t1, t2_1, t2_2));
Map<String, List<Transport>> groups = manager.groupByName();
- Assert.assertEquals(2, groups.size());
- Assert.assertEquals(1, groups.get("t1").size());
- Assert.assertEquals(t1, groups.get("t1").get(0));
- Assert.assertEquals(2, groups.get("t2").size());
- Assert.assertEquals(t2_1, groups.get("t2").get(0));
- Assert.assertEquals(t2_2, groups.get("t2").get(1));
+ Assertions.assertEquals(2, groups.size());
+ Assertions.assertEquals(1, groups.get("t1").size());
+ Assertions.assertEquals(t1, groups.get("t1").get(0));
+ Assertions.assertEquals(2, groups.get("t2").size());
+ Assertions.assertEquals(t2_1, groups.get("t2").get(0));
+ Assertions.assertEquals(t2_2, groups.get("t2").get(1));
}
@Test
@@ -123,9 +123,9 @@
try {
manager.checkTransportGroup(group);
- Assert.fail("must throw exception");
+ Assertions.fail("must throw exception");
} catch (ServiceCombException e) {
- Assert.assertEquals(
+ Assertions.assertEquals(
"org.apache.servicecomb.core.$Impl_Transport and org.apache.servicecomb.core.$Impl_Transport have the same order 1",
e.getMessage());
}
@@ -149,7 +149,7 @@
try {
manager.checkTransportGroup(group);
} catch (ServiceCombException e) {
- Assert.fail("must not throw exception: " + e.getMessage());
+ Assertions.fail("must not throw exception: " + e.getMessage());
}
}
@@ -170,7 +170,7 @@
TransportManager manager = new TransportManager();
List<Transport> group = Arrays.asList(t1, t2);
- Assert.assertEquals(t1, manager.chooseOneTransport(group));
+ Assertions.assertEquals(t1, manager.chooseOneTransport(group));
}
@Test
@@ -192,7 +192,7 @@
TransportManager manager = new TransportManager();
List<Transport> group = Arrays.asList(t1, t2);
- Assert.assertEquals(t1, manager.chooseOneTransport(group));
+ Assertions.assertEquals(t1, manager.chooseOneTransport(group));
}
@Test
@@ -218,9 +218,9 @@
try {
manager.chooseOneTransport(group);
- Assert.fail("must throw exception");
+ Assertions.fail("must throw exception");
} catch (ServiceCombException e) {
- Assert.assertEquals("all transport named t refused to init.", e.getMessage());
+ Assertions.assertEquals("all transport named t refused to init.", e.getMessage());
}
}
}