You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2022/05/19 08:07:55 UTC
[servicecomb-java-chassis] branch master updated: [SCB-2475] migrate to junit5 foundations part1 (#2954)
This is an automated email from the ASF dual-hosted git repository.
liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git
The following commit(s) were added to refs/heads/master by this push:
new a441d611c [SCB-2475] migrate to junit5 foundations part1 (#2954)
a441d611c is described below
commit a441d611c66619353289f45da2be2a012578c013
Author: ZhangJian He <sh...@gmail.com>
AuthorDate: Thu May 19 16:07:49 2022 +0800
[SCB-2475] migrate to junit5 foundations part1 (#2954)
---
.../foundation/common/utils/FortifyUtils.java | 2 +-
.../foundation/common/utils/Log4jUtils.java | 6 +
.../common/cache/TestVersionedCache.java | 61 +++---
.../common/concurrency/RunnableWrapperTest.java | 7 +-
.../foundation/common/encrypt/TestEncryptions.java | 30 +--
.../foundation/common/event/TestEventManager.java | 24 +--
.../foundation/common/http/TestHttpStatus.java | 21 +--
.../common/http/TestHttpStatusUtils.java | 7 +-
.../foundation/common/http/TestHttpUtils.java | 61 +++---
.../foundation/common/net/TestIpPort.java | 18 +-
.../foundation/common/net/TestNetUtils.java | 198 ++++++++++----------
.../common/net/TestURIEndpointObject.java | 53 +++---
.../foundation/common/part/TestAbstractPart.java | 21 +--
.../foundation/common/part/TestFilePart.java | 18 +-
.../common/part/TestInputStreamPart.java | 8 +-
.../foundation/common/part/TestResourcePart.java | 8 +-
.../common/spring/TestPaasNamespaceHandler.java | 4 +-
.../foundation/common/utils/Log4jUtilsTest.java | 40 ++--
.../foundation/common/utils/ResourceUtilTest.java | 22 +--
.../foundation/common/utils/TestBeanUtils.java | 20 +-
.../common/utils/TestExceptionUtils.java | 8 +-
.../common/utils/TestFileNameTooLong.java | 14 +-
.../foundation/common/utils/TestFortifyUtils.java | 26 ++-
.../foundation/common/utils/TestGenericsUtils.java | 18 +-
.../foundation/common/utils/TestIOUtils.java | 19 +-
.../foundation/common/utils/TestJvmUtils.java | 28 +--
.../common/utils/TestMimeTypesUtils.java | 52 +++---
.../foundation/common/utils/TestRSAUtil.java | 16 +-
.../common/utils/TestRollingFileAppenderExt.java | 10 +-
.../foundation/common/utils/TestTypesUtil.java | 12 +-
.../foundation/logback/TestMarkerFilter.java | 12 +-
.../servicecomb/config/TestConfigMapping.java | 18 +-
.../apache/servicecomb/config/TestConfigUtil.java | 46 ++---
.../TestLastPropertyPlaceholderConfigurer.java | 8 +-
.../apache/servicecomb/config/TestYAMLUtil.java | 22 +--
.../sources/TestMicroserviceConfigLoader.java | 18 +-
.../sources/TestYAMLConfigurationSource.java | 43 +++--
.../config/inject/TestConfigObjectFactory.java | 204 ++++++++++-----------
.../config/priority/TestPriorityProperty.java | 102 +++++------
.../priority/TestPriorityPropertyManager.java | 10 +-
.../foundation/metrics/TestMetricsBootstrap.java | 6 +-
.../metrics/health/TestHealthCheckerManager.java | 20 +-
.../meter/TestLatencyDistributionConfig.java | 13 +-
.../meter/TestLatencyDistributionMeter.java | 20 +-
.../foundation/metrics/meter/TestSimpleTimer.java | 13 +-
.../publish/spectator/TestDefaultTagFinder.java | 11 +-
.../spectator/TestMeasurementGroupConfig.java | 14 +-
.../publish/spectator/TestMeasurementNode.java | 18 +-
.../publish/spectator/TestMeasurementTree.java | 11 +-
.../metrics/publish/spectator/TestTagFinder.java | 11 +-
.../TestCompatibilityOfImplementations.java | 20 +-
.../protobuf/internal/TestModelWrap.java | 18 +-
.../protobuf/internal/TestSchemaBase.java | 12 +-
.../internal/bean/TestBeanDescriptorManager.java | 28 +--
.../protobuf/internal/parser/TestProtoParser.java | 20 +-
.../protobuf/internal/schema/TestAnySchema.java | 10 +-
.../internal/schema/TestMessageSchema.java | 12 +-
.../internal/schema/TestRepeatedSchema.java | 10 +-
.../internal/schema/scalar/TestBoolSchema.java | 12 +-
.../internal/schema/scalar/TestEnumSchema.java | 18 +-
.../schema/scalar/TestNumberBaseSchema.java | 10 +-
.../internal/schema/scalar/TestStringSchema.java | 11 +-
.../api/registry/TestServiceCombVersion.java | 6 +-
.../config/TestAbstractPropertiesLoader.java | 10 +-
.../discovery/TestAbstractDiscoveryFilter.java | 25 ++-
.../TestAbstractTransportDiscoveryFilter.java | 22 +--
.../registry/discovery/TestDiscoveryContext.java | 18 +-
.../registry/discovery/TestDiscoveryTree.java | 35 ++--
.../registry/discovery/TestDiscoveryTreeNode.java | 23 ++-
.../servicecomb/registry/version/TestVersion.java | 71 ++++---
.../registry/version/TestVersionRule.java | 10 +-
.../version/TestVersionRuleFixedParser.java | 10 +-
.../version/TestVersionRuleLatestParser.java | 14 +-
.../version/TestVersionRuleRangeParser.java | 20 +-
.../version/TestVersionRuleStartFromParser.java | 20 +-
.../registry/version/TestVersionRuleUtils.java | 21 +--
.../foundation/ssl/CertificateUtilTest.java | 16 +-
.../foundation/ssl/KeyStoreUtilTest.java | 24 +--
.../servicecomb/foundation/ssl/SSLManagerTest.java | 65 ++++---
.../servicecomb/foundation/ssl/SSLOptionTest.java | 127 +++++++------
.../foundation/ssl/TestSSLOptionFactory.java | 5 +-
.../foundation/ssl/TestSSLSocketFactoryExt.java | 4 +-
.../foundation/ssl/TestTrustAllManager.java | 8 +-
.../foundation/ssl/TrustManagerExtTest.java | 20 +-
.../ext/web/impl/TestHttpServerRequestUtils.java | 4 +-
.../vertx/TestAddressResolverConfig.java | 36 ++--
.../foundation/vertx/TestSharedVertxFactory.java | 8 +-
.../foundation/vertx/TestSimpleBodyHandler.java | 6 +-
.../foundation/vertx/TestSimpleJsonObject.java | 8 +-
.../servicecomb/foundation/vertx/TestStream.java | 20 +-
.../foundation/vertx/TestVertxTLSBuilder.java | 40 ++--
.../foundation/vertx/TestVertxUtils.java | 28 +--
.../vertx/client/TestClientPoolManager.java | 36 ++--
.../vertx/client/TestClientVerticle.java | 4 +-
.../client/http/TestHttpClientPoolFactory.java | 6 +-
.../tcp/TestAbstractTcpClientPoolFactory.java | 10 +-
.../vertx/client/tcp/TestNetClientWrapper.java | 6 +-
.../vertx/client/tcp/TestTcpClientConfig.java | 10 +-
.../vertx/client/tcp/TestTcpClientConnection.java | 48 ++---
.../vertx/http/TestAbstractHttpServletRequest.java | 5 +-
.../http/TestAbstractHttpServletResponse.java | 5 +-
.../vertx/http/TestBodyBufferSupportImpl.java | 25 ++-
.../foundation/vertx/http/TestFileUploadPart.java | 14 +-
.../foundation/vertx/http/TestReadStreamPart.java | 23 ++-
.../http/TestStandardHttpServletRequestEx.java | 28 +--
.../http/TestStandardHttpServletResponseEx.java | 23 ++-
...TestVertxClientRequestToHttpServletRequest.java | 16 +-
...stVertxClientResponseToHttpServletResponse.java | 14 +-
...TestVertxServerRequestToHttpServletRequest.java | 86 ++++-----
...stVertxServerResponseToHttpServletResponse.java | 57 +++---
.../metrics/TestDefaultHttpClientMetrics.java | 136 +++++++-------
.../metrics/TestDefaultHttpServerMetrics.java | 54 +++---
.../vertx/metrics/TestDefaultTcpClientMetrics.java | 132 ++++++-------
.../vertx/metrics/TestDefaultTcpServerMetrics.java | 48 ++---
.../metrics/TestDefaultVertxMetricsFactory.java | 10 +-
.../vertx/metrics/TestMetricsOptionsEx.java | 14 +-
.../foundation/vertx/server/TestTcpParser.java | 10 +-
.../foundation/vertx/server/TestTcpServer.java | 6 +-
.../vertx/server/TestTcpServerConnection.java | 15 +-
.../vertx/stream/TestBufferInputStream.java | 30 +--
.../foundation/vertx/stream/TestPumpFromPart.java | 34 ++--
.../servicecomb/metrics/core/AssertUtil.java | 20 +-
metrics/metrics-core/src/test/resources/log4j2.xml | 29 +++
123 files changed, 1639 insertions(+), 1672 deletions(-)
diff --git a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/FortifyUtils.java b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/FortifyUtils.java
index bb65f0916..63234af5a 100644
--- a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/FortifyUtils.java
+++ b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/FortifyUtils.java
@@ -83,7 +83,7 @@ public final class FortifyUtils {
}
public static String getErrorInfo(Throwable e, boolean isPrintMsg) {
- StringBuffer error = new StringBuffer(System.lineSeparator());
+ StringBuilder error = new StringBuilder(System.lineSeparator());
error.append("Exception: ").append(e.getClass().getName()).append("; ");
if (isPrintMsg) {
diff --git a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/Log4jUtils.java b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/Log4jUtils.java
index d636bcdb9..0f06c26a4 100644
--- a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/Log4jUtils.java
+++ b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/Log4jUtils.java
@@ -27,6 +27,7 @@ import java.util.Map.Entry;
import java.util.Properties;
import java.util.stream.Collectors;
+import com.google.common.annotations.VisibleForTesting;
import org.apache.commons.io.FileUtils;
import org.apache.log4j.PropertyConfigurator;
import org.apache.servicecomb.foundation.common.config.impl.PropertiesLoader;
@@ -86,6 +87,11 @@ public final class Log4jUtils {
}
}
+ @VisibleForTesting
+ static boolean isInited() {
+ return inited;
+ }
+
private static void outputFile(List<Resource> resList,
Properties properties) throws IOException {
//不可以作为class的变量初始化,因为在outputFile前一句log机制才初始化完成的
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/cache/TestVersionedCache.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/cache/TestVersionedCache.java
index 61f7490bf..cdfe99f57 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/cache/TestVersionedCache.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/cache/TestVersionedCache.java
@@ -20,10 +20,9 @@ package org.apache.servicecomb.foundation.common.cache;
import java.util.Collections;
import java.util.concurrent.atomic.AtomicInteger;
-import org.junit.Assert;
-import org.junit.Test;
-
import mockit.Deencapsulation;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestVersionedCache {
private static final AtomicInteger VERSION = Deencapsulation.getField(VersionedCache.class, "VERSION");
@@ -32,16 +31,16 @@ public class TestVersionedCache {
public void construct() {
VersionedCache cache = new VersionedCache();
- Assert.assertNull(cache.data());
- Assert.assertNull(cache.arrayData());
- Assert.assertTrue(cache.isEmpty());
+ Assertions.assertNull(cache.data());
+ Assertions.assertNull(cache.arrayData());
+ Assertions.assertTrue(cache.isEmpty());
}
@Test
public void autoCacheVersion() {
VersionedCache cache = new VersionedCache().autoCacheVersion();
- Assert.assertEquals(VERSION.get(), cache.cacheVersion());
+ Assertions.assertEquals(VERSION.get(), cache.cacheVersion());
}
@Test
@@ -49,14 +48,14 @@ public class TestVersionedCache {
VersionedCache parent = new VersionedCache().autoCacheVersion();
VersionedCache cache = new VersionedCache().cacheVersion(parent.cacheVersion());
- Assert.assertEquals(parent.cacheVersion(), cache.cacheVersion());
+ Assertions.assertEquals(parent.cacheVersion(), cache.cacheVersion());
}
@Test
public void setName() {
VersionedCache cache = new VersionedCache().name("n");
- Assert.assertEquals("n", cache.name());
+ Assertions.assertEquals("n", cache.name());
}
@Test
@@ -64,31 +63,31 @@ public class TestVersionedCache {
VersionedCache parent = new VersionedCache().name("parent");
VersionedCache child = new VersionedCache().subName(parent, "child");
- Assert.assertEquals("parent/child", child.name());
+ Assertions.assertEquals("parent/child", child.name());
}
@Test
public void setMapData() {
VersionedCache cache = new VersionedCache().data(Collections.emptyMap());
- Assert.assertSame(Collections.emptyMap(), cache.data());
- Assert.assertSame(Collections.emptyMap(), cache.mapData());
- Assert.assertTrue(cache.isEmpty());
+ Assertions.assertSame(Collections.emptyMap(), cache.data());
+ Assertions.assertSame(Collections.emptyMap(), cache.mapData());
+ Assertions.assertTrue(cache.isEmpty());
cache.data(Collections.singletonMap("k", "v"));
- Assert.assertFalse(cache.isEmpty());
+ Assertions.assertFalse(cache.isEmpty());
}
@Test
public void setCollectionData() {
VersionedCache cache = new VersionedCache().data(Collections.emptyList());
- Assert.assertSame(Collections.emptyList(), cache.data());
- Assert.assertSame(Collections.emptyList(), cache.collectionData());
- Assert.assertTrue(cache.isEmpty());
+ Assertions.assertSame(Collections.emptyList(), cache.data());
+ Assertions.assertSame(Collections.emptyList(), cache.collectionData());
+ Assertions.assertTrue(cache.isEmpty());
cache.data(Collections.singletonList("v"));
- Assert.assertFalse(cache.isEmpty());
+ Assertions.assertFalse(cache.isEmpty());
}
@Test
@@ -96,24 +95,24 @@ public class TestVersionedCache {
Object[] array = Collections.emptyList().toArray();
VersionedCache cache = new VersionedCache().data(array);
- Assert.assertSame(array, cache.data());
- Assert.assertSame(array, cache.arrayData());
- Assert.assertTrue(cache.isEmpty());
+ Assertions.assertSame(array, cache.data());
+ Assertions.assertSame(array, cache.arrayData());
+ Assertions.assertTrue(cache.isEmpty());
cache.data(new String[] {"a", "b"});
- Assert.assertFalse(cache.isEmpty());
+ Assertions.assertFalse(cache.isEmpty());
}
@Test
public void setCommonData() {
VersionedCache cache = new VersionedCache().data(null);
- Assert.assertNull(cache.data());
- Assert.assertNull(cache.arrayData());
- Assert.assertTrue(cache.isEmpty());
+ Assertions.assertNull(cache.data());
+ Assertions.assertNull(cache.arrayData());
+ Assertions.assertTrue(cache.isEmpty());
cache.data("a");
- Assert.assertFalse(cache.isEmpty());
+ Assertions.assertFalse(cache.isEmpty());
}
@Test
@@ -121,9 +120,9 @@ public class TestVersionedCache {
VersionedCache cacheOld = new VersionedCache().autoCacheVersion();
VersionedCache cacheNew = new VersionedCache().autoCacheVersion();
- Assert.assertTrue(cacheOld.isExpired(cacheNew));
- Assert.assertFalse(cacheOld.isExpired(cacheOld));
- Assert.assertFalse(cacheNew.isExpired(cacheOld));
+ Assertions.assertTrue(cacheOld.isExpired(cacheNew));
+ Assertions.assertFalse(cacheOld.isExpired(cacheOld));
+ Assertions.assertFalse(cacheNew.isExpired(cacheOld));
}
@Test
@@ -132,7 +131,7 @@ public class TestVersionedCache {
VersionedCache cacheNew = new VersionedCache().autoCacheVersion();
VersionedCache cacheSame = new VersionedCache().cacheVersion(cacheNew.cacheVersion());
- Assert.assertFalse(cacheOld.isSameVersion(cacheNew));
- Assert.assertTrue(cacheSame.isSameVersion(cacheNew));
+ Assertions.assertFalse(cacheOld.isSameVersion(cacheNew));
+ Assertions.assertTrue(cacheSame.isSameVersion(cacheNew));
}
}
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/concurrency/RunnableWrapperTest.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/concurrency/RunnableWrapperTest.java
index d9a7da588..79581ef39 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/concurrency/RunnableWrapperTest.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/concurrency/RunnableWrapperTest.java
@@ -17,13 +17,12 @@
package org.apache.servicecomb.foundation.common.concurrency;
-import static org.junit.Assert.assertEquals;
-
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class RunnableWrapperTest {
/**
@@ -61,6 +60,6 @@ public class RunnableWrapperTest {
scheduledThreadPoolExecutor.shutdownNow();
}
- assertEquals(0, countDownLatch.getCount());
+ Assertions.assertEquals(0, countDownLatch.getCount());
}
}
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/encrypt/TestEncryptions.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/encrypt/TestEncryptions.java
index 74bb90b76..35090bad5 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/encrypt/TestEncryptions.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/encrypt/TestEncryptions.java
@@ -17,11 +17,11 @@
package org.apache.servicecomb.foundation.common.encrypt;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestEncryptions {
- class MyEncryption implements Encryption {
+ static class MyEncryption implements Encryption {
@Override
public char[] decode(char[] encrypted, String tags) {
@@ -42,24 +42,24 @@ public class TestEncryptions {
@Test
public void testEncryptions() {
- Assert.assertEquals(Encryptions.decode((String) null, ""), null);
- Assert.assertEquals(Encryptions.decode("abcd", ""), "abcd");
- Assert.assertEquals(Encryptions.decode("abcd", null), "abcd");
- Assert.assertEquals(Encryptions.encode((String) null, ""), null);
- Assert.assertEquals(Encryptions.encode("abcd", ""), "abcd");
- Assert.assertEquals(Encryptions.decode("abcd", null), "abcd");
+ Assertions.assertNull(Encryptions.decode((String) null, ""));
+ Assertions.assertEquals(Encryptions.decode("abcd", ""), "abcd");
+ Assertions.assertEquals(Encryptions.decode("abcd", null), "abcd");
+ Assertions.assertNull(Encryptions.encode((String) null, ""));
+ Assertions.assertEquals(Encryptions.encode("abcd", ""), "abcd");
+ Assertions.assertEquals(Encryptions.decode("abcd", null), "abcd");
}
@Test
public void testEncryptionsMy() {
Encryption old = Encryptions.getEncryption();
Encryptions.setEncryption(new MyEncryption());
- Assert.assertEquals(Encryptions.decode((String) null, ""), null);
- Assert.assertEquals(Encryptions.decode("abcd", ""), "abcd");
- Assert.assertEquals(Encryptions.decode("abcd", null), null);
- Assert.assertEquals(Encryptions.encode((String) null, ""), null);
- Assert.assertEquals(Encryptions.encode("abcd", ""), "abcd");
- Assert.assertEquals(Encryptions.encode("abcd", null), null);
+ Assertions.assertNull(Encryptions.decode((String) null, ""));
+ Assertions.assertEquals(Encryptions.decode("abcd", ""), "abcd");
+ Assertions.assertNull(Encryptions.decode("abcd", null));
+ Assertions.assertNull(Encryptions.encode((String) null, ""));
+ Assertions.assertEquals(Encryptions.encode("abcd", ""), "abcd");
+ Assertions.assertNull(Encryptions.encode("abcd", null));
Encryptions.setEncryption(old);
}
}
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/event/TestEventManager.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/event/TestEventManager.java
index 77df59db2..c1fbf71d5 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/event/TestEventManager.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/event/TestEventManager.java
@@ -18,10 +18,10 @@
package org.apache.servicecomb.foundation.common.event;
import org.apache.servicecomb.foundation.test.scaffolding.log.LogCollector;
-import org.junit.Assert;
-import org.junit.Test;
import com.google.common.eventbus.Subscribe;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestEventManager {
private int objCount = 0;
@@ -32,14 +32,14 @@ public class TestEventManager {
EventManager.register(listener);
EventManager.post("a");
EventManager.post(1);
- Assert.assertEquals(2, objCount);
- Assert.assertEquals(1, iCount);
+ Assertions.assertEquals(2, objCount);
+ Assertions.assertEquals(1, iCount);
EventManager.unregister(listener);
EventManager.post("a");
EventManager.post(1);
- Assert.assertEquals(2, objCount);
- Assert.assertEquals(1, iCount);
+ Assertions.assertEquals(2, objCount);
+ Assertions.assertEquals(1, iCount);
}
@Test
@@ -47,7 +47,7 @@ public class TestEventManager {
LogCollector collector = new LogCollector();
test(this);
- Assert.assertTrue(collector.getEvents().isEmpty()); // ensure no warning logs
+ Assertions.assertTrue(collector.getEvents().isEmpty()); // ensure no warning logs
collector.teardown();
}
@@ -67,9 +67,9 @@ public class TestEventManager {
};
try {
test(listener);
- Assert.fail();
+ Assertions.fail();
} catch (IllegalStateException e) {
- Assert.assertTrue(true);
+ Assertions.assertTrue(true);
}
collector.teardown();
@@ -91,13 +91,13 @@ public class TestEventManager {
};
try {
test(listener);
- Assert.fail();
+ Assertions.fail();
} catch (IllegalStateException e) {
- Assert.assertTrue(true);
+ Assertions.assertTrue(true);
}
// ensure logs: "LOGGER.warn("Failed to create lambda for method: {}, fallback to reflect.", method, throwable);"
- Assert.assertTrue(!collector.getEvents().isEmpty());
+ Assertions.assertTrue(!collector.getEvents().isEmpty());
collector.teardown();
}
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/http/TestHttpStatus.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/http/TestHttpStatus.java
index 71e6eb46d..6797c85ac 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/http/TestHttpStatus.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/http/TestHttpStatus.java
@@ -17,41 +17,40 @@
package org.apache.servicecomb.foundation.common.http;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.Response.Status.Family;
-import org.junit.Assert;
-import org.junit.Test;
-
-
public class TestHttpStatus {
@Test
public void testIsSuccessCode() {
- Assert.assertTrue(HttpStatus.isSuccess(200));
- Assert.assertFalse(HttpStatus.isSuccess(300));
+ Assertions.assertTrue(HttpStatus.isSuccess(200));
+ Assertions.assertFalse(HttpStatus.isSuccess(300));
}
@Test
public void testIsSuccessType() {
- Assert.assertTrue(HttpStatus.isSuccess(Status.OK));
- Assert.assertFalse(HttpStatus.isSuccess(Status.BAD_REQUEST));
+ Assertions.assertTrue(HttpStatus.isSuccess(Status.OK));
+ Assertions.assertFalse(HttpStatus.isSuccess(Status.BAD_REQUEST));
}
@Test
public void testGetStatusCode() {
HttpStatus status = new HttpStatus(200, "ok");
- Assert.assertEquals(200, status.getStatusCode());
+ Assertions.assertEquals(200, status.getStatusCode());
}
@Test
public void testGetFamily() {
HttpStatus status = new HttpStatus(200, "ok");
- Assert.assertEquals(Family.familyOf(200), status.getFamily());
+ Assertions.assertEquals(Family.familyOf(200), status.getFamily());
}
@Test
public void testGetReasonPhrase() {
HttpStatus status = new HttpStatus(200, "ok");
- Assert.assertEquals("ok", status.getReasonPhrase());
+ Assertions.assertEquals("ok", status.getReasonPhrase());
}
}
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/http/TestHttpStatusUtils.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/http/TestHttpStatusUtils.java
index 28079d801..43a59cf48 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/http/TestHttpStatusUtils.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/http/TestHttpStatusUtils.java
@@ -19,9 +19,8 @@ package org.apache.servicecomb.foundation.common.http;
import javax.ws.rs.core.Response.StatusType;
-import org.junit.Assert;
-import org.junit.Test;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestHttpStatusUtils {
HttpStatusManager mgr = new HttpStatusManager();
@@ -31,13 +30,13 @@ public class TestHttpStatusUtils {
@Test
public void testStandard() {
st = HttpStatusUtils.getOrCreateByStatusCode(200);
- Assert.assertEquals(200, st.getStatusCode());
+ Assertions.assertEquals(200, st.getStatusCode());
}
@Test
public void testNotStandard() {
st = mgr.getOrCreateByStatusCode(250);
- Assert.assertEquals(250, st.getStatusCode());
+ Assertions.assertEquals(250, st.getStatusCode());
}
@Test
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/http/TestHttpUtils.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/http/TestHttpUtils.java
index bb3516ed2..0c56a9785 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/http/TestHttpUtils.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/http/TestHttpUtils.java
@@ -20,57 +20,56 @@ import java.net.URISyntaxException;
import javax.ws.rs.core.MediaType;
-import org.junit.Assert;
-import org.junit.Test;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestHttpUtils {
@Test
public void parseParamFromHeaderValue_normal() {
- Assert.assertEquals("v", HttpUtils.parseParamFromHeaderValue("xx;k=v", "k"));
+ Assertions.assertEquals("v", HttpUtils.parseParamFromHeaderValue("xx;k=v", "k"));
}
@Test
public void parseParamFromHeaderValue_normal_ignoreCase() {
- Assert.assertEquals("v", HttpUtils.parseParamFromHeaderValue("xx;K=v", "k"));
+ Assertions.assertEquals("v", HttpUtils.parseParamFromHeaderValue("xx;K=v", "k"));
}
@Test
public void parseParamFromHeaderValue_null() {
- Assert.assertNull(HttpUtils.parseParamFromHeaderValue(null, "k"));
+ Assertions.assertNull(HttpUtils.parseParamFromHeaderValue(null, "k"));
}
@Test
public void parseParamFromHeaderValue_noKv() {
- Assert.assertNull(HttpUtils.parseParamFromHeaderValue("xx", "k"));
+ Assertions.assertNull(HttpUtils.parseParamFromHeaderValue("xx", "k"));
}
@Test
public void parseParamFromHeaderValue_noV() {
- Assert.assertEquals("", HttpUtils.parseParamFromHeaderValue("xx;k=", "k"));
+ Assertions.assertEquals("", HttpUtils.parseParamFromHeaderValue("xx;k=", "k"));
}
@Test
public void parseParamFromHeaderValue_keyNotFound() {
- Assert.assertNull(HttpUtils.parseParamFromHeaderValue("xx;k=", "kk"));
+ Assertions.assertNull(HttpUtils.parseParamFromHeaderValue("xx;k=", "kk"));
}
@Test
public void uriEncode_null() {
- Assert.assertEquals("", HttpUtils.uriEncodePath(null));
+ Assertions.assertEquals("", HttpUtils.uriEncodePath(null));
}
@Test
public void uriDecode_null() {
- Assert.assertNull(HttpUtils.uriDecodePath(null));
+ Assertions.assertNull(HttpUtils.uriDecodePath(null));
}
@Test
public void uriEncode_chineseAndSpace() {
String encoded = HttpUtils.uriEncodePath("测 试");
- Assert.assertEquals("%E6%B5%8B%20%E8%AF%95", encoded);
- Assert.assertEquals("测 试", HttpUtils.uriDecodePath(encoded));
+ Assertions.assertEquals("%E6%B5%8B%20%E8%AF%95", encoded);
+ Assertions.assertEquals("测 试", HttpUtils.uriDecodePath(encoded));
}
@Test
@@ -84,23 +83,23 @@ public class TestHttpUtils {
@Test
public void uriEncode_plus() {
String encoded = HttpUtils.uriEncodePath("a+b");
- Assert.assertEquals("a+b", encoded);
- Assert.assertEquals("a+b", HttpUtils.uriDecodePath(encoded));
+ Assertions.assertEquals("a+b", encoded);
+ Assertions.assertEquals("a+b", HttpUtils.uriDecodePath(encoded));
}
@Test
public void uriEncode_encodeEntirePath() {
String encoded = HttpUtils.uriEncodePath("a%%'+b/def");
- Assert.assertEquals("a%25%25'+b/def", encoded);
+ Assertions.assertEquals("a%25%25'+b/def", encoded);
}
@Test
public void pathParamEncode() {
- Assert.assertEquals("a+b", HttpUtils.encodePathParam("a+b"));
- Assert.assertEquals("a%25b", HttpUtils.encodePathParam("a%b"));
- Assert.assertEquals("a%25%25b", HttpUtils.encodePathParam("a%%b"));
- Assert.assertEquals("%3C%20%3E'%22%EF%BC%88)&%2F%20%20", HttpUtils.encodePathParam("< >'\"()&/ "));
- Assert.assertEquals("%E6%B5%8B%20%E8%AF%95", HttpUtils.encodePathParam("测 试"));
+ Assertions.assertEquals("a+b", HttpUtils.encodePathParam("a+b"));
+ Assertions.assertEquals("a%25b", HttpUtils.encodePathParam("a%b"));
+ Assertions.assertEquals("a%25%25b", HttpUtils.encodePathParam("a%%b"));
+ Assertions.assertEquals("%3C%20%3E'%22%EF%BC%88)&%2F%20%20", HttpUtils.encodePathParam("< >'\"()&/ "));
+ Assertions.assertEquals("%E6%B5%8B%20%E8%AF%95", HttpUtils.encodePathParam("测 试"));
}
/**
@@ -109,7 +108,7 @@ public class TestHttpUtils {
*/
@Test
public void pathParamEncode_SafeChar() {
- Assert.assertEquals("-._~!$'()*,;&=@:+", HttpUtils.encodePathParam("-._~!$'()*,;&=@:+"));
+ Assertions.assertEquals("-._~!$'()*,;&=@:+", HttpUtils.encodePathParam("-._~!$'()*,;&=@:+"));
}
@Test
@@ -124,65 +123,65 @@ public class TestHttpUtils {
public void parseFileNameFromHeaderValue() {
String fileName = "测 试.txt";
String encoded = HttpUtils.uriEncodePath(fileName);
- Assert.assertEquals(fileName, HttpUtils.parseFileNameFromHeaderValue("xx;filename=" + encoded));
+ Assertions.assertEquals(fileName, HttpUtils.parseFileNameFromHeaderValue("xx;filename=" + encoded));
}
@Test
public void parseFileNameFromHeaderValue_defaultName() {
- Assert.assertEquals("default", HttpUtils.parseFileNameFromHeaderValue("xx"));
+ Assertions.assertEquals("default", HttpUtils.parseFileNameFromHeaderValue("xx"));
}
@Test
public void parseFileNameFromHeaderValue_ignorePath() {
- Assert.assertEquals("a.txt", HttpUtils.parseFileNameFromHeaderValue("xx;filename=../../a.txt"));
+ Assertions.assertEquals("a.txt", HttpUtils.parseFileNameFromHeaderValue("xx;filename=../../a.txt"));
}
@Test
public void getCharsetFromContentType_noContentType() {
String character = HttpUtils.getCharsetFromContentType(null);
- Assert.assertNull(character);
+ Assertions.assertNull(character);
}
@Test
public void getCharsetFromContentType_noCharset() {
String character = HttpUtils.getCharsetFromContentType(MediaType.APPLICATION_JSON);
- Assert.assertNull(character);
+ Assertions.assertNull(character);
}
@Test
public void getCharsetFromContentType_noSemicolonEnd() {
String character = HttpUtils.getCharsetFromContentType(MediaType.APPLICATION_JSON + ";charset=utf-8");
- Assert.assertEquals("utf-8", character);
+ Assertions.assertEquals("utf-8", character);
}
@Test
public void getCharsetFromContentType_semicolonEnd() {
String character = HttpUtils.getCharsetFromContentType(MediaType.APPLICATION_JSON + ";charset=utf-8;");
- Assert.assertEquals("utf-8", character);
+ Assertions.assertEquals("utf-8", character);
}
@Test
public void getCharsetFromContentType_needTrim() {
String character = HttpUtils.getCharsetFromContentType(MediaType.APPLICATION_JSON + ";charset= utf-8 ;");
- Assert.assertEquals("utf-8", character);
+ Assertions.assertEquals("utf-8", character);
}
@Test
public void getCharsetFromContentType_quotationMarks() {
String character = HttpUtils.getCharsetFromContentType(MediaType.APPLICATION_JSON + ";charset=\"utf-8\";");
- Assert.assertEquals("utf-8", character);
+ Assertions.assertEquals("utf-8", character);
}
@Test
public void getCharsetFromContentType_quotationMarks_needTrim() {
String character = HttpUtils.getCharsetFromContentType(MediaType.APPLICATION_JSON + ";charset=\" utf-8 \";");
- Assert.assertEquals("utf-8", character);
+ Assertions.assertEquals("utf-8", character);
}
}
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/net/TestIpPort.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/net/TestIpPort.java
index fcd18bb8f..9194515cb 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/net/TestIpPort.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/net/TestIpPort.java
@@ -17,8 +17,8 @@
package org.apache.servicecomb.foundation.common.net;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestIpPort {
@Test
@@ -27,12 +27,12 @@ public class TestIpPort {
inst1.setHostOrIp("localhost");
inst1.setPort(3333);
IpPort inst2 = new IpPort("localhost", 3333);
- Assert.assertEquals(inst1.getHostOrIp(), inst2.getHostOrIp());
- Assert.assertEquals(inst1.getPort(), inst2.getPort());
- Assert.assertEquals(inst1.getSocketAddress().getHostName(), inst2.getSocketAddress().getHostName());
- Assert.assertEquals(inst1, inst1);
- Assert.assertEquals(inst1, inst2);
- Assert.assertEquals(inst1.toString(), "localhost:3333");
- Assert.assertNotEquals(inst1, new Object());
+ Assertions.assertEquals(inst1.getHostOrIp(), inst2.getHostOrIp());
+ Assertions.assertEquals(inst1.getPort(), inst2.getPort());
+ Assertions.assertEquals(inst1.getSocketAddress().getHostName(), inst2.getSocketAddress().getHostName());
+ Assertions.assertEquals(inst1, inst1);
+ Assertions.assertEquals(inst1, inst2);
+ Assertions.assertEquals(inst1.toString(), "localhost:3333");
+ Assertions.assertNotEquals(inst1, new Object());
}
}
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/net/TestNetUtils.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/net/TestNetUtils.java
index b6ba8249d..dd13d96d4 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/net/TestNetUtils.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/net/TestNetUtils.java
@@ -17,8 +17,6 @@
package org.apache.servicecomb.foundation.common.net;
-import static org.junit.Assert.fail;
-
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
@@ -26,8 +24,8 @@ import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import mockit.Deencapsulation;
@@ -38,52 +36,52 @@ public class TestNetUtils {
NetUtils.resetHostName();
String result = NetUtils.getHostName();
System.out.println(result);
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
result = NetUtils.getHostAddress();
System.out.println(result);
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
result = NetUtils.getIpv6HostAddress();
System.out.println(result);
if (result != null) {
- Assert.assertFalse(result.contains("%"));
+ Assertions.assertFalse(result.contains("%"));
}
}
@Test
public void testIpPort() {
IpPort oIPPort = new IpPort("10.145.154.45", 8080);
- Assert.assertEquals("10.145.154.45", oIPPort.getHostOrIp());
- Assert.assertEquals(8080, oIPPort.getPort());
+ Assertions.assertEquals("10.145.154.45", oIPPort.getHostOrIp());
+ Assertions.assertEquals(8080, oIPPort.getPort());
oIPPort.setPort(9090);
- Assert.assertEquals(9090, oIPPort.getPort());
- Assert.assertNotEquals(null, oIPPort.getSocketAddress());
+ Assertions.assertEquals(9090, oIPPort.getPort());
+ Assertions.assertNotEquals(null, oIPPort.getSocketAddress());
}
@Test
public void testNetUtils() {
- Assert.assertEquals("127.0.0.1", NetUtils.parseIpPort("127.0.0.1:8080").getHostOrIp());
- Assert.assertEquals(8080, NetUtils.parseIpPort("127.0.0.1:8080").getPort());
- Assert.assertEquals("127.0.0.1", NetUtils.parseIpPort("127.0.0.1").getHostOrIp());
- Assert.assertEquals(-1, NetUtils.parseIpPort("127.0.0.1").getPort());
- Assert.assertNull(NetUtils.parseIpPort((String) null));
- Assert.assertNull(NetUtils.parseIpPortFromURI(null));
- Assert.assertEquals("127.0.0.1", NetUtils.parseIpPortFromURI("rest://127.0.0.1:8080").getHostOrIp());
- Assert.assertEquals(8080, NetUtils.parseIpPortFromURI("http://127.0.0.1:8080").getPort());
- Assert.assertEquals(80, NetUtils.parseIpPortFromURI("http://127.0.0.1").getPort());
- Assert.assertEquals(8080, NetUtils.parseIpPortFromURI("https://127.0.0.1:8080").getPort());
- Assert.assertEquals(443, NetUtils.parseIpPortFromURI("https://127.0.0.1").getPort());
-
- Assert.assertEquals(30000, NetUtils.parseIpPort("http", "127.0.0.1:30000").getPort());
- Assert.assertEquals("127.0.0.1", NetUtils.parseIpPort("http", "127.0.0.1:30000").getHostOrIp());
- Assert.assertEquals(30000, NetUtils.parseIpPort("https", "127.0.0.1:30000").getPort());
- Assert.assertEquals("127.0.0.1", NetUtils.parseIpPort("https", "127.0.0.1:30000").getHostOrIp());
- Assert.assertEquals(80, NetUtils.parseIpPort("http", "127.0.0.1").getPort());
- Assert.assertEquals("127.0.0.1", NetUtils.parseIpPort("http", "127.0.0.1").getHostOrIp());
- Assert.assertEquals(443, NetUtils.parseIpPort("https", "127.0.0.1").getPort());
- Assert.assertEquals("127.0.0.1", NetUtils.parseIpPort("https", "127.0.0.1").getHostOrIp());
- Assert.assertNull(NetUtils.parseIpPort("http", null));
+ Assertions.assertEquals("127.0.0.1", NetUtils.parseIpPort("127.0.0.1:8080").getHostOrIp());
+ Assertions.assertEquals(8080, NetUtils.parseIpPort("127.0.0.1:8080").getPort());
+ Assertions.assertEquals("127.0.0.1", NetUtils.parseIpPort("127.0.0.1").getHostOrIp());
+ Assertions.assertEquals(-1, NetUtils.parseIpPort("127.0.0.1").getPort());
+ Assertions.assertNull(NetUtils.parseIpPort((String) null));
+ Assertions.assertNull(NetUtils.parseIpPortFromURI(null));
+ Assertions.assertEquals("127.0.0.1", NetUtils.parseIpPortFromURI("rest://127.0.0.1:8080").getHostOrIp());
+ Assertions.assertEquals(8080, NetUtils.parseIpPortFromURI("http://127.0.0.1:8080").getPort());
+ Assertions.assertEquals(80, NetUtils.parseIpPortFromURI("http://127.0.0.1").getPort());
+ Assertions.assertEquals(8080, NetUtils.parseIpPortFromURI("https://127.0.0.1:8080").getPort());
+ Assertions.assertEquals(443, NetUtils.parseIpPortFromURI("https://127.0.0.1").getPort());
+
+ Assertions.assertEquals(30000, NetUtils.parseIpPort("http", "127.0.0.1:30000").getPort());
+ Assertions.assertEquals("127.0.0.1", NetUtils.parseIpPort("http", "127.0.0.1:30000").getHostOrIp());
+ Assertions.assertEquals(30000, NetUtils.parseIpPort("https", "127.0.0.1:30000").getPort());
+ Assertions.assertEquals("127.0.0.1", NetUtils.parseIpPort("https", "127.0.0.1:30000").getHostOrIp());
+ Assertions.assertEquals(80, NetUtils.parseIpPort("http", "127.0.0.1").getPort());
+ Assertions.assertEquals("127.0.0.1", NetUtils.parseIpPort("http", "127.0.0.1").getHostOrIp());
+ Assertions.assertEquals(443, NetUtils.parseIpPort("https", "127.0.0.1").getPort());
+ Assertions.assertEquals("127.0.0.1", NetUtils.parseIpPort("https", "127.0.0.1").getHostOrIp());
+ Assertions.assertNull(NetUtils.parseIpPort("http", null));
checkException(v -> NetUtils.parseIpPort("127.0.0.18080"));
checkException(v -> NetUtils.parseIpPortFromURI("ss"));
@@ -91,52 +89,52 @@ public class TestNetUtils {
@Test
public void testNetUtilsIPv6() {
- Assert.assertEquals("[::1]", NetUtils.parseIpPort("[::1]:8080").getHostOrIp());
- Assert.assertEquals("[::]", NetUtils.parseIpPort("[::]:8080").getHostOrIp());
- Assert.assertEquals("[fe80::f816:3eff:feda:38cd%eth0]",
+ Assertions.assertEquals("[::1]", NetUtils.parseIpPort("[::1]:8080").getHostOrIp());
+ Assertions.assertEquals("[::]", NetUtils.parseIpPort("[::]:8080").getHostOrIp());
+ Assertions.assertEquals("[fe80::f816:3eff:feda:38cd%eth0]",
NetUtils.parseIpPort("[fe80::f816:3eff:feda:38cd%eth0]:8080").getHostOrIp());
- Assert.assertEquals("[fe80::38f7:44b8:8ab1:468%16]",
+ Assertions.assertEquals("[fe80::38f7:44b8:8ab1:468%16]",
NetUtils.parseIpPort("[fe80::38f7:44b8:8ab1:468%16]:8080").getHostOrIp());
- Assert.assertEquals(8080, NetUtils.parseIpPort("[::1]:8080").getPort());
- Assert.assertEquals(8080, NetUtils.parseIpPort("[::]:8080").getPort());
- Assert.assertEquals(8080, NetUtils.parseIpPort("[fe80::f816:3eff:feda:38cd%eth0]:8080").getPort());
- Assert.assertEquals(8080, NetUtils.parseIpPort("[fe80::38f7:44b8:8ab1:468%16]:8080").getPort());
-
- Assert.assertEquals("[::1]", NetUtils.parseIpPortFromURI("rest://[::1]:8080").getHostOrIp());
- Assert.assertEquals("[::]", NetUtils.parseIpPortFromURI("rest://[::]:8080").getHostOrIp());
- Assert.assertEquals("[fe80::f816:3eff:feda:38cd%eth0]",
+ Assertions.assertEquals(8080, NetUtils.parseIpPort("[::1]:8080").getPort());
+ Assertions.assertEquals(8080, NetUtils.parseIpPort("[::]:8080").getPort());
+ Assertions.assertEquals(8080, NetUtils.parseIpPort("[fe80::f816:3eff:feda:38cd%eth0]:8080").getPort());
+ Assertions.assertEquals(8080, NetUtils.parseIpPort("[fe80::38f7:44b8:8ab1:468%16]:8080").getPort());
+
+ Assertions.assertEquals("[::1]", NetUtils.parseIpPortFromURI("rest://[::1]:8080").getHostOrIp());
+ Assertions.assertEquals("[::]", NetUtils.parseIpPortFromURI("rest://[::]:8080").getHostOrIp());
+ Assertions.assertEquals("[fe80::f816:3eff:feda:38cd%eth0]",
NetUtils.parseIpPortFromURI("rest://[fe80::f816:3eff:feda:38cd%eth0]:8080").getHostOrIp());
- Assert.assertEquals("[fe80::38f7:44b8:8ab1:468%16]",
+ Assertions.assertEquals("[fe80::38f7:44b8:8ab1:468%16]",
NetUtils.parseIpPortFromURI("rest://[fe80::38f7:44b8:8ab1:468%16]:8080").getHostOrIp());
- Assert.assertEquals(8080, NetUtils.parseIpPortFromURI("rest://[::1]:8080").getPort());
- Assert.assertEquals(80, NetUtils.parseIpPortFromURI("http://[::1]").getPort());
- Assert.assertEquals(8080, NetUtils.parseIpPortFromURI("https://[::1]:8080").getPort());
- Assert.assertEquals(443, NetUtils.parseIpPortFromURI("https://[::1]").getPort());
+ Assertions.assertEquals(8080, NetUtils.parseIpPortFromURI("rest://[::1]:8080").getPort());
+ Assertions.assertEquals(80, NetUtils.parseIpPortFromURI("http://[::1]").getPort());
+ Assertions.assertEquals(8080, NetUtils.parseIpPortFromURI("https://[::1]:8080").getPort());
+ Assertions.assertEquals(443, NetUtils.parseIpPortFromURI("https://[::1]").getPort());
- Assert.assertEquals(30000, NetUtils.parseIpPort("http", "[fe80::f816:3eff:feda:38cd%eth0]:30000").getPort());
- Assert.assertEquals("[fe80::f816:3eff:feda:38cd%eth0]",
+ Assertions.assertEquals(30000, NetUtils.parseIpPort("http", "[fe80::f816:3eff:feda:38cd%eth0]:30000").getPort());
+ Assertions.assertEquals("[fe80::f816:3eff:feda:38cd%eth0]",
NetUtils.parseIpPort("http", "[fe80::f816:3eff:feda:38cd%eth0]:30000").getHostOrIp());
- Assert.assertEquals(30000, NetUtils.parseIpPort("https", "[fe80::f816:3eff:feda:38cd%eth0]:30000").getPort());
- Assert.assertEquals("[fe80::f816:3eff:feda:38cd%eth0]",
+ Assertions.assertEquals(30000, NetUtils.parseIpPort("https", "[fe80::f816:3eff:feda:38cd%eth0]:30000").getPort());
+ Assertions.assertEquals("[fe80::f816:3eff:feda:38cd%eth0]",
NetUtils.parseIpPort("https", "[fe80::f816:3eff:feda:38cd%eth0]:30000").getHostOrIp());
- Assert.assertEquals(80, NetUtils.parseIpPort("http", "[fe80::f816:3eff:feda:38cd%eth0]").getPort());
- Assert.assertEquals("[fe80::f816:3eff:feda:38cd%eth0]",
+ Assertions.assertEquals(80, NetUtils.parseIpPort("http", "[fe80::f816:3eff:feda:38cd%eth0]").getPort());
+ Assertions.assertEquals("[fe80::f816:3eff:feda:38cd%eth0]",
NetUtils.parseIpPort("http", "[fe80::f816:3eff:feda:38cd%eth0]").getHostOrIp());
- Assert.assertEquals(443, NetUtils.parseIpPort("https", "[fe80::f816:3eff:feda:38cd%eth0]").getPort());
- Assert.assertEquals("[fe80::f816:3eff:feda:38cd%eth0]",
+ Assertions.assertEquals(443, NetUtils.parseIpPort("https", "[fe80::f816:3eff:feda:38cd%eth0]").getPort());
+ Assertions.assertEquals("[fe80::f816:3eff:feda:38cd%eth0]",
NetUtils.parseIpPort("https", "[fe80::f816:3eff:feda:38cd%eth0]").getHostOrIp());
}
@Test
public void testFullOperation() {
- Assert.assertNotNull(NetUtils.getHostAddress());
- Assert.assertNotNull(NetUtils.getHostName());
+ Assertions.assertNotNull(NetUtils.getHostAddress());
+ Assertions.assertNotNull(NetUtils.getHostName());
}
@Test
public void testGetRealListenAddress() {
- Assert.assertNull(NetUtils.getRealListenAddress("http", null));
- Assert.assertEquals("http://1.1.1.1:8080", NetUtils.getRealListenAddress("http", "1.1.1.1:8080"));
+ Assertions.assertNull(NetUtils.getRealListenAddress("http", null));
+ Assertions.assertEquals("http://1.1.1.1:8080", NetUtils.getRealListenAddress("http", "1.1.1.1:8080"));
checkException(v -> NetUtils.getRealListenAddress("http:1", "1.1.1.1:8080"));
}
@@ -150,14 +148,14 @@ public class TestNetUtils {
newValue.put("eth100", addr);
Deencapsulation.setField(NetUtils.class, "allInterfaceAddresses", newValue);
- Assert.assertEquals(addr, NetUtils.getInterfaceAddress("eth100"));
- Assert.assertEquals(addr, NetUtils.ensureGetInterfaceAddress("eth100"));
+ Assertions.assertEquals(addr, NetUtils.getInterfaceAddress("eth100"));
+ Assertions.assertEquals(addr, NetUtils.ensureGetInterfaceAddress("eth100"));
try {
NetUtils.ensureGetInterfaceAddress("xxx");
- fail("must throw exception");
+ Assertions.fail("must throw exception");
} catch (IllegalArgumentException e) {
- Assert.assertEquals("Can not find address for interface name: xxx", e.getMessage());
+ Assertions.assertEquals("Can not find address for interface name: xxx", e.getMessage());
}
Deencapsulation.setField(NetUtils.class, "allInterfaceAddresses", org);
@@ -167,7 +165,7 @@ public class TestNetUtils {
public void testCanTcpListenNo() throws IOException {
InetAddress address = InetAddress.getByName("127.0.0.1");
try (ServerSocket ss = new ServerSocket(0, 0, address)) {
- Assert.assertFalse(NetUtils.canTcpListen(address, ss.getLocalPort()));
+ Assertions.assertFalse(NetUtils.canTcpListen(address, ss.getLocalPort()));
}
}
@@ -178,66 +176,66 @@ public class TestNetUtils {
int port = ss.getLocalPort();
ss.close();
- Assert.assertTrue(NetUtils.canTcpListen(address, port));
+ Assertions.assertTrue(NetUtils.canTcpListen(address, port));
}
@Test
public void humanReadableBytes() {
- Assert.assertEquals("0", NetUtils.humanReadableBytes(0L));
- Assert.assertEquals("1", NetUtils.humanReadableBytes(1L));
- Assert.assertEquals("1023", NetUtils.humanReadableBytes(1023L));
-
- Assert.assertEquals("1.000K", NetUtils.humanReadableBytes(1024L));
- Assert.assertEquals("1.001K", NetUtils.humanReadableBytes(1025L));
- Assert.assertEquals("1023.999K", NetUtils.humanReadableBytes(1024L * 1024 - 1));
-
- Assert.assertEquals("1.000M", NetUtils.humanReadableBytes(1024L * 1024));
- Assert.assertEquals("1.000M", NetUtils.humanReadableBytes(1024L * 1024 + 1));
- Assert.assertEquals("1.001M", NetUtils.humanReadableBytes(1024L * 1024 + 1024));
- Assert.assertEquals("1023.999M", NetUtils.humanReadableBytes(1024L * 1024 * 1024 - 1024));
- Assert.assertEquals("1024.000M", NetUtils.humanReadableBytes(1024L * 1024 * 1024 - 1));
- Assert.assertEquals("1.000G", NetUtils.humanReadableBytes(1024L * 1024 * 1024));
- Assert.assertEquals("1.000G", NetUtils.humanReadableBytes(1024L * 1024 * 1024 + 1));
- Assert.assertEquals("1.000G", NetUtils.humanReadableBytes(1024L * 1024 * 1024 + 1024));
- Assert.assertEquals("1023.999G", NetUtils.humanReadableBytes(1024L * 1024 * 1024 * 1024 - 1024 * 1024));
- Assert.assertEquals("1024.000G", NetUtils.humanReadableBytes(1024L * 1024 * 1024 * 1024 - 1024));
- Assert.assertEquals("1.000T", NetUtils.humanReadableBytes(1024L * 1024 * 1024 * 1024));
- Assert.assertEquals("1.001T", NetUtils.humanReadableBytes(1024L * 1024 * 1024 * 1024 + 1024 * 1024 * 1024));
- Assert.assertEquals("1023.999T",
+ Assertions.assertEquals("0", NetUtils.humanReadableBytes(0L));
+ Assertions.assertEquals("1", NetUtils.humanReadableBytes(1L));
+ Assertions.assertEquals("1023", NetUtils.humanReadableBytes(1023L));
+
+ Assertions.assertEquals("1.000K", NetUtils.humanReadableBytes(1024L));
+ Assertions.assertEquals("1.001K", NetUtils.humanReadableBytes(1025L));
+ Assertions.assertEquals("1023.999K", NetUtils.humanReadableBytes(1024L * 1024 - 1));
+
+ Assertions.assertEquals("1.000M", NetUtils.humanReadableBytes(1024L * 1024));
+ Assertions.assertEquals("1.000M", NetUtils.humanReadableBytes(1024L * 1024 + 1));
+ Assertions.assertEquals("1.001M", NetUtils.humanReadableBytes(1024L * 1024 + 1024));
+ Assertions.assertEquals("1023.999M", NetUtils.humanReadableBytes(1024L * 1024 * 1024 - 1024));
+ Assertions.assertEquals("1024.000M", NetUtils.humanReadableBytes(1024L * 1024 * 1024 - 1));
+ Assertions.assertEquals("1.000G", NetUtils.humanReadableBytes(1024L * 1024 * 1024));
+ Assertions.assertEquals("1.000G", NetUtils.humanReadableBytes(1024L * 1024 * 1024 + 1));
+ Assertions.assertEquals("1.000G", NetUtils.humanReadableBytes(1024L * 1024 * 1024 + 1024));
+ Assertions.assertEquals("1023.999G", NetUtils.humanReadableBytes(1024L * 1024 * 1024 * 1024 - 1024 * 1024));
+ Assertions.assertEquals("1024.000G", NetUtils.humanReadableBytes(1024L * 1024 * 1024 * 1024 - 1024));
+ Assertions.assertEquals("1.000T", NetUtils.humanReadableBytes(1024L * 1024 * 1024 * 1024));
+ Assertions.assertEquals("1.001T", NetUtils.humanReadableBytes(1024L * 1024 * 1024 * 1024 + 1024 * 1024 * 1024));
+ Assertions.assertEquals("1023.999T",
NetUtils.humanReadableBytes(1024L * 1024 * 1024 * 1024 * 1024 - 1024L * 1024 * 1024));
- Assert.assertEquals("1.000P", NetUtils.humanReadableBytes(1024L * 1024 * 1024 * 1024 * 1024));
- Assert.assertEquals("1.001P",
+ Assertions.assertEquals("1.000P", NetUtils.humanReadableBytes(1024L * 1024 * 1024 * 1024 * 1024));
+ Assertions.assertEquals("1.001P",
NetUtils.humanReadableBytes(1024L * 1024 * 1024 * 1024 * 1024 + 1024L * 1024 * 1024 * 1024));
- Assert.assertEquals("1023.999P",
+ Assertions.assertEquals("1023.999P",
NetUtils.humanReadableBytes(1024L * 1024 * 1024 * 1024 * 1024 * 1024 - 1024L * 1024 * 1024 * 1024));
- Assert.assertEquals("1.000E", NetUtils.humanReadableBytes(1024L * 1024 * 1024 * 1024 * 1024 * 1024));
- Assert.assertEquals("1.001E",
+ Assertions.assertEquals("1.000E", NetUtils.humanReadableBytes(1024L * 1024 * 1024 * 1024 * 1024 * 1024));
+ Assertions.assertEquals("1.001E",
NetUtils.humanReadableBytes(1024L * 1024 * 1024 * 1024 * 1024 * 1024 + 1024L * 1024 * 1024 * 1024 * 1024));
- Assert.assertEquals("8.000E", NetUtils.humanReadableBytes(Long.MAX_VALUE));
+ Assertions.assertEquals("8.000E", NetUtils.humanReadableBytes(Long.MAX_VALUE));
}
@Test
public void testGetHostName() {
- Assert.assertNotEquals(null, NetUtils.getHostName());
+ Assertions.assertNotEquals(null, NetUtils.getHostName());
Deencapsulation.setField(NetUtils.class, "hostName", null);
- Assert.assertNotEquals(null, NetUtils.getHostName());
+ Assertions.assertNotEquals(null, NetUtils.getHostName());
}
@Test
public void testGetHostAddress() {
- Assert.assertNotEquals(null, NetUtils.getHostAddress());
+ Assertions.assertNotEquals(null, NetUtils.getHostAddress());
Deencapsulation.setField(NetUtils.class, "hostAddress", null);
- Assert.assertNotEquals(null, NetUtils.getHostAddress());
+ Assertions.assertNotEquals(null, NetUtils.getHostAddress());
}
public void checkException(Consumer<Void> testedBehavior) {
try {
testedBehavior.accept(null);
- fail("IllegalArgumentException is expected!");
+ Assertions.fail("IllegalArgumentException is expected!");
} catch (Exception e) {
- Assert.assertEquals(IllegalArgumentException.class, e.getClass());
+ Assertions.assertEquals(IllegalArgumentException.class, e.getClass());
}
}
}
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/net/TestURIEndpointObject.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/net/TestURIEndpointObject.java
index 973414eb6..7651a0d39 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/net/TestURIEndpointObject.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/net/TestURIEndpointObject.java
@@ -23,41 +23,40 @@ import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
-import org.junit.Assert;
-import org.junit.Test;
-
import mockit.Deencapsulation;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestURIEndpointObject {
@Test
public void testRestEndpointObject() {
URIEndpointObject obj = new URIEndpointObject("http://127.0.2.0:8080");
- Assert.assertEquals("127.0.2.0", obj.getHostOrIp());
- Assert.assertEquals(8080, obj.getPort());
- Assert.assertFalse(obj.isSslEnabled());
+ Assertions.assertEquals("127.0.2.0", obj.getHostOrIp());
+ Assertions.assertEquals(8080, obj.getPort());
+ Assertions.assertFalse(obj.isSslEnabled());
obj = new URIEndpointObject("http://127.0.2.0:8080?sslEnabled=true");
- Assert.assertEquals("127.0.2.0", obj.getHostOrIp());
- Assert.assertEquals(8080, obj.getPort());
- Assert.assertTrue(obj.isSslEnabled());
- Assert.assertNull(obj.getFirst("notExist"));
+ Assertions.assertEquals("127.0.2.0", obj.getHostOrIp());
+ Assertions.assertEquals(8080, obj.getPort());
+ Assertions.assertTrue(obj.isSslEnabled());
+ Assertions.assertNull(obj.getFirst("notExist"));
obj = new URIEndpointObject("http://127.0.2.0:8080?sslEnabled=true&protocol=http2");
- Assert.assertEquals("127.0.2.0", obj.getHostOrIp());
- Assert.assertEquals(8080, obj.getPort());
- Assert.assertTrue(obj.isSslEnabled());
- Assert.assertTrue(obj.isHttp2Enabled());
- Assert.assertNull(obj.getFirst("notExist"));
+ Assertions.assertEquals("127.0.2.0", obj.getHostOrIp());
+ Assertions.assertEquals(8080, obj.getPort());
+ Assertions.assertTrue(obj.isSslEnabled());
+ Assertions.assertTrue(obj.isHttp2Enabled());
+ Assertions.assertNull(obj.getFirst("notExist"));
obj = new URIEndpointObject("rest://127.0.2.0:8080?urlPrefix=%2Froot");
- Assert.assertEquals("127.0.2.0", obj.getHostOrIp());
- Assert.assertEquals(8080, obj.getPort());
- Assert.assertEquals("/root", obj.getQuery("urlPrefix").get(0));
+ Assertions.assertEquals("127.0.2.0", obj.getHostOrIp());
+ Assertions.assertEquals(8080, obj.getPort());
+ Assertions.assertEquals("/root", obj.getQuery("urlPrefix").get(0));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testRestEndpointObjectException() {
- new URIEndpointObject("http://127.0.2.0");
+ Assertions.assertThrows(IllegalArgumentException.class, () -> new URIEndpointObject("http://127.0.2.0"));
}
@Test
@@ -67,15 +66,15 @@ public class TestURIEndpointObject {
URIEndpointObject ep = new URIEndpointObject(strUri);
Map<String, List<String>> querys = Deencapsulation.getField(ep, "querys");
- Assert.assertEquals(3, querys.size());
+ Assertions.assertEquals(3, querys.size());
- Assert.assertEquals(1, ep.getQuery("a").size());
- Assert.assertEquals("1", ep.getFirst("a"));
+ Assertions.assertEquals(1, ep.getQuery("a").size());
+ Assertions.assertEquals("1", ep.getFirst("a"));
- Assert.assertEquals(1, ep.getQuery("b").size());
- Assert.assertEquals("", ep.getFirst("b"));
+ Assertions.assertEquals(1, ep.getQuery("b").size());
+ Assertions.assertEquals("", ep.getFirst("b"));
- Assert.assertEquals(1, ep.getQuery("country").size());
- Assert.assertEquals("中 国", ep.getFirst("country"));
+ Assertions.assertEquals(1, ep.getQuery("country").size());
+ Assertions.assertEquals("中 国", ep.getFirst("country"));
}
}
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/part/TestAbstractPart.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/part/TestAbstractPart.java
index c3d11525a..de00d29d3 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/part/TestAbstractPart.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/part/TestAbstractPart.java
@@ -21,9 +21,8 @@ import java.io.IOException;
import javax.ws.rs.core.MediaType;
-import org.junit.Assert;
-import org.junit.Test;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestAbstractPart {
AbstractPart part = new AbstractPart();
@@ -40,29 +39,29 @@ public class TestAbstractPart {
@Test
public void getContentType() throws IOException {
- Assert.assertEquals(MediaType.APPLICATION_OCTET_STREAM, part.getContentType());
+ Assertions.assertEquals(MediaType.APPLICATION_OCTET_STREAM, part.getContentType());
String contentType = "abc";
part.contentType(contentType);
- Assert.assertEquals(contentType, part.getContentType());
+ Assertions.assertEquals(contentType, part.getContentType());
}
@Test
public void getName() throws IOException {
- Assert.assertNull(part.getName());
+ Assertions.assertNull(part.getName());
String name = "abc";
part.name = name;
- Assert.assertEquals(name, part.getName());
+ Assertions.assertEquals(name, part.getName());
}
@Test
public void getSubmittedFileName() throws IOException {
- Assert.assertNull(part.getSubmittedFileName());
+ Assertions.assertNull(part.getSubmittedFileName());
String submittedFileName = "abc";
part.setSubmittedFileName(submittedFileName);
- Assert.assertEquals(submittedFileName, part.getSubmittedFileName());
+ Assertions.assertEquals(submittedFileName, part.getSubmittedFileName());
}
@Test
@@ -70,21 +69,21 @@ public class TestAbstractPart {
part.contentType(MediaType.TEXT_PLAIN);
part.setSubmittedFileName("a.zip");
- Assert.assertEquals(MediaType.TEXT_PLAIN, part.getContentType());
+ Assertions.assertEquals(MediaType.TEXT_PLAIN, part.getContentType());
}
@Test
public void setSubmittedFileName_setNull() {
part.setSubmittedFileName(null);
- Assert.assertEquals(MediaType.APPLICATION_OCTET_STREAM, part.getContentType());
+ Assertions.assertEquals(MediaType.APPLICATION_OCTET_STREAM, part.getContentType());
}
@Test
public void setSubmittedFileName_setNormal() {
part.setSubmittedFileName("a.zip");
- Assert.assertEquals("application/zip", part.getContentType());
+ Assertions.assertEquals("application/zip", part.getContentType());
}
@Test
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/part/TestFilePart.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/part/TestFilePart.java
index c2e874179..a2b6cf496 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/part/TestFilePart.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/part/TestFilePart.java
@@ -25,9 +25,9 @@ import java.nio.charset.StandardCharsets;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.junit.AfterClass;
-import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
public class TestFilePart {
static File file = new File("testFilePart.txt");
@@ -51,19 +51,19 @@ public class TestFilePart {
@Test
public void getName() {
- Assert.assertEquals(name, part.getName());
+ Assertions.assertEquals(name, part.getName());
}
@Test
public void getInputStream() throws IOException {
try (InputStream is = part.getInputStream()) {
- Assert.assertEquals(content, IOUtils.toString(is, StandardCharsets.UTF_8));
+ Assertions.assertEquals(content, IOUtils.toString(is, StandardCharsets.UTF_8));
}
}
@Test
public void getSize() {
- Assert.assertEquals(content.length(), part.getSize());
+ Assertions.assertEquals(content.length(), part.getSize());
}
@Test
@@ -71,22 +71,22 @@ public class TestFilePart {
File destFile = new File("testFilePartCopy.txt");
part.write(destFile.getPath());
- Assert.assertEquals(content, FileUtils.readFileToString(destFile, StandardCharsets.UTF_8));
+ Assertions.assertEquals(content, FileUtils.readFileToString(destFile, StandardCharsets.UTF_8));
FilePart destPart = new FilePart(null, destFile);
destPart.delete();
- Assert.assertFalse(destFile.exists());
+ Assertions.assertFalse(destFile.exists());
}
@Test
public void deleteAfterFinished() {
- Assert.assertFalse(part.isDeleteAfterFinished());
+ Assertions.assertFalse(part.isDeleteAfterFinished());
- Assert.assertTrue(part.setDeleteAfterFinished(true).isDeleteAfterFinished());
+ Assertions.assertTrue(part.setDeleteAfterFinished(true).isDeleteAfterFinished());
}
@Test
public void getAbsolutePath() {
- Assert.assertEquals(file.getAbsolutePath(), part.getAbsolutePath());
+ Assertions.assertEquals(file.getAbsolutePath(), part.getAbsolutePath());
}
}
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/part/TestInputStreamPart.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/part/TestInputStreamPart.java
index f7e9a970e..6af3016ec 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/part/TestInputStreamPart.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/part/TestInputStreamPart.java
@@ -22,8 +22,8 @@ import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.io.IOUtils;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestInputStreamPart {
String name = "paramName";
@@ -36,14 +36,14 @@ public class TestInputStreamPart {
@Test
public void getName() {
- Assert.assertEquals(name, part.getName());
+ Assertions.assertEquals(name, part.getName());
}
@Test
public void test() throws IOException {
try (InputStream is = part.getInputStream()) {
byte[] content = IOUtils.toByteArray(is);
- Assert.assertArrayEquals(bytes, content);
+ Assertions.assertArrayEquals(bytes, content);
}
}
}
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/part/TestResourcePart.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/part/TestResourcePart.java
index 2608bba11..e0d398e69 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/part/TestResourcePart.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/part/TestResourcePart.java
@@ -21,8 +21,8 @@ import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.io.IOUtils;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.Resource;
@@ -37,14 +37,14 @@ public class TestResourcePart {
@Test
public void getName() {
- Assert.assertEquals(name, part.getName());
+ Assertions.assertEquals(name, part.getName());
}
@Test
public void getInputStream() throws IOException {
try (InputStream is = part.getInputStream()) {
byte[] content = IOUtils.toByteArray(is);
- Assert.assertArrayEquals(bytes, content);
+ Assertions.assertArrayEquals(bytes, content);
}
}
}
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/spring/TestPaasNamespaceHandler.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/spring/TestPaasNamespaceHandler.java
index 93729f031..a22324564 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/spring/TestPaasNamespaceHandler.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/spring/TestPaasNamespaceHandler.java
@@ -18,9 +18,9 @@
package org.apache.servicecomb.foundation.common.spring;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
public class TestPaasNamespaceHandler {
@@ -44,6 +44,6 @@ public class TestPaasNamespaceHandler {
} catch (Exception e) {
status = true;
}
- Assert.assertFalse(status);
+ Assertions.assertFalse(status);
}
}
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/Log4jUtilsTest.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/Log4jUtilsTest.java
index 0d1962f87..3fd0c5b5b 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/Log4jUtilsTest.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/Log4jUtilsTest.java
@@ -17,8 +17,6 @@
package org.apache.servicecomb.foundation.common.utils;
-import static org.junit.Assert.fail;
-
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@@ -26,9 +24,9 @@ import java.util.Properties;
import org.apache.log4j.PropertyConfigurator;
import org.apache.servicecomb.foundation.common.Holder;
import org.apache.servicecomb.foundation.common.config.impl.PropertiesLoader;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
import org.springframework.core.io.Resource;
import mockit.Deencapsulation;
@@ -66,28 +64,28 @@ public class Log4jUtilsTest {
@Mock
void configure(Properties properties) {
logConfigured.value = true;
- Assert.assertSame(properties, logProperties);
+ Assertions.assertSame(properties, logProperties);
}
};
new MockUp<Log4jUtils>() {
@Mock
void outputFile(List<Resource> resList, Properties properties) {
mergedFileWritten.value = true;
- Assert.assertSame(logResList, resList);
- Assert.assertSame(logProperties, properties);
+ Assertions.assertSame(logResList, resList);
+ Assertions.assertSame(logProperties, properties);
}
};
- Assert.assertFalse(Deencapsulation.getField(Log4jUtils.class, "inited"));
+ Assertions.assertFalse(Log4jUtils.isInited());
try {
Log4jUtils.init();
} catch (Exception e) {
- fail(e.getMessage());
+ Assertions.fail(e.getMessage());
}
- Assert.assertTrue(Deencapsulation.getField(Log4jUtils.class, "inited"));
- Assert.assertTrue(propertiesLoaded.value);
- Assert.assertTrue(logConfigured.value);
- Assert.assertTrue(mergedFileWritten.value);
+ Assertions.assertTrue(Log4jUtils.isInited());
+ Assertions.assertTrue(propertiesLoaded.value);
+ Assertions.assertTrue(logConfigured.value);
+ Assertions.assertTrue(mergedFileWritten.value);
}
@Test
@@ -109,27 +107,27 @@ public class Log4jUtilsTest {
@Mock
void configure(Properties properties) {
logConfigured.value = true;
- Assert.assertSame(properties, logProperties);
+ Assertions.assertSame(properties, logProperties);
}
};
new MockUp<Log4jUtils>() {
@Mock
void outputFile(List<Resource> resList, Properties properties) {
mergedFileWritten.value = true;
- Assert.assertSame(logResList, resList);
- Assert.assertSame(logProperties, properties);
+ Assertions.assertSame(logResList, resList);
+ Assertions.assertSame(logProperties, properties);
}
};
- Assert.assertFalse(Deencapsulation.getField(Log4jUtils.class, "inited"));
+ Assertions.assertFalse(Log4jUtils.isInited());
try {
Log4jUtils.init();
} catch (Exception e) {
- fail(e.getMessage());
+ Assertions.fail(e.getMessage());
}
- Assert.assertTrue(Deencapsulation.getField(Log4jUtils.class, "inited"));
- Assert.assertTrue(propertiesLoaded.value);
- Assert.assertTrue(logConfigured.value);
- Assert.assertFalse(mergedFileWritten.value);
+ Assertions.assertTrue(Log4jUtils.isInited());
+ Assertions.assertTrue(propertiesLoaded.value);
+ Assertions.assertTrue(logConfigured.value);
+ Assertions.assertFalse(mergedFileWritten.value);
}
}
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/ResourceUtilTest.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/ResourceUtilTest.java
index f2a579bd1..c5e7a1fd9 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/ResourceUtilTest.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/ResourceUtilTest.java
@@ -22,8 +22,8 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class ResourceUtilTest {
@@ -34,26 +34,26 @@ public class ResourceUtilTest {
@Test
public void loadResources_in_jar() throws IOException, URISyntaxException {
List<URI> uris = ResourceUtil.findResources("META-INF", p -> p.toString().endsWith("spring.factories"));
- Assert.assertEquals(1, uris.size());
- Assert.assertTrue(uris.get(0).toString().startsWith("jar:file:"));
- Assert.assertTrue(uris.get(0).toString().endsWith("!/META-INF/spring.factories"));
+ Assertions.assertEquals(1, uris.size());
+ Assertions.assertTrue(uris.get(0).toString().startsWith("jar:file:"));
+ Assertions.assertTrue(uris.get(0).toString().endsWith("!/META-INF/spring.factories"));
}
@Test
public void loadResources_in_disk() throws IOException, URISyntaxException {
List<URI> uris = ResourceUtil.findResourcesBySuffix("META-INF/spring", ".xml");
- Assert.assertEquals(1, uris.size());
+ Assertions.assertEquals(1, uris.size());
URI uri = uris.get(0);
- Assert.assertTrue("unexpected uri: " + uri, uri.toString().startsWith("file:"));
- Assert.assertTrue("unexpected uri: " + uri, uri.toString().endsWith("META-INF/spring/config.bean.xml"));
+ Assertions.assertTrue(uri.toString().startsWith("file:"), "unexpected uri: " + uri);
+ Assertions.assertTrue(uri.toString().endsWith("META-INF/spring/config.bean.xml"), "unexpected uri: " + uri);
}
@Test
public void loadResources_exact_file_in_disk() throws IOException, URISyntaxException {
List<URI> uris = ResourceUtil.findResources("META-INF/spring/config.bean.xml");
- Assert.assertEquals(1, uris.size());
+ Assertions.assertEquals(1, uris.size());
URI uri = uris.get(0);
- Assert.assertTrue("unexpected uri: " + uri, uri.toString().startsWith("file:"));
- Assert.assertTrue("unexpected uri: " + uri, uri.toString().endsWith("META-INF/spring/config.bean.xml"));
+ Assertions.assertTrue(uri.toString().startsWith("file:"), "unexpected uri: " + uri);
+ Assertions.assertTrue(uri.toString().endsWith("META-INF/spring/config.bean.xml"), "unexpected uri: " + uri);
}
}
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestBeanUtils.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestBeanUtils.java
index 826ac2289..f1e72ef03 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestBeanUtils.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestBeanUtils.java
@@ -20,9 +20,9 @@ import java.math.BigDecimal;
import org.aspectj.lang.annotation.Aspect;
import org.junit.AfterClass;
-import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
import org.springframework.aop.SpringProxy;
import org.springframework.aop.aspectj.annotation.AspectJProxyFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -71,8 +71,8 @@ public class TestBeanUtils {
factory.addAspect(aspect);
Intf proxy = factory.getProxy();
- Assert.assertEquals(Impl.class, BeanUtils.getImplClassFromBean(proxy));
- Assert.assertEquals(Impl.class, BeanUtils.getImplClassFromBean(new Impl()));
+ Assertions.assertEquals(Impl.class, BeanUtils.getImplClassFromBean(proxy));
+ Assertions.assertEquals(Impl.class, BeanUtils.getImplClassFromBean(new Impl()));
}
@Test
@@ -89,7 +89,7 @@ public class TestBeanUtils {
BeanUtils.prepareServiceCombScanPackage();
- Assert.assertEquals("org.apache.servicecomb", System.getProperty(BeanUtils.SCB_SCAN_PACKAGE));
+ Assertions.assertEquals("org.apache.servicecomb", System.getProperty(BeanUtils.SCB_SCAN_PACKAGE));
}
@Test
@@ -106,7 +106,7 @@ public class TestBeanUtils {
BeanUtils.prepareServiceCombScanPackage();
- Assert.assertEquals("org.apache.servicecomb", System.getProperty(BeanUtils.SCB_SCAN_PACKAGE));
+ Assertions.assertEquals("org.apache.servicecomb", System.getProperty(BeanUtils.SCB_SCAN_PACKAGE));
}
@Test
@@ -123,7 +123,7 @@ public class TestBeanUtils {
BeanUtils.prepareServiceCombScanPackage();
- Assert.assertEquals("org.apache.servicecomb,java.lang,java.math", System.getProperty(BeanUtils.SCB_SCAN_PACKAGE));
+ Assertions.assertEquals("org.apache.servicecomb,java.lang,java.math", System.getProperty(BeanUtils.SCB_SCAN_PACKAGE));
}
@Test
@@ -140,7 +140,7 @@ public class TestBeanUtils {
BeanUtils.prepareServiceCombScanPackage();
- Assert.assertEquals("a.b,c.d,org.apache.servicecomb", System.getProperty(BeanUtils.SCB_SCAN_PACKAGE));
+ Assertions.assertEquals("a.b,c.d,org.apache.servicecomb", System.getProperty(BeanUtils.SCB_SCAN_PACKAGE));
}
@Test
@@ -156,15 +156,15 @@ public class TestBeanUtils {
};
BeanUtils.init();
- Assert.assertEquals("org.apache.servicecomb", System.getProperty(BeanUtils.SCB_SCAN_PACKAGE));
+ Assertions.assertEquals("org.apache.servicecomb", System.getProperty(BeanUtils.SCB_SCAN_PACKAGE));
}
@Test
public void testGetImplClassFromBeanFromCglib(){
TestBean testBeanByCGLIB = new TestBean$$TestBeanByCGLIB$$e1a36bab();
Class<?> generatedClass = BeanUtils.getImplClassFromBean(testBeanByCGLIB);
- Assert.assertNotNull(generatedClass);
- Assert.assertEquals(TestBean.class, generatedClass);
+ Assertions.assertNotNull(generatedClass);
+ Assertions.assertEquals(TestBean.class, generatedClass);
}
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestExceptionUtils.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestExceptionUtils.java
index 1d075444b..a9746b078 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestExceptionUtils.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestExceptionUtils.java
@@ -19,16 +19,16 @@ package org.apache.servicecomb.foundation.common.utils;
import java.io.IOException;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestExceptionUtils {
@Test
public void testExceptionUtils() {
Exception e = new Exception("Hello");
- Assert.assertEquals("cause:Exception,message:Hello", ExceptionUtils.getExceptionMessageWithoutTrace(e));
+ Assertions.assertEquals("cause:Exception,message:Hello", ExceptionUtils.getExceptionMessageWithoutTrace(e));
Exception e2 = new Exception("FAIL", new IOException("IO"));
- Assert.assertEquals("cause:Exception,message:FAIL;cause:IOException,message:IO",
+ Assertions.assertEquals("cause:Exception,message:FAIL;cause:IOException,message:IO",
ExceptionUtils.getExceptionMessageWithoutTrace(e2));
}
}
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestFileNameTooLong.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestFileNameTooLong.java
index bf13d8808..7ad60568d 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestFileNameTooLong.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestFileNameTooLong.java
@@ -22,8 +22,8 @@ import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,18 +41,18 @@ public class TestFileNameTooLong {
LOGGER.error(folder.getAbsolutePath()); // $ROOT\foundations\foundation-common
File root = new File(folder.getParentFile().getParent());
LOGGER.error(root.getAbsolutePath()); // $ROOT\foundations\foundation-common
- Assert.assertTrue(root.exists());
- Assert.assertTrue(root.isDirectory());
+ Assertions.assertTrue(root.exists());
+ Assertions.assertTrue(root.isDirectory());
List<String> names = new LinkedList<>();
findLongFileName(root, names, root.getAbsolutePath().length());
Collections.sort(names);
- names.forEach(e -> LOGGER.error(e));
+ names.forEach(LOGGER::error);
if (!names.isEmpty()) {
// for debug
- Assert.assertEquals("", names.toString());
+ Assertions.assertEquals("", names.toString());
}
- Assert.assertTrue(names.isEmpty());
+ Assertions.assertTrue(names.isEmpty());
}
private static void findLongFileName(File folder, List<String> holder, int baseLenght) {
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestFortifyUtils.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestFortifyUtils.java
index 03b568b40..4af04181d 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestFortifyUtils.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestFortifyUtils.java
@@ -17,26 +17,23 @@
package org.apache.servicecomb.foundation.common.utils;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
import java.io.IOException;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestFortifyUtils {
@Test
public void testFortifyUtils() throws IOException {
- Assert.assertEquals("", FortifyUtils.getErrorMsg(null));
- Assert.assertEquals("", FortifyUtils.getErrorStack(null));
+ Assertions.assertEquals("", FortifyUtils.getErrorMsg(null));
+ Assertions.assertEquals("", FortifyUtils.getErrorStack(null));
}
@Test
public void testFilePerm() {
- Assert.assertEquals(10, (FilePerm.getDefaultAclPerm().size()));
- Assert.assertEquals(3, (FilePerm.getDefaultPosixPerm().size()));
- Assert.assertEquals(4, (FilePerm.getPosixPerm(400).size()));
+ Assertions.assertEquals(10, (FilePerm.getDefaultAclPerm().size()));
+ Assertions.assertEquals(3, (FilePerm.getDefaultPosixPerm().size()));
+ Assertions.assertEquals(4, (FilePerm.getPosixPerm(400).size()));
}
@Test
@@ -46,7 +43,7 @@ public class TestFortifyUtils {
FortifyUtils.getErrorMsg(e);
- assertNull(FortifyUtils.getErrorMsg(e));
+ Assertions.assertNull(FortifyUtils.getErrorMsg(e));
}
@Test
@@ -54,10 +51,10 @@ public class TestFortifyUtils {
try {
FortifyUtils.getSecurityXmlDocumentFactory();
- assertNotNull(FortifyUtils.getSecurityXmlDocumentFactory());
+ Assertions.assertNotNull(FortifyUtils.getSecurityXmlDocumentFactory());
} catch (Exception e) {
/* Do not Worry */
- Assert.assertTrue(false);
+ Assertions.assertTrue(false);
}
}
@@ -66,7 +63,7 @@ public class TestFortifyUtils {
Throwable e = new Throwable();
FortifyUtils.getErrorStack(e);
- Assert.assertNotEquals(true, FortifyUtils.getErrorStack(e));
+ Assertions.assertNotEquals(true, FortifyUtils.getErrorStack(e));
}
@Test
@@ -74,6 +71,5 @@ public class TestFortifyUtils {
Throwable e = new Throwable();
FortifyUtils.getErrorInfo(e, true);
- Assert.assertNotEquals(true, FortifyUtils.getErrorInfo(e, true));
}
}
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestGenericsUtils.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestGenericsUtils.java
index d54320afb..06de9612d 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestGenericsUtils.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestGenericsUtils.java
@@ -20,22 +20,22 @@ package org.apache.servicecomb.foundation.common.utils;
import java.util.List;
import java.util.Map;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.springframework.core.ParameterizedTypeReference;
public class TestGenericsUtils {
@Test
public void testIsGenerics() {
- Assert.assertTrue(GenericsUtils.isGenericResponseType(List.class));
- Assert.assertTrue(GenericsUtils.isGenericResponseType(Map.class));
- Assert.assertTrue(GenericsUtils.isGenericResponseType(Person.class));
+ Assertions.assertTrue(GenericsUtils.isGenericResponseType(List.class));
+ Assertions.assertTrue(GenericsUtils.isGenericResponseType(Map.class));
+ Assertions.assertTrue(GenericsUtils.isGenericResponseType(Person.class));
- Assert.assertFalse(GenericsUtils.isGenericResponseType(Man.class));
- Assert.assertFalse(GenericsUtils.isGenericResponseType(String.class));
- Assert.assertFalse(GenericsUtils.isGenericResponseType(GenericsUtils.class));
+ Assertions.assertFalse(GenericsUtils.isGenericResponseType(Man.class));
+ Assertions.assertFalse(GenericsUtils.isGenericResponseType(String.class));
+ Assertions.assertFalse(GenericsUtils.isGenericResponseType(GenericsUtils.class));
- Assert.assertFalse(GenericsUtils.isGenericResponseType(new ParameterizedTypeReference<List<Man>>() {
+ Assertions.assertFalse(GenericsUtils.isGenericResponseType(new ParameterizedTypeReference<List<Man>>() {
}.getType()));
}
}
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestIOUtils.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestIOUtils.java
index fe4f0e4dc..42c7abe5d 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestIOUtils.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestIOUtils.java
@@ -17,29 +17,28 @@
package org.apache.servicecomb.foundation.common.utils;
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestIOUtils {
@Test
public void testAnonymousPath() {
- assertEquals(":/:/r/2/y/b/y/0/s/microservice.yaml",
+ Assertions.assertEquals(":/:/r/2/y/b/y/0/s/microservice.yaml",
IOUtils.anonymousPath("jar:file:/D:/User/.m2/repository/servicecomb"
+ "/transport-highway/2.3.0/classes/microservice.yaml"));
- assertEquals(":/:/r/microservice.yaml", IOUtils.anonymousPath("file:/D:/User/microservice.yaml"));
+ Assertions.assertEquals(":/:/r/microservice.yaml", IOUtils.anonymousPath("file:/D:/User/microservice.yaml"));
- assertEquals(":\\:\\r\\microservice.yaml", IOUtils.anonymousPath("file:\\D:\\User\\microservice.yaml"));
+ Assertions.assertEquals(":\\:\\r\\microservice.yaml", IOUtils.anonymousPath("file:\\D:\\User\\microservice.yaml"));
- assertEquals("r\\t\\a.txt", IOUtils.anonymousPath("user\\test\\a.txt"));
+ Assertions.assertEquals("r\\t\\a.txt", IOUtils.anonymousPath("user\\test\\a.txt"));
- assertEquals(":\\:\\a.txt", IOUtils.anonymousPath("file:\\D:\\a.txt"));
+ Assertions.assertEquals(":\\:\\a.txt", IOUtils.anonymousPath("file:\\D:\\a.txt"));
- assertEquals(":\\a.txt", IOUtils.anonymousPath("D:\\a.txt"));
+ Assertions.assertEquals(":\\a.txt", IOUtils.anonymousPath("D:\\a.txt"));
- assertEquals("a.txt", IOUtils.anonymousPath("a.txt"));
+ Assertions.assertEquals("a.txt", IOUtils.anonymousPath("a.txt"));
}
}
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestJvmUtils.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestJvmUtils.java
index 736c9ec70..0eee21530 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestJvmUtils.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestJvmUtils.java
@@ -25,9 +25,9 @@ import java.util.jar.JarFile;
import org.apache.servicecomb.foundation.test.scaffolding.exception.RuntimeExceptionWithoutStackTrace;
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 org.junit.jupiter.api.Assertions;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
@@ -58,13 +58,13 @@ public class TestJvmUtils {
@Test
public void findMainClass_notExist() {
- Assert.assertNull(JvmUtils.findMainClass());
+ Assertions.assertNull(JvmUtils.findMainClass());
}
@Test
public void findMainClass_existButEmpty() {
System.setProperty(JvmUtils.SUN_JAVA_COMMAND, "");
- Assert.assertNull(JvmUtils.findMainClass());
+ Assertions.assertNull(JvmUtils.findMainClass());
}
@Test
@@ -73,8 +73,8 @@ public class TestJvmUtils {
System.setProperty(JvmUtils.SUN_JAVA_COMMAND, "invalidCls");
- Assert.assertNull(JvmUtils.findMainClass());
- Assert.assertEquals("\"invalidCls\" is not a valid class.", logCollector.getEvents().get(0).getMessage());
+ Assertions.assertNull(JvmUtils.findMainClass());
+ Assertions.assertEquals("\"invalidCls\" is not a valid class.", logCollector.getEvents().get(0).getMessage());
logCollector.teardown();
}
@@ -82,7 +82,7 @@ public class TestJvmUtils {
public void findMainClass_class_normal() {
System.setProperty(JvmUtils.SUN_JAVA_COMMAND, TestJvmUtils.class.getName() + " arg");
- Assert.assertEquals(TestJvmUtils.class, JvmUtils.findMainClass());
+ Assertions.assertEquals(TestJvmUtils.class, JvmUtils.findMainClass());
}
@Test
@@ -101,7 +101,7 @@ public class TestJvmUtils {
System.setProperty(JvmUtils.SUN_JAVA_COMMAND, command + " arg");
- Assert.assertEquals(TestJvmUtils.class, JvmUtils.findMainClass());
+ Assertions.assertEquals(TestJvmUtils.class, JvmUtils.findMainClass());
}
@Test
@@ -120,7 +120,7 @@ public class TestJvmUtils {
System.setProperty(JvmUtils.SUN_JAVA_COMMAND, command + " arg");
- Assert.assertNull(JvmUtils.findMainClass());
+ Assertions.assertNull(JvmUtils.findMainClass());
}
@Test
@@ -136,7 +136,7 @@ public class TestJvmUtils {
System.setProperty(JvmUtils.SUN_JAVA_COMMAND, command + " arg");
- Assert.assertNull(JvmUtils.findMainClass());
+ Assertions.assertNull(JvmUtils.findMainClass());
}
@@ -149,7 +149,7 @@ public class TestJvmUtils {
});
PowerMockito.whenNew(RuntimeException.class).withNoArguments().thenReturn(re);
- Assert.assertEquals(String.class, JvmUtils.findMainClassByStackTrace());
+ Assertions.assertEquals(String.class, JvmUtils.findMainClassByStackTrace());
}
@Test
@@ -161,7 +161,7 @@ public class TestJvmUtils {
});
PowerMockito.whenNew(RuntimeException.class).withNoArguments().thenReturn(re);
- Assert.assertNull(JvmUtils.findMainClassByStackTrace());
+ Assertions.assertNull(JvmUtils.findMainClassByStackTrace());
}
@@ -174,7 +174,7 @@ public class TestJvmUtils {
});
PowerMockito.whenNew(RuntimeException.class).withNoArguments().thenReturn(re);
- Assert.assertNull(JvmUtils.findMainClassByStackTrace());
+ Assertions.assertNull(JvmUtils.findMainClassByStackTrace());
}
@Test
@@ -183,7 +183,7 @@ public class TestJvmUtils {
PowerMockito.when(re.getStackTrace()).thenReturn(new StackTraceElement[]{});
PowerMockito.whenNew(RuntimeException.class).withNoArguments().thenReturn(re);
- Assert.assertNull(JvmUtils.findMainClassByStackTrace());
+ Assertions.assertNull(JvmUtils.findMainClassByStackTrace());
}
@Test
@@ -192,7 +192,7 @@ public class TestJvmUtils {
PowerMockito.when(re.getStackTrace()).thenReturn(null);
PowerMockito.whenNew(RuntimeException.class).withNoArguments().thenReturn(re);
- Assert.assertNull(JvmUtils.findMainClassByStackTrace());
+ Assertions.assertNull(JvmUtils.findMainClassByStackTrace());
}
}
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestMimeTypesUtils.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestMimeTypesUtils.java
index 2b5efe27f..55d88f6ef 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestMimeTypesUtils.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestMimeTypesUtils.java
@@ -17,82 +17,80 @@
package org.apache.servicecomb.foundation.common.utils;
-import static org.junit.Assert.assertEquals;
-
import java.util.Collections;
import java.util.List;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestMimeTypesUtils {
@Test
public void testSortedAcceptableMimeTypes1() {
String accept = "text/html";
List<String> types = MimeTypesUtils.getSortedAcceptableMimeTypes(accept);
- assertEquals(1, types.size());
- assertEquals("text/html", types.get(0));
+ Assertions.assertEquals(1, types.size());
+ Assertions.assertEquals("text/html", types.get(0));
}
@Test
public void testSortedAcceptableMimeTypes2() {
String accept = "text/html, application/json";
List<String> types = MimeTypesUtils.getSortedAcceptableMimeTypes(accept);
- assertEquals(2, types.size());
- assertEquals("text/html", types.get(0));
- assertEquals("application/json", types.get(1));
+ Assertions.assertEquals(2, types.size());
+ Assertions.assertEquals("text/html", types.get(0));
+ Assertions.assertEquals("application/json", types.get(1));
}
@Test
public void testSortedAcceptableMimeTypes3() {
String accept = "text/html,application/json";
List<String> types = MimeTypesUtils.getSortedAcceptableMimeTypes(accept);
- assertEquals(2, types.size());
- assertEquals("text/html", types.get(0));
- assertEquals("application/json", types.get(1));
+ Assertions.assertEquals(2, types.size());
+ Assertions.assertEquals("text/html", types.get(0));
+ Assertions.assertEquals("application/json", types.get(1));
}
@Test
public void testSortedAcceptableMimeTypes4() {
String accept = "text/html; q=0.8,application/json; q=0.9";
List<String> types = MimeTypesUtils.getSortedAcceptableMimeTypes(accept);
- assertEquals(2, types.size());
- assertEquals("application/json", types.get(0));
- assertEquals("text/html", types.get(1));
+ Assertions.assertEquals(2, types.size());
+ Assertions.assertEquals("application/json", types.get(0));
+ Assertions.assertEquals("text/html", types.get(1));
}
@Test
public void testSortedAcceptableMimeTypes5() {
String accept = "text/html;q=0.8,application/json;q=0.9";
List<String> types = MimeTypesUtils.getSortedAcceptableMimeTypes(accept);
- assertEquals(2, types.size());
- assertEquals("application/json", types.get(0));
- assertEquals("text/html", types.get(1));
+ Assertions.assertEquals(2, types.size());
+ Assertions.assertEquals("application/json", types.get(0));
+ Assertions.assertEquals("text/html", types.get(1));
}
@Test
public void testSortedAcceptableMimeTypes6() {
String accept = "text/html; q=0.8,application/json; q=0.9, text/plain";
List<String> types = MimeTypesUtils.getSortedAcceptableMimeTypes(accept);
- assertEquals(3, types.size());
- assertEquals("text/plain", types.get(0));
- assertEquals("application/json", types.get(1));
- assertEquals("text/html", types.get(2));
+ Assertions.assertEquals(3, types.size());
+ Assertions.assertEquals("text/plain", types.get(0));
+ Assertions.assertEquals("application/json", types.get(1));
+ Assertions.assertEquals("text/html", types.get(2));
}
@Test
public void testSortedAcceptableMimeTypes7() {
String accept = "text/html;q=0.8,application/json;q=0.9,text/plain";
List<String> types = MimeTypesUtils.getSortedAcceptableMimeTypes(accept);
- assertEquals(3, types.size());
- assertEquals("text/plain", types.get(0));
- assertEquals("application/json", types.get(1));
- assertEquals("text/html", types.get(2));
+ Assertions.assertEquals(3, types.size());
+ Assertions.assertEquals("text/plain", types.get(0));
+ Assertions.assertEquals("application/json", types.get(1));
+ Assertions.assertEquals("text/html", types.get(2));
}
@Test
public void getSortedAcceptableMimeTypesNull() {
List<String> types = MimeTypesUtils.getSortedAcceptableMimeTypes(null);
- Assert.assertSame(Collections.emptyList(), types);
+ Assertions.assertSame(Collections.emptyList(), types);
}
}
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestRSAUtil.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestRSAUtil.java
index 2d43ff9d7..b259c5edb 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestRSAUtil.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestRSAUtil.java
@@ -16,14 +16,14 @@
*/
package org.apache.servicecomb.foundation.common.utils;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SignatureException;
import java.security.spec.InvalidKeySpecException;
-import org.junit.Assert;
-import org.junit.Test;
-
public class TestRSAUtil {
@Test
@@ -31,12 +31,12 @@ public class TestRSAUtil {
throws InvalidKeyException, NoSuchAlgorithmException, InvalidKeySpecException, SignatureException {
RSAKeyPairEntry rsaKeyPairEntry = RSAUtils.generateRSAKeyPair();
- Assert.assertNotNull(rsaKeyPairEntry.getPublicKeyEncoded());
- Assert.assertNotNull(rsaKeyPairEntry.getPrivateKey());
- Assert.assertNotNull(rsaKeyPairEntry.getPublicKey());
+ Assertions.assertNotNull(rsaKeyPairEntry.getPublicKeyEncoded());
+ Assertions.assertNotNull(rsaKeyPairEntry.getPrivateKey());
+ Assertions.assertNotNull(rsaKeyPairEntry.getPublicKey());
String testContent = "instance-id@201711201930@randomstr";
String signstr = RSAUtils.sign(testContent, rsaKeyPairEntry.getPrivateKey());
- Assert.assertTrue(RSAUtils.verify(rsaKeyPairEntry.getPublicKeyEncoded(), signstr, testContent));
+ Assertions.assertTrue(RSAUtils.verify(rsaKeyPairEntry.getPublicKeyEncoded(), signstr, testContent));
}
@Test
@@ -48,6 +48,6 @@ public class TestRSAUtil {
"e8a04b54cf2711e7b701286ed488fc20@c8636e5acf1f11e7b701286ed488fc20@1511315597475@9t0tp8ce80SUM5ts6iRGjFJMvCdQ7uvhpyh0RM7smKm3p4wYOrojr4oT1Pnwx7xwgcgEFbQdwPJxIMfivpQ1rHGqiLp67cjACvJ3Ke39pmeAVhybsLADfid6oSjscFaJ";
String pubKey =
"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCxKl5TNUTec7fL2degQcCk6vKf3c0wsfNK5V6elKzjWxm0MwbRj/UeR20VSnicBmVIOWrBS9LiERPPvjmmWUOSS2vxwr5XfhBhZ07gCAUNxBOTzgMo5nE45DhhZu5Jzt5qSV6o10Kq7+fCCBlDZ1UoWxZceHkUt5AxcrhEDulFjQIDAQAB";
- Assert.assertTrue(RSAUtils.verify(pubKey, sign, content));
+ Assertions.assertTrue(RSAUtils.verify(pubKey, sign, content));
}
}
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestRollingFileAppenderExt.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestRollingFileAppenderExt.java
index e7fe419b2..7c70752f8 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestRollingFileAppenderExt.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestRollingFileAppenderExt.java
@@ -21,11 +21,11 @@ import java.io.File;
import org.apache.log4j.Layout;
import org.apache.log4j.spi.LoggingEvent;
-import org.junit.Assert;
import org.junit.Test;
import mockit.Expectations;
import mockit.Injectable;
+import org.junit.jupiter.api.Assertions;
public class TestRollingFileAppenderExt {
@Test
@@ -47,15 +47,15 @@ public class TestRollingFileAppenderExt {
ext.setLogPermission("rw-------");
ext.setFile(temp.getAbsolutePath());
ext.setFile(temp.getAbsolutePath(), false, false, 300000);
- Assert.assertEquals(ext.getLogPermission(), "rw-------");
- Assert.assertTrue(temp.exists());
+ Assertions.assertEquals(ext.getLogPermission(), "rw-------");
+ Assertions.assertTrue(temp.exists());
temp.delete();
ext.subAppend(event);
- Assert.assertTrue(temp.exists());
+ Assertions.assertTrue(temp.exists());
ext.close();
temp.delete();
- Assert.assertFalse(temp.exists());
+ Assertions.assertFalse(temp.exists());
}
}
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestTypesUtil.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestTypesUtil.java
index c2fe52c58..487ad2885 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestTypesUtil.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestTypesUtil.java
@@ -16,17 +16,17 @@
*/
package org.apache.servicecomb.foundation.common.utils;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestTypesUtil {
@Test
public void testTypesUtil() {
- Assert.assertEquals(double.class, TypesUtil.wrapperTypeToPrimitive(Double.class));
- Assert.assertEquals(Float.class, TypesUtil.primitiveTypeToWrapper(float.class));
- Assert
+ Assertions.assertEquals(double.class, TypesUtil.wrapperTypeToPrimitive(Double.class));
+ Assertions.assertEquals(Float.class, TypesUtil.primitiveTypeToWrapper(float.class));
+ Assertions
.assertEquals(TypesUtil.PRIMITIVE_CHAR, TypesUtil.wrapperJavaTypeToPrimitive(TypesUtil.PRIMITIVE_WRAPPER_CHAR));
- Assert
+ Assertions
.assertEquals(TypesUtil.PRIMITIVE_WRAPPER_BYTE, TypesUtil.primitiveJavaTypeToWrapper(TypesUtil.PRIMITIVE_BYTE));
}
}
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/logback/TestMarkerFilter.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/logback/TestMarkerFilter.java
index eb48d1b74..99348db94 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/logback/TestMarkerFilter.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/logback/TestMarkerFilter.java
@@ -17,8 +17,8 @@
package org.apache.servicecomb.foundation.logback;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.slf4j.Marker;
@@ -31,16 +31,16 @@ public class TestMarkerFilter {
MarkerFilter filter = new MarkerFilter();
filter.setMarker("hello");
filter.start();
- Assert.assertEquals(filter.getOnMatch(), FilterReply.ACCEPT);
- Assert.assertEquals(filter.getOnMismatch(), FilterReply.DENY);
+ Assertions.assertEquals(filter.getOnMatch(), FilterReply.ACCEPT);
+ Assertions.assertEquals(filter.getOnMismatch(), FilterReply.DENY);
ILoggingEvent event = Mockito.mock(ILoggingEvent.class);
Marker marker = Mockito.mock(Marker.class);
Mockito.when(event.getMarker()).thenReturn(marker);
Mockito.when(marker.getName()).thenReturn("hello");
- Assert.assertEquals(FilterReply.ACCEPT, filter.decide(event));
+ Assertions.assertEquals(FilterReply.ACCEPT, filter.decide(event));
Mockito.when(event.getMarker()).thenReturn(null);
- Assert.assertEquals(FilterReply.DENY, filter.decide(event));
+ Assertions.assertEquals(FilterReply.DENY, filter.decide(event));
}
}
diff --git a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/TestConfigMapping.java b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/TestConfigMapping.java
index ff1601e96..1da5a2f59 100644
--- a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/TestConfigMapping.java
+++ b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/TestConfigMapping.java
@@ -17,24 +17,22 @@
package org.apache.servicecomb.config;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
import java.util.List;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestConfigMapping {
@Test
public void testMapping() {
List<String> value = ConfigMapping.map("SERVICECOMB_ENV");
- assertEquals(2, value.size());
- assertEquals("service_description.environment", value.get(0));
- assertEquals("service_description.environment.old", value.get(1));
+ Assertions.assertEquals(2, value.size());
+ Assertions.assertEquals("service_description.environment", value.get(0));
+ Assertions.assertEquals("service_description.environment.old", value.get(1));
Map<String, Object> m = ConfigMapping.getMapping();
- assertNotNull(m);
+ Assertions.assertNotNull(m);
}
@Test
@@ -42,7 +40,7 @@ public class TestConfigMapping {
String value = ConfigMapping.map("CSE_ENV_MAPPING");
Map<String, Object> m = ConfigMapping.getMapping();
Map<String, Object> m1 = ConfigMapping.getConvertedMap(m);
- assertEquals("servicecomb.testmapping.key", value);
- assertNotNull(m1);
+ Assertions.assertEquals("servicecomb.testmapping.key", value);
+ Assertions.assertNotNull(m1);
}
}
diff --git a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/TestConfigUtil.java b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/TestConfigUtil.java
index c292aa2ad..8df5fa0e3 100644
--- a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/TestConfigUtil.java
+++ b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/TestConfigUtil.java
@@ -91,18 +91,18 @@ public class TestConfigUtil {
@Test
public void testArrayData() {
Configuration configuration = ConfigUtil.createLocalConfig();
- Assert.assertEquals("a,b,c", configuration.getString("test.commonSeparatedString"));
- Assert.assertEquals(1, configuration.getStringArray("test.commonSeparatedString").length);
- Assert.assertEquals("a,b,c", configuration.getStringArray("test.commonSeparatedString")[0]);
-
- Assert.assertEquals("b,c,d", configuration.getString("test.commonSeparatedStringHolder"));
- Assert.assertEquals(1, configuration.getStringArray("test.commonSeparatedStringHolder").length);
- Assert.assertEquals("b,c,d", configuration.getStringArray("test.commonSeparatedStringHolder")[0]);
-
- Assert.assertEquals("m", configuration.getString("test.stringArray")); // first element
- Assert.assertEquals(2, configuration.getStringArray("test.stringArray").length);
- Assert.assertEquals("m", configuration.getStringArray("test.stringArray")[0]);
- Assert.assertEquals("n", configuration.getStringArray("test.stringArray")[1]);
+ Assertions.assertEquals("a,b,c", configuration.getString("test.commonSeparatedString"));
+ Assertions.assertEquals(1, configuration.getStringArray("test.commonSeparatedString").length);
+ Assertions.assertEquals("a,b,c", configuration.getStringArray("test.commonSeparatedString")[0]);
+
+ Assertions.assertEquals("b,c,d", configuration.getString("test.commonSeparatedStringHolder"));
+ Assertions.assertEquals(1, configuration.getStringArray("test.commonSeparatedStringHolder").length);
+ Assertions.assertEquals("b,c,d", configuration.getStringArray("test.commonSeparatedStringHolder")[0]);
+
+ Assertions.assertEquals("m", configuration.getString("test.stringArray")); // first element
+ Assertions.assertEquals(2, configuration.getStringArray("test.stringArray").length);
+ Assertions.assertEquals("m", configuration.getStringArray("test.stringArray")[0]);
+ Assertions.assertEquals("n", configuration.getStringArray("test.stringArray")[1]);
}
@Test
@@ -114,22 +114,22 @@ public class TestConfigUtil {
ConfigUtil.addConfig("cse.test.enabled", true);
ConfigUtil.addConfig("cse.test.num", 10);
AbstractConfiguration configuration = ConfigUtil.createLocalConfig();
- Assert.assertEquals(configuration.getString("service_description.name"), "service_name_test");
- Assert.assertTrue(configuration.getBoolean("cse.test.enabled"));
- Assert.assertEquals(configuration.getInt("cse.test.num"), 10);
+ Assertions.assertEquals(configuration.getString("service_description.name"), "service_name_test");
+ Assertions.assertTrue(configuration.getBoolean("cse.test.enabled"));
+ Assertions.assertEquals(configuration.getInt("cse.test.num"), 10);
}
@Test
public void testCreateDynamicConfigNoConfigCenterSPI() {
AbstractConfiguration dynamicConfig = ConfigUtil.createLocalConfig();
- Assert.assertNotEquals(DynamicWatchedConfiguration.class,
+ Assertions.assertNotEquals(DynamicWatchedConfiguration.class,
((ConcurrentCompositeConfiguration) dynamicConfig).getConfiguration(0).getClass());
}
@Test
public void testGetPropertyInvalidConfig() {
- Assert.assertNull(ConfigUtil.getProperty(null, "any"));
- Assert.assertNull(ConfigUtil.getProperty(new Object(), "any"));
+ Assertions.assertNull(ConfigUtil.getProperty(null, "any"));
+ Assertions.assertNull(ConfigUtil.getProperty(new Object(), "any"));
}
@Test
@@ -331,11 +331,11 @@ public class TestConfigUtil {
ConcurrentCompositeConfiguration localConfiguration = ConfigUtil.createLocalConfig();
- Assert.assertEquals(extraConfigValue, localConfiguration.getProperty(extraConfigKey));
- Assert.assertEquals(propertyHigherPriority, localConfiguration.getString(overriddenConfigKey));
+ Assertions.assertEquals(extraConfigValue, localConfiguration.getProperty(extraConfigKey));
+ Assertions.assertEquals(propertyHigherPriority, localConfiguration.getString(overriddenConfigKey));
// Test mapping key/value from self mappfing.xml
- Assert.assertEquals("https://myhost:8888", localConfiguration.getString(mapedKey1));
- Assert.assertEquals("https://myhost:8888", localConfiguration.getString(mapedKey2));
+ Assertions.assertEquals("https://myhost:8888", localConfiguration.getString(mapedKey1));
+ Assertions.assertEquals("https://myhost:8888", localConfiguration.getString(mapedKey2));
}
@SuppressWarnings("unchecked")
@@ -372,6 +372,6 @@ public class TestConfigUtil {
ConfigUtil.destroyConfigCenterConfigurationSource();
- Assert.assertEquals(2, count.get());
+ Assertions.assertEquals(2, count.get());
}
}
diff --git a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/TestLastPropertyPlaceholderConfigurer.java b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/TestLastPropertyPlaceholderConfigurer.java
index 223820c5b..fa6f3e2fe 100644
--- a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/TestLastPropertyPlaceholderConfigurer.java
+++ b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/TestLastPropertyPlaceholderConfigurer.java
@@ -20,8 +20,8 @@ package org.apache.servicecomb.config;
import java.io.IOException;
import java.util.Properties;
-import org.junit.Assert;
import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
import org.springframework.context.EmbeddedValueResolverAware;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
@@ -56,12 +56,12 @@ public class TestLastPropertyPlaceholderConfigurer {
new AnnotationConfigApplicationContext(this.getClass().getPackage().getName());
Bean bean = context.getBean(Bean.class);
- Assert.assertEquals("aValue", bean.resolver.resolveStringValue("${a}"));
+ Assertions.assertEquals("aValue", bean.resolver.resolveStringValue("${a}"));
try {
bean.resolver.resolveStringValue("${b}");
- Assert.fail("must throw exception");
+ Assertions.fail("must throw exception");
} catch (IllegalArgumentException e) {
- Assert.assertEquals("Could not resolve placeholder 'b' in value \"${b}\"", e.getMessage());
+ Assertions.assertEquals("Could not resolve placeholder 'b' in value \"${b}\"", e.getMessage());
}
context.close();
diff --git a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/TestYAMLUtil.java b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/TestYAMLUtil.java
index 356bd549b..6a5ad966e 100644
--- a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/TestYAMLUtil.java
+++ b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/TestYAMLUtil.java
@@ -17,12 +17,10 @@
package org.apache.servicecomb.config;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
import java.util.Map;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestYAMLUtil {
public static class Person {
@@ -52,36 +50,36 @@ public class TestYAMLUtil {
@Test
public void testSafeParser() {
Person person = YAMLUtil.parserObject("name: hello", Person.class);
- Assert.assertEquals("hello", person.getName());
+ Assertions.assertEquals("hello", person.getName());
person = YAMLUtil.parserObject("!!org.apache.servicecomb.config.TestYAMLUtil$Person\n"
+ "name: hello", Person.class);
- Assert.assertEquals("hello", person.getName());
+ Assertions.assertEquals("hello", person.getName());
person = YAMLUtil.parserObject("!!org.apache.servicecomb.config.TestYAMLUtil$UnsafePerson\n"
+ "name: hello", Person.class);
- Assert.assertEquals("hello", person.getName());
+ Assertions.assertEquals("hello", person.getName());
// using Object.class is not safe, do not used in product code.
Object object = YAMLUtil.parserObject("!!org.apache.servicecomb.config.TestYAMLUtil$UnsafePerson\n"
+ "name: hello", Object.class);
- Assert.assertEquals("hello", ((UnsafePerson) object).getName());
+ Assertions.assertEquals("hello", ((UnsafePerson) object).getName());
}
@Test
public void testYamlConfig() {
- RuntimeException runtimeException = assertThrows(RuntimeException.class, () -> {
+ RuntimeException runtimeException = Assertions.assertThrows(RuntimeException.class, () -> {
YAMLUtil.yaml2Properties("servicecomb.service.registry.enabled: {{true}}");
});
- Assert.assertEquals("input cannot be convert to map", runtimeException.getMessage());
+ Assertions.assertEquals("input cannot be convert to map", runtimeException.getMessage());
}
@Test
@SuppressWarnings("unchecked")
public void testListValue() {
Map<String, Object> result = YAMLUtil.yaml2Properties("hello: a,b");
- Assert.assertEquals(result.size(), 1);
+ Assertions.assertEquals(result.size(), 1);
String listValue = (String) result.get("hello");
- Assert.assertEquals(listValue, "a,b");
+ Assertions.assertEquals(listValue, "a,b");
}
}
diff --git a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/archaius/sources/TestMicroserviceConfigLoader.java b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/archaius/sources/TestMicroserviceConfigLoader.java
index cadfc2244..c9836bf4a 100644
--- a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/archaius/sources/TestMicroserviceConfigLoader.java
+++ b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/archaius/sources/TestMicroserviceConfigLoader.java
@@ -17,8 +17,6 @@
package org.apache.servicecomb.config.archaius.sources;
-import static org.junit.Assert.assertEquals;
-
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
@@ -27,8 +25,8 @@ import java.net.URL;
import java.util.List;
import java.util.stream.Collectors;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestMicroserviceConfigLoader {
@@ -49,7 +47,7 @@ public class TestMicroserviceConfigLoader {
loader.sort();
- assertEquals(urls("jar:c", "jar:b", "jar:a"), urlsOf(loader.getConfigModels()));
+ Assertions.assertEquals(urls("jar:c", "jar:b", "jar:a"), urlsOf(loader.getConfigModels()));
}
@Test
@@ -60,7 +58,7 @@ public class TestMicroserviceConfigLoader {
loader.sort();
- assertEquals(urls("jar:c", "jar:b", "jar:a"), urlsOf(loader.getConfigModels()));
+ Assertions.assertEquals(urls("jar:c", "jar:b", "jar:a"), urlsOf(loader.getConfigModels()));
}
@Test
@@ -71,7 +69,7 @@ public class TestMicroserviceConfigLoader {
loader.sort();
- assertEquals(urls("jar:j1", "file:f2", "file:f1"), urlsOf(loader.getConfigModels()));
+ Assertions.assertEquals(urls("jar:j1", "file:f2", "file:f1"), urlsOf(loader.getConfigModels()));
}
private String urlsOf(List<ConfigModel> configModels) {
@@ -89,7 +87,7 @@ public class TestMicroserviceConfigLoader {
@Test
public void testLoadEmptyYaml() throws IOException {
loader.load("empty.yaml");
- Assert.assertTrue(loader.getConfigModels().get(0).getConfig().isEmpty());
+ Assertions.assertTrue(loader.getConfigModels().get(0).getConfig().isEmpty());
}
@Test
@@ -97,9 +95,9 @@ public class TestMicroserviceConfigLoader {
URL url = URI.create("file:/notExist.yaml").toURL();
try {
loader.load(url);
- Assert.fail("must throw exception");
+ Assertions.fail("must throw exception");
} catch (FileNotFoundException e) {
- Assert.assertTrue(true);
+ Assertions.assertTrue(true);
}
}
}
diff --git a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/archaius/sources/TestYAMLConfigurationSource.java b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/archaius/sources/TestYAMLConfigurationSource.java
index f04aa7d40..635b822c8 100644
--- a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/archaius/sources/TestYAMLConfigurationSource.java
+++ b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/archaius/sources/TestYAMLConfigurationSource.java
@@ -17,23 +17,19 @@
package org.apache.servicecomb.config.archaius.sources;
-import static org.apache.servicecomb.config.archaius.sources.ConfigSourceMaker.yamlConfigSource;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
import java.net.URL;
import java.util.List;
import java.util.Map;
import org.apache.commons.configuration.SystemConfiguration;
import org.apache.servicecomb.config.archaius.scheduler.NeverStartPollingScheduler;
-import org.junit.Assert;
import org.junit.Test;
import com.netflix.config.ConcurrentCompositeConfiguration;
import com.netflix.config.ConcurrentMapConfiguration;
import com.netflix.config.DynamicConfiguration;
import com.netflix.config.PollResult;
+import org.junit.jupiter.api.Assertions;
/**
* Created by on 2017/1/5.
@@ -42,13 +38,16 @@ public class TestYAMLConfigurationSource {
@Test
public void testPullFromClassPath() throws Exception {
- MicroserviceConfigurationSource configSource = yamlConfigSource();
+ MicroserviceConfigLoader loader = new MicroserviceConfigLoader();
+ loader.loadAndSort();
+
+ MicroserviceConfigurationSource configSource = new MicroserviceConfigurationSource(loader.getConfigModels());
PollResult result = configSource.poll(true, null);
Map<String, Object> configMap = result.getComplete();
- assertNotNull(configMap);
- assertEquals(29, configMap.size());
- assertNotNull(configMap.get("trace.handler.sampler.percent"));
- assertEquals(0.5, configMap.get("trace.handler.sampler.percent"));
+ Assertions.assertNotNull(configMap);
+ Assertions.assertEquals(29, configMap.size());
+ Assertions.assertNotNull(configMap.get("trace.handler.sampler.percent"));
+ Assertions.assertEquals(0.5, configMap.get("trace.handler.sampler.percent"));
}
@Test
@@ -57,15 +56,18 @@ public class TestYAMLConfigurationSource {
URL test1URL = loader.getResource("test1.yaml");
URL test2URL = loader.getResource("test2.yaml");
System.setProperty("servicecomb.configurationSource.additionalUrls", test1URL.toString() + "," + test2URL.toString());
- MicroserviceConfigurationSource configSource = yamlConfigSource();
+ MicroserviceConfigLoader loader1 = new MicroserviceConfigLoader();
+ loader1.loadAndSort();
+
+ MicroserviceConfigurationSource configSource = new MicroserviceConfigurationSource(loader1.getConfigModels());
PollResult result = configSource.poll(true, null);
Map<String, Object> configMap = result.getComplete();
- assertEquals(3, configSource.getConfigModels().size());
- assertNotNull(configMap);
- assertEquals(40, configMap.size());
- assertNotNull(configMap.get("trace.handler.sampler.percent"));
- assertEquals(0.5, configMap.get("trace.handler.sampler.percent"));
+ Assertions.assertEquals(3, configSource.getConfigModels().size());
+ Assertions.assertNotNull(configMap);
+ Assertions.assertEquals(40, configMap.size());
+ Assertions.assertNotNull(configMap.get("trace.handler.sampler.percent"));
+ Assertions.assertEquals(0.5, configMap.get("trace.handler.sampler.percent"));
System.getProperties().remove("servicecomb.configurationSource.additionalUrls");
}
@@ -76,18 +78,21 @@ public class TestYAMLConfigurationSource {
ConcurrentMapConfiguration configFromSystemProperties =
new ConcurrentMapConfiguration(new SystemConfiguration());
// configuration from yaml file
+ MicroserviceConfigLoader loader = new MicroserviceConfigLoader();
+ loader.loadAndSort();
+
DynamicConfiguration configFromYamlFile =
- new DynamicConfiguration(yamlConfigSource(), new NeverStartPollingScheduler());
+ new DynamicConfiguration(new MicroserviceConfigurationSource(loader.getConfigModels()), new NeverStartPollingScheduler());
// create a hierarchy of configuration that makes
// 1) dynamic configuration source override system properties
ConcurrentCompositeConfiguration finalConfig = new ConcurrentCompositeConfiguration();
finalConfig.addConfiguration(configFromYamlFile, "yamlConfig");
finalConfig.addConfiguration(configFromSystemProperties, "systemEnvConfig");
- Assert.assertEquals(0.5, finalConfig.getDouble("trace.handler.sampler.percent"), 0.5);
+ Assertions.assertEquals(0.5, finalConfig.getDouble("trace.handler.sampler.percent"), 0.5);
Object o = finalConfig.getProperty("zq");
@SuppressWarnings("unchecked")
List<Map<String, Object>> listO = (List<Map<String, Object>>) o;
- Assert.assertEquals(3, listO.size());
+ Assertions.assertEquals(3, listO.size());
}
}
diff --git a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/inject/TestConfigObjectFactory.java b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/inject/TestConfigObjectFactory.java
index 8ca76c6fe..b80bb60bf 100644
--- a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/inject/TestConfigObjectFactory.java
+++ b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/inject/TestConfigObjectFactory.java
@@ -20,7 +20,7 @@ import java.util.Arrays;
import org.apache.servicecomb.config.priority.TestPriorityPropertyBase;
import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class TestConfigObjectFactory extends TestPriorityPropertyBase {
@@ -162,33 +162,33 @@ public class TestConfigObjectFactory extends TestPriorityPropertyBase {
public void noAnnotation_defaultValue() {
ConfigNoAnnotation config = priorityPropertyManager.createConfigObject(ConfigNoAnnotation.class);
- Assert.assertNull(config.strValue);
- Assert.assertNull(config.getStrValue1());
-
- Assert.assertEquals(0, config.intValue);
- Assert.assertEquals(0, config.getIntValue1());
- Assert.assertNull(config.intValueObj);
- Assert.assertNull(config.getIntValueObj1());
-
- Assert.assertEquals(0, config.longValue);
- Assert.assertEquals(0, config.getLongValue1());
- Assert.assertNull(config.longValueObj);
- Assert.assertNull(config.getLongValueObj1());
-
- Assert.assertEquals(0, config.floatValue, 0);
- Assert.assertEquals(0, config.getFloatValue1(), 0);
- Assert.assertNull(config.floatValueObj);
- Assert.assertNull(config.getFloatValueObj1());
-
- Assert.assertEquals(0, config.doubleValue, 0);
- Assert.assertEquals(0, config.getDoubleValue1(), 0);
- Assert.assertNull(config.doubleValueObj);
- Assert.assertNull(config.getDoubleValueObj1());
-
- Assert.assertFalse(config.booleanValue);
- Assert.assertFalse(config.isBooleanValue1());
- Assert.assertNull(config.booleanValueObj);
- Assert.assertNull(config.getBooleanValueObj1());
+ Assertions.assertNull(config.strValue);
+ Assertions.assertNull(config.getStrValue1());
+
+ Assertions.assertEquals(0, config.intValue);
+ Assertions.assertEquals(0, config.getIntValue1());
+ Assertions.assertNull(config.intValueObj);
+ Assertions.assertNull(config.getIntValueObj1());
+
+ Assertions.assertEquals(0, config.longValue);
+ Assertions.assertEquals(0, config.getLongValue1());
+ Assertions.assertNull(config.longValueObj);
+ Assertions.assertNull(config.getLongValueObj1());
+
+ Assertions.assertEquals(0, config.floatValue, 0);
+ Assertions.assertEquals(0, config.getFloatValue1(), 0);
+ Assertions.assertNull(config.floatValueObj);
+ Assertions.assertNull(config.getFloatValueObj1());
+
+ Assertions.assertEquals(0, config.doubleValue, 0);
+ Assertions.assertEquals(0, config.getDoubleValue1(), 0);
+ Assertions.assertNull(config.doubleValueObj);
+ Assertions.assertNull(config.getDoubleValueObj1());
+
+ Assertions.assertFalse(config.booleanValue);
+ Assertions.assertFalse(config.isBooleanValue1());
+ Assertions.assertNull(config.booleanValueObj);
+ Assertions.assertNull(config.getBooleanValueObj1());
}
@Test
@@ -223,33 +223,33 @@ public class TestConfigObjectFactory extends TestPriorityPropertyBase {
ConfigNoAnnotation config = priorityPropertyManager.createConfigObject(ConfigNoAnnotation.class);
- Assert.assertEquals("strValue", config.strValue);
- Assert.assertEquals("strValue1", config.getStrValue1());
-
- Assert.assertEquals(1, config.intValue);
- Assert.assertEquals(2, config.getIntValue1());
- Assert.assertEquals(3, (int) config.intValueObj);
- Assert.assertEquals(4, (int) config.getIntValueObj1());
-
- Assert.assertEquals(5, config.longValue);
- Assert.assertEquals(6, config.getLongValue1());
- Assert.assertEquals(7, (long) config.longValueObj);
- Assert.assertEquals(8, (long) config.getLongValueObj1());
-
- Assert.assertEquals(9, config.floatValue, 0);
- Assert.assertEquals(10, config.getFloatValue1(), 0);
- Assert.assertEquals(11, config.floatValueObj, 0);
- Assert.assertEquals(12, config.getFloatValueObj1(), 0);
-
- Assert.assertEquals(13, config.doubleValue, 0);
- Assert.assertEquals(14, config.getDoubleValue1(), 0);
- Assert.assertEquals(15, config.doubleValueObj, 0);
- Assert.assertEquals(16, config.getDoubleValueObj1(), 0);
-
- Assert.assertTrue(config.booleanValue);
- Assert.assertTrue(config.isBooleanValue1());
- Assert.assertTrue(config.booleanValueObj);
- Assert.assertTrue(config.getBooleanValueObj1());
+ Assertions.assertEquals("strValue", config.strValue);
+ Assertions.assertEquals("strValue1", config.getStrValue1());
+
+ Assertions.assertEquals(1, config.intValue);
+ Assertions.assertEquals(2, config.getIntValue1());
+ Assertions.assertEquals(3, (int) config.intValueObj);
+ Assertions.assertEquals(4, (int) config.getIntValueObj1());
+
+ Assertions.assertEquals(5, config.longValue);
+ Assertions.assertEquals(6, config.getLongValue1());
+ Assertions.assertEquals(7, (long) config.longValueObj);
+ Assertions.assertEquals(8, (long) config.getLongValueObj1());
+
+ Assertions.assertEquals(9, config.floatValue, 0);
+ Assertions.assertEquals(10, config.getFloatValue1(), 0);
+ Assertions.assertEquals(11, config.floatValueObj, 0);
+ Assertions.assertEquals(12, config.getFloatValueObj1(), 0);
+
+ Assertions.assertEquals(13, config.doubleValue, 0);
+ Assertions.assertEquals(14, config.getDoubleValue1(), 0);
+ Assertions.assertEquals(15, config.doubleValueObj, 0);
+ Assertions.assertEquals(16, config.getDoubleValueObj1(), 0);
+
+ Assertions.assertTrue(config.booleanValue);
+ Assertions.assertTrue(config.isBooleanValue1());
+ Assertions.assertTrue(config.booleanValueObj);
+ Assertions.assertTrue(config.getBooleanValueObj1());
}
@Test
@@ -284,33 +284,33 @@ public class TestConfigObjectFactory extends TestPriorityPropertyBase {
ArchaiusUtils.setProperty("booleanValueObj", true);
ArchaiusUtils.setProperty("booleanValueObj1", true);
- Assert.assertEquals("strValue", config.strValue);
- Assert.assertEquals("strValue1", config.getStrValue1());
-
- Assert.assertEquals(1, config.intValue);
- Assert.assertEquals(2, config.getIntValue1());
- Assert.assertEquals(3, (int) config.intValueObj);
- Assert.assertEquals(4, (int) config.getIntValueObj1());
-
- Assert.assertEquals(5, config.longValue);
- Assert.assertEquals(6, config.getLongValue1());
- Assert.assertEquals(7, (long) config.longValueObj);
- Assert.assertEquals(8, (long) config.getLongValueObj1());
-
- Assert.assertEquals(9, config.floatValue, 0);
- Assert.assertEquals(10, config.getFloatValue1(), 0);
- Assert.assertEquals(11, config.floatValueObj, 0);
- Assert.assertEquals(12, config.getFloatValueObj1(), 0);
-
- Assert.assertEquals(13, config.doubleValue, 0);
- Assert.assertEquals(14, config.getDoubleValue1(), 0);
- Assert.assertEquals(15, config.doubleValueObj, 0);
- Assert.assertEquals(16, config.getDoubleValueObj1(), 0);
-
- Assert.assertTrue(config.booleanValue);
- Assert.assertTrue(config.isBooleanValue1());
- Assert.assertTrue(config.booleanValueObj);
- Assert.assertTrue(config.getBooleanValueObj1());
+ Assertions.assertEquals("strValue", config.strValue);
+ Assertions.assertEquals("strValue1", config.getStrValue1());
+
+ Assertions.assertEquals(1, config.intValue);
+ Assertions.assertEquals(2, config.getIntValue1());
+ Assertions.assertEquals(3, (int) config.intValueObj);
+ Assertions.assertEquals(4, (int) config.getIntValueObj1());
+
+ Assertions.assertEquals(5, config.longValue);
+ Assertions.assertEquals(6, config.getLongValue1());
+ Assertions.assertEquals(7, (long) config.longValueObj);
+ Assertions.assertEquals(8, (long) config.getLongValueObj1());
+
+ Assertions.assertEquals(9, config.floatValue, 0);
+ Assertions.assertEquals(10, config.getFloatValue1(), 0);
+ Assertions.assertEquals(11, config.floatValueObj, 0);
+ Assertions.assertEquals(12, config.getFloatValueObj1(), 0);
+
+ Assertions.assertEquals(13, config.doubleValue, 0);
+ Assertions.assertEquals(14, config.getDoubleValue1(), 0);
+ Assertions.assertEquals(15, config.doubleValueObj, 0);
+ Assertions.assertEquals(16, config.getDoubleValueObj1(), 0);
+
+ Assertions.assertTrue(config.booleanValue);
+ Assertions.assertTrue(config.isBooleanValue1());
+ Assertions.assertTrue(config.booleanValueObj);
+ Assertions.assertTrue(config.getBooleanValueObj1());
}
@InjectProperties(prefix = "root")
@@ -350,12 +350,12 @@ public class TestConfigObjectFactory extends TestPriorityPropertyBase {
public void annotationDefault() {
ConfigWithAnnotation config = priorityPropertyManager.createConfigObject(ConfigWithAnnotation.class);
- Assert.assertEquals("abc", config.strDef);
- Assert.assertEquals(1, config.intDef);
- Assert.assertEquals(2, config.longDef);
- Assert.assertEquals(3, config.floatDef, 0);
- Assert.assertEquals(4, config.doubleDef, 0);
- Assert.assertTrue(config.booleanDef);
+ Assertions.assertEquals("abc", config.strDef);
+ Assertions.assertEquals(1, config.intDef);
+ Assertions.assertEquals(2, config.longDef);
+ Assertions.assertEquals(3, config.floatDef, 0);
+ Assertions.assertEquals(4, config.doubleDef, 0);
+ Assertions.assertTrue(config.booleanDef);
}
@Test
@@ -368,19 +368,19 @@ public class TestConfigObjectFactory extends TestPriorityPropertyBase {
// low-2.a.high-1.b
// low-2.a.high-2.b
- Assert.assertEquals(0, config.longValue);
+ Assertions.assertEquals(0, config.longValue);
ArchaiusUtils.setProperty("root.low-2.a.high-2.b", Long.MAX_VALUE);
- Assert.assertEquals(Long.MAX_VALUE, config.longValue);
+ Assertions.assertEquals(Long.MAX_VALUE, config.longValue);
ArchaiusUtils.setProperty("root.low-2.a.high-1.b", Long.MAX_VALUE - 1);
- Assert.assertEquals(Long.MAX_VALUE - 1, config.longValue);
+ Assertions.assertEquals(Long.MAX_VALUE - 1, config.longValue);
ArchaiusUtils.setProperty("root.low-1.a.high-2.b", Long.MAX_VALUE - 2);
- Assert.assertEquals(Long.MAX_VALUE - 2, config.longValue);
+ Assertions.assertEquals(Long.MAX_VALUE - 2, config.longValue);
ArchaiusUtils.setProperty("root.low-1.a.high-1.b", Long.MAX_VALUE - 3);
- Assert.assertEquals(Long.MAX_VALUE - 3, config.longValue);
+ Assertions.assertEquals(Long.MAX_VALUE - 3, config.longValue);
}
@Test
@@ -388,23 +388,23 @@ public class TestConfigObjectFactory extends TestPriorityPropertyBase {
ConfigWithAnnotation config = priorityPropertyManager.createConfigObject(ConfigWithAnnotation.class,
"full-list", Arrays.asList("l1-1", "l1-2"));
- Assert.assertEquals(0, config.floatValue, 0);
+ Assertions.assertEquals(0, config.floatValue, 0);
ArchaiusUtils.setProperty("root.l1-2", String.valueOf(1f));
- Assert.assertEquals(1f, config.floatValue, 0);
+ Assertions.assertEquals(1f, config.floatValue, 0);
ArchaiusUtils.setProperty("root.l1-1", String.valueOf(2f));
- Assert.assertEquals(2f, config.floatValue, 0);
+ Assertions.assertEquals(2f, config.floatValue, 0);
}
@Test
public void placeholder_normal() {
ConfigWithAnnotation config = priorityPropertyManager.createConfigObject(ConfigWithAnnotation.class, "key", "k");
- Assert.assertEquals(0, config.intValue);
+ Assertions.assertEquals(0, config.intValue);
ArchaiusUtils.setProperty("root.k.value", "1");
- Assert.assertEquals(1, config.intValue);
+ Assertions.assertEquals(1, config.intValue);
}
@Test
@@ -412,15 +412,15 @@ public class TestConfigObjectFactory extends TestPriorityPropertyBase {
ConfigWithAnnotation config = priorityPropertyManager.createConfigObject(ConfigWithAnnotation.class);
ArchaiusUtils.setProperty("override.high", "high");
- Assert.assertEquals("high", config.strValue);
+ Assertions.assertEquals("high", config.strValue);
ArchaiusUtils.setProperty("override.high", null);
- Assert.assertNull(config.strValue);
+ Assertions.assertNull(config.strValue);
ArchaiusUtils.setProperty("override.low", "low");
- Assert.assertEquals("low", config.strValue);
+ Assertions.assertEquals("low", config.strValue);
ArchaiusUtils.setProperty("override.low", null);
- Assert.assertNull(config.strValue);
+ Assertions.assertNull(config.strValue);
}
}
diff --git a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityProperty.java b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityProperty.java
index 9f4db6352..4448a313d 100644
--- a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityProperty.java
+++ b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityProperty.java
@@ -20,7 +20,7 @@ import java.util.Collections;
import org.apache.commons.configuration.MapConfiguration;
import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import com.netflix.config.ConcurrentCompositeConfiguration;
@@ -38,181 +38,181 @@ public class TestPriorityProperty extends TestPriorityPropertyBase {
@Test
public void testLong() {
PriorityProperty<Long> config = propertyFactory.getOrCreate(Long.class, -1L, -2L, keys);
- Assert.assertEquals(-2L, (long) config.getValue());
+ Assertions.assertEquals(-2L, (long) config.getValue());
ArchaiusUtils.setProperty(low, 1L);
- Assert.assertEquals(1L, (long) config.getValue());
+ Assertions.assertEquals(1L, (long) config.getValue());
ArchaiusUtils.setProperty(middle, 2L);
- Assert.assertEquals(2L, (long) config.getValue());
+ Assertions.assertEquals(2L, (long) config.getValue());
ArchaiusUtils.setProperty(high, 3L);
- Assert.assertEquals(3L, (long) config.getValue());
+ Assertions.assertEquals(3L, (long) config.getValue());
ArchaiusUtils.setProperty(middle, null);
- Assert.assertEquals(3L, (long) config.getValue());
+ Assertions.assertEquals(3L, (long) config.getValue());
ArchaiusUtils.setProperty(middle, 2L);
ArchaiusUtils.setProperty(high, null);
- Assert.assertEquals(2L, (long) config.getValue());
+ Assertions.assertEquals(2L, (long) config.getValue());
ArchaiusUtils.setProperty(middle, null);
- Assert.assertEquals(1L, (long) config.getValue());
+ Assertions.assertEquals(1L, (long) config.getValue());
ArchaiusUtils.setProperty(low, null);
- Assert.assertEquals(-2L, (long) config.getValue());
+ Assertions.assertEquals(-2L, (long) config.getValue());
}
@Test
public void testInt() {
PriorityProperty<Integer> config = propertyFactory.getOrCreate(Integer.class, -1, -2, keys);
- Assert.assertEquals(-2L, (int) config.getValue());
+ Assertions.assertEquals(-2L, (int) config.getValue());
ArchaiusUtils.setProperty(low, 1);
- Assert.assertEquals(1, (int) config.getValue());
+ Assertions.assertEquals(1, (int) config.getValue());
ArchaiusUtils.setProperty(middle, 2);
- Assert.assertEquals(2, (int) config.getValue());
+ Assertions.assertEquals(2, (int) config.getValue());
ArchaiusUtils.setProperty(high, 3);
- Assert.assertEquals(3, (int) config.getValue());
+ Assertions.assertEquals(3, (int) config.getValue());
ArchaiusUtils.setProperty(middle, null);
- Assert.assertEquals(3, (int) config.getValue());
+ Assertions.assertEquals(3, (int) config.getValue());
ArchaiusUtils.setProperty(middle, 2);
ArchaiusUtils.setProperty(high, null);
- Assert.assertEquals(2, (int) config.getValue());
+ Assertions.assertEquals(2, (int) config.getValue());
ArchaiusUtils.setProperty(middle, null);
- Assert.assertEquals(1, (int) config.getValue());
+ Assertions.assertEquals(1, (int) config.getValue());
ArchaiusUtils.setProperty(low, null);
- Assert.assertEquals(-2, (int) config.getValue());
+ Assertions.assertEquals(-2, (int) config.getValue());
}
@Test
public void testString() {
PriorityProperty<String> config = propertyFactory.getOrCreate(String.class, null, "def", keys);
- Assert.assertEquals("def", config.getValue());
+ Assertions.assertEquals("def", config.getValue());
ArchaiusUtils.setProperty(low, 1);
- Assert.assertEquals("1", config.getValue());
+ Assertions.assertEquals("1", config.getValue());
ArchaiusUtils.setProperty(middle, 2);
- Assert.assertEquals("2", config.getValue());
+ Assertions.assertEquals("2", config.getValue());
ArchaiusUtils.setProperty(high, 3);
- Assert.assertEquals("3", config.getValue());
+ Assertions.assertEquals("3", config.getValue());
ArchaiusUtils.setProperty(middle, null);
- Assert.assertEquals("3", config.getValue());
+ Assertions.assertEquals("3", config.getValue());
ArchaiusUtils.setProperty(middle, 2);
ArchaiusUtils.setProperty(high, null);
- Assert.assertEquals("2", config.getValue());
+ Assertions.assertEquals("2", config.getValue());
ArchaiusUtils.setProperty(middle, null);
- Assert.assertEquals("1", config.getValue());
+ Assertions.assertEquals("1", config.getValue());
ArchaiusUtils.setProperty(low, null);
- Assert.assertEquals("def", config.getValue());
+ Assertions.assertEquals("def", config.getValue());
}
@Test
public void testBoolean() {
PriorityProperty<Boolean> config = propertyFactory.getOrCreate(Boolean.class, null, false, keys);
- Assert.assertFalse(config.getValue());
+ Assertions.assertFalse(config.getValue());
ArchaiusUtils.setProperty(low, true);
- Assert.assertTrue(config.getValue());
+ Assertions.assertTrue(config.getValue());
ArchaiusUtils.setProperty(middle, false);
- Assert.assertFalse(config.getValue());
+ Assertions.assertFalse(config.getValue());
ArchaiusUtils.setProperty(high, true);
- Assert.assertTrue(config.getValue());
+ Assertions.assertTrue(config.getValue());
ArchaiusUtils.setProperty(middle, false);
- Assert.assertTrue(config.getValue());
+ Assertions.assertTrue(config.getValue());
ArchaiusUtils.setProperty(middle, false);
ArchaiusUtils.setProperty(high, null);
- Assert.assertFalse(config.getValue());
+ Assertions.assertFalse(config.getValue());
ArchaiusUtils.setProperty(middle, null);
- Assert.assertTrue(config.getValue());
+ Assertions.assertTrue(config.getValue());
ArchaiusUtils.setProperty(low, null);
- Assert.assertFalse(config.getValue());
+ Assertions.assertFalse(config.getValue());
}
@Test
public void testDouble() {
PriorityProperty<Double> config = propertyFactory.getOrCreate(Double.class, null, -2.0, keys);
- Assert.assertEquals(-2, config.getValue(), 0);
+ Assertions.assertEquals(-2, config.getValue(), 0);
ArchaiusUtils.setProperty(low, 1);
- Assert.assertEquals(1, config.getValue(), 0);
+ Assertions.assertEquals(1, config.getValue(), 0);
ArchaiusUtils.setProperty(middle, 2);
- Assert.assertEquals(2, config.getValue(), 0);
+ Assertions.assertEquals(2, config.getValue(), 0);
ArchaiusUtils.setProperty(high, 3);
- Assert.assertEquals(3, config.getValue(), 0);
+ Assertions.assertEquals(3, config.getValue(), 0);
ArchaiusUtils.setProperty(middle, null);
- Assert.assertEquals(3, config.getValue(), 0);
+ Assertions.assertEquals(3, config.getValue(), 0);
ArchaiusUtils.setProperty(middle, 2);
ArchaiusUtils.setProperty(high, null);
- Assert.assertEquals(2, config.getValue(), 0);
+ Assertions.assertEquals(2, config.getValue(), 0);
ArchaiusUtils.setProperty(middle, null);
- Assert.assertEquals(1, config.getValue(), 0);
+ Assertions.assertEquals(1, config.getValue(), 0);
ArchaiusUtils.setProperty(low, null);
- Assert.assertEquals(-2, config.getValue(), 0);
+ Assertions.assertEquals(-2, config.getValue(), 0);
}
@Test
public void testFloat() {
PriorityProperty<Float> config = propertyFactory.getOrCreate(Float.class, null, -2.0f, keys);
- Assert.assertEquals(-2, config.getValue(), 0);
+ Assertions.assertEquals(-2, config.getValue(), 0);
ArchaiusUtils.setProperty(low, 1);
- Assert.assertEquals(1, config.getValue(), 0);
+ Assertions.assertEquals(1, config.getValue(), 0);
ArchaiusUtils.setProperty(middle, 2);
- Assert.assertEquals(2, config.getValue(), 0);
+ Assertions.assertEquals(2, config.getValue(), 0);
ArchaiusUtils.setProperty(high, 3);
- Assert.assertEquals(3, config.getValue(), 0);
+ Assertions.assertEquals(3, config.getValue(), 0);
ArchaiusUtils.setProperty(middle, null);
- Assert.assertEquals(3, config.getValue(), 0);
+ Assertions.assertEquals(3, config.getValue(), 0);
ArchaiusUtils.setProperty(middle, 2);
ArchaiusUtils.setProperty(high, null);
- Assert.assertEquals(2, config.getValue(), 0);
+ Assertions.assertEquals(2, config.getValue(), 0);
ArchaiusUtils.setProperty(middle, null);
- Assert.assertEquals(1, config.getValue(), 0);
+ Assertions.assertEquals(1, config.getValue(), 0);
ArchaiusUtils.setProperty(low, null);
- Assert.assertEquals(-2, config.getValue(), 0);
+ Assertions.assertEquals(-2, config.getValue(), 0);
}
@Test
public void globalRefresh() {
PriorityProperty<String> property = propertyFactory.getOrCreate(String.class, null, null, keys);
- Assert.assertNull(property.getValue());
+ Assertions.assertNull(property.getValue());
ConcurrentCompositeConfiguration config = (ConcurrentCompositeConfiguration) DynamicPropertyFactory
.getBackingConfigurationSource();
config.addConfiguration(new MapConfiguration(Collections.singletonMap(high, "high-value")));
- Assert.assertEquals("high-value", property.getValue());
+ Assertions.assertEquals("high-value", property.getValue());
}
}
diff --git a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityPropertyManager.java b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityPropertyManager.java
index 35402ae6e..294a506df 100644
--- a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityPropertyManager.java
+++ b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityPropertyManager.java
@@ -21,7 +21,7 @@ import org.apache.servicecomb.config.ConfigUtil;
import org.apache.servicecomb.config.inject.InjectProperties;
import org.apache.servicecomb.config.inject.InjectProperty;
import org.apache.servicecomb.config.inject.TestConfigObjectFactory;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import com.netflix.config.DynamicProperty;
@@ -67,17 +67,17 @@ public class TestPriorityPropertyManager extends TestPriorityPropertyBase {
for (int j = 0; j < 100; j++) {
TestConfigObjectFactory.ConfigWithAnnotation configConfigObject = priorityPropertyManager.createConfigObject(
TestConfigObjectFactory.ConfigWithAnnotation.class);
- Assert.assertEquals("abc", configConfigObject.strDef);
+ Assertions.assertEquals("abc", configConfigObject.strDef);
PriorityProperty<Long> configPriorityProperty = propertyFactory.getOrCreate(Long.class, -1L, -2L, keys);
- Assert.assertEquals(-2L, (long) configPriorityProperty.getValue());
+ Assertions.assertEquals(-2L, (long) configPriorityProperty.getValue());
}
}
waitKeyForGC(priorityPropertyManager);
- Assert.assertTrue(priorityPropertyManager.getConfigObjectMap().isEmpty());
+ Assertions.assertTrue(priorityPropertyManager.getConfigObjectMap().isEmpty());
for (DynamicProperty property : ConfigUtil.getAllDynamicProperties().values()) {
- Assert.assertTrue(ConfigUtil.getCallbacks(property).isEmpty());
+ Assertions.assertTrue(ConfigUtil.getCallbacks(property).isEmpty());
}
System.out.println("Token : " + (System.currentTimeMillis() - timeBegin));
diff --git a/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/TestMetricsBootstrap.java b/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/TestMetricsBootstrap.java
index a9450e824..8e93f0bef 100644
--- a/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/TestMetricsBootstrap.java
+++ b/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/TestMetricsBootstrap.java
@@ -27,7 +27,6 @@ import org.apache.servicecomb.foundation.common.utils.SPIServiceUtils;
import org.apache.servicecomb.foundation.metrics.registry.GlobalRegistry;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
-import org.junit.Assert;
import org.junit.Test;
import com.google.common.eventbus.EventBus;
@@ -39,6 +38,7 @@ import com.netflix.spectator.api.Registry;
import mockit.Deencapsulation;
import mockit.Expectations;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestMetricsBootstrap {
MetricsBootstrap bootstrap = new MetricsBootstrap();
@@ -97,7 +97,7 @@ public class TestMetricsBootstrap {
bootstrap.pollMeters();
bootstrap.shutdown();
- Assert.assertEquals(meters, result.getMeters());
+ Assertions.assertEquals(meters, result.getMeters());
MatcherAssert.assertThat(result.getMeasurements(), Matchers.contains(measurement));
}
@@ -151,7 +151,7 @@ public class TestMetricsBootstrap {
@Test
public void shutdown_notStart() {
- Assert.assertNull(Deencapsulation.getField(bootstrap, "executorService"));
+ Assertions.assertNull(Deencapsulation.getField(bootstrap, "executorService"));
// should not throw exception
bootstrap.shutdown();
diff --git a/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/health/TestHealthCheckerManager.java b/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/health/TestHealthCheckerManager.java
index b79d04fe9..7e98fbd50 100644
--- a/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/health/TestHealthCheckerManager.java
+++ b/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/health/TestHealthCheckerManager.java
@@ -19,9 +19,9 @@ package org.apache.servicecomb.foundation.metrics.health;
import java.util.Map;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
public class TestHealthCheckerManager {
@@ -58,14 +58,14 @@ public class TestHealthCheckerManager {
@Test
public void checkResultCount_None() {
Map<String, HealthCheckResult> results = HealthCheckerManager.getInstance().check();
- Assert.assertEquals(0, results.size());
+ Assertions.assertEquals(0, results.size());
}
@Test
public void checkResultCount_One() {
HealthCheckerManager.getInstance().register(good);
Map<String, HealthCheckResult> results = HealthCheckerManager.getInstance().check();
- Assert.assertEquals(1, results.size());
+ Assertions.assertEquals(1, results.size());
}
@Test
@@ -73,7 +73,7 @@ public class TestHealthCheckerManager {
HealthCheckerManager.getInstance().register(good);
HealthCheckerManager.getInstance().register(bad);
Map<String, HealthCheckResult> results = HealthCheckerManager.getInstance().check();
- Assert.assertEquals(2, results.size());
+ Assertions.assertEquals(2, results.size());
}
@Test
@@ -81,9 +81,9 @@ public class TestHealthCheckerManager {
HealthCheckerManager.getInstance().register(good);
HealthCheckerManager.getInstance().register(bad);
HealthCheckResult result = HealthCheckerManager.getInstance().check().get("testGood");
- Assert.assertEquals(true, result.isHealthy());
- Assert.assertEquals("good", result.getInformation());
- Assert.assertEquals("good component", result.getExtraData());
+ Assertions.assertTrue(result.isHealthy());
+ Assertions.assertEquals("good", result.getInformation());
+ Assertions.assertEquals("good component", result.getExtraData());
}
@Test
@@ -91,8 +91,8 @@ public class TestHealthCheckerManager {
HealthCheckerManager.getInstance().register(good);
HealthCheckerManager.getInstance().register(bad);
HealthCheckResult result = HealthCheckerManager.getInstance().check().get("testBad");
- Assert.assertEquals(false, result.isHealthy());
- Assert.assertEquals("bad", result.getInformation());
- Assert.assertEquals("bad component", result.getExtraData());
+ Assertions.assertFalse(result.isHealthy());
+ Assertions.assertEquals("bad", result.getInformation());
+ Assertions.assertEquals("bad component", result.getExtraData());
}
}
diff --git a/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/meter/TestLatencyDistributionConfig.java b/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/meter/TestLatencyDistributionConfig.java
index f05302a09..5144896e0 100644
--- a/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/meter/TestLatencyDistributionConfig.java
+++ b/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/meter/TestLatencyDistributionConfig.java
@@ -16,9 +16,8 @@
*/
package org.apache.servicecomb.foundation.metrics.meter;
-import org.junit.Assert;
-import org.junit.Test;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestLatencyDistributionConfig {
@@ -32,16 +31,16 @@ public class TestLatencyDistributionConfig {
LatencyDistributionConfig config2 = new LatencyDistributionConfig(validProperty2);
LatencyDistributionConfig config3 = new LatencyDistributionConfig(validProperty3);
- Assert.assertEquals(4, config1.getScopeConfigs().size());
- Assert.assertEquals(4, config2.getScopeConfigs().size());
- Assert.assertEquals(4, config3.getScopeConfigs().size());
+ Assertions.assertEquals(4, config1.getScopeConfigs().size());
+ Assertions.assertEquals(4, config2.getScopeConfigs().size());
+ Assertions.assertEquals(4, config3.getScopeConfigs().size());
}
@Test
public void testInValidProperty1() {
IllegalStateException exception = Assertions.assertThrows(IllegalStateException.class, () -> {
LatencyDistributionConfig latencyDistributionConfig = new LatencyDistributionConfig("2,1,10");
- Assert.assertEquals(0, latencyDistributionConfig.getScopeConfigs().size());
+ Assertions.assertEquals(0, latencyDistributionConfig.getScopeConfigs().size());
});
Assertions.assertEquals("invalid latency scope, min=2, max=1.", exception.getMessage());
}
@@ -50,7 +49,7 @@ public class TestLatencyDistributionConfig {
public void testInValidProperty2() {
NumberFormatException exception = Assertions.assertThrows(NumberFormatException.class, () -> {
LatencyDistributionConfig latencyDistributionConfig = new LatencyDistributionConfig("a,1,10");
- Assert.assertEquals(0, latencyDistributionConfig.getScopeConfigs().size());
+ Assertions.assertEquals(0, latencyDistributionConfig.getScopeConfigs().size());
});
Assertions.assertEquals("For input string: \"a\"", exception.getMessage());
}
diff --git a/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/meter/TestLatencyDistributionMeter.java b/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/meter/TestLatencyDistributionMeter.java
index 72f900b6a..d5cd26074 100644
--- a/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/meter/TestLatencyDistributionMeter.java
+++ b/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/meter/TestLatencyDistributionMeter.java
@@ -20,28 +20,28 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
-import org.junit.Assert;
-import org.junit.Test;
-
import com.netflix.spectator.api.Id;
import com.netflix.spectator.api.Measurement;
-import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
public class TestLatencyDistributionMeter {
@Test
- public void testMeasure(@Mocked Id id) {
+ public void testMeasure() {
+ Id id = Mockito.mock(Id.class);
LatencyDistributionMeter latencyDistributionMeter = new LatencyDistributionMeter(id, "0,1,3,10");
latencyDistributionMeter.record(TimeUnit.MILLISECONDS.toNanos(1L));
latencyDistributionMeter.record(TimeUnit.MILLISECONDS.toNanos(5L));
latencyDistributionMeter.record(TimeUnit.MILLISECONDS.toNanos(2L));
List<Measurement> measurements = new ArrayList<>();
latencyDistributionMeter.calcMeasurements(measurements, 0L, 0L);
- Assert.assertEquals(4, measurements.size());
- Assert.assertEquals(0, ((int) (measurements.get(0).value())));
- Assert.assertEquals(2, ((int) (measurements.get(1).value())));
- Assert.assertEquals(1, ((int) (measurements.get(2).value())));
- Assert.assertEquals(0, ((int) (measurements.get(3).value())));
+ Assertions.assertEquals(4, measurements.size());
+ Assertions.assertEquals(0, ((int) (measurements.get(0).value())));
+ Assertions.assertEquals(2, ((int) (measurements.get(1).value())));
+ Assertions.assertEquals(1, ((int) (measurements.get(2).value())));
+ Assertions.assertEquals(0, ((int) (measurements.get(3).value())));
}
}
diff --git a/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/meter/TestSimpleTimer.java b/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/meter/TestSimpleTimer.java
index 1d344973e..47b60ec47 100644
--- a/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/meter/TestSimpleTimer.java
+++ b/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/meter/TestSimpleTimer.java
@@ -16,10 +16,9 @@
*/
package org.apache.servicecomb.foundation.metrics.meter;
-import org.junit.Assert;
-import org.junit.Test;
-
import com.netflix.spectator.api.SpectatorUtils;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestSimpleTimer {
SimpleTimer timer = new SimpleTimer(SpectatorUtils.createDefaultId("name"));
@@ -29,13 +28,13 @@ public class TestSimpleTimer {
timer.record(2);
timer.record(4);
- Assert.assertFalse(timer.measure().iterator().hasNext());
+ Assertions.assertFalse(timer.measure().iterator().hasNext());
timer.calcMeasurements(1, 2);
- Assert.assertEquals(
+ Assertions.assertEquals(
"[Measurement(name:statistic=count,1,1.0), Measurement(name:statistic=totalTime,1,3.0000000000000004E-9), Measurement(name:statistic=max,1,4.0E-9)]",
timer.measure().toString());
- Assert.assertFalse(timer.hasExpired());
- Assert.assertEquals("name", timer.id().name());
+ Assertions.assertFalse(timer.hasExpired());
+ Assertions.assertEquals("name", timer.id().name());
}
}
diff --git a/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/publish/spectator/TestDefaultTagFinder.java b/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/publish/spectator/TestDefaultTagFinder.java
index 84a288a01..c892b6a8b 100644
--- a/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/publish/spectator/TestDefaultTagFinder.java
+++ b/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/publish/spectator/TestDefaultTagFinder.java
@@ -19,18 +19,17 @@ package org.apache.servicecomb.foundation.metrics.publish.spectator;
import java.util.Arrays;
import java.util.List;
-import org.junit.Assert;
-import org.junit.Test;
-
import com.netflix.spectator.api.BasicTag;
import com.netflix.spectator.api.Tag;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestDefaultTagFinder {
TagFinder finder = new DefaultTagFinder("key");
@Test
public void getTagKey() {
- Assert.assertEquals("key", finder.getTagKey());
+ Assertions.assertEquals("key", finder.getTagKey());
}
@Test
@@ -39,13 +38,13 @@ public class TestDefaultTagFinder {
List<Tag> tags = Arrays.asList(new BasicTag("t1", "t1v"),
tag);
- Assert.assertSame(tag, finder.find(tags));
+ Assertions.assertSame(tag, finder.find(tags));
}
@Test
public void readFail() {
List<Tag> tags = Arrays.asList(new BasicTag("t1", "t1v"));
- Assert.assertNull(finder.find(tags));
+ Assertions.assertNull(finder.find(tags));
}
}
diff --git a/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/publish/spectator/TestMeasurementGroupConfig.java b/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/publish/spectator/TestMeasurementGroupConfig.java
index 848ab57eb..033740096 100644
--- a/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/publish/spectator/TestMeasurementGroupConfig.java
+++ b/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/publish/spectator/TestMeasurementGroupConfig.java
@@ -21,10 +21,10 @@ import java.util.Map;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
-import org.junit.Assert;
-import org.junit.Test;
import mockit.Deencapsulation;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestMeasurementGroupConfig {
MeasurementGroupConfig config = new MeasurementGroupConfig();
@@ -33,7 +33,7 @@ public class TestMeasurementGroupConfig {
@Test
public void defaultConstruct() {
- Assert.assertTrue(groups.isEmpty());
+ Assertions.assertTrue(groups.isEmpty());
}
@Test
@@ -52,12 +52,8 @@ public class TestMeasurementGroupConfig {
config.addGroup("id2", "tag2.1", "tag2.2");
MatcherAssert.assertThat(groups.keySet(), Matchers.contains("id2", "id1"));
- MatcherAssert.assertThat(groups.get("id1").stream().map(e -> {
- return e.getTagKey();
- }).toArray(), Matchers.arrayContaining("tag1.1", "tag1.2"));
- MatcherAssert.assertThat(groups.get("id2").stream().map(e -> {
- return e.getTagKey();
- }).toArray(), Matchers.arrayContaining("tag2.1", "tag2.2"));
+ MatcherAssert.assertThat(groups.get("id1").stream().map(TagFinder::getTagKey).toArray(), Matchers.arrayContaining("tag1.1", "tag1.2"));
+ MatcherAssert.assertThat(groups.get("id2").stream().map(TagFinder::getTagKey).toArray(), Matchers.arrayContaining("tag2.1", "tag2.2"));
}
@Test
diff --git a/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/publish/spectator/TestMeasurementNode.java b/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/publish/spectator/TestMeasurementNode.java
index 5ae60a0e7..7c5691f92 100644
--- a/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/publish/spectator/TestMeasurementNode.java
+++ b/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/publish/spectator/TestMeasurementNode.java
@@ -21,20 +21,20 @@ import java.util.Map;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
-import org.junit.Assert;
import org.junit.Test;
import com.netflix.spectator.api.Measurement;
import mockit.Expectations;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestMeasurementNode {
MeasurementNode node = new MeasurementNode("name", null);
@Test
public void getName() {
- Assert.assertEquals("name", node.getName());
+ Assertions.assertEquals("name", node.getName());
}
@Test
@@ -42,12 +42,12 @@ public class TestMeasurementNode {
Map<String, MeasurementNode> children = new HashMap<>();
node = new MeasurementNode("name", children);
- Assert.assertSame(children, node.getChildren());
+ Assertions.assertSame(children, node.getChildren());
}
@Test
public void findChild_noChildren() {
- Assert.assertNull(node.findChild("child"));
+ Assertions.assertNull(node.findChild("child"));
}
@Test
@@ -55,7 +55,7 @@ public class TestMeasurementNode {
MeasurementNode c1 = node.addChild("c1", measurement);
c1.addChild("c2", measurement);
- Assert.assertNull(node.findChild("c1_notExist", "c2"));
+ Assertions.assertNull(node.findChild("c1_notExist", "c2"));
}
@Test
@@ -63,7 +63,7 @@ public class TestMeasurementNode {
MeasurementNode c1 = node.addChild("c1", measurement);
MeasurementNode c2 = c1.addChild("c2", measurement);
- Assert.assertSame(c2, node.findChild("c1", "c2"));
+ Assertions.assertSame(c2, node.findChild("c1", "c2"));
}
@Test
@@ -71,8 +71,8 @@ public class TestMeasurementNode {
MeasurementNode c1 = node.addChild("c1", measurement);
MeasurementNode c2 = node.addChild("c2", measurement);
- Assert.assertSame(c1, node.findChild("c1"));
- Assert.assertSame(c2, node.findChild("c2"));
+ Assertions.assertSame(c1, node.findChild("c1"));
+ Assertions.assertSame(c2, node.findChild("c2"));
}
@Test
@@ -93,6 +93,6 @@ public class TestMeasurementNode {
node.addMeasurement(measurement);
node.addMeasurement(measurement);
- Assert.assertEquals(20, node.summary(), 0);
+ Assertions.assertEquals(20, node.summary(), 0);
}
}
diff --git a/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/publish/spectator/TestMeasurementTree.java b/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/publish/spectator/TestMeasurementTree.java
index b236b3d94..108831d0b 100644
--- a/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/publish/spectator/TestMeasurementTree.java
+++ b/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/publish/spectator/TestMeasurementTree.java
@@ -18,7 +18,6 @@ package org.apache.servicecomb.foundation.metrics.publish.spectator;
import java.util.concurrent.TimeUnit;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
@@ -60,12 +59,12 @@ public class TestMeasurementTree {
MeasurementGroupConfig config = new MeasurementGroupConfig("id", "g1", "g2", Statistic.count.key());
tree.from(registry.iterator(), config);
- Assert.assertEquals(2, tree.getChildren().size());
+ Assertions.assertEquals(2, tree.getChildren().size());
MeasurementNode node = tree.findChild("id", "g1v", "g2v");
- Assert.assertEquals(2d, node.findChild(Statistic.count.value()).getMeasurements().get(0).value(), 0);
- Assert.assertEquals(12d, node.findChild(Statistic.totalTime.value()).getMeasurements().get(0).value(), 0);
- Assert.assertEquals(0d, tree.findChild("id_notCare").summary(), 0);
+ Assertions.assertEquals(2d, node.findChild(Statistic.count.value()).getMeasurements().get(0).value(), 0);
+ Assertions.assertEquals(12d, node.findChild(Statistic.totalTime.value()).getMeasurements().get(0).value(), 0);
+ Assertions.assertEquals(0d, tree.findChild("id_notCare").summary(), 0);
}
@Test
@@ -74,7 +73,7 @@ public class TestMeasurementTree {
MeasurementGroupConfig config = new MeasurementGroupConfig("id", new DefaultTagFinder("notExist", true));
tree.from(registry.iterator(), config);
} catch (Exception e) {
- Assert.fail("should not throw exception");
+ Assertions.fail("should not throw exception");
}
}
diff --git a/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/publish/spectator/TestTagFinder.java b/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/publish/spectator/TestTagFinder.java
index 249b51af2..a4c40320e 100644
--- a/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/publish/spectator/TestTagFinder.java
+++ b/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/publish/spectator/TestTagFinder.java
@@ -16,9 +16,8 @@
*/
package org.apache.servicecomb.foundation.metrics.publish.spectator;
-import org.junit.Assert;
-import org.junit.Test;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestTagFinder {
@@ -27,16 +26,16 @@ public class TestTagFinder {
String name = "key";
TagFinder finder = TagFinder.build(name);
- Assert.assertEquals(name, finder.getTagKey());
- Assert.assertEquals(DefaultTagFinder.class, finder.getClass());
+ Assertions.assertEquals(name, finder.getTagKey());
+ Assertions.assertEquals(DefaultTagFinder.class, finder.getClass());
}
@Test
public void buildFromTagFinder() {
TagFinder finder = new DefaultTagFinder("key");
- Assert.assertSame(finder, TagFinder.build(finder));
+ Assertions.assertSame(finder, TagFinder.build(finder));
DefaultTagFinder tagFinder = new DefaultTagFinder("key", true);
- Assert.assertSame(tagFinder, TagFinder.build(tagFinder));
+ Assertions.assertSame(tagFinder, TagFinder.build(tagFinder));
}
@Test
diff --git a/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/compatibility/TestCompatibilityOfImplementations.java b/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/compatibility/TestCompatibilityOfImplementations.java
index e5fb65259..f5100648f 100644
--- a/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/compatibility/TestCompatibilityOfImplementations.java
+++ b/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/compatibility/TestCompatibilityOfImplementations.java
@@ -26,8 +26,8 @@ import org.apache.servicecomb.foundation.protobuf.internal.model.Root;
import org.apache.servicecomb.foundation.protobuf.performance.ProtubufCodecEngine;
import org.apache.servicecomb.foundation.protobuf.performance.engine.Protobuf;
import org.apache.servicecomb.foundation.protobuf.performance.engine.ScbWeak;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestCompatibilityOfImplementations {
static ProtubufCodecEngine scbWeak = new ScbWeak();
@@ -39,30 +39,30 @@ public class TestCompatibilityOfImplementations {
public void testEmptyCollection() throws Exception {
ProtobufRoot.Root.Builder builder = ProtobufRoot.Root.newBuilder();
byte[] values = protobuf.serialize(builder);
- Assert.assertEquals(values.length, 0);
+ Assertions.assertEquals(values.length, 0);
ProtobufRoot.Root.Builder o = (ProtobufRoot.Root.Builder) protobuf.deserialize(values);
- Assert.assertTrue(o.getFixed32SNotPackedList().isEmpty());
+ Assertions.assertTrue(o.getFixed32SNotPackedList().isEmpty());
builder = ProtobufRoot.Root.newBuilder().addFixed32SNotPacked(30);
values = protobuf.serialize(builder);
- Assert.assertArrayEquals(new byte[] {(byte) -123, (byte) 6, (byte) 30, (byte) 0, (byte) 0, (byte) 0}, values);
+ Assertions.assertArrayEquals(new byte[] {(byte) -123, (byte) 6, (byte) 30, (byte) 0, (byte) 0, (byte) 0}, values);
o = (ProtobufRoot.Root.Builder) protobuf.deserialize(values);
- Assert.assertEquals(30, (int) o.getFixed32SNotPackedList().get(0));
+ Assertions.assertEquals(30, (int) o.getFixed32SNotPackedList().get(0));
Root root = new Root();
root.setFixed32sNotPacked(new ArrayList<>());
values = scbWeak.serialize(root);
- Assert.assertEquals(values.length, 0);
+ Assertions.assertEquals(values.length, 0);
Map<String, Object> newRootMap = (Map<String, Object>) scbWeak.deserialize(values);
- Assert.assertEquals(null,
+ Assertions.assertEquals(null,
newRootMap.get("fixed32sNotPacked")); // This is different , because depends on default model initializer
List<Integer> iValues = new ArrayList<>();
iValues.add(30);
root.setFixed32sNotPacked(iValues);
values = scbWeak.serialize(root);
- Assert.assertArrayEquals(new byte[] {(byte) -123, (byte) 6, (byte) 30, (byte) 0, (byte) 0, (byte) 0}, values);
+ Assertions.assertArrayEquals(new byte[] {(byte) -123, (byte) 6, (byte) 30, (byte) 0, (byte) 0, (byte) 0}, values);
newRootMap = (Map<String, Object>) scbWeak.deserialize(values);
- Assert.assertEquals(30, (int) ((List<Integer>) newRootMap.get("fixed32sNotPacked")).get(0));
+ Assertions.assertEquals(30, (int) ((List<Integer>) newRootMap.get("fixed32sNotPacked")).get(0));
}
}
diff --git a/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/TestModelWrap.java b/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/TestModelWrap.java
index 26d447cd3..fd19fd8f0 100644
--- a/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/TestModelWrap.java
+++ b/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/TestModelWrap.java
@@ -26,10 +26,10 @@ import org.apache.servicecomb.foundation.protobuf.ProtoMapper;
import org.apache.servicecomb.foundation.protobuf.ProtoMapperFactory;
import org.apache.servicecomb.foundation.protobuf.RootDeserializer;
import org.apache.servicecomb.foundation.protobuf.RootSerializer;
-import org.junit.Assert;
-import org.junit.Test;
import io.vertx.core.json.Json;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestModelWrap {
protected static ProtoMapperFactory factory = new ProtoMapperFactory();
@@ -278,20 +278,20 @@ public class TestModelWrap {
// serialize
byte[] bytes = protoSerializer.serialize(protoModel);
- Assert.assertArrayEquals(bytes, protoSerializer.serialize(mapFromProtoModel));
- Assert.assertArrayEquals(bytes, pojoSerializer.serialize(pojoModel));
- Assert.assertArrayEquals(bytes, pojoSerializer.serialize(mapFromPojoModel));
+ Assertions.assertArrayEquals(bytes, protoSerializer.serialize(mapFromProtoModel));
+ Assertions.assertArrayEquals(bytes, pojoSerializer.serialize(pojoModel));
+ Assertions.assertArrayEquals(bytes, pojoSerializer.serialize(mapFromPojoModel));
// deserialize pojoModel
PojoModel newPojoModel = pojoModelDeserializer.deserialize(bytes);
- Assert.assertEquals(jsonPojoModel, Json.encode(newPojoModel));
+ Assertions.assertEquals(jsonPojoModel, Json.encode(newPojoModel));
Map<String, Object> mapFromNewPojoModel = pojoMapDeserializer.deserialize(bytes);
- Assert.assertEquals(jsonPojoModel, Json.encode(mapFromNewPojoModel));
+ Assertions.assertEquals(jsonPojoModel, Json.encode(mapFromNewPojoModel));
// deserialize protoModel
ProtoModel newProtoModel = protoModelDeserializer.deserialize(bytes);
- Assert.assertEquals(jsonProtoModel, Json.encode(newProtoModel));
+ Assertions.assertEquals(jsonProtoModel, Json.encode(newProtoModel));
Map<String, Object> mapFromNewProtoModel = protoMapDeserializer.deserialize(bytes);
- Assert.assertEquals(jsonProtoModel, Json.encode(mapFromNewProtoModel));
+ Assertions.assertEquals(jsonProtoModel, Json.encode(mapFromNewProtoModel));
}
}
diff --git a/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/TestSchemaBase.java b/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/TestSchemaBase.java
index 6f38d89c1..6353815df 100644
--- a/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/TestSchemaBase.java
+++ b/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/TestSchemaBase.java
@@ -28,9 +28,9 @@ import org.apache.servicecomb.foundation.protobuf.internal.model.PrimitiveArrays
import org.apache.servicecomb.foundation.protobuf.internal.model.PrimitiveWrapperArrays;
import org.apache.servicecomb.foundation.protobuf.internal.model.ProtobufRoot;
import org.apache.servicecomb.foundation.protobuf.internal.model.Root;
-import org.junit.Assert;
import io.protostuff.compiler.model.Field;
+import org.junit.jupiter.api.Assertions;
public class TestSchemaBase {
protected static ProtoMapperFactory factory = new ProtoMapperFactory();
@@ -115,19 +115,19 @@ public class TestSchemaBase {
scbMap.clear();
scbMap.put(primitiveFieldName, strings);
scbMapBytes = primitiveArraysSerializer.serialize(scbMap);
- Assert.assertArrayEquals(protobufBytes, scbMapBytes);
+ Assertions.assertArrayEquals(protobufBytes, scbMapBytes);
// dynamic primitive array
scbMap.clear();
scbMap.put(primitiveFieldName, primitiveArray);
scbMapBytes = primitiveArraysSerializer.serialize(scbMap);
- Assert.assertArrayEquals(protobufBytes, scbMapBytes);
+ Assertions.assertArrayEquals(protobufBytes, scbMapBytes);
// dynamic array
scbMap.clear();
scbMap.put(primitiveFieldName, array);
scbMapBytes = primitiveArraysSerializer.serialize(scbMap);
- Assert.assertArrayEquals(protobufBytes, scbMapBytes);
+ Assertions.assertArrayEquals(protobufBytes, scbMapBytes);
}
protected void check() throws IOException {
@@ -160,7 +160,7 @@ public class TestSchemaBase {
System.out.println("protobuf :" + Hex.encodeHexString(protobufBytes));
System.out.println("protobuf len :" + protobufBytes.length);
}
- Assert.assertArrayEquals(protobufBytes, scbMapBytes);
- Assert.assertArrayEquals(protobufBytes, scbRootBytes);
+ Assertions.assertArrayEquals(protobufBytes, scbMapBytes);
+ Assertions.assertArrayEquals(protobufBytes, scbRootBytes);
}
}
diff --git a/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/bean/TestBeanDescriptorManager.java b/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/bean/TestBeanDescriptorManager.java
index 9d2994bad..60054c021 100644
--- a/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/bean/TestBeanDescriptorManager.java
+++ b/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/bean/TestBeanDescriptorManager.java
@@ -23,10 +23,10 @@ import org.apache.servicecomb.foundation.common.utils.bean.Getter;
import org.apache.servicecomb.foundation.common.utils.bean.IntGetter;
import org.apache.servicecomb.foundation.common.utils.bean.IntSetter;
import org.apache.servicecomb.foundation.common.utils.bean.Setter;
-import org.junit.Assert;
-import org.junit.Test;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestBeanDescriptorManager {
public static class Model {
@@ -95,13 +95,13 @@ public class TestBeanDescriptorManager {
BeanDescriptor beanDescriptor = beanDescriptorManager
.getOrCreateBeanDescriptor(method.getGenericParameterTypes()[0]);
- Assert.assertEquals(String.class, beanDescriptor.getPropertyDescriptors().get("value").getJavaType().getRawClass());
+ Assertions.assertEquals(String.class, beanDescriptor.getPropertyDescriptors().get("value").getJavaType().getRawClass());
}
@Test
public void getOrCreate() {
- Assert.assertSame(beanDescriptor, beanDescriptorManager.getOrCreateBeanDescriptor(Model.class));
- Assert.assertSame(Model.class, beanDescriptor.getJavaType().getRawClass());
+ Assertions.assertSame(beanDescriptor, beanDescriptorManager.getOrCreateBeanDescriptor(Model.class));
+ Assertions.assertSame(Model.class, beanDescriptor.getJavaType().getRawClass());
}
@SuppressWarnings("unchecked")
@@ -109,29 +109,29 @@ public class TestBeanDescriptorManager {
public void both() {
PropertyDescriptor propertyDescriptor = beanDescriptor.getPropertyDescriptors().get("both");
((IntSetter<Model>) propertyDescriptor.getSetter()).set(model, 1);
- Assert.assertEquals(1, ((IntGetter<Model>) propertyDescriptor.getGetter()).get(model));
- Assert.assertEquals(1, model.getBoth());
+ Assertions.assertEquals(1, ((IntGetter<Model>) propertyDescriptor.getGetter()).get(model));
+ Assertions.assertEquals(1, model.getBoth());
}
@SuppressWarnings("unchecked")
@Test
public void onlyGet() {
PropertyDescriptor propertyDescriptor = beanDescriptor.getPropertyDescriptors().get("onlyGet");
- Assert.assertNull(propertyDescriptor.getSetter());
+ Assertions.assertNull(propertyDescriptor.getSetter());
model.onlyGet(1);
- Assert.assertEquals(1, ((IntGetter<Model>) propertyDescriptor.getGetter()).get(model));
- Assert.assertEquals(1, model.getOnlyGet());
+ Assertions.assertEquals(1, ((IntGetter<Model>) propertyDescriptor.getGetter()).get(model));
+ Assertions.assertEquals(1, model.getOnlyGet());
}
@SuppressWarnings("unchecked")
@Test
public void onlySet() {
PropertyDescriptor propertyDescriptor = beanDescriptor.getPropertyDescriptors().get("onlySet");
- Assert.assertNull(propertyDescriptor.getGetter());
+ Assertions.assertNull(propertyDescriptor.getGetter());
((IntSetter<Model>) propertyDescriptor.getSetter()).set(model, 1);
- Assert.assertEquals(1, model.onlySet());
+ Assertions.assertEquals(1, model.onlySet());
}
@SuppressWarnings("unchecked")
@@ -139,7 +139,7 @@ public class TestBeanDescriptorManager {
public void direct() {
PropertyDescriptor propertyDescriptor = beanDescriptor.getPropertyDescriptors().get("direct");
((Setter<Model, Integer>) propertyDescriptor.getSetter()).set(model, 1);
- Assert.assertEquals(1, (int) ((Getter<Model, Integer>) propertyDescriptor.getGetter()).get(model));
- Assert.assertEquals(1, model.direct);
+ Assertions.assertEquals(1, (int) ((Getter<Model, Integer>) propertyDescriptor.getGetter()).get(model));
+ Assertions.assertEquals(1, model.direct);
}
}
diff --git a/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/parser/TestProtoParser.java b/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/parser/TestProtoParser.java
index 0f3bb4b26..268281b91 100644
--- a/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/parser/TestProtoParser.java
+++ b/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/parser/TestProtoParser.java
@@ -16,18 +16,16 @@
*/
package org.apache.servicecomb.foundation.protobuf.internal.parser;
+import com.google.common.base.MoreObjects;
+import io.protostuff.compiler.model.Proto;
+import org.apache.commons.io.IOUtils;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
import java.io.IOException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
-import org.apache.commons.io.IOUtils;
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.google.common.base.MoreObjects;
-
-import io.protostuff.compiler.model.Proto;
-
public class TestProtoParser {
@Test
public void parse() throws IOException {
@@ -38,10 +36,10 @@ public class TestProtoParser {
Proto protoFromContent = parser.parseFromContent(content);
Proto protoFromName = parser.parse("protobufRoot.proto");
- Assert.assertNotNull(protoFromContent.getMessage("Root"));
- Assert.assertNotNull(protoFromContent.getMessage("User"));
+ Assertions.assertNotNull(protoFromContent.getMessage("Root"));
+ Assertions.assertNotNull(protoFromContent.getMessage("User"));
- Assert.assertEquals(MoreObjects.toStringHelper(protoFromContent)
+ Assertions.assertEquals(MoreObjects.toStringHelper(protoFromContent)
.omitNullValues()
.add("messages", protoFromContent.getMessages())
.toString(),
diff --git a/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/TestAnySchema.java b/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/TestAnySchema.java
index 658c20a05..8bcbddd9d 100644
--- a/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/TestAnySchema.java
+++ b/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/TestAnySchema.java
@@ -28,17 +28,17 @@ import org.apache.servicecomb.foundation.protobuf.internal.model.ProtobufRoot;
import org.apache.servicecomb.foundation.protobuf.internal.model.Root;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
-import org.junit.Assert;
-import org.junit.Test;
import com.google.protobuf.Any;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestAnySchema extends TestSchemaBase {
@Test
public void empty() throws Throwable {
scbMap = new HashMap<>();
scbMap.put("any", null);
- Assert.assertEquals(0, rootSerializer.serialize(scbMap).length);
+ Assertions.assertEquals(0, rootSerializer.serialize(scbMap).length);
}
@Test
@@ -69,7 +69,7 @@ public class TestAnySchema extends TestSchemaBase {
map.put("name", "n1");
Root root = new Root();
root.setAny(map);
- Assert.assertArrayEquals(protobufBytes, rootSerializer.serialize(root));
+ Assertions.assertArrayEquals(protobufBytes, rootSerializer.serialize(root));
}
@SuppressWarnings("unchecked")
@@ -97,6 +97,6 @@ public class TestAnySchema extends TestSchemaBase {
scbRootBytes = rootSerializer.serialize(root);
root = rootDeserializer.deserialize(scbRootBytes);
- Assert.assertEquals("abc", root.getAny());
+ Assertions.assertEquals("abc", root.getAny());
}
}
diff --git a/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/TestMessageSchema.java b/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/TestMessageSchema.java
index b7ac75c99..4e5045408 100644
--- a/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/TestMessageSchema.java
+++ b/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/TestMessageSchema.java
@@ -24,20 +24,18 @@ import org.apache.servicecomb.foundation.protobuf.internal.TestSchemaBase;
import org.apache.servicecomb.foundation.protobuf.internal.model.CustomGeneric;
import org.apache.servicecomb.foundation.protobuf.internal.model.ProtobufRoot;
import org.apache.servicecomb.foundation.protobuf.internal.model.User;
-import org.hamcrest.MatcherAssert;
-import org.hamcrest.Matchers;
-import org.junit.Assert;
-import org.junit.Test;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.type.TypeFactory;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestMessageSchema extends TestSchemaBase {
@Test
public void empty() throws Throwable {
check();
- Assert.assertArrayEquals(protobufBytes, rootSerializer.serialize(null));
+ Assertions.assertArrayEquals(protobufBytes, rootSerializer.serialize(null));
}
@Test
@@ -50,7 +48,7 @@ public class TestMessageSchema extends TestSchemaBase {
@SuppressWarnings("unchecked")
CustomGeneric<User> generic = (CustomGeneric<User>) scbRoot;
- MatcherAssert.assertThat(generic.user, Matchers.instanceOf(User.class));
+ Assertions.assertNotNull(generic.user);
}
@Test
@@ -72,6 +70,6 @@ public class TestMessageSchema extends TestSchemaBase {
map.put("notExist", null);
- Assert.assertArrayEquals(protobufBytes, rootSerializer.serialize(map));
+ Assertions.assertArrayEquals(protobufBytes, rootSerializer.serialize(map));
}
}
diff --git a/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/TestRepeatedSchema.java b/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/TestRepeatedSchema.java
index 9ce2a742d..a26156a37 100644
--- a/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/TestRepeatedSchema.java
+++ b/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/TestRepeatedSchema.java
@@ -24,10 +24,10 @@ import org.apache.servicecomb.foundation.protobuf.internal.TestSchemaBase;
import org.apache.servicecomb.foundation.protobuf.internal.model.ProtobufRoot;
import org.apache.servicecomb.foundation.protobuf.internal.model.ProtobufRoot.Color;
import org.apache.servicecomb.foundation.protobuf.internal.model.User;
-import org.junit.Assert;
-import org.junit.Test;
import com.google.protobuf.ByteString;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestRepeatedSchema extends TestSchemaBase {
public static class RootWithArray {
@@ -214,7 +214,7 @@ public class TestRepeatedSchema extends TestSchemaBase {
RootWithArray rootWithArray = new RootWithArray();
rootWithArray.bytess = sList.toArray(new byte[0][]);
- Assert.assertArrayEquals(protobufBytes, rootSerializer.serialize(rootWithArray));
+ Assertions.assertArrayEquals(protobufBytes, rootSerializer.serialize(rootWithArray));
}
@Test
@@ -225,7 +225,7 @@ public class TestRepeatedSchema extends TestSchemaBase {
RootWithArray rootWithArray = new RootWithArray();
rootWithArray.strings = sList.toArray(new String[0]);
- Assert.assertArrayEquals(protobufBytes, rootSerializer.serialize(rootWithArray));
+ Assertions.assertArrayEquals(protobufBytes, rootSerializer.serialize(rootWithArray));
}
@Test
@@ -237,6 +237,6 @@ public class TestRepeatedSchema extends TestSchemaBase {
RootWithArray rootWithArray = new RootWithArray();
rootWithArray.users = new User[] {new User("name1"), new User("name2")};
- Assert.assertArrayEquals(protobufBytes, rootSerializer.serialize(rootWithArray));
+ Assertions.assertArrayEquals(protobufBytes, rootSerializer.serialize(rootWithArray));
}
}
diff --git a/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/scalar/TestBoolSchema.java b/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/scalar/TestBoolSchema.java
index 187264baf..a82fc971c 100644
--- a/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/scalar/TestBoolSchema.java
+++ b/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/scalar/TestBoolSchema.java
@@ -20,10 +20,8 @@ import java.util.HashMap;
import org.apache.servicecomb.foundation.protobuf.internal.TestSchemaBase;
import org.apache.servicecomb.foundation.protobuf.internal.model.User;
-import org.hamcrest.Matchers;
-import org.junit.Assert;
-import org.junit.Test;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestBoolSchema extends TestSchemaBase {
public TestBoolSchema() {
@@ -56,22 +54,22 @@ public class TestBoolSchema extends TestSchemaBase {
// string[]
scbMap = new HashMap<>();
scbMap.put("bool", new String[] {value});
- Assert.assertArrayEquals(protobufBytes, rootSerializer.serialize(scbMap));
+ Assertions.assertArrayEquals(protobufBytes, rootSerializer.serialize(scbMap));
// string
scbMap.put("bool", value);
- Assert.assertArrayEquals(protobufBytes, rootSerializer.serialize(scbMap));
+ Assertions.assertArrayEquals(protobufBytes, rootSerializer.serialize(scbMap));
}
@Test
public void nullOrEmpty() throws Throwable {
// null
scbMap = new HashMap<>();
- Assert.assertEquals(0, rootSerializer.serialize(scbMap).length);
+ Assertions.assertEquals(0, rootSerializer.serialize(scbMap).length);
// empty string[]
scbMap.put("bool", new String[] {});
- Assert.assertEquals(0, rootSerializer.serialize(scbMap).length);
+ Assertions.assertEquals(0, rootSerializer.serialize(scbMap).length);
}
@Test
diff --git a/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/scalar/TestEnumSchema.java b/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/scalar/TestEnumSchema.java
index a248702b8..4c70eb2e4 100644
--- a/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/scalar/TestEnumSchema.java
+++ b/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/scalar/TestEnumSchema.java
@@ -22,21 +22,19 @@ import java.util.Map;
import org.apache.servicecomb.foundation.protobuf.internal.TestSchemaBase;
import org.apache.servicecomb.foundation.protobuf.internal.model.User;
import org.apache.servicecomb.foundation.test.scaffolding.model.Color;
-import org.hamcrest.Matchers;
-import org.junit.Assert;
-import org.junit.Test;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestEnumSchema extends TestSchemaBase {
@Test
public void empty() throws Throwable {
// null
scbMap = new HashMap<>();
- Assert.assertEquals(0, rootSerializer.serialize(scbMap).length);
+ Assertions.assertEquals(0, rootSerializer.serialize(scbMap).length);
// empty string[]
scbMap.put("color", new String[] {});
- Assert.assertEquals(0, rootSerializer.serialize(scbMap).length);
+ Assertions.assertEquals(0, rootSerializer.serialize(scbMap).length);
}
public static class EnumRoot {
@@ -58,19 +56,19 @@ public class TestEnumSchema extends TestSchemaBase {
Map<String, Object> map = new HashMap<>();
map.put("color", Color.BLUE);
- Assert.assertArrayEquals(protobufBytes, rootSerializer.serialize(map));
+ Assertions.assertArrayEquals(protobufBytes, rootSerializer.serialize(map));
map.put("color", 2);
- Assert.assertArrayEquals(protobufBytes, rootSerializer.serialize(map));
+ Assertions.assertArrayEquals(protobufBytes, rootSerializer.serialize(map));
map.put("color", new String[] {"BLUE"});
- Assert.assertArrayEquals(protobufBytes, rootSerializer.serialize(map));
+ Assertions.assertArrayEquals(protobufBytes, rootSerializer.serialize(map));
map.put("color", "BLUE");
- Assert.assertArrayEquals(protobufBytes, rootSerializer.serialize(map));
+ Assertions.assertArrayEquals(protobufBytes, rootSerializer.serialize(map));
EnumRoot enumRoot = protoMapper.<EnumRoot>createRootDeserializer("Root", EnumRoot.class).deserialize(protobufBytes);
- Assert.assertEquals(2, enumRoot.color);
+ Assertions.assertEquals(2, enumRoot.color);
}
enum Sharp {
diff --git a/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/scalar/TestNumberBaseSchema.java b/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/scalar/TestNumberBaseSchema.java
index f723e26aa..c7e85f178 100644
--- a/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/scalar/TestNumberBaseSchema.java
+++ b/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/scalar/TestNumberBaseSchema.java
@@ -25,8 +25,6 @@ import org.apache.servicecomb.foundation.common.utils.ReflectUtils;
import org.apache.servicecomb.foundation.protobuf.internal.TestSchemaBase;
import org.apache.servicecomb.foundation.protobuf.internal.model.ProtobufRoot;
import org.apache.servicecomb.foundation.test.scaffolding.model.User;
-import org.hamcrest.Matchers;
-import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
@@ -53,19 +51,19 @@ public abstract class TestNumberBaseSchema extends TestSchemaBase {
// null
scbMap = new HashMap<>();
scbMap.put(field, null);
- Assert.assertEquals(0, rootSerializer.serialize(scbMap).length);
+ Assertions.assertEquals(0, rootSerializer.serialize(scbMap).length);
// empty string[]
scbMap.put(field, new String[] {});
- Assert.assertEquals(0, rootSerializer.serialize(scbMap).length);
+ Assertions.assertEquals(0, rootSerializer.serialize(scbMap).length);
// string[]
scbMap.put(field, new String[] {String.valueOf(value)});
- Assert.assertArrayEquals(expectBytes, rootSerializer.serialize(scbMap));
+ Assertions.assertArrayEquals(expectBytes, rootSerializer.serialize(scbMap));
// string
scbMap.put(field, String.valueOf(value));
- Assert.assertArrayEquals(expectBytes, rootSerializer.serialize(scbMap));
+ Assertions.assertArrayEquals(expectBytes, rootSerializer.serialize(scbMap));
}
private byte[] doTestPojoNormal(String name) throws Throwable {
diff --git a/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/scalar/TestStringSchema.java b/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/scalar/TestStringSchema.java
index 4de133079..c10845683 100644
--- a/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/scalar/TestStringSchema.java
+++ b/foundations/foundation-protobuf/src/test/java/org/apache/servicecomb/foundation/protobuf/internal/schema/scalar/TestStringSchema.java
@@ -20,9 +20,8 @@ import java.util.HashMap;
import org.apache.servicecomb.foundation.protobuf.internal.TestSchemaBase;
import org.apache.servicecomb.foundation.protobuf.internal.model.User;
-import org.junit.Assert;
-import org.junit.Test;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestStringSchema extends TestSchemaBase {
@Test
@@ -34,22 +33,22 @@ public class TestStringSchema extends TestSchemaBase {
// string[]
scbMap = new HashMap<>();
scbMap.put("string", new String[] {value});
- Assert.assertArrayEquals(protobufBytes, rootSerializer.serialize(scbMap));
+ Assertions.assertArrayEquals(protobufBytes, rootSerializer.serialize(scbMap));
// string
scbMap.put("string", value);
- Assert.assertArrayEquals(protobufBytes, rootSerializer.serialize(scbMap));
+ Assertions.assertArrayEquals(protobufBytes, rootSerializer.serialize(scbMap));
}
@Test
public void nullOrEmpty() throws Throwable {
// null
scbMap = new HashMap<>();
- Assert.assertEquals(0, rootSerializer.serialize(scbMap).length);
+ Assertions.assertEquals(0, rootSerializer.serialize(scbMap).length);
// empty string[]
scbMap.put("string", new String[] {});
- Assert.assertEquals(0, rootSerializer.serialize(scbMap).length);
+ Assertions.assertEquals(0, rootSerializer.serialize(scbMap).length);
}
@Test
diff --git a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/api/registry/TestServiceCombVersion.java b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/api/registry/TestServiceCombVersion.java
index 2ae6ee019..3bbfbf6cd 100644
--- a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/api/registry/TestServiceCombVersion.java
+++ b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/api/registry/TestServiceCombVersion.java
@@ -17,8 +17,8 @@
package org.apache.servicecomb.registry.api.registry;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestServiceCombVersion {
@Test
@@ -26,6 +26,6 @@ public class TestServiceCombVersion {
ServiceCombVersion version = new ServiceCombVersion();
// this.getClass().getPackage().getImplementationVersion()
// is not stable, may get null or 2.0.1-SNAPSHOT
- Assert.assertTrue(version.loadVersion().toString().contains("ServiceComb"));
+ Assertions.assertTrue(version.loadVersion().toString().contains("ServiceComb"));
}
}
diff --git a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/config/TestAbstractPropertiesLoader.java b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/config/TestAbstractPropertiesLoader.java
index be5a48c8f..b5b28f082 100644
--- a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/config/TestAbstractPropertiesLoader.java
+++ b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/config/TestAbstractPropertiesLoader.java
@@ -19,10 +19,10 @@ package org.apache.servicecomb.registry.config;
import org.apache.commons.configuration.Configuration;
import org.apache.servicecomb.config.BootStrapProperties;
-import org.junit.Assert;
-import org.junit.Test;
import com.netflix.config.DynamicConfiguration;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestAbstractPropertiesLoader {
@Test
@@ -33,10 +33,10 @@ public class TestAbstractPropertiesLoader {
AbstractPropertiesLoader loader = MicroservicePropertiesLoader.INSTANCE;
try {
loader.loadProperties(configuration);
- Assert.fail("Must throw exception");
+ Assertions.fail("Must throw exception");
} catch (Error e) {
- Assert.assertEquals(ClassNotFoundException.class, e.getCause().getClass());
- Assert.assertEquals("invalidClass", e.getCause().getMessage());
+ Assertions.assertEquals(ClassNotFoundException.class, e.getCause().getClass());
+ Assertions.assertEquals("invalidClass", e.getCause().getMessage());
}
}
}
diff --git a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/discovery/TestAbstractDiscoveryFilter.java b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/discovery/TestAbstractDiscoveryFilter.java
index 456743fa7..987ec0a0b 100644
--- a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/discovery/TestAbstractDiscoveryFilter.java
+++ b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/discovery/TestAbstractDiscoveryFilter.java
@@ -17,11 +17,8 @@
package org.apache.servicecomb.registry.discovery;
-import org.apache.servicecomb.registry.discovery.AbstractDiscoveryFilter;
-import org.apache.servicecomb.registry.discovery.DiscoveryContext;
-import org.apache.servicecomb.registry.discovery.DiscoveryTreeNode;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestAbstractDiscoveryFilter {
int initCallCount;
@@ -71,9 +68,9 @@ public class TestAbstractDiscoveryFilter {
public void discoveryInited() {
doDiscovery();
- Assert.assertEquals(1, childrenInitedCallCount);
- Assert.assertEquals(0, initCallCount);
- Assert.assertSame(child, result);
+ Assertions.assertEquals(1, childrenInitedCallCount);
+ Assertions.assertEquals(0, initCallCount);
+ Assertions.assertSame(child, result);
}
@Test
@@ -81,9 +78,9 @@ public class TestAbstractDiscoveryFilter {
inited[0] = false;
doDiscovery();
- Assert.assertEquals(2, childrenInitedCallCount);
- Assert.assertEquals(0, initCallCount);
- Assert.assertSame(child, result);
+ Assertions.assertEquals(2, childrenInitedCallCount);
+ Assertions.assertEquals(0, initCallCount);
+ Assertions.assertSame(child, result);
}
@Test
@@ -92,8 +89,8 @@ public class TestAbstractDiscoveryFilter {
inited[1] = false;
doDiscovery();
- Assert.assertEquals(2, childrenInitedCallCount);
- Assert.assertEquals(1, initCallCount);
- Assert.assertSame(child, result);
+ Assertions.assertEquals(2, childrenInitedCallCount);
+ Assertions.assertEquals(1, initCallCount);
+ Assertions.assertSame(child, result);
}
}
diff --git a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/discovery/TestAbstractTransportDiscoveryFilter.java b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/discovery/TestAbstractTransportDiscoveryFilter.java
index df9ef8598..1c6ea66fb 100644
--- a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/discovery/TestAbstractTransportDiscoveryFilter.java
+++ b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/discovery/TestAbstractTransportDiscoveryFilter.java
@@ -27,8 +27,8 @@ import java.util.UUID;
import org.apache.servicecomb.registry.api.registry.MicroserviceInstance;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
-import org.junit.Assert;
import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
public class TestAbstractTransportDiscoveryFilter {
class AbstractEndpointDiscoveryFilterForTest extends AbstractEndpointDiscoveryFilter {
@@ -67,22 +67,22 @@ public class TestAbstractTransportDiscoveryFilter {
@Test
public void isGroupingFilter() {
- Assert.assertTrue(filter.isGroupingFilter());
+ Assertions.assertTrue(filter.isGroupingFilter());
}
@Test
public void isTransportNameMatch_expectAll() {
- Assert.assertTrue(filter.isTransportNameMatch("any", ""));
+ Assertions.assertTrue(filter.isTransportNameMatch("any", ""));
}
@Test
public void isTransportNameMatch_equals() {
- Assert.assertTrue(filter.isTransportNameMatch("rest", "rest"));
+ Assertions.assertTrue(filter.isTransportNameMatch("rest", "rest"));
}
@Test
public void isTransportNameMatch_notEquals() {
- Assert.assertFalse(filter.isTransportNameMatch("rest", "highway"));
+ Assertions.assertFalse(filter.isTransportNameMatch("rest", "highway"));
}
@Test
@@ -91,7 +91,7 @@ public class TestAbstractTransportDiscoveryFilter {
parent.data(Collections.emptyMap());
result = filter.discovery(context, parent);
- Assert.assertTrue(result.isEmpty());
+ Assertions.assertTrue(result.isEmpty());
}
@Test
@@ -101,7 +101,7 @@ public class TestAbstractTransportDiscoveryFilter {
parent.child(transportName, child);
result = filter.discovery(context, parent);
- Assert.assertSame(child, result);
+ Assertions.assertSame(child, result);
}
private MicroserviceInstance createInstance(String... schemas) {
@@ -133,7 +133,7 @@ public class TestAbstractTransportDiscoveryFilter {
result = filter.createDiscoveryTreeNode("a", context, parent);
- Assert.assertEquals("parent/a", result.name());
+ Assertions.assertEquals("parent/a", result.name());
MatcherAssert.assertThat(result.collectionData(), Matchers.contains(instance1.getEndpoints().get(0)));
}
@@ -146,7 +146,7 @@ public class TestAbstractTransportDiscoveryFilter {
result = filter.createDiscoveryTreeNode("", context, parent);
- Assert.assertEquals("parent/", result.name());
+ Assertions.assertEquals("parent/", result.name());
List<String> expect = new ArrayList<>();
expect.addAll(instance1.getEndpoints());
@@ -163,7 +163,7 @@ public class TestAbstractTransportDiscoveryFilter {
result = filter.createDiscoveryTreeNode("", context, parent);
- Assert.assertEquals("parent/", result.name());
+ Assertions.assertEquals("parent/", result.name());
MatcherAssert.assertThat(result.collectionData(), Matchers.contains(instance1.getEndpoints().toArray()));
}
@@ -176,7 +176,7 @@ public class TestAbstractTransportDiscoveryFilter {
result = filter.createDiscoveryTreeNode("", context, parent);
- Assert.assertEquals("parent/", result.name());
+ Assertions.assertEquals("parent/", result.name());
MatcherAssert.assertThat(result.collectionData(), Matchers.empty());
}
}
diff --git a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/discovery/TestDiscoveryContext.java b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/discovery/TestDiscoveryContext.java
index faae6f330..53c9d026c 100644
--- a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/discovery/TestDiscoveryContext.java
+++ b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/discovery/TestDiscoveryContext.java
@@ -17,10 +17,8 @@
package org.apache.servicecomb.registry.discovery;
-import org.apache.servicecomb.registry.discovery.DiscoveryContext;
-import org.apache.servicecomb.registry.discovery.DiscoveryTreeNode;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestDiscoveryContext {
DiscoveryContext context = new DiscoveryContext();
@@ -30,7 +28,7 @@ public class TestDiscoveryContext {
Object inputParameters = new Object();
context.setInputParameters(inputParameters);
- Assert.assertSame(inputParameters, context.getInputParameters());
+ Assertions.assertSame(inputParameters, context.getInputParameters());
}
@Test
@@ -39,19 +37,19 @@ public class TestDiscoveryContext {
Object value = new Object();
context.putContextParameter(name, value);
- Assert.assertSame(value, context.getContextParameter(name));
- Assert.assertNull(context.getContextParameter("notExist"));
+ Assertions.assertSame(value, context.getContextParameter(name));
+ Assertions.assertNull(context.getContextParameter("notExist"));
}
@Test
public void rerun() {
- Assert.assertNull(context.popRerunFilter());
+ Assertions.assertNull(context.popRerunFilter());
DiscoveryTreeNode node = new DiscoveryTreeNode();
context.setCurrentNode(node);
context.pushRerunFilter();
- Assert.assertSame(node, context.popRerunFilter());
- Assert.assertNull(context.popRerunFilter());
+ Assertions.assertSame(node, context.popRerunFilter());
+ Assertions.assertNull(context.popRerunFilter());
}
}
diff --git a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/discovery/TestDiscoveryTree.java b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/discovery/TestDiscoveryTree.java
index 7b5bcd505..8914419e1 100644
--- a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/discovery/TestDiscoveryTree.java
+++ b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/discovery/TestDiscoveryTree.java
@@ -30,7 +30,6 @@ import org.apache.servicecomb.registry.cache.InstanceCacheManager;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
@@ -102,36 +101,36 @@ public class TestDiscoveryTree {
@Test
public void isMatch_existingNull() {
- Assert.assertFalse(discoveryTree.isMatch(null, null));
+ Assertions.assertFalse(discoveryTree.isMatch(null, null));
}
@Test
public void isMatch_yes() {
parent.cacheVersion(1);
- Assert.assertTrue(discoveryTree.isMatch(new DiscoveryTreeNode().cacheVersion(1), parent));
+ Assertions.assertTrue(discoveryTree.isMatch(new DiscoveryTreeNode().cacheVersion(1), parent));
}
@Test
public void isMatch_no() {
parent.cacheVersion(0);
- Assert.assertFalse(discoveryTree.isExpired(new DiscoveryTreeNode().cacheVersion(1), parent));
+ Assertions.assertFalse(discoveryTree.isExpired(new DiscoveryTreeNode().cacheVersion(1), parent));
}
@Test
public void isExpired_existingNull() {
- Assert.assertTrue(discoveryTree.isExpired(null, null));
+ Assertions.assertTrue(discoveryTree.isExpired(null, null));
}
@Test
public void isExpired_yes() {
parent.cacheVersion(1);
- Assert.assertTrue(discoveryTree.isExpired(new DiscoveryTreeNode().cacheVersion(0), parent));
+ Assertions.assertTrue(discoveryTree.isExpired(new DiscoveryTreeNode().cacheVersion(0), parent));
}
@Test
public void isExpired_no() {
parent.cacheVersion(0);
- Assert.assertFalse(discoveryTree.isExpired(new DiscoveryTreeNode().cacheVersion(0), parent));
+ Assertions.assertFalse(discoveryTree.isExpired(new DiscoveryTreeNode().cacheVersion(0), parent));
}
static class DiscoveryFilterForTest implements DiscoveryFilter {
@@ -172,7 +171,7 @@ public class TestDiscoveryTree {
result = discoveryTree.discovery(context, parent);
- Assert.assertEquals("1.0.0-2.0.0/g1/g2", result.name());
+ Assertions.assertEquals("1.0.0-2.0.0/g1/g2", result.name());
}
@Test
@@ -187,8 +186,8 @@ public class TestDiscoveryTree {
};
result = discoveryTree.discovery(context, null, null, null);
- Assert.assertEquals(parent.name(), result.name());
- Assert.assertEquals(parent.cacheVersion(), result.cacheVersion());
+ Assertions.assertEquals(parent.name(), result.name());
+ Assertions.assertEquals(parent.cacheVersion(), result.cacheVersion());
}
@Test
@@ -251,16 +250,16 @@ public class TestDiscoveryTree {
result = discoveryTree.discovery(context, parent);
- Assert.assertEquals("second", result.data());
+ Assertions.assertEquals("second", result.data());
}
@Test
public void avoidConcurrentProblem() {
Deencapsulation.setField(discoveryTree, "root", parent.cacheVersion(1));
- Assert.assertTrue(parent.children().isEmpty());
+ Assertions.assertTrue(parent.children().isEmpty());
discoveryTree.discovery(context, new VersionedCache().cacheVersion(0).name("input"));
- Assert.assertTrue(parent.children().isEmpty());
+ Assertions.assertTrue(parent.children().isEmpty());
}
@Test
@@ -269,7 +268,7 @@ public class TestDiscoveryTree {
DiscoveryTreeNode root = discoveryTree.getOrCreateRoot(parent);
- Assert.assertSame(parent, root);
+ Assertions.assertSame(parent, root);
}
@Test
@@ -279,8 +278,8 @@ public class TestDiscoveryTree {
VersionedCache inputCache = new VersionedCache().cacheVersion(parent.cacheVersion() + 1);
DiscoveryTreeNode root = discoveryTree.getOrCreateRoot(inputCache);
- Assert.assertEquals(inputCache.cacheVersion(), root.cacheVersion());
- Assert.assertSame(Deencapsulation.getField(discoveryTree, "root"), root);
+ Assertions.assertEquals(inputCache.cacheVersion(), root.cacheVersion());
+ Assertions.assertSame(Deencapsulation.getField(discoveryTree, "root"), root);
}
@Test
@@ -290,7 +289,7 @@ public class TestDiscoveryTree {
VersionedCache inputCache = new VersionedCache().cacheVersion(parent.cacheVersion() - 1);
DiscoveryTreeNode root = discoveryTree.getOrCreateRoot(inputCache);
- Assert.assertEquals(inputCache.cacheVersion(), root.cacheVersion());
- Assert.assertNotSame(Deencapsulation.getField(discoveryTree, "root"), root);
+ Assertions.assertEquals(inputCache.cacheVersion(), root.cacheVersion());
+ Assertions.assertNotSame(Deencapsulation.getField(discoveryTree, "root"), root);
}
}
diff --git a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/discovery/TestDiscoveryTreeNode.java b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/discovery/TestDiscoveryTreeNode.java
index e450a8709..0dcd4ff99 100644
--- a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/discovery/TestDiscoveryTreeNode.java
+++ b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/discovery/TestDiscoveryTreeNode.java
@@ -21,33 +21,32 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.servicecomb.foundation.common.cache.VersionedCache;
-import org.apache.servicecomb.registry.discovery.DiscoveryTreeNode;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestDiscoveryTreeNode {
DiscoveryTreeNode node = new DiscoveryTreeNode();
@Test
public void childrenInited() {
- Assert.assertFalse(node.childrenInited());
+ Assertions.assertFalse(node.childrenInited());
node.childrenInited(true);
- Assert.assertTrue(node.childrenInited());
+ Assertions.assertTrue(node.childrenInited());
}
@Test
public void level() {
node.level(1);
- Assert.assertEquals(1, node.level());
+ Assertions.assertEquals(1, node.level());
}
@Test
public void attribute() {
node.attribute("k1", "v1");
- Assert.assertEquals("v1", node.attribute("k1"));
+ Assertions.assertEquals("v1", node.attribute("k1"));
}
@Test
@@ -55,7 +54,7 @@ public class TestDiscoveryTreeNode {
Map<String, DiscoveryTreeNode> children = new HashMap<>();
node.children(children);
- Assert.assertSame(children, node.children());
+ Assertions.assertSame(children, node.children());
}
@Test
@@ -63,7 +62,7 @@ public class TestDiscoveryTreeNode {
DiscoveryTreeNode child = new DiscoveryTreeNode().name("child");
node.child(child.name(), child);
- Assert.assertSame(child, node.child(child.name()));
+ Assertions.assertSame(child, node.child(child.name()));
}
@Test
@@ -72,8 +71,8 @@ public class TestDiscoveryTreeNode {
VersionedCache other = new VersionedCache().cacheVersion(1).name("cache").data(data);
node.fromCache(other);
- Assert.assertEquals(1, node.cacheVersion());
- Assert.assertEquals("cache", node.name());
- Assert.assertSame(data, node.data());
+ Assertions.assertEquals(1, node.cacheVersion());
+ Assertions.assertEquals("cache", node.name());
+ Assertions.assertSame(data, node.data());
}
}
diff --git a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersion.java b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersion.java
index d239003e6..8cea823c3 100644
--- a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersion.java
+++ b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersion.java
@@ -18,9 +18,8 @@
package org.apache.servicecomb.registry.version;
import org.apache.servicecomb.foundation.common.Version;
-import org.junit.Assert;
-import org.junit.Test;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestVersion {
Version version;
@@ -32,39 +31,39 @@ public class TestVersion {
@Test
public void constructFromStringNormalOnlyMajor() {
version = new Version("1");
- Assert.assertEquals("1.0.0.0", version.getVersion());
- Assert.assertEquals(1, version.getMajor());
- Assert.assertEquals(0, version.getMinor());
- Assert.assertEquals(0, version.getPatch());
+ Assertions.assertEquals("1.0.0.0", version.getVersion());
+ Assertions.assertEquals(1, version.getMajor());
+ Assertions.assertEquals(0, version.getMinor());
+ Assertions.assertEquals(0, version.getPatch());
}
@Test
public void constructFromStringNormalOnlyMajorMinor() {
version = new Version("1.1");
- Assert.assertEquals("1.1.0.0", version.getVersion());
- Assert.assertEquals(1, version.getMajor());
- Assert.assertEquals(1, version.getMinor());
- Assert.assertEquals(0, version.getPatch());
+ Assertions.assertEquals("1.1.0.0", version.getVersion());
+ Assertions.assertEquals(1, version.getMajor());
+ Assertions.assertEquals(1, version.getMinor());
+ Assertions.assertEquals(0, version.getPatch());
}
@Test
public void constructFromStringOnlyMajorMinorPatch() {
version = new Version("1.1.1");
- Assert.assertEquals("1.1.1.0", version.getVersion());
- Assert.assertEquals(1, version.getMajor());
- Assert.assertEquals(1, version.getMinor());
- Assert.assertEquals(1, version.getPatch());
- Assert.assertEquals(0, version.getBuild());
+ Assertions.assertEquals("1.1.1.0", version.getVersion());
+ Assertions.assertEquals(1, version.getMajor());
+ Assertions.assertEquals(1, version.getMinor());
+ Assertions.assertEquals(1, version.getPatch());
+ Assertions.assertEquals(0, version.getBuild());
}
@Test
public void constructFromStringNormal() {
version = new Version("1.1.1.1");
- Assert.assertEquals("1.1.1.1", version.getVersion());
- Assert.assertEquals(1, version.getMajor());
- Assert.assertEquals(1, version.getMinor());
- Assert.assertEquals(1, version.getPatch());
- Assert.assertEquals(1, version.getBuild());
+ Assertions.assertEquals("1.1.1.1", version.getVersion());
+ Assertions.assertEquals(1, version.getMajor());
+ Assertions.assertEquals(1, version.getMinor());
+ Assertions.assertEquals(1, version.getPatch());
+ Assertions.assertEquals(1, version.getBuild());
}
@Test
@@ -153,46 +152,46 @@ public class TestVersion {
@Test
public void constructFromNumber() {
version = new Version(s1, s1, s1, s1);
- Assert.assertEquals("1.1.1.1", version.getVersion());
- Assert.assertEquals(1, version.getMajor());
- Assert.assertEquals(1, version.getMinor());
- Assert.assertEquals(1, version.getPatch());
- Assert.assertEquals(1, version.getPatch());
+ Assertions.assertEquals("1.1.1.1", version.getVersion());
+ Assertions.assertEquals(1, version.getMajor());
+ Assertions.assertEquals(1, version.getMinor());
+ Assertions.assertEquals(1, version.getPatch());
+ Assertions.assertEquals(1, version.getPatch());
}
@Test
public void testToString() {
version = new Version(s1, s1, s1, s1);
- Assert.assertEquals("1.1.1.1", version.toString());
+ Assertions.assertEquals("1.1.1.1", version.toString());
}
@Test
public void testHashCode() {
version = new Version(s1, s1, s1, s1);
- Assert.assertEquals(version.getVersion().hashCode(), version.hashCode());
+ Assertions.assertEquals(version.getVersion().hashCode(), version.hashCode());
}
@Test
public void testEquals() {
version = new Version(s1, s1, s1, s1);
- Assert.assertTrue(version.equals(version));
- Assert.assertTrue(version.equals(new Version(s1, s1, s1, s1)));
- Assert.assertFalse(version.equals(null));
+ Assertions.assertTrue(version.equals(version));
+ Assertions.assertTrue(version.equals(new Version(s1, s1, s1, s1)));
+ Assertions.assertFalse(version.equals(null));
}
@Test
public void compareTo() {
version = new Version(s1, s1, s1, s1);
- Assert.assertEquals(0, version.compareTo(version));
- Assert.assertEquals(0, version.compareTo(new Version(s1, s1, s1, s1)));
+ Assertions.assertEquals(0, version.compareTo(version));
+ Assertions.assertEquals(0, version.compareTo(new Version(s1, s1, s1, s1)));
- Assert.assertEquals(-1, version.compareTo(new Version(s1, s1, s2, s1)));
- Assert.assertEquals(-1, version.compareTo(new Version(s1, s2, s1, s1)));
- Assert.assertEquals(-1, version.compareTo(new Version(s2, s1, s1, s1)));
+ Assertions.assertEquals(-1, version.compareTo(new Version(s1, s1, s2, s1)));
+ Assertions.assertEquals(-1, version.compareTo(new Version(s1, s2, s1, s1)));
+ Assertions.assertEquals(-1, version.compareTo(new Version(s2, s1, s1, s1)));
- Assert.assertEquals(1, version.compareTo(new Version((short) 0,
+ Assertions.assertEquals(1, version.compareTo(new Version((short) 0,
Short.MAX_VALUE, Short.MAX_VALUE, Short.MAX_VALUE)));
}
}
diff --git a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersionRule.java b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersionRule.java
index 6726de574..a2a338242 100644
--- a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersionRule.java
+++ b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersionRule.java
@@ -18,11 +18,11 @@
package org.apache.servicecomb.registry.version;
import org.apache.servicecomb.foundation.common.Version;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestVersionRule {
- class VersionRuleForTest extends VersionRule {
+ static class VersionRuleForTest extends VersionRule {
public VersionRuleForTest(String versionRule) {
super(versionRule);
}
@@ -37,11 +37,11 @@ public class TestVersionRule {
@Test
public void isAccept() {
- Assert.assertTrue(versionRule.isAccept(null));
+ Assertions.assertTrue(versionRule.isAccept(null));
}
@Test
public void getVersionRule() {
- Assert.assertEquals("abc", versionRule.getVersionRule());
+ Assertions.assertEquals("abc", versionRule.getVersionRule());
}
}
diff --git a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersionRuleFixedParser.java b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersionRuleFixedParser.java
index 079d6cb75..2fec0b623 100644
--- a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersionRuleFixedParser.java
+++ b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersionRuleFixedParser.java
@@ -17,8 +17,8 @@
package org.apache.servicecomb.registry.version;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestVersionRuleFixedParser {
VersionRule versionRule;
@@ -28,13 +28,13 @@ public class TestVersionRuleFixedParser {
@Test
public void parseNormal() {
versionRule = parser.parse("1");
- Assert.assertEquals("1.0.0.0", versionRule.getVersionRule());
+ Assertions.assertEquals("1.0.0.0", versionRule.getVersionRule());
}
@Test
public void isMatch() {
versionRule = parser.parse("1");
- Assert.assertTrue(versionRule.isMatch(VersionConst.v1, null));
- Assert.assertFalse(versionRule.isMatch(VersionConst.v2, null));
+ Assertions.assertTrue(versionRule.isMatch(VersionConst.v1, null));
+ Assertions.assertFalse(versionRule.isMatch(VersionConst.v2, null));
}
}
diff --git a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersionRuleLatestParser.java b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersionRuleLatestParser.java
index f12c648ec..2592fc3a1 100644
--- a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersionRuleLatestParser.java
+++ b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersionRuleLatestParser.java
@@ -18,8 +18,8 @@
package org.apache.servicecomb.registry.version;
import org.apache.servicecomb.registry.definition.DefinitionConst;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestVersionRuleLatestParser {
VersionRuleParser parser = new VersionRuleLatestParser();
@@ -28,22 +28,22 @@ public class TestVersionRuleLatestParser {
@Test
public void parseInvalue() {
- Assert.assertNull(parser.parse(""));
+ Assertions.assertNull(parser.parse(""));
}
@Test
public void parseNormal() {
- Assert.assertEquals(DefinitionConst.VERSION_RULE_LATEST, versionRule.getVersionRule());
+ Assertions.assertEquals(DefinitionConst.VERSION_RULE_LATEST, versionRule.getVersionRule());
}
@Test
public void isAccept() {
- Assert.assertTrue(versionRule.isAccept(null));
+ Assertions.assertTrue(versionRule.isAccept(null));
}
@Test
public void isMatch() {
- Assert.assertTrue(versionRule.isMatch(VersionConst.v1, VersionConst.v1));
- Assert.assertFalse(versionRule.isMatch(VersionConst.v2, VersionConst.v1));
+ Assertions.assertTrue(versionRule.isMatch(VersionConst.v1, VersionConst.v1));
+ Assertions.assertFalse(versionRule.isMatch(VersionConst.v2, VersionConst.v1));
}
}
diff --git a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersionRuleRangeParser.java b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersionRuleRangeParser.java
index 768c7a61d..605e31671 100644
--- a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersionRuleRangeParser.java
+++ b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersionRuleRangeParser.java
@@ -17,8 +17,8 @@
package org.apache.servicecomb.registry.version;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestVersionRuleRangeParser {
VersionRuleParser parser = new VersionRuleRangeParser();
@@ -27,21 +27,21 @@ public class TestVersionRuleRangeParser {
@Test
public void parseInvalid() {
- Assert.assertNull(parser.parse(""));
- Assert.assertNull(parser.parse("-"));
- Assert.assertNull(parser.parse("1-"));
+ Assertions.assertNull(parser.parse(""));
+ Assertions.assertNull(parser.parse("-"));
+ Assertions.assertNull(parser.parse("1-"));
}
@Test
public void parseNormal() {
- Assert.assertEquals("1.0.0.0-2.0.0.0", versionRule.getVersionRule());
+ Assertions.assertEquals("1.0.0.0-2.0.0.0", versionRule.getVersionRule());
}
@Test
public void isMatch() {
- Assert.assertFalse(versionRule.isMatch(VersionConst.v0, null));
- Assert.assertTrue(versionRule.isMatch(VersionConst.v1, null));
- Assert.assertTrue(versionRule.isMatch(VersionConst.v1Max, null));
- Assert.assertFalse(versionRule.isMatch(VersionConst.v2, null));
+ Assertions.assertFalse(versionRule.isMatch(VersionConst.v0, null));
+ Assertions.assertTrue(versionRule.isMatch(VersionConst.v1, null));
+ Assertions.assertTrue(versionRule.isMatch(VersionConst.v1Max, null));
+ Assertions.assertFalse(versionRule.isMatch(VersionConst.v2, null));
}
}
diff --git a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersionRuleStartFromParser.java b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersionRuleStartFromParser.java
index 75ac90050..c5f31ed11 100644
--- a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersionRuleStartFromParser.java
+++ b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersionRuleStartFromParser.java
@@ -17,8 +17,8 @@
package org.apache.servicecomb.registry.version;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestVersionRuleStartFromParser {
VersionRuleParser parser = new VersionRuleStartFromParser();
@@ -27,21 +27,21 @@ public class TestVersionRuleStartFromParser {
@Test
public void parseInvalid() {
- Assert.assertNull(parser.parse(""));
- Assert.assertNull(parser.parse("+"));
- Assert.assertNull(parser.parse("1+1"));
+ Assertions.assertNull(parser.parse(""));
+ Assertions.assertNull(parser.parse("+"));
+ Assertions.assertNull(parser.parse("1+1"));
}
@Test
public void parseNormal() {
- Assert.assertEquals("1.0.0.0+", versionRule.getVersionRule());
+ Assertions.assertEquals("1.0.0.0+", versionRule.getVersionRule());
}
@Test
public void isMatch() {
- Assert.assertFalse(versionRule.isMatch(VersionConst.v0, null));
- Assert.assertTrue(versionRule.isMatch(VersionConst.v1, null));
- Assert.assertTrue(versionRule.isMatch(VersionConst.v1Max, null));
- Assert.assertTrue(versionRule.isMatch(VersionConst.v2, null));
+ Assertions.assertFalse(versionRule.isMatch(VersionConst.v0, null));
+ Assertions.assertTrue(versionRule.isMatch(VersionConst.v1, null));
+ Assertions.assertTrue(versionRule.isMatch(VersionConst.v1Max, null));
+ Assertions.assertTrue(versionRule.isMatch(VersionConst.v2, null));
}
}
diff --git a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersionRuleUtils.java b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersionRuleUtils.java
index 27f0952df..8b6c53a22 100644
--- a/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersionRuleUtils.java
+++ b/foundations/foundation-registry/src/test/java/org/apache/servicecomb/registry/version/TestVersionRuleUtils.java
@@ -22,40 +22,37 @@ import org.apache.servicecomb.registry.version.VersionRuleFixedParser.FixedVersi
import org.apache.servicecomb.registry.version.VersionRuleLatestParser.LatestVersionRule;
import org.apache.servicecomb.registry.version.VersionRuleRangeParser.RangeVersionRule;
import org.apache.servicecomb.registry.version.VersionRuleStartFromParser.StartFromVersionRule;
-import org.hamcrest.MatcherAssert;
-import org.hamcrest.Matchers;
-import org.junit.Assert;
-import org.junit.Test;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestVersionRuleUtils {
@Test
public void fixed() {
VersionRule versionRule = VersionRuleUtils.getOrCreate("1");
- MatcherAssert.assertThat(versionRule, Matchers.instanceOf(FixedVersionRule.class));
- Assert.assertSame(versionRule, VersionRuleUtils.getOrCreate("1"));
+ Assertions.assertTrue(versionRule instanceof FixedVersionRule);
+ Assertions.assertSame(versionRule, VersionRuleUtils.getOrCreate("1"));
}
@Test
public void latest() {
VersionRule versionRule = VersionRuleUtils.getOrCreate(DefinitionConst.VERSION_RULE_LATEST);
- MatcherAssert.assertThat(versionRule, Matchers.instanceOf(LatestVersionRule.class));
- Assert.assertSame(versionRule, VersionRuleUtils.getOrCreate(DefinitionConst.VERSION_RULE_LATEST));
+ Assertions.assertTrue(versionRule instanceof LatestVersionRule);
+ Assertions.assertSame(versionRule, VersionRuleUtils.getOrCreate(DefinitionConst.VERSION_RULE_LATEST));
}
@Test
public void range() {
VersionRule versionRule = VersionRuleUtils.getOrCreate("1-2");
- MatcherAssert.assertThat(versionRule, Matchers.instanceOf(RangeVersionRule.class));
- Assert.assertSame(versionRule, VersionRuleUtils.getOrCreate("1-2"));
+ Assertions.assertTrue(versionRule instanceof RangeVersionRule);
+ Assertions.assertSame(versionRule, VersionRuleUtils.getOrCreate("1-2"));
}
@Test
public void startFrom() {
VersionRule versionRule = VersionRuleUtils.getOrCreate("1+");
- MatcherAssert.assertThat(versionRule, Matchers.instanceOf(StartFromVersionRule.class));
- Assert.assertSame(versionRule, VersionRuleUtils.getOrCreate("1+"));
+ Assertions.assertTrue(versionRule instanceof StartFromVersionRule);
+ Assertions.assertSame(versionRule, VersionRuleUtils.getOrCreate("1+"));
}
@Test
diff --git a/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/CertificateUtilTest.java b/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/CertificateUtilTest.java
index 0285b8b31..341c65f4e 100644
--- a/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/CertificateUtilTest.java
+++ b/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/CertificateUtilTest.java
@@ -35,15 +35,15 @@ import java.util.Set;
import javax.security.auth.x500.X500Principal;
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 CertificateUtilTest {
- class MyX509Certificate extends X509Certificate {
+ static class MyX509Certificate extends X509Certificate {
private static final long serialVersionUID = -3585440601605666278L;
public void checkValidity() throws CertificateExpiredException, CertificateNotYetValidException {
@@ -199,7 +199,7 @@ public class CertificateUtilTest {
MyX509Certificate xxmyX509Certificate = new MyX509Certificate();
Set<String> strExpect = CertificateUtil.getCN(xxmyX509Certificate);
- Assert.assertEquals(true, strExpect.contains("Test1234"));
+ Assertions.assertTrue(strExpect.contains("Test1234"));
}
@Test
@@ -218,9 +218,9 @@ public class CertificateUtilTest {
try {
Set<String> strExpect = CertificateUtil.getCN(xxmyX509Certificate);
- Assert.assertEquals(strExpect.size(), 0);
+ Assertions.assertEquals(strExpect.size(), 0);
} catch (IllegalArgumentException e) {
- Assert.assertNotNull(null);
+ Assertions.assertNotNull(null);
}
}
@@ -255,7 +255,7 @@ public class CertificateUtilTest {
xxmyX509Certificate[1] = myX509Certificate2;
X509Certificate aX509Certificate = CertificateUtil.findOwner(xxmyX509Certificate);
- Assert.assertNull(aX509Certificate);
+ Assertions.assertNull(aX509Certificate);
}
@Test
@@ -290,9 +290,9 @@ public class CertificateUtilTest {
try {
X509Certificate aX509Certificate = CertificateUtil.findOwner(xxmyX509Certificate);
- Assert.assertNull(aX509Certificate);
+ Assertions.assertNull(aX509Certificate);
} catch (IllegalArgumentException e) {
- Assert.assertEquals("bad certificate chain: no root CA.", e.getMessage());
+ Assertions.assertEquals("bad certificate chain: no root CA.", e.getMessage());
}
}
}
diff --git a/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/KeyStoreUtilTest.java b/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/KeyStoreUtilTest.java
index 06f9a30ff..29bb19103 100644
--- a/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/KeyStoreUtilTest.java
+++ b/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/KeyStoreUtilTest.java
@@ -27,8 +27,8 @@ import java.security.cert.CertificateFactory;
import java.util.Collection;
import org.apache.commons.lang3.SystemUtils;
-import org.junit.Assert;
import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
import org.mockito.Mockito;
import mockit.Mock;
@@ -46,7 +46,7 @@ public class KeyStoreUtilTest {
try {
KeyStoreUtil.createKeyStore(storename, storetype, storevalue);
} catch (IllegalArgumentException e) {
- Assert.assertEquals("Bad key store or value.testType not found", e.getMessage());
+ Assertions.assertEquals("Bad key store or value.testType not found", e.getMessage());
}
}
@@ -59,7 +59,7 @@ public class KeyStoreUtilTest {
try {
KeyStoreUtil.createKeyStore(storename, storetype, storevalue);
} catch (IllegalArgumentException e) {
- Assert.assertEquals("Bad key store or value.DerInputStream.getLength(): lengthTag=109, too big.",
+ Assertions.assertEquals("Bad key store or value.DerInputStream.getLength(): lengthTag=109, too big.",
e.getMessage());
}
}
@@ -79,11 +79,11 @@ public class KeyStoreUtilTest {
KeyStoreUtil.createKeyManagers(keystore, storeKeyValue);
} catch (IllegalArgumentException e) {
if (SystemUtils.JAVA_SPECIFICATION_VERSION.startsWith("17")) {
- Assert.assertEquals("Bad key store.Get Key failed:"
+ Assertions.assertEquals("Bad key store.Get Key failed:"
+ " Cannot read the array length because \"password\" is null",
e.getMessage());
} else {
- Assert.assertEquals("Bad key store.Get Key failed: null",
+ Assertions.assertEquals("Bad key store.Get Key failed: null",
e.getMessage());
}
}
@@ -96,11 +96,11 @@ public class KeyStoreUtilTest {
boolean validAssert = true;
try {
CRL[] crl = KeyStoreUtil.createCRL(crlfile);
- Assert.assertNull(crl);
+ Assertions.assertNull(crl);
} catch (Exception e) {
validAssert = false;
}
- Assert.assertTrue(validAssert);
+ Assertions.assertTrue(validAssert);
}
@Test
@@ -119,7 +119,7 @@ public class KeyStoreUtilTest {
} catch (Exception e) {
validAssert = false;
}
- Assert.assertFalse(validAssert);
+ Assertions.assertFalse(validAssert);
}
@Test
@@ -137,9 +137,9 @@ public class KeyStoreUtilTest {
KeyStoreUtil.createCRL(crlfile);
} catch (Exception e) {
validAssert = false;
- Assert.assertEquals("java.lang.IllegalArgumentException", e.getClass().getName());
+ Assertions.assertEquals("java.lang.IllegalArgumentException", e.getClass().getName());
}
- Assert.assertFalse(validAssert);
+ Assertions.assertFalse(validAssert);
}
@Test
@@ -156,9 +156,9 @@ public class KeyStoreUtilTest {
KeyStoreUtil.createCRL(crlfile);
} catch (Exception e) {
validAssert = false;
- Assert.assertEquals("java.lang.IllegalArgumentException", e.getClass().getName());
+ Assertions.assertEquals("java.lang.IllegalArgumentException", e.getClass().getName());
}
- Assert.assertFalse(validAssert);
+ Assertions.assertFalse(validAssert);
}
private void mockGenerateCRLs() {
diff --git a/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/SSLManagerTest.java b/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/SSLManagerTest.java
index b89f149b7..6aa67c1ef 100644
--- a/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/SSLManagerTest.java
+++ b/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/SSLManagerTest.java
@@ -35,13 +35,13 @@ import javax.net.ssl.SSLServerSocket;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
-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 SSLManagerTest {
private final String DIR = Thread.currentThread().getContextClassLoader().getResource("").getPath();
@@ -120,19 +120,19 @@ public class SSLManagerTest {
}
};
final SSLServerSocket serverSocket = SSLManager.createSSLServerSocket(option, custom);
- Assert.assertTrue(serverSocket.getNeedClientAuth());
+ Assertions.assertTrue(serverSocket.getNeedClientAuth());
serverSocket.bind(new InetSocketAddress("127.0.0.1", 8886));
String[] protos = serverSocket.getEnabledCipherSuites();
String[] protosExpected =
"TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_DSS_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_DSS_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA"
.split(",");
- Assert.assertArrayEquals(protos, protosExpected);
+ Assertions.assertArrayEquals(protos, protosExpected);
String[] ciphers = serverSocket.getEnabledCipherSuites();
String[] ciphersExpected =
"TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_DSS_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_DSS_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA"
.split(",");
- Assert.assertArrayEquals(ciphers, ciphersExpected);
- Assert.assertEquals(serverSocket.getNeedClientAuth(), true);
+ Assertions.assertArrayEquals(ciphers, ciphersExpected);
+ Assertions.assertEquals(serverSocket.getNeedClientAuth(), true);
SSLOption clientoption = SSLOption.build(DIR + "/client.ssl.properties");
SSLSocket clientsocket = SSLManager.createSSLSocket(clientoption, custom);
@@ -140,13 +140,13 @@ public class SSLManagerTest {
String[] clientprotosExpected =
"TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_DSS_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_DSS_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA"
.split(",");
- Assert.assertArrayEquals(clientprotos, clientprotosExpected);
+ Assertions.assertArrayEquals(clientprotos, clientprotosExpected);
String[] clientciphers = clientsocket.getEnabledCipherSuites();
String[] clientciphersExpected =
"TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_DSS_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_DSS_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA"
.split(",");
- Assert.assertArrayEquals(clientciphers, clientciphersExpected);
- Assert.assertEquals(clientsocket.getNeedClientAuth(), false);
+ Assertions.assertArrayEquals(clientciphers, clientciphersExpected);
+ Assertions.assertEquals(clientsocket.getNeedClientAuth(), false);
boolean validAssert = true;
try {
clientsocket.connect(new InetSocketAddress("127.0.0.1", 8886));
@@ -166,8 +166,7 @@ public class SSLManagerTest {
s.getOutputStream().write(new byte[] {0, 1});
} catch (IOException e) {
e.printStackTrace();
- // this should not happen, do a false assert
- Assert.assertEquals(false, true);
+ Assertions.fail("this should not happen");
}
}
}.start();
@@ -181,7 +180,7 @@ public class SSLManagerTest {
e.printStackTrace();
validAssert = false;
}
- Assert.assertTrue(validAssert);
+ Assertions.assertTrue(validAssert);
}
@Test
@@ -201,8 +200,8 @@ public class SSLManagerTest {
SSLEngine aSSLEngine = SSLManager.createSSLEngine(option, custom);
// if client mode may not decided at initialization. Different JDK is different, do not check it.
- // Assert.assertEquals(false, aSSLEngine.getUseClientMode());
- Assert.assertTrue(aSSLEngine.getNeedClientAuth());
+ // Assertions.assertEquals(false, aSSLEngine.getUseClientMode());
+ Assertions.assertTrue(aSSLEngine.getNeedClientAuth());
}
@Test
@@ -224,9 +223,9 @@ public class SSLManagerTest {
SSLEngine aSSLEngine = SSLManager.createSSLEngine(option, custom);
// if client mode may not decided at initialization. Different JDK is different, do not check it.
- // Assert.assertEquals(false, aSSLEngine.getUseClientMode());
- Assert.assertFalse(aSSLEngine.getNeedClientAuth());
- Assert.assertFalse(aSSLEngine.getWantClientAuth());
+ // Assertions.assertEquals(false, aSSLEngine.getUseClientMode());
+ Assertions.assertFalse(aSSLEngine.getNeedClientAuth());
+ Assertions.assertFalse(aSSLEngine.getWantClientAuth());
}
@Test
@@ -247,8 +246,8 @@ public class SSLManagerTest {
int port = 39093;
String peerHost = "host1";
SSLEngine aSSLEngine = SSLManager.createSSLEngine(option, custom, peerHost, port);
- Assert.assertNotNull(aSSLEngine);
- Assert.assertEquals("host1", aSSLEngine.getPeerHost());
+ Assertions.assertNotNull(aSSLEngine);
+ Assertions.assertEquals("host1", aSSLEngine.getPeerHost());
}
@Test
@@ -258,7 +257,7 @@ public class SSLManagerTest {
SSLCustom custom = SSLCustom.defaultSSLCustom();
SSLContext context = SSLManager.createSSLContext(option, custom);
- Assert.assertNotNull(context);
+ Assertions.assertNotNull(context);
}
@Test
@@ -286,9 +285,9 @@ public class SSLManagerTest {
try {
SSLManager.createSSLContext(option, custom);
- Assert.assertNotNull(null);
+ Assertions.assertNotNull(null);
} catch (Exception e) {
- Assert.assertEquals("java.lang.IllegalArgumentException", e.getClass().getName());
+ Assertions.assertEquals("java.lang.IllegalArgumentException", e.getClass().getName());
}
}
@@ -317,9 +316,9 @@ public class SSLManagerTest {
try {
SSLManager.createSSLContext(option, custom);
- Assert.assertNotNull(null);
+ Assertions.assertNotNull(null);
} catch (Exception e) {
- Assert.assertEquals("java.lang.IllegalArgumentException", e.getClass().getName());
+ Assertions.assertEquals("java.lang.IllegalArgumentException", e.getClass().getName());
}
}
@@ -349,9 +348,9 @@ public class SSLManagerTest {
try {
SSLManager.createSSLServerSocket(option, custom);
- Assert.assertNotNull(null);
+ Assertions.assertNotNull(null);
} catch (Exception e) {
- Assert.assertEquals("java.lang.IllegalArgumentException", e.getClass().getName());
+ Assertions.assertEquals("java.lang.IllegalArgumentException", e.getClass().getName());
}
}
@@ -380,9 +379,9 @@ public class SSLManagerTest {
try {
SSLManager.createSSLServerSocket(option, custom);
- Assert.assertNotNull(null);
+ Assertions.assertNotNull(null);
} catch (Exception e) {
- Assert.assertEquals("java.lang.IllegalArgumentException", e.getClass().getName());
+ Assertions.assertEquals("java.lang.IllegalArgumentException", e.getClass().getName());
}
}
@@ -411,9 +410,9 @@ public class SSLManagerTest {
try {
SSLManager.createSSLSocket(option, custom);
- Assert.assertNotNull(null);
+ Assertions.assertNotNull(null);
} catch (Exception e) {
- Assert.assertEquals("java.lang.IllegalArgumentException", e.getClass().getName());
+ Assertions.assertEquals("java.lang.IllegalArgumentException", e.getClass().getName());
}
}
@@ -442,9 +441,9 @@ public class SSLManagerTest {
try {
SSLManager.createSSLSocket(option, custom);
- Assert.assertNotNull(null);
+ Assertions.assertNotNull(null);
} catch (Exception e) {
- Assert.assertEquals("java.lang.IllegalArgumentException", e.getClass().getName());
+ Assertions.assertEquals("java.lang.IllegalArgumentException", e.getClass().getName());
}
}
@@ -464,12 +463,12 @@ public class SSLManagerTest {
};
SSLSocketFactory aSSLSocketFactory = SSLManager.createSSLSocketFactory(option, custom);
- Assert.assertNotNull(aSSLSocketFactory.getDefaultCipherSuites()[0]);
+ Assertions.assertNotNull(aSSLSocketFactory.getDefaultCipherSuites()[0]);
}
@Test
public void testGetSupportedCiphers() {
String[] ciphers = SSLManager.getEnabledCiphers("TLS_RSA_WITH_AES_128_GCM_SHA256");
- Assert.assertEquals(ciphers[0], "TLS_RSA_WITH_AES_128_GCM_SHA256");
+ Assertions.assertEquals(ciphers[0], "TLS_RSA_WITH_AES_128_GCM_SHA256");
}
}
diff --git a/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/SSLOptionTest.java b/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/SSLOptionTest.java
index 6864d61b5..31334409e 100644
--- a/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/SSLOptionTest.java
+++ b/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/SSLOptionTest.java
@@ -17,8 +17,6 @@
package org.apache.servicecomb.foundation.ssl;
-import static org.apache.servicecomb.config.archaius.sources.ConfigSourceMaker.yamlConfigSource;
-
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -28,8 +26,8 @@ import java.util.Properties;
import org.apache.commons.configuration.SystemConfiguration;
import org.apache.servicecomb.config.ConfigUtil;
+import org.apache.servicecomb.config.archaius.sources.ConfigSourceMaker;
import org.junit.AfterClass;
-import org.junit.Assert;
import org.junit.Test;
import com.netflix.config.ConcurrentCompositeConfiguration;
@@ -42,6 +40,7 @@ import com.netflix.config.FixedDelayPollingScheduler;
import mockit.Deencapsulation;
import mockit.Mock;
import mockit.MockUp;
+import org.junit.jupiter.api.Assertions;
public class SSLOptionTest {
private static final String DIR = Thread.currentThread().getContextClassLoader().getResource("").getPath();
@@ -60,11 +59,11 @@ public class SSLOptionTest {
String protocols = option.getProtocols();
option.setProtocols(protocols);
- Assert.assertEquals("TLSv1.2,TLSv1.1,TLSv1,SSLv2Hello", protocols);
+ Assertions.assertEquals("TLSv1.2,TLSv1.1,TLSv1,SSLv2Hello", protocols);
String ciphers = option.getCiphers();
option.setCiphers(ciphers);
- Assert.assertEquals(
+ Assertions.assertEquals(
"TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_DSS_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SH"
+
"A,TLS_DHE_DSS_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA",
@@ -72,62 +71,62 @@ public class SSLOptionTest {
boolean authPeer = option.isAuthPeer();
option.setAuthPeer(authPeer);
- Assert.assertTrue(authPeer);
+ Assertions.assertTrue(authPeer);
boolean checkCNHost = option.isCheckCNHost();
option.setCheckCNHost(checkCNHost);
- Assert.assertTrue(checkCNHost);
+ Assertions.assertTrue(checkCNHost);
boolean checkCNWhite = option.isCheckCNWhite();
option.setCheckCNWhite(checkCNWhite);
- Assert.assertTrue(checkCNWhite);
+ Assertions.assertTrue(checkCNWhite);
String checkCNWhiteFile = option.getCheckCNWhiteFile();
option.setCheckCNWhiteFile(checkCNWhiteFile);
- Assert.assertEquals("white.list", checkCNWhiteFile);
+ Assertions.assertEquals("white.list", checkCNWhiteFile);
boolean allowRenegociate = option.isAllowRenegociate();
option.setAllowRenegociate(allowRenegociate);
- Assert.assertFalse(allowRenegociate);
+ Assertions.assertFalse(allowRenegociate);
String storePath = option.getStorePath();
option.setStorePath(storePath);
- Assert.assertEquals("internal", storePath);
+ Assertions.assertEquals("internal", storePath);
String trustStore = option.getTrustStore();
option.setTrustStore(trustStore);
- Assert.assertEquals("trust.jks", trustStore);
+ Assertions.assertEquals("trust.jks", trustStore);
String trustStoreType = option.getTrustStoreType();
option.setTrustStoreType(trustStoreType);
- Assert.assertEquals("JKS", trustStoreType);
+ Assertions.assertEquals("JKS", trustStoreType);
String trustStoreValue = option.getTrustStoreValue();
option.setTrustStoreValue(trustStoreValue);
- Assert.assertEquals("Changeme_123", trustStoreValue);
+ Assertions.assertEquals("Changeme_123", trustStoreValue);
String keyStore = option.getKeyStore();
option.setKeyStore(keyStore);
- Assert.assertEquals("server.p12", keyStore);
+ Assertions.assertEquals("server.p12", keyStore);
String keyStoreType = option.getKeyStoreType();
option.setKeyStoreType(keyStoreType);
- Assert.assertEquals("PKCS12", keyStoreType);
+ Assertions.assertEquals("PKCS12", keyStoreType);
String keyStoreValue = option.getKeyStoreValue();
option.setKeyStoreValue(keyStoreValue);
- Assert.assertEquals("Changeme_123", keyStoreValue);
+ Assertions.assertEquals("Changeme_123", keyStoreValue);
String crl = option.getCrl();
option.setCrl(crl);
- Assert.assertEquals("revoke.crl", crl);
+ Assertions.assertEquals("revoke.crl", crl);
}
@Test
public void testSSLOptionYaml() {
// configuration from yaml files: default microservice.yaml
DynamicConfiguration configFromYamlFile =
- new DynamicConfiguration(yamlConfigSource(), new FixedDelayPollingScheduler());
+ new DynamicConfiguration(ConfigSourceMaker.yamlConfigSource(), new FixedDelayPollingScheduler());
// configuration from system properties
ConcurrentMapConfiguration configFromSystemProperties =
new ConcurrentMapConfiguration(new SystemConfiguration());
@@ -143,11 +142,11 @@ public class SSLOptionTest {
String protocols = option.getProtocols();
option.setProtocols(protocols);
- Assert.assertEquals("TLSv1.2,TLSv1.1,TLSv1,SSLv2Hello", protocols);
+ Assertions.assertEquals("TLSv1.2,TLSv1.1,TLSv1,SSLv2Hello", protocols);
String ciphers = option.getCiphers();
option.setCiphers(ciphers);
- Assert.assertEquals(
+ Assertions.assertEquals(
"TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_DSS_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SH"
+
"A,TLS_DHE_DSS_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA",
@@ -155,60 +154,60 @@ public class SSLOptionTest {
boolean authPeer = option.isAuthPeer();
option.setAuthPeer(authPeer);
- Assert.assertTrue(authPeer);
+ Assertions.assertTrue(authPeer);
boolean checkCNHost = option.isCheckCNHost();
option.setCheckCNHost(checkCNHost);
- Assert.assertTrue(checkCNHost);
+ Assertions.assertTrue(checkCNHost);
boolean checkCNWhite = option.isCheckCNWhite();
option.setCheckCNWhite(checkCNWhite);
- Assert.assertTrue(checkCNWhite);
+ Assertions.assertTrue(checkCNWhite);
String checkCNWhiteFile = option.getCheckCNWhiteFile();
option.setCheckCNWhiteFile(checkCNWhiteFile);
- Assert.assertEquals("white.list", checkCNWhiteFile);
+ Assertions.assertEquals("white.list", checkCNWhiteFile);
boolean allowRenegociate = option.isAllowRenegociate();
option.setAllowRenegociate(allowRenegociate);
- Assert.assertFalse(allowRenegociate);
+ Assertions.assertFalse(allowRenegociate);
String storePath = option.getStorePath();
option.setStorePath(storePath);
- Assert.assertEquals("internal", storePath);
+ Assertions.assertEquals("internal", storePath);
String trustStore = option.getTrustStore();
option.setTrustStore(trustStore);
- Assert.assertEquals("trust.jks", trustStore);
+ Assertions.assertEquals("trust.jks", trustStore);
String trustStoreType = option.getTrustStoreType();
option.setTrustStoreType(trustStoreType);
- Assert.assertEquals("JKS", trustStoreType);
+ Assertions.assertEquals("JKS", trustStoreType);
String trustStoreValue = option.getTrustStoreValue();
option.setTrustStoreValue(trustStoreValue);
- Assert.assertEquals("Changeme_123", trustStoreValue);
+ Assertions.assertEquals("Changeme_123", trustStoreValue);
String keyStore = option.getKeyStore();
option.setKeyStore(keyStore);
- Assert.assertEquals("server.p12", keyStore);
+ Assertions.assertEquals("server.p12", keyStore);
String keyStoreType = option.getKeyStoreType();
option.setKeyStoreType(keyStoreType);
- Assert.assertEquals("PKCS12", keyStoreType);
+ Assertions.assertEquals("PKCS12", keyStoreType);
String keyStoreValue = option.getKeyStoreValue();
option.setKeyStoreValue(keyStoreValue);
- Assert.assertEquals("Changeme_123", keyStoreValue);
+ Assertions.assertEquals("Changeme_123", keyStoreValue);
String crl = option.getCrl();
option.setCrl(crl);
- Assert.assertEquals("revoke.crl", crl);
+ Assertions.assertEquals("revoke.crl", crl);
option.setSslCustomClass("123");
SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
- Assert.assertArrayEquals(custom.decode("123".toCharArray()), "123".toCharArray());
+ Assertions.assertArrayEquals(custom.decode("123".toCharArray()), "123".toCharArray());
}
@Test
@@ -220,7 +219,7 @@ public class SSLOptionTest {
String protocols = option.getProtocols();
option.setProtocols(protocols);
- Assert.assertEquals("TLSv1.2", protocols);
+ Assertions.assertEquals("TLSv1.2", protocols);
System.clearProperty("ssl.protocols");
}
@@ -233,7 +232,7 @@ public class SSLOptionTest {
boolean authPeer = option.isAuthPeer();
option.setAuthPeer(authPeer);
- Assert.assertFalse(authPeer);
+ Assertions.assertFalse(authPeer);
System.getProperties().remove("ssl.authPeer");
}
@@ -246,7 +245,7 @@ public class SSLOptionTest {
boolean authPeer = option.isAuthPeer();
option.setAuthPeer(authPeer);
- Assert.assertTrue(authPeer);
+ Assertions.assertTrue(authPeer);
System.getProperties().remove("ssl.authPeer");
}
@@ -258,11 +257,11 @@ public class SSLOptionTest {
String protocols = option.getProtocols();
option.setProtocols(protocols);
- Assert.assertEquals("TLSv1.2,TLSv1.1,TLSv1,SSLv2Hello", protocols);
+ Assertions.assertEquals("TLSv1.2,TLSv1.1,TLSv1,SSLv2Hello", protocols);
String ciphers = option.getCiphers();
option.setCiphers(ciphers);
- Assert.assertEquals(
+ Assertions.assertEquals(
"TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_DSS_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SH"
+
"A,TLS_DHE_DSS_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA",
@@ -270,60 +269,60 @@ public class SSLOptionTest {
boolean authPeer = option.isAuthPeer();
option.setAuthPeer(authPeer);
- Assert.assertTrue(authPeer);
+ Assertions.assertTrue(authPeer);
boolean checkCNHost = option.isCheckCNHost();
option.setCheckCNHost(checkCNHost);
- Assert.assertTrue(checkCNHost);
+ Assertions.assertTrue(checkCNHost);
boolean checkCNWhite = option.isCheckCNWhite();
option.setCheckCNWhite(checkCNWhite);
- Assert.assertTrue(checkCNWhite);
+ Assertions.assertTrue(checkCNWhite);
String checkCNWhiteFile = option.getCheckCNWhiteFile();
option.setCheckCNWhiteFile(checkCNWhiteFile);
- Assert.assertEquals("white.list", checkCNWhiteFile);
+ Assertions.assertEquals("white.list", checkCNWhiteFile);
boolean allowRenegociate = option.isAllowRenegociate();
option.setAllowRenegociate(allowRenegociate);
- Assert.assertFalse(allowRenegociate);
+ Assertions.assertFalse(allowRenegociate);
String storePath = option.getStorePath();
option.setStorePath(storePath);
- Assert.assertEquals("internal", storePath);
+ Assertions.assertEquals("internal", storePath);
String trustStore = option.getTrustStore();
option.setTrustStore(trustStore);
- Assert.assertEquals("trust.jks", trustStore);
+ Assertions.assertEquals("trust.jks", trustStore);
String trustStoreType = option.getTrustStoreType();
option.setTrustStoreType(trustStoreType);
- Assert.assertEquals("JKS", trustStoreType);
+ Assertions.assertEquals("JKS", trustStoreType);
String trustStoreValue = option.getTrustStoreValue();
option.setTrustStoreValue(trustStoreValue);
- Assert.assertEquals("Changeme_123", trustStoreValue);
+ Assertions.assertEquals("Changeme_123", trustStoreValue);
String keyStore = option.getKeyStore();
option.setKeyStore(keyStore);
- Assert.assertEquals("server.p12", keyStore);
+ Assertions.assertEquals("server.p12", keyStore);
String keyStoreType = option.getKeyStoreType();
option.setKeyStoreType(keyStoreType);
- Assert.assertEquals("PKCS12", keyStoreType);
+ Assertions.assertEquals("PKCS12", keyStoreType);
String keyStoreValue = option.getKeyStoreValue();
option.setKeyStoreValue(keyStoreValue);
- Assert.assertEquals("Changeme_123", keyStoreValue);
+ Assertions.assertEquals("Changeme_123", keyStoreValue);
String crl = option.getCrl();
option.setCrl(crl);
- Assert.assertEquals("revoke.crl", crl);
+ Assertions.assertEquals("revoke.crl", crl);
option.setSslCustomClass("123");
SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
- Assert.assertArrayEquals(custom.decode("123".toCharArray()), "123".toCharArray());
+ Assertions.assertArrayEquals(custom.decode("123".toCharArray()), "123".toCharArray());
}
@SuppressWarnings("unused")
@@ -332,7 +331,7 @@ public class SSLOptionTest {
try {
SSLOption option = SSLOption.build(DIR + "/servers.ssl.properties");
} catch (IllegalArgumentException e) {
- Assert.assertEquals("Bad file name.", e.getMessage());
+ Assertions.assertEquals("Bad file name.", e.getMessage());
}
}
@@ -347,9 +346,9 @@ public class SSLOptionTest {
try {
SSLOption option = SSLOption.build(DIR + "/server.ssl.properties");
- Assert.assertNotNull(option);
+ Assertions.assertNotNull(option);
} catch (Exception e) {
- Assert.assertEquals("java.lang.IllegalArgumentException", e.getClass().getName());
+ Assertions.assertEquals("java.lang.IllegalArgumentException", e.getClass().getName());
}
}
@@ -364,12 +363,12 @@ public class SSLOptionTest {
boolean validAssert = true;
try {
SSLOption option = SSLOption.build(DIR + "/server.ssl.properties");
- Assert.assertEquals("revoke.crl", option.getCrl());
+ Assertions.assertEquals("revoke.crl", option.getCrl());
} catch (Exception e) {
- Assert.assertEquals("java.lang.IllegalArgumentException", e.getClass().getName());
+ Assertions.assertEquals("java.lang.IllegalArgumentException", e.getClass().getName());
validAssert = false;
}
- Assert.assertFalse(validAssert);
+ Assertions.assertFalse(validAssert);
}
@Test
@@ -380,9 +379,9 @@ public class SSLOptionTest {
InputStream inputStream = url.openStream();
SSLOption option = SSLOption.build(inputStream);
- Assert.assertNotNull(option);
+ Assertions.assertNotNull(option);
} catch (Exception e) {
- Assert.assertEquals("java.lang.IllegalArgumentException", e.getClass().getName());
+ Assertions.assertEquals("java.lang.IllegalArgumentException", e.getClass().getName());
}
}
@@ -393,9 +392,9 @@ public class SSLOptionTest {
try {
option.load("test");
} catch (Exception e) {
- Assert.assertEquals("java.lang.IllegalArgumentException", e.getClass().getName());
+ Assertions.assertEquals("java.lang.IllegalArgumentException", e.getClass().getName());
validAssert = false;
}
- Assert.assertFalse(validAssert);
+ Assertions.assertFalse(validAssert);
}
}
diff --git a/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/TestSSLOptionFactory.java b/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/TestSSLOptionFactory.java
index cf3e70755..184763ca5 100644
--- a/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/TestSSLOptionFactory.java
+++ b/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/TestSSLOptionFactory.java
@@ -17,7 +17,6 @@
package org.apache.servicecomb.foundation.ssl;
-import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
@@ -33,7 +32,7 @@ public class TestSSLOptionFactory {
@Test
public void testSSLOptionFactory() {
SSLOptionFactory factory = SSLOptionFactory.createSSLOptionFactory("cc", null);
- Assert.assertEquals(factory, null);
+ Assertions.assertEquals(factory, null);
}
@Test
@@ -60,6 +59,6 @@ public class TestSSLOptionFactory {
}
};
SSLOptionFactory factory = SSLOptionFactory.createSSLOptionFactory("cc", null);
- Assert.assertEquals(factory.createSSLOption().getProtocols(), "TLSv1.2");
+ Assertions.assertEquals(factory.createSSLOption().getProtocols(), "TLSv1.2");
}
}
diff --git a/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/TestSSLSocketFactoryExt.java b/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/TestSSLSocketFactoryExt.java
index 001600bd0..7c1e8c877 100644
--- a/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/TestSSLSocketFactoryExt.java
+++ b/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/TestSSLSocketFactoryExt.java
@@ -20,9 +20,9 @@ package org.apache.servicecomb.foundation.ssl;
import javax.net.ssl.SSLSocketFactory;
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 TestSSLSocketFactoryExt {
@@ -51,6 +51,6 @@ public class TestSSLSocketFactoryExt {
} catch (Exception e) {
validAssert = false;
}
- Assert.assertFalse(validAssert);
+ Assertions.assertFalse(validAssert);
}
}
diff --git a/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/TestTrustAllManager.java b/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/TestTrustAllManager.java
index 8690a79ab..7a5256925 100644
--- a/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/TestTrustAllManager.java
+++ b/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/TestTrustAllManager.java
@@ -17,14 +17,14 @@
package org.apache.servicecomb.foundation.ssl;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
import java.net.Socket;
import java.security.cert.X509Certificate;
import javax.net.ssl.SSLEngine;
-import org.junit.Assert;
-import org.junit.Test;
-
public class TestTrustAllManager {
@Test
public void testTrustAllManager() throws Exception {
@@ -45,6 +45,6 @@ public class TestTrustAllManager {
manager.checkServerTrusted((X509Certificate[]) null,
(String) null,
(SSLEngine) null);
- Assert.assertEquals(manager.getAcceptedIssuers() == null, true);
+ Assertions.assertNull(manager.getAcceptedIssuers());
}
}
diff --git a/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/TrustManagerExtTest.java b/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/TrustManagerExtTest.java
index 22f8cb740..5391a646c 100644
--- a/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/TrustManagerExtTest.java
+++ b/foundations/foundation-ssl/src/test/java/org/apache/servicecomb/foundation/ssl/TrustManagerExtTest.java
@@ -41,7 +41,6 @@ import javax.net.ssl.TrustManager;
import javax.net.ssl.X509ExtendedTrustManager;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -49,6 +48,7 @@ import mockit.Expectations;
import mockit.Mock;
import mockit.MockUp;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TrustManagerExtTest {
final String strFilePath = Thread.currentThread().getContextClassLoader().getResource("").getPath();
@@ -260,8 +260,8 @@ public class TrustManagerExtTest {
TrustManagerExt trustManagerExt = new TrustManagerExt((X509ExtendedTrustManager) trustManager[0],
option, custom);
- Assert.assertEquals(3, trustManagerExt.getAcceptedIssuers()[0].getVersion());
- Assert.assertNotNull(trustManagerExt);
+ Assertions.assertEquals(3, trustManagerExt.getAcceptedIssuers()[0].getVersion());
+ Assertions.assertNotNull(trustManagerExt);
}
@Test
@@ -286,7 +286,7 @@ public class TrustManagerExtTest {
MyX509ExtendedTrustManager myX509ExtendedTrustManager = new MyX509ExtendedTrustManager();
TrustManagerExt trustManagerExt = new TrustManagerExt(myX509ExtendedTrustManager, option, custom);
- Assert.assertNotNull(trustManagerExt);
+ Assertions.assertNotNull(trustManagerExt);
boolean validAssert = true;
try {
trustManagerExt.checkClientTrusted(MyX509CertificateArray, "pks");
@@ -295,7 +295,7 @@ public class TrustManagerExtTest {
} catch (Exception e) {
validAssert = false;
}
- Assert.assertTrue(validAssert);
+ Assertions.assertTrue(validAssert);
}
@Test
@@ -331,7 +331,7 @@ public class TrustManagerExtTest {
} catch (Exception e) {
validAssert = false;
}
- Assert.assertTrue(validAssert);
+ Assertions.assertTrue(validAssert);
}
@Test
@@ -359,10 +359,10 @@ public class TrustManagerExtTest {
try {
trustManagerExt.checkClientTrusted(MyX509CertificateArray, "pks");
} catch (CertificateException e) {
- Assert.assertEquals("CN does not match IP: e=[10.67.147.114],t=null", e.getMessage());
+ Assertions.assertEquals("CN does not match IP: e=[10.67.147.114],t=null", e.getMessage());
validAssert = false;
}
- Assert.assertFalse(validAssert);
+ Assertions.assertFalse(validAssert);
}
@Test
@@ -403,9 +403,9 @@ public class TrustManagerExtTest {
trustManagerExt.checkServerTrusted(MyX509CertificateArray, "pks", socket);
trustManagerExt.checkServerTrusted(MyX509CertificateArray, "pks", sslengine);
} catch (Exception e) {
- Assert.assertEquals("java.security.cert.CertificateException", e.getClass().getName());
+ Assertions.assertEquals("java.security.cert.CertificateException", e.getClass().getName());
validAssert = false;
}
- Assert.assertFalse(validAssert);
+ Assertions.assertFalse(validAssert);
}
}
diff --git a/foundations/foundation-vertx/src/test/java/io/vertx/ext/web/impl/TestHttpServerRequestUtils.java b/foundations/foundation-vertx/src/test/java/io/vertx/ext/web/impl/TestHttpServerRequestUtils.java
index f4c918957..67140330a 100644
--- a/foundations/foundation-vertx/src/test/java/io/vertx/ext/web/impl/TestHttpServerRequestUtils.java
+++ b/foundations/foundation-vertx/src/test/java/io/vertx/ext/web/impl/TestHttpServerRequestUtils.java
@@ -18,7 +18,6 @@
package io.vertx.ext.web.impl;
import org.apache.servicecomb.foundation.vertx.http.VertxServerRequestToHttpServletRequest;
-import org.junit.Assert;
import org.junit.Test;
import io.vertx.core.http.impl.HttpServerRequestInternal;
@@ -26,6 +25,7 @@ import io.vertx.ext.web.AllowForwardHeaders;
import io.vertx.ext.web.RoutingContext;
import mockit.Expectations;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
// HttpServerRequestWrapper is a package visible class, so put this test in package io.vertx.ext.web.impl
public class TestHttpServerRequestUtils {
@@ -43,6 +43,6 @@ public class TestHttpServerRequestUtils {
};
VertxServerRequestToHttpServletRequest reqEx = new VertxServerRequestToHttpServletRequest(context, "abc");
- Assert.assertEquals("abc", reqEx.getRequestURI());
+ Assertions.assertEquals("abc", reqEx.getRequestURI());
}
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestAddressResolverConfig.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestAddressResolverConfig.java
index 08741be27..dd57ee4ae 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestAddressResolverConfig.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestAddressResolverConfig.java
@@ -17,22 +17,19 @@
package org.apache.servicecomb.foundation.vertx;
-import static org.hamcrest.CoreMatchers.is;
-
import java.util.Arrays;
import java.util.Collections;
import org.apache.commons.configuration.Configuration;
import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
-import org.hamcrest.MatcherAssert;
import org.junit.AfterClass;
-import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import io.vertx.core.dns.AddressResolverOptions;
import mockit.Expectations;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestAddressResolverConfig {
@@ -63,12 +60,11 @@ public class TestAddressResolverConfig {
}
};
AddressResolverOptions resolverOptions = AddressResolverConfig.getAddressResover("test", finalConfig);
- MatcherAssert.assertThat(resolverOptions.getServers(), is(Arrays.asList("6.6.6.6", "6.6.4.4")));
- MatcherAssert.assertThat(resolverOptions.getSearchDomains(),
- is(Collections.singletonList("default.svc.local.cluster")));
- Assert.assertEquals(resolverOptions.getQueryTimeout(),
+ Assertions.assertEquals(Arrays.asList("6.6.6.6", "6.6.4.4"), resolverOptions.getServers());
+ Assertions.assertEquals(Collections.singletonList("default.svc.local.cluster"), resolverOptions.getSearchDomains());
+ Assertions.assertEquals(resolverOptions.getQueryTimeout(),
2000);
- Assert.assertNotEquals(resolverOptions.getMaxQueries(),
+ Assertions.assertNotEquals(resolverOptions.getMaxQueries(),
-2);
}
@@ -91,13 +87,13 @@ public class TestAddressResolverConfig {
ArchaiusUtils.setProperty("addressResolver.ndots", 3);
ArchaiusUtils.setProperty("addressResolver.rotateServers", true);
AddressResolverOptions aroc = AddressResolverConfig.getAddressResover("test");
- MatcherAssert.assertThat(aroc.getServers(), is(Arrays.asList("8.8.8.8", "8.8.4.4")));
- MatcherAssert.assertThat(aroc.getSearchDomains(),
- is(Arrays.asList("test.svc.local.cluster", "svc.local.cluster", "local.cluster")));
+ Assertions.assertEquals(Arrays.asList("8.8.8.8", "8.8.4.4"), aroc.getServers());
+ Assertions.assertEquals(Arrays.asList("test.svc.local.cluster", "svc.local.cluster", "local.cluster"),
+ aroc.getSearchDomains());
AddressResolverOptions aroc1 = AddressResolverConfig.getAddressResover("test1");
- MatcherAssert.assertThat(aroc1.getSearchDomains(),
- is(Arrays.asList("default.svc.local.cluster", "svc.local.cluster", "local.cluster")));
- Assert.assertTrue(aroc.isOptResourceEnabled());
+ Assertions.assertEquals(Arrays.asList("default.svc.local.cluster", "svc.local.cluster", "local.cluster"),
+ aroc1.getSearchDomains());
+ Assertions.assertTrue(aroc.isOptResourceEnabled());
}
@Test
@@ -107,10 +103,10 @@ public class TestAddressResolverConfig {
ArchaiusUtils.setProperty("addressResolver.maxQueries", 3);
ArchaiusUtils.setProperty("addressResolver.rdFlag", false);
AddressResolverOptions resolverOptions = AddressResolverConfig.getAddressResover("test");
- MatcherAssert.assertThat(resolverOptions.getServers(), is(Arrays.asList("8.8.8.8", "8.8.4.4")));
- Assert.assertEquals(3, resolverOptions.getMaxQueries());
- Assert.assertEquals(Integer.MAX_VALUE, resolverOptions.getCacheMaxTimeToLive());
- Assert.assertFalse(resolverOptions.isOptResourceEnabled());
- Assert.assertNull(resolverOptions.getSearchDomains());
+ Assertions.assertEquals(Arrays.asList("8.8.8.8", "8.8.4.4"), resolverOptions.getServers());
+ Assertions.assertEquals(3, resolverOptions.getMaxQueries());
+ Assertions.assertEquals(Integer.MAX_VALUE, resolverOptions.getCacheMaxTimeToLive());
+ Assertions.assertFalse(resolverOptions.isOptResourceEnabled());
+ Assertions.assertNull(resolverOptions.getSearchDomains());
}
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestSharedVertxFactory.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestSharedVertxFactory.java
index a27c47f15..176285b71 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestSharedVertxFactory.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestSharedVertxFactory.java
@@ -16,14 +16,14 @@
*/
package org.apache.servicecomb.foundation.vertx;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestSharedVertxFactory {
@Test
public void getTransportVertx() {
- Assert.assertNotNull(SharedVertxFactory.getSharedVertx());
- Assert.assertSame(SharedVertxFactory.getSharedVertx(), SharedVertxFactory.getSharedVertx());
+ Assertions.assertNotNull(SharedVertxFactory.getSharedVertx());
+ Assertions.assertSame(SharedVertxFactory.getSharedVertx(), SharedVertxFactory.getSharedVertx());
SharedVertxFactory.getSharedVertx().close();
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestSimpleBodyHandler.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestSimpleBodyHandler.java
index 0012e73cf..76ede3d96 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestSimpleBodyHandler.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestSimpleBodyHandler.java
@@ -20,9 +20,9 @@ package org.apache.servicecomb.foundation.vertx;
import javax.ws.rs.core.Response.Status;
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;
import io.vertx.core.MultiMap;
@@ -63,7 +63,7 @@ public class TestSimpleBodyHandler {
}
};
instance.handle(context);
- Assert.assertTrue(instance.checkContentType(context));
+ Assertions.assertTrue(instance.checkContentType(context));
}
@Test
@@ -75,6 +75,6 @@ public class TestSimpleBodyHandler {
}
};
instance.handle(context);
- Assert.assertFalse(instance.checkContentType(context));
+ Assertions.assertFalse(instance.checkContentType(context));
}
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestSimpleJsonObject.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestSimpleJsonObject.java
index 8f621f7c4..d0a517080 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestSimpleJsonObject.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestSimpleJsonObject.java
@@ -16,8 +16,8 @@
*/
package org.apache.servicecomb.foundation.vertx;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestSimpleJsonObject {
@Test
@@ -26,12 +26,12 @@ public class TestSimpleJsonObject {
SimpleJsonObject json = new SimpleJsonObject();
json.put("k", value);
- Assert.assertSame(value, json.getValue("k"));
+ Assertions.assertSame(value, json.getValue("k"));
}
@Test
public void testCopy() {
SimpleJsonObject json = new SimpleJsonObject();
- Assert.assertSame(json, json.copy());
+ Assertions.assertSame(json, json.copy());
}
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestStream.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestStream.java
index 905705614..bb4081ead 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestStream.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestStream.java
@@ -19,11 +19,11 @@ package org.apache.servicecomb.foundation.vertx;
import org.apache.servicecomb.foundation.vertx.stream.BufferInputStream;
import org.apache.servicecomb.foundation.vertx.stream.BufferOutputStream;
-import org.junit.Assert;
-import org.junit.Test;
import io.netty.buffer.ByteBuf;
import io.vertx.core.buffer.Buffer;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestStream {
@@ -35,13 +35,12 @@ public class TestStream {
obuf.writeBytes(("testss").getBytes());
@SuppressWarnings("resource")
BufferInputStream oBufferInputStream = new BufferInputStream(obuf);
- Assert.assertNotEquals(1234, oBufferInputStream.skip(0));
- Assert.assertNotEquals(obuf.readByte(), oBufferInputStream.readByte());
- Assert.assertEquals(obuf.readByte() + 1, oBufferInputStream.read());
- Assert.assertEquals(obuf.readBoolean(), oBufferInputStream.readBoolean());
- Assert.assertEquals(obuf.readerIndex(), oBufferInputStream.getIndex());
- Assert.assertEquals(obuf.readableBytes(), oBufferInputStream.available());
- Assert.assertNotEquals(null, oBufferInputStream.read(("test").getBytes()));
+ Assertions.assertNotEquals(1234, oBufferInputStream.skip(0));
+ Assertions.assertNotEquals(obuf.readByte(), oBufferInputStream.readByte());
+ Assertions.assertEquals(obuf.readByte() + 1, oBufferInputStream.read());
+ Assertions.assertEquals(obuf.readBoolean(), oBufferInputStream.readBoolean());
+ Assertions.assertEquals(obuf.readerIndex(), oBufferInputStream.getIndex());
+ Assertions.assertEquals(obuf.readableBytes(), oBufferInputStream.available());
}
@Test
@@ -49,9 +48,8 @@ public class TestStream {
@SuppressWarnings({"resource"})
BufferOutputStream oBufferOutputStream = new BufferOutputStream();
oBufferOutputStream.writeString("test");
- Assert.assertNotEquals(null, oBufferOutputStream.writerIndex());
oBufferOutputStream.write(1);
oBufferOutputStream.write(true);
- Assert.assertEquals(true, (1 < oBufferOutputStream.length()));
+ Assertions.assertTrue((1 < oBufferOutputStream.length()));
}
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestVertxTLSBuilder.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestVertxTLSBuilder.java
index 95a2cd167..1422631e1 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestVertxTLSBuilder.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestVertxTLSBuilder.java
@@ -22,7 +22,6 @@ import org.apache.servicecomb.foundation.ssl.SSLOption;
import org.apache.servicecomb.foundation.ssl.SSLOptionFactory;
import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
import org.junit.AfterClass;
-import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -31,6 +30,7 @@ import io.vertx.core.http.HttpClientOptions;
import io.vertx.core.http.HttpServerOptions;
import mockit.Mock;
import mockit.MockUp;
+import org.junit.jupiter.api.Assertions;
public class TestVertxTLSBuilder {
@BeforeClass
@@ -49,15 +49,15 @@ public class TestVertxTLSBuilder {
SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
HttpServerOptions serverOptions = new HttpServerOptions();
VertxTLSBuilder.buildNetServerOptions(option, custom, serverOptions);
- Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
- Assert.assertEquals(serverOptions.getClientAuth(), ClientAuth.REQUEST);
+ Assertions.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
+ Assertions.assertEquals(serverOptions.getClientAuth(), ClientAuth.REQUEST);
}
@Test
public void testbuildHttpClientOptions_sslKey_noFactory() {
HttpClientOptions clientOptions = new HttpClientOptions();
VertxTLSBuilder.buildHttpClientOptions("notExist", clientOptions);
- Assert.assertTrue(clientOptions.isSsl());
+ Assertions.assertTrue(clientOptions.isSsl());
}
public static class SSLOptionFactoryForTest implements SSLOptionFactory {
@@ -81,8 +81,8 @@ public class TestVertxTLSBuilder {
ArchaiusUtils.setProperty("ssl.exist.sslOptionFactory", SSLOptionFactoryForTest.class.getName());
HttpClientOptions clientOptions = new HttpClientOptions();
VertxTLSBuilder.buildHttpClientOptions("exist", clientOptions);
- Assert.assertTrue(clientOptions.isSsl());
- Assert.assertTrue(clientOptions.isVerifyHost());
+ Assertions.assertTrue(clientOptions.isSsl());
+ Assertions.assertTrue(clientOptions.isVerifyHost());
}
@Test
@@ -91,8 +91,8 @@ public class TestVertxTLSBuilder {
SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
HttpClientOptions serverOptions = new HttpClientOptions();
VertxTLSBuilder.buildHttpClientOptions(option, custom, serverOptions);
- Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
- Assert.assertEquals(serverOptions.isTrustAll(), true);
+ Assertions.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
+ Assertions.assertTrue(serverOptions.isTrustAll());
}
@Test
@@ -101,8 +101,8 @@ public class TestVertxTLSBuilder {
SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
HttpClientOptions serverOptions = new HttpClientOptions();
VertxTLSBuilder.buildClientOptionsBase(option, custom, serverOptions);
- Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
- Assert.assertEquals(serverOptions.isTrustAll(), true);
+ Assertions.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
+ Assertions.assertTrue(serverOptions.isTrustAll());
}
@Test
@@ -114,8 +114,8 @@ public class TestVertxTLSBuilder {
SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
HttpClientOptions serverOptions = new HttpClientOptions();
VertxTLSBuilder.buildClientOptionsBase(option, custom, serverOptions);
- Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
- Assert.assertEquals(serverOptions.isTrustAll(), true);
+ Assertions.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
+ Assertions.assertTrue(serverOptions.isTrustAll());
}
@Test
@@ -131,8 +131,8 @@ public class TestVertxTLSBuilder {
}
};
VertxTLSBuilder.buildClientOptionsBase(option, custom, serverOptions);
- Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
- Assert.assertEquals(serverOptions.isTrustAll(), true);
+ Assertions.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
+ Assertions.assertTrue(serverOptions.isTrustAll());
}
@Test
@@ -148,8 +148,8 @@ public class TestVertxTLSBuilder {
}
};
VertxTLSBuilder.buildClientOptionsBase(option, custom, serverOptions);
- Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
- Assert.assertEquals(serverOptions.isTrustAll(), true);
+ Assertions.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
+ Assertions.assertTrue(serverOptions.isTrustAll());
}
@Test
@@ -165,8 +165,8 @@ public class TestVertxTLSBuilder {
}
};
VertxTLSBuilder.buildClientOptionsBase(option, custom, serverOptions);
- Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
- Assert.assertEquals(serverOptions.isTrustAll(), true);
+ Assertions.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
+ Assertions.assertTrue(serverOptions.isTrustAll());
}
@Test
@@ -183,7 +183,7 @@ public class TestVertxTLSBuilder {
}
};
VertxTLSBuilder.buildNetServerOptions(option, custom, serverOptions);
- Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
- Assert.assertEquals(serverOptions.getClientAuth(), ClientAuth.REQUEST);
+ Assertions.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
+ Assertions.assertEquals(serverOptions.getClientAuth(), ClientAuth.REQUEST);
}
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestVertxUtils.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestVertxUtils.java
index 6f127e89f..813e01525 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestVertxUtils.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestVertxUtils.java
@@ -28,14 +28,14 @@ import org.apache.commons.io.FileUtils;
import org.apache.servicecomb.foundation.common.Holder;
import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
import org.apache.servicecomb.foundation.vertx.stream.BufferInputStream;
-import org.junit.Assert;
-import org.junit.Test;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.vertx.core.Vertx;
import io.vertx.core.VertxOptions;
import io.vertx.core.buffer.Buffer;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestVertxUtils {
@Test
@@ -50,7 +50,7 @@ public class TestVertxUtils {
});
latch.await();
- Assert.assertEquals(name.value, "ut-vert.x-eventloop-thread-0");
+ Assertions.assertEquals(name.value, "ut-vert.x-eventloop-thread-0");
VertxUtils.blockCloseVertxByName("ut");
}
@@ -63,15 +63,15 @@ public class TestVertxUtils {
ArchaiusUtils.setProperty(FileResolverImpl.DISABLE_CP_RESOLVING_PROP_NAME, false);
deleteCacheFile();
VertxUtils.getOrCreateVertxByName("testCreateVertxWithFileCPResolvingFalse", null);
- Assert.assertTrue(isCacheFileExists());
+ Assertions.assertTrue(isCacheFileExists());
VertxUtils.blockCloseVertxByName("testCreateVertxWithFileCPResolvingFalse");
// don't create .vertx folder
deleteCacheFile();
- Assert.assertFalse(isCacheFileExists());
+ Assertions.assertFalse(isCacheFileExists());
ArchaiusUtils.setProperty(FileResolverImpl.DISABLE_CP_RESOLVING_PROP_NAME, true);
VertxUtils.getOrCreateVertxByName("testCreateVertxWithFileCPResolvingTrue", null);
- Assert.assertFalse(isCacheFileExists());
+ Assertions.assertFalse(isCacheFileExists());
VertxUtils.blockCloseVertxByName("testCreateVertxWithFileCPResolvingTrue");
ArchaiusUtils.resetConfig();
@@ -105,7 +105,7 @@ public class TestVertxUtils {
@Test
public void testVertxUtilsInitNullOptions() {
Vertx vertx = VertxUtils.init(null, null);
- Assert.assertNotEquals(null, vertx);
+ Assertions.assertNotEquals(null, vertx);
VertxUtils.blockCloseVertx(vertx);
}
@@ -114,7 +114,7 @@ public class TestVertxUtils {
VertxOptions oOptions = new VertxOptions();
Vertx vertx = VertxUtils.init(null, oOptions);
- Assert.assertNotEquals(null, vertx);
+ Assertions.assertNotEquals(null, vertx);
VertxUtils.blockCloseVertx(vertx);
}
@@ -125,7 +125,7 @@ public class TestVertxUtils {
try (BufferInputStream inputStream = new BufferInputStream(byteBuf)) {
byte[] result = VertxUtils.getBytesFast(inputStream);
- Assert.assertSame(bytes, result);
+ Assertions.assertSame(bytes, result);
}
}
@@ -135,7 +135,7 @@ public class TestVertxUtils {
try (InputStream inputStream = new ByteArrayInputStream(bytes)) {
byte[] result = VertxUtils.getBytesFast(inputStream);
- Assert.assertEquals(1, result[0]);
+ Assertions.assertEquals(1, result[0]);
}
}
@@ -145,7 +145,7 @@ public class TestVertxUtils {
buffer.appendByte((byte) 1);
byte[] result = VertxUtils.getBytesFast(buffer);
- Assert.assertEquals(1, result[0]);
+ Assertions.assertEquals(1, result[0]);
}
@Test
@@ -154,17 +154,17 @@ public class TestVertxUtils {
ByteBuf byteBuf = Unpooled.wrappedBuffer(bytes);
byte[] result = VertxUtils.getBytesFast(byteBuf);
- Assert.assertSame(bytes, result);
+ Assertions.assertSame(bytes, result);
}
@Test
public void testgetBytesFastByteBufCopy() {
ByteBuf byteBuf = Unpooled.directBuffer();
byteBuf.writeByte(1);
- Assert.assertFalse(byteBuf.hasArray());
+ Assertions.assertFalse(byteBuf.hasArray());
byte[] result = VertxUtils.getBytesFast(byteBuf);
- Assert.assertEquals(1, result[0]);
+ Assertions.assertEquals(1, result[0]);
byteBuf.release();
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/TestClientPoolManager.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/TestClientPoolManager.java
index 2bc953155..fea328340 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/TestClientPoolManager.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/TestClientPoolManager.java
@@ -24,7 +24,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.apache.servicecomb.foundation.vertx.client.http.HttpClientWithContext;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -36,6 +35,7 @@ import mockit.Expectations;
import mockit.Mock;
import mockit.MockUp;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestClientPoolManager {
@Mocked
@@ -93,8 +93,8 @@ public class TestClientPoolManager {
}
};
- Assert.assertSame(pool, poolMgr.createClientPool(context));
- Assert.assertSame(pool, context.get(id));
+ Assertions.assertSame(pool, poolMgr.createClientPool(context));
+ Assertions.assertSame(pool, context.get(id));
MatcherAssert.assertThat(pools, Matchers.contains(pool));
}
@@ -109,8 +109,8 @@ public class TestClientPoolManager {
}
};
- Assert.assertSame(pool1, poolMgr.findClientPool(true));
- Assert.assertSame(pool2, poolMgr.findClientPool(false));
+ Assertions.assertSame(pool1, poolMgr.findClientPool(true));
+ Assertions.assertSame(pool2, poolMgr.findClientPool(false));
}
@Test
@@ -125,9 +125,9 @@ public class TestClientPoolManager {
}
};
- Assert.assertSame(pool1, poolMgr.findThreadBindClientPool());
+ Assertions.assertSame(pool1, poolMgr.findThreadBindClientPool());
// find again, get the same result
- Assert.assertSame(pool1, poolMgr.findThreadBindClientPool());
+ Assertions.assertSame(pool1, poolMgr.findThreadBindClientPool());
new MockUp<Thread>() {
@Mock
@@ -136,9 +136,9 @@ public class TestClientPoolManager {
}
};
- Assert.assertSame(pool2, poolMgr.findThreadBindClientPool());
+ Assertions.assertSame(pool2, poolMgr.findThreadBindClientPool());
// find again, get the same result
- Assert.assertSame(pool2, poolMgr.findThreadBindClientPool());
+ Assertions.assertSame(pool2, poolMgr.findThreadBindClientPool());
}
@Test
@@ -156,9 +156,9 @@ public class TestClientPoolManager {
};
HttpClientWithContext result = poolMgr.findByContext();
- Assert.assertNotSame(notMatchPool, result);
+ Assertions.assertNotSame(notMatchPool, result);
// find again, get the same result
- Assert.assertSame(result, poolMgr.findByContext());
+ Assertions.assertSame(result, poolMgr.findByContext());
}
@Test
@@ -178,10 +178,10 @@ public class TestClientPoolManager {
AtomicInteger reactiveNextIndex = Deencapsulation.getField(poolMgr, "reactiveNextIndex");
reactiveNextIndex.set(Integer.MAX_VALUE);
// each time invoke find, reactiveNextIndex will inc 1
- Assert.assertSame(pool2, poolMgr.findByContext());
- Assert.assertSame(pool1, poolMgr.findByContext());
- Assert.assertSame(pool2, poolMgr.findByContext());
- Assert.assertSame(pool1, poolMgr.findByContext());
+ Assertions.assertSame(pool2, poolMgr.findByContext());
+ Assertions.assertSame(pool1, poolMgr.findByContext());
+ Assertions.assertSame(pool2, poolMgr.findByContext());
+ Assertions.assertSame(pool1, poolMgr.findByContext());
}
@Test
@@ -196,7 +196,7 @@ public class TestClientPoolManager {
}
};
- Assert.assertSame(pool, poolMgr.findByContext());
+ Assertions.assertSame(pool, poolMgr.findByContext());
}
@Test
@@ -213,7 +213,7 @@ public class TestClientPoolManager {
}
};
- Assert.assertSame(pool, poolMgr.findByContext());
+ Assertions.assertSame(pool, poolMgr.findByContext());
}
@Test
@@ -232,6 +232,6 @@ public class TestClientPoolManager {
}
};
- Assert.assertSame(pool, poolMgr.findByContext());
+ Assertions.assertSame(pool, poolMgr.findByContext());
}
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/TestClientVerticle.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/TestClientVerticle.java
index 6f7637239..197eb9f1f 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/TestClientVerticle.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/TestClientVerticle.java
@@ -20,7 +20,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.apache.servicecomb.foundation.vertx.SimpleJsonObject;
import org.apache.servicecomb.foundation.vertx.client.http.HttpClientWithContext;
-import org.junit.Assert;
import org.junit.Test;
import io.vertx.core.Context;
@@ -29,6 +28,7 @@ import mockit.Expectations;
import mockit.Mock;
import mockit.MockUp;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestClientVerticle {
ClientVerticle<HttpClientWithContext> clientVerticle = new ClientVerticle<>();
@@ -56,6 +56,6 @@ public class TestClientVerticle {
clientVerticle.start();
- Assert.assertEquals(1, count.get());
+ Assertions.assertEquals(1, count.get());
}
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/http/TestHttpClientPoolFactory.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/http/TestHttpClientPoolFactory.java
index ee65f098f..76b6c84bb 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/http/TestHttpClientPoolFactory.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/http/TestHttpClientPoolFactory.java
@@ -16,7 +16,6 @@
*/
package org.apache.servicecomb.foundation.vertx.client.http;
-import org.junit.Assert;
import org.junit.Test;
import io.vertx.core.http.HttpClient;
@@ -26,6 +25,7 @@ import io.vertx.core.impl.VertxImpl;
import io.vertx.core.impl.VertxInternal;
import mockit.Expectations;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestHttpClientPoolFactory {
private final HttpClientOptions httpClientOptions = new HttpClientOptions();
@@ -45,7 +45,7 @@ public class TestHttpClientPoolFactory {
};
HttpClientWithContext pool = factory.createClientPool(context);
- Assert.assertSame(context, pool.context());
- Assert.assertSame(httpClient, pool.getHttpClient());
+ Assertions.assertSame(context, pool.context());
+ Assertions.assertSame(httpClient, pool.getHttpClient());
}
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/tcp/TestAbstractTcpClientPoolFactory.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/tcp/TestAbstractTcpClientPoolFactory.java
index b0673e4b2..dd01fdab1 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/tcp/TestAbstractTcpClientPoolFactory.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/tcp/TestAbstractTcpClientPoolFactory.java
@@ -16,12 +16,12 @@
*/
package org.apache.servicecomb.foundation.vertx.client.tcp;
-import org.junit.Assert;
-import org.junit.Test;
-import org.mockito.Mockito;
+import org.junit.jupiter.api.Assertions;
import io.vertx.core.Context;
import io.vertx.core.Vertx;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
public class TestAbstractTcpClientPoolFactory {
private final TcpClientConfig normalClientConfig = new TcpClientConfig();
@@ -37,7 +37,7 @@ public class TestAbstractTcpClientPoolFactory {
Mockito.when(context.owner()).thenReturn(vertx);
TcpClientConnectionPool pool = factory.createClientPool(context);
- Assert.assertSame(normalClientConfig, pool.netClientWrapper.getClientConfig(false));
- Assert.assertSame(sslClientConfig, pool.netClientWrapper.getClientConfig(true));
+ Assertions.assertSame(normalClientConfig, pool.netClientWrapper.getClientConfig(false));
+ Assertions.assertSame(sslClientConfig, pool.netClientWrapper.getClientConfig(true));
}
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/tcp/TestNetClientWrapper.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/tcp/TestNetClientWrapper.java
index 1af3eb9fc..da106f406 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/tcp/TestNetClientWrapper.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/tcp/TestNetClientWrapper.java
@@ -22,7 +22,6 @@ import java.util.List;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -36,6 +35,7 @@ import mockit.Expectations;
import mockit.Mock;
import mockit.MockUp;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestNetClientWrapper {
@Mocked
@@ -70,8 +70,8 @@ public class TestNetClientWrapper {
@Test
public void getClientConfig() {
- Assert.assertSame(normalClientConfig, netClientWrapper.getClientConfig(false));
- Assert.assertSame(sslClientConfig, netClientWrapper.getClientConfig(true));
+ Assertions.assertSame(normalClientConfig, netClientWrapper.getClientConfig(false));
+ Assertions.assertSame(sslClientConfig, netClientWrapper.getClientConfig(true));
}
@Test
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/tcp/TestTcpClientConfig.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/tcp/TestTcpClientConfig.java
index 558eb513d..b7a2f50d0 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/tcp/TestTcpClientConfig.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/tcp/TestTcpClientConfig.java
@@ -17,16 +17,16 @@
package org.apache.servicecomb.foundation.vertx.client.tcp;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestTcpClientConfig {
@Test
public void testTcpClientConfig() {
TcpClientConfig config = new TcpClientConfig();
- Assert.assertEquals(config.getMsLoginTimeout(), 30000);
- Assert.assertEquals(config.isSsl(), false);
+ Assertions.assertEquals(config.getMsLoginTimeout(), 30000);
+ Assertions.assertFalse(config.isSsl());
config.setMsLoginTimeout(500);
- Assert.assertEquals(config.getMsLoginTimeout(), 500);
+ Assertions.assertEquals(config.getMsLoginTimeout(), 500);
}
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/tcp/TestTcpClientConnection.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/tcp/TestTcpClientConnection.java
index f6c13ee52..10262ca50 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/tcp/TestTcpClientConnection.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/client/tcp/TestTcpClientConnection.java
@@ -23,7 +23,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.apache.servicecomb.foundation.test.scaffolding.exception.RuntimeExceptionWithoutStackTrace;
import org.apache.servicecomb.foundation.vertx.client.tcp.TcpClientConnection.Status;
import org.apache.servicecomb.foundation.vertx.tcp.TcpOutputStream;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -40,6 +39,7 @@ import mockit.Expectations;
import mockit.Mock;
import mockit.MockUp;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestTcpClientConnection {
@Mocked
@@ -68,20 +68,20 @@ public class TestTcpClientConnection {
@Test
public void localSupportLogin() {
- Assert.assertFalse(tcpClientConnection.isLocalSupportLogin());
+ Assertions.assertFalse(tcpClientConnection.isLocalSupportLogin());
tcpClientConnection.setLocalSupportLogin(true);
- Assert.assertTrue(tcpClientConnection.isLocalSupportLogin());
+ Assertions.assertTrue(tcpClientConnection.isLocalSupportLogin());
}
@Test
public void createLogin() {
- Assert.assertNull(tcpClientConnection.createLogin());
+ Assertions.assertNull(tcpClientConnection.createLogin());
}
@Test
public void onLoginResponse_buffer() {
- Assert.assertTrue(tcpClientConnection.onLoginResponse(null));
+ Assertions.assertTrue(tcpClientConnection.onLoginResponse(null));
}
@Test
@@ -110,9 +110,9 @@ public class TestTcpClientConnection {
tcpClientConnection.send(tcpClientPackage, ar -> {
});
- Assert.assertSame(byteBuf, writeQueue.poll());
- Assert.assertNull(writeQueue.poll());
- Assert.assertEquals(Status.WORKING, Deencapsulation.getField(tcpClientConnection, "status"));
+ Assertions.assertSame(byteBuf, writeQueue.poll());
+ Assertions.assertNull(writeQueue.poll());
+ Assertions.assertEquals(Status.WORKING, Deencapsulation.getField(tcpClientConnection, "status"));
}
@Test
@@ -134,9 +134,9 @@ public class TestTcpClientConnection {
tcpClientConnection.send(tcpClientPackage, ar -> {
});
- Assert.assertSame(tcpClientPackage, packageQueue.poll());
- Assert.assertNull(packageQueue.poll());
- Assert.assertEquals(Status.CONNECTING, Deencapsulation.getField(tcpClientConnection, "status"));
+ Assertions.assertSame(tcpClientPackage, packageQueue.poll());
+ Assertions.assertNull(packageQueue.poll());
+ Assertions.assertEquals(Status.CONNECTING, Deencapsulation.getField(tcpClientConnection, "status"));
}
@Test
@@ -159,9 +159,9 @@ public class TestTcpClientConnection {
tcpClientConnection.send(tcpClientPackage, ar -> {
});
- Assert.assertSame(tcpClientPackage, packageQueue.poll());
- Assert.assertNull(packageQueue.poll());
- Assert.assertEquals(Status.TRY_LOGIN, Deencapsulation.getField(tcpClientConnection, "status"));
+ Assertions.assertSame(tcpClientPackage, packageQueue.poll());
+ Assertions.assertNull(packageQueue.poll());
+ Assertions.assertEquals(Status.TRY_LOGIN, Deencapsulation.getField(tcpClientConnection, "status"));
}
@Test
@@ -185,9 +185,9 @@ public class TestTcpClientConnection {
tcpClientConnection.send(tcpClientPackage, ar -> {
});
- Assert.assertNull(writeQueue.poll());
- Assert.assertNull(packageQueue.poll());
- Assert.assertEquals(Status.WORKING, Deencapsulation.getField(tcpClientConnection, "status"));
+ Assertions.assertNull(writeQueue.poll());
+ Assertions.assertNull(packageQueue.poll());
+ Assertions.assertEquals(Status.WORKING, Deencapsulation.getField(tcpClientConnection, "status"));
}
@Test
@@ -203,8 +203,8 @@ public class TestTcpClientConnection {
tcpClientConnection.connect();
- Assert.assertSame(netSocket, tcpClientConnection.getNetSocket());
- Assert.assertEquals(Status.WORKING, Deencapsulation.getField(tcpClientConnection, "status"));
+ Assertions.assertSame(netSocket, tcpClientConnection.getNetSocket());
+ Assertions.assertEquals(Status.WORKING, Deencapsulation.getField(tcpClientConnection, "status"));
}
@Test
@@ -224,8 +224,8 @@ public class TestTcpClientConnection {
tcpClientConnection.connect();
- Assert.assertEquals(Status.DISCONNECTED, Deencapsulation.getField(tcpClientConnection, "status"));
- Assert.assertEquals(0, requestMap.size());
+ Assertions.assertEquals(Status.DISCONNECTED, Deencapsulation.getField(tcpClientConnection, "status"));
+ Assertions.assertEquals(0, requestMap.size());
}
@Test
@@ -235,8 +235,8 @@ public class TestTcpClientConnection {
tcpClientConnection.initNetSocket(netSocket);
Deencapsulation.invoke(tcpClientConnection, "onClosed", new Class<?>[] {Void.class}, new Object[] {null});
- Assert.assertEquals(Status.DISCONNECTED, Deencapsulation.getField(tcpClientConnection, "status"));
- Assert.assertEquals(0, requestMap.size());
+ Assertions.assertEquals(Status.DISCONNECTED, Deencapsulation.getField(tcpClientConnection, "status"));
+ Assertions.assertEquals(0, requestMap.size());
}
@Test
@@ -254,6 +254,6 @@ public class TestTcpClientConnection {
}));
tcpClientConnection.onReply(msgId, null, null);
- Assert.assertEquals(1, count.get());
+ Assertions.assertEquals(1, count.get());
}
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestAbstractHttpServletRequest.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestAbstractHttpServletRequest.java
index c308efb88..653bb5a68 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestAbstractHttpServletRequest.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestAbstractHttpServletRequest.java
@@ -23,7 +23,6 @@ import javax.servlet.http.HttpServletRequest;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
-import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
@@ -36,14 +35,14 @@ public class TestAbstractHttpServletRequest {
String key = "a1";
String value = "abc";
request.setAttribute(key, value);
- Assert.assertSame(value, request.getAttribute(key));
+ Assertions.assertSame(value, request.getAttribute(key));
MatcherAssert.assertThat(Collections.list(request.getAttributeNames()), Matchers.contains(key));
request.setAttribute("a2", "v");
MatcherAssert.assertThat(Collections.list(request.getAttributeNames()), Matchers.contains(key, "a2"));
request.removeAttribute(key);
- Assert.assertNull(request.getAttribute(key));
+ Assertions.assertNull(request.getAttribute(key));
}
private void checkError(Error error) {
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestAbstractHttpServletResponse.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestAbstractHttpServletResponse.java
index 2e185dc2c..845e37458 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestAbstractHttpServletResponse.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestAbstractHttpServletResponse.java
@@ -17,9 +17,8 @@
package org.apache.servicecomb.foundation.vertx.http;
-import org.junit.Assert;
-import org.junit.Test;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestAbstractHttpServletResponse {
@@ -268,7 +267,7 @@ public class TestAbstractHttpServletResponse {
@Test
public void attribute() {
response.setAttribute("k", "v");
- Assert.assertEquals("v", response.getAttribute("k"));
+ Assertions.assertEquals("v", response.getAttribute("k"));
}
@Test
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestBodyBufferSupportImpl.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestBodyBufferSupportImpl.java
index 8e777f4e5..cf8f4bf10 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestBodyBufferSupportImpl.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestBodyBufferSupportImpl.java
@@ -17,11 +17,10 @@
package org.apache.servicecomb.foundation.vertx.http;
-import org.junit.Assert;
-import org.junit.Test;
-
import io.vertx.core.buffer.Buffer;
import mockit.Deencapsulation;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestBodyBufferSupportImpl {
BodyBufferSupportImpl impl = new BodyBufferSupportImpl();
@@ -31,44 +30,44 @@ public class TestBodyBufferSupportImpl {
Deencapsulation.setField(impl, "bodyBytes", new byte[] {});
Deencapsulation.setField(impl, "bodyLength", 10);
- Assert.assertNotNull(impl.getBodyBytes());
- Assert.assertEquals(10, impl.getBodyBytesLength());
+ Assertions.assertNotNull(impl.getBodyBytes());
+ Assertions.assertEquals(10, impl.getBodyBytesLength());
impl.setBodyBuffer(null);
- Assert.assertNull(impl.getBodyBytes());
- Assert.assertEquals(0, impl.getBodyBytesLength());
+ Assertions.assertNull(impl.getBodyBytes());
+ Assertions.assertEquals(0, impl.getBodyBytesLength());
}
@Test
public void testGetBodyBuffer() {
- Assert.assertNull(impl.getBodyBuffer());
+ Assertions.assertNull(impl.getBodyBuffer());
Buffer bodyBuffer = Buffer.buffer();
impl.setBodyBuffer(bodyBuffer);
- Assert.assertSame(bodyBuffer, impl.getBodyBuffer());
+ Assertions.assertSame(bodyBuffer, impl.getBodyBuffer());
}
@Test
public void testGetBodyBytes() {
- Assert.assertNull(impl.getBodyBytes());
+ Assertions.assertNull(impl.getBodyBytes());
byte[] bytes = new byte[] {1, 2, 3};
Buffer bodyBuffer = Buffer.buffer(bytes);
impl.setBodyBuffer(bodyBuffer);
- Assert.assertArrayEquals(bytes, impl.getBodyBytes());
+ Assertions.assertArrayEquals(bytes, impl.getBodyBytes());
}
@Test
public void testGetBodyBytesLength() {
- Assert.assertEquals(0, impl.getBodyBytesLength());
+ Assertions.assertEquals(0, impl.getBodyBytesLength());
byte[] bytes = new byte[] {1, 2, 3};
Buffer bodyBuffer = Buffer.buffer(bytes);
impl.setBodyBuffer(bodyBuffer);
- Assert.assertEquals(3, impl.getBodyBytesLength());
+ Assertions.assertEquals(3, impl.getBodyBytesLength());
}
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestFileUploadPart.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestFileUploadPart.java
index 92098621f..bd436c197 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestFileUploadPart.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestFileUploadPart.java
@@ -25,7 +25,6 @@ import java.util.UUID;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -33,6 +32,7 @@ import org.junit.Test;
import io.vertx.ext.web.FileUpload;
import mockit.Expectations;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestFileUploadPart {
@Mocked
@@ -65,7 +65,7 @@ public class TestFileUploadPart {
}
};
try (InputStream is = part.getInputStream()) {
- Assert.assertEquals(content, IOUtils.toString(is, StandardCharsets.UTF_8));
+ Assertions.assertEquals(content, IOUtils.toString(is, StandardCharsets.UTF_8));
}
}
@@ -79,7 +79,7 @@ public class TestFileUploadPart {
}
};
- Assert.assertEquals(contentType, part.getContentType());
+ Assertions.assertEquals(contentType, part.getContentType());
}
@Test
@@ -92,7 +92,7 @@ public class TestFileUploadPart {
}
};
- Assert.assertEquals(name, part.getName());
+ Assertions.assertEquals(name, part.getName());
}
@Test
@@ -105,7 +105,7 @@ public class TestFileUploadPart {
}
};
- Assert.assertEquals(clientName, part.getSubmittedFileName());
+ Assertions.assertEquals(clientName, part.getSubmittedFileName());
}
@Test
@@ -118,7 +118,7 @@ public class TestFileUploadPart {
}
};
- Assert.assertEquals(fileSize, part.getSize());
+ Assertions.assertEquals(fileSize, part.getSize());
}
@Test
@@ -133,6 +133,6 @@ public class TestFileUploadPart {
File targetFile = new File(UUID.randomUUID().toString());
targetFile.deleteOnExit();
part.write(targetFile.getAbsolutePath());
- Assert.assertEquals(content, FileUtils.readFileToString(targetFile, StandardCharsets.UTF_8));
+ Assertions.assertEquals(content, FileUtils.readFileToString(targetFile, StandardCharsets.UTF_8));
}
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestReadStreamPart.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestReadStreamPart.java
index c07648d89..8f2a23f03 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestReadStreamPart.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestReadStreamPart.java
@@ -30,7 +30,6 @@ import org.apache.commons.io.FileUtils;
import org.apache.servicecomb.foundation.test.scaffolding.exception.RuntimeExceptionWithoutStackTrace;
import org.apache.servicecomb.foundation.vertx.stream.InputStreamToReadStream;
import org.junit.AfterClass;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
@@ -86,8 +85,8 @@ public class TestReadStreamPart {
part = new ReadStreamPart(context, httpClientResponse);
- Assert.assertEquals("name.txt", part.getSubmittedFileName());
- Assert.assertEquals("text/plain", part.getContentType());
+ Assertions.assertEquals("name.txt", part.getSubmittedFileName());
+ Assertions.assertEquals("text/plain", part.getContentType());
}
@Test
@@ -103,8 +102,8 @@ public class TestReadStreamPart {
part = new ReadStreamPart(context, httpClientResponse);
- Assert.assertEquals("name.txt", part.getSubmittedFileName());
- Assert.assertEquals("type", part.getContentType());
+ Assertions.assertEquals("name.txt", part.getSubmittedFileName());
+ Assertions.assertEquals("type", part.getContentType());
}
@Test
@@ -120,7 +119,7 @@ public class TestReadStreamPart {
part.saveToWriteStream(writeStream).get();
- Assert.assertEquals(src, buf.toString());
+ Assertions.assertEquals(src, buf.toString());
}
@Test
@@ -166,12 +165,12 @@ public class TestReadStreamPart {
@Test
public void saveAsBytes() throws InterruptedException, ExecutionException {
- Assert.assertArrayEquals(src.getBytes(), part.saveAsBytes().get());
+ Assertions.assertArrayEquals(src.getBytes(), part.saveAsBytes().get());
}
@Test
public void saveAsString() throws InterruptedException, ExecutionException {
- Assert.assertEquals(src, part.saveAsString().get());
+ Assertions.assertEquals(src, part.saveAsString().get());
}
@Test
@@ -179,14 +178,14 @@ public class TestReadStreamPart {
File dir = new File("target/notExist-" + UUID.randomUUID().toString());
File file = new File(dir, "a.txt");
- Assert.assertFalse(dir.exists());
+ Assertions.assertFalse(dir.exists());
part.saveToFile(file.getAbsolutePath()).get();
- Assert.assertEquals(src, FileUtils.readFileToString(file, StandardCharsets.UTF_8));
+ Assertions.assertEquals(src, FileUtils.readFileToString(file, StandardCharsets.UTF_8));
FileUtils.forceDelete(dir);
- Assert.assertFalse(dir.exists());
+ Assertions.assertFalse(dir.exists());
}
@Test
@@ -194,7 +193,7 @@ public class TestReadStreamPart {
File dir = new File("target/notExist-" + UUID.randomUUID().toString());
File file = new File(dir, "a.txt");
- Assert.assertFalse(dir.exists());
+ Assertions.assertFalse(dir.exists());
ExecutionException exception = Assertions.assertThrows(ExecutionException.class, () -> {
OpenOptions openOptions = new OpenOptions().setCreateNew(false);
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestStandardHttpServletRequestEx.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestStandardHttpServletRequestEx.java
index 10a5a7d39..9aed227b3 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestStandardHttpServletRequestEx.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestStandardHttpServletRequestEx.java
@@ -34,7 +34,6 @@ import org.apache.commons.io.IOUtils;
import org.apache.servicecomb.foundation.vertx.stream.BufferInputStream;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -42,6 +41,7 @@ import io.vertx.core.buffer.Buffer;
import mockit.Deencapsulation;
import mockit.Expectations;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestStandardHttpServletRequestEx {
@Mocked
@@ -60,15 +60,15 @@ public class TestStandardHttpServletRequestEx {
bodyBuffer.appendString("abc");
requestEx.setBodyBuffer(bodyBuffer);
- Assert.assertSame(bodyBuffer, requestEx.getBodyBuffer());
- Assert.assertArrayEquals("abc".getBytes(), Arrays.copyOf(requestEx.getBodyBytes(), requestEx.getBodyBytesLength()));
+ Assertions.assertSame(bodyBuffer, requestEx.getBodyBuffer());
+ Assertions.assertArrayEquals("abc".getBytes(), Arrays.copyOf(requestEx.getBodyBytes(), requestEx.getBodyBytesLength()));
}
@Test
public void getInputStreamNotCache() throws IOException {
ServletInputStream inputStream = request.getInputStream();
- Assert.assertSame(inputStream, requestEx.getInputStream());
+ Assertions.assertSame(inputStream, requestEx.getInputStream());
}
@Test
@@ -84,10 +84,10 @@ public class TestStandardHttpServletRequestEx {
};
ServletInputStream cachedInputStream = requestEx.getInputStream();
- Assert.assertEquals("abc", IOUtils.toString(cachedInputStream, StandardCharsets.UTF_8));
- Assert.assertEquals("abc", requestEx.getBodyBuffer().toString());
+ Assertions.assertEquals("abc", IOUtils.toString(cachedInputStream, StandardCharsets.UTF_8));
+ Assertions.assertEquals("abc", requestEx.getBodyBuffer().toString());
// do not create another one
- Assert.assertSame(cachedInputStream, requestEx.getInputStream());
+ Assertions.assertSame(cachedInputStream, requestEx.getInputStream());
}
@Test
@@ -104,10 +104,10 @@ public class TestStandardHttpServletRequestEx {
}
};
- Assert.assertSame(inherited, requestEx.getParameterMap());
+ Assertions.assertSame(inherited, requestEx.getParameterMap());
MatcherAssert.assertThat(Collections.list(requestEx.getParameterNames()), Matchers.contains("p1"));
- Assert.assertSame(v1, requestEx.getParameterValues("p1"));
- Assert.assertEquals("v1-1", requestEx.getParameter("p1"));
+ Assertions.assertSame(v1, requestEx.getParameterValues("p1"));
+ Assertions.assertEquals("v1-1", requestEx.getParameter("p1"));
}
@Test
@@ -133,7 +133,7 @@ public class TestStandardHttpServletRequestEx {
MatcherAssert.assertThat(Collections.list(requestEx.getParameterNames()), Matchers.contains("p1", "p2"));
MatcherAssert.assertThat(requestEx.getParameterValues("p1"), Matchers.arrayContaining("v1-1", "v1-2", "v1-3"));
- Assert.assertEquals("v1-1", requestEx.getParameter("p1"));
+ Assertions.assertEquals("v1-1", requestEx.getParameter("p1"));
}
@Test
@@ -144,10 +144,10 @@ public class TestStandardHttpServletRequestEx {
requestEx.setParameter("k1", "v1");
requestEx.setParameter("k2", "v2");
- Assert.assertEquals("v1", requestEx.getParameter("k1"));
- Assert.assertEquals("v2", requestEx.getParameter("k2"));
+ Assertions.assertEquals("v1", requestEx.getParameter("k1"));
+ Assertions.assertEquals("v2", requestEx.getParameter("k2"));
- Assert.assertSame(parameterMap, requestEx.getParameterMap());
+ Assertions.assertSame(parameterMap, requestEx.getParameterMap());
MatcherAssert.assertThat(Collections.list(requestEx.getParameterNames()), Matchers.contains("k1", "k2"));
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestStandardHttpServletResponseEx.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestStandardHttpServletResponseEx.java
index 7e3c5856f..43a7bede7 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestStandardHttpServletResponseEx.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestStandardHttpServletResponseEx.java
@@ -29,7 +29,6 @@ import javax.servlet.http.Part;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.servicecomb.foundation.common.part.InputStreamPart;
import org.apache.servicecomb.foundation.test.scaffolding.exception.RuntimeExceptionWithoutStackTrace;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
@@ -53,12 +52,12 @@ public class TestStandardHttpServletResponseEx {
@Test
public void setBodyBuffer() {
- Assert.assertNull(responseEx.getBodyBuffer());
+ Assertions.assertNull(responseEx.getBodyBuffer());
Buffer bodyBuffer = Buffer.buffer();
bodyBuffer.appendString("abc");
responseEx.setBodyBuffer(bodyBuffer);
- Assert.assertEquals("abc", responseEx.getBodyBuffer().toString());
+ Assertions.assertEquals("abc", responseEx.getBodyBuffer().toString());
}
@Test
@@ -66,7 +65,7 @@ public class TestStandardHttpServletResponseEx {
Buffer bodyBuffer = Buffer.buffer();
bodyBuffer.appendString("abc");
responseEx.setBodyBuffer(bodyBuffer);
- Assert.assertEquals("abc", new String(responseEx.getBodyBytes(), 0, responseEx.getBodyBytesLength()));
+ Assertions.assertEquals("abc", new String(responseEx.getBodyBytes(), 0, responseEx.getBodyBytesLength()));
}
@Test
@@ -74,15 +73,15 @@ public class TestStandardHttpServletResponseEx {
Buffer bodyBuffer = Buffer.buffer();
bodyBuffer.appendString("abc");
responseEx.setBodyBuffer(bodyBuffer);
- Assert.assertEquals(3, responseEx.getBodyBytesLength());
+ Assertions.assertEquals(3, responseEx.getBodyBytesLength());
}
@Test
public void setStatus() {
responseEx.setStatus(200, "ok");
- Assert.assertEquals(200, responseEx.getStatus());
- Assert.assertEquals(200, responseEx.getStatusType().getStatusCode());
- Assert.assertEquals("ok", responseEx.getStatusType().getReasonPhrase());
+ Assertions.assertEquals(200, responseEx.getStatus());
+ Assertions.assertEquals(200, responseEx.getStatusType().getStatusCode());
+ Assertions.assertEquals("ok", responseEx.getStatusType().getReasonPhrase());
}
@Test
@@ -114,18 +113,18 @@ public class TestStandardHttpServletResponseEx {
// no body
responseEx.flushBuffer();
- Assert.assertEquals(0, buffer.length());
+ Assertions.assertEquals(0, buffer.length());
Buffer body = Buffer.buffer().appendString("body");
responseEx.setBodyBuffer(body);
responseEx.flushBuffer();
- Assert.assertEquals("body", buffer.toString());
+ Assertions.assertEquals("body", buffer.toString());
}
@Test
public void attribute() {
responseEx.setAttribute("k", "v");
- Assert.assertEquals("v", responseEx.getAttribute("k"));
+ Assertions.assertEquals("v", responseEx.getAttribute("k"));
}
@Test
@@ -150,7 +149,7 @@ public class TestStandardHttpServletResponseEx {
responseEx.sendPart(part).get();
- Assert.assertEquals(src, buffer.toString());
+ Assertions.assertEquals(src, buffer.toString());
}
@Test
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestVertxClientRequestToHttpServletRequest.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestVertxClientRequestToHttpServletRequest.java
index 0c15700b2..2633a764c 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestVertxClientRequestToHttpServletRequest.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestVertxClientRequestToHttpServletRequest.java
@@ -24,7 +24,6 @@ import javax.ws.rs.core.HttpHeaders;
import org.apache.servicecomb.foundation.common.http.HttpUtils;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -34,6 +33,7 @@ import io.vertx.core.http.HttpClientRequest;
import io.vertx.core.http.HttpMethod;
import mockit.Expectations;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestVertxClientRequestToHttpServletRequest {
@Mocked
@@ -57,7 +57,7 @@ public class TestVertxClientRequestToHttpServletRequest {
}
};
- Assert.assertEquals("/path", request.getRequestURI());
+ Assertions.assertEquals("/path", request.getRequestURI());
}
@Test
@@ -69,7 +69,7 @@ public class TestVertxClientRequestToHttpServletRequest {
}
};
- Assert.assertEquals("a=1&b=2", request.getQueryString());
+ Assertions.assertEquals("a=1&b=2", request.getQueryString());
}
@Test
@@ -83,7 +83,7 @@ public class TestVertxClientRequestToHttpServletRequest {
}
};
- Assert.assertEquals("value", request.getHeader("name"));
+ Assertions.assertEquals("value", request.getHeader("name"));
}
@Test
@@ -146,7 +146,7 @@ public class TestVertxClientRequestToHttpServletRequest {
@Test
public void testGetContextPath() {
- Assert.assertEquals("", request.getContextPath());
+ Assertions.assertEquals("", request.getContextPath());
}
@Test
@@ -158,7 +158,7 @@ public class TestVertxClientRequestToHttpServletRequest {
}
};
- Assert.assertEquals("GET", request.getMethod());
+ Assertions.assertEquals("GET", request.getMethod());
}
@Test
@@ -173,7 +173,7 @@ public class TestVertxClientRequestToHttpServletRequest {
request.addHeader(HttpHeaders.CONTENT_TYPE, "ct");
- Assert.assertEquals("ct", request.getContentType());
+ Assertions.assertEquals("ct", request.getContentType());
}
@Test
@@ -193,6 +193,6 @@ public class TestVertxClientRequestToHttpServletRequest {
request.addHeader(HttpHeaders.CONTENT_TYPE, contentType);
- Assert.assertEquals("ce", request.getCharacterEncoding());
+ Assertions.assertEquals("ce", request.getCharacterEncoding());
}
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestVertxClientResponseToHttpServletResponse.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestVertxClientResponseToHttpServletResponse.java
index 9618ed8d5..d8009211e 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestVertxClientResponseToHttpServletResponse.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestVertxClientResponseToHttpServletResponse.java
@@ -22,7 +22,6 @@ import javax.ws.rs.core.Response.StatusType;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -31,6 +30,7 @@ import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.HttpClientResponse;
import mockit.Expectations;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestVertxClientResponseToHttpServletResponse {
@Mocked
@@ -54,7 +54,7 @@ public class TestVertxClientResponseToHttpServletResponse {
}
};
- Assert.assertEquals(123, response.getStatus());
+ Assertions.assertEquals(123, response.getStatus());
}
@Test
@@ -69,9 +69,9 @@ public class TestVertxClientResponseToHttpServletResponse {
};
StatusType type = response.getStatusType();
- Assert.assertSame(type, response.getStatusType());
- Assert.assertEquals(123, type.getStatusCode());
- Assert.assertEquals("test", type.getReasonPhrase());
+ Assertions.assertSame(type, response.getStatusType());
+ Assertions.assertEquals(123, type.getStatusCode());
+ Assertions.assertEquals("test", type.getReasonPhrase());
}
@Test
@@ -83,7 +83,7 @@ public class TestVertxClientResponseToHttpServletResponse {
}
};
- Assert.assertEquals("json", response.getContentType());
+ Assertions.assertEquals("json", response.getContentType());
}
@Test
@@ -95,7 +95,7 @@ public class TestVertxClientResponseToHttpServletResponse {
}
};
- Assert.assertEquals("value", response.getHeader("name"));
+ Assertions.assertEquals("value", response.getHeader("name"));
}
@Test
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestVertxServerRequestToHttpServletRequest.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestVertxServerRequestToHttpServletRequest.java
index 8e1f056af..184d12074 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestVertxServerRequestToHttpServletRequest.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestVertxServerRequestToHttpServletRequest.java
@@ -34,7 +34,6 @@ import org.apache.servicecomb.foundation.common.Holder;
import org.apache.servicecomb.foundation.common.http.HttpUtils;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -49,6 +48,7 @@ import mockit.Expectations;
import mockit.Mock;
import mockit.MockUp;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestVertxServerRequestToHttpServletRequest {
@Mocked
@@ -80,7 +80,7 @@ public class TestVertxServerRequestToHttpServletRequest {
public void constructWithPath() {
request = new VertxServerRequestToHttpServletRequest(context, "/path");
- Assert.assertEquals("/path", request.getRequestURI());
+ Assertions.assertEquals("/path", request.getRequestURI());
}
@Test
@@ -102,8 +102,8 @@ public class TestVertxServerRequestToHttpServletRequest {
Buffer bodyBuffer = Buffer.buffer();
request.setBodyBuffer(bodyBuffer);
- Assert.assertSame(bodyBuffer, bodyHolder.value);
- Assert.assertSame(bodyBuffer, request.getBodyBuffer());
+ Assertions.assertSame(bodyBuffer, bodyHolder.value);
+ Assertions.assertSame(bodyBuffer, request.getBodyBuffer());
}
@Test
@@ -115,7 +115,7 @@ public class TestVertxServerRequestToHttpServletRequest {
}
};
- Assert.assertEquals("json", request.getContentType());
+ Assertions.assertEquals("json", request.getContentType());
}
@Test
@@ -133,15 +133,15 @@ public class TestVertxServerRequestToHttpServletRequest {
Cookie[] cookies = request.getCookies();
// we can't ensure the sequence when set to list
if (cookies[0].getName().equals("c1")) {
- Assert.assertEquals("c1", cookies[0].getName());
- Assert.assertEquals("c1v", cookies[0].getValue());
- Assert.assertEquals("c2", cookies[1].getName());
- Assert.assertEquals("c2v", cookies[1].getValue());
+ Assertions.assertEquals("c1", cookies[0].getName());
+ Assertions.assertEquals("c1v", cookies[0].getValue());
+ Assertions.assertEquals("c2", cookies[1].getName());
+ Assertions.assertEquals("c2v", cookies[1].getValue());
} else {
- Assert.assertEquals("c2", cookies[0].getName());
- Assert.assertEquals("c2v", cookies[0].getValue());
- Assert.assertEquals("c1", cookies[1].getName());
- Assert.assertEquals("c1v", cookies[1].getValue());
+ Assertions.assertEquals("c2", cookies[0].getName());
+ Assertions.assertEquals("c2v", cookies[0].getValue());
+ Assertions.assertEquals("c1", cookies[1].getName());
+ Assertions.assertEquals("c1v", cookies[1].getValue());
}
}
@@ -154,12 +154,12 @@ public class TestVertxServerRequestToHttpServletRequest {
}
};
- Assert.assertEquals("value", request.getParameter("name"));
+ Assertions.assertEquals("value", request.getParameter("name"));
}
@Test
public void testGetParameterValuesNull() {
- Assert.assertEquals(0, request.getParameterValues("name").length);
+ Assertions.assertEquals(0, request.getParameterValues("name").length);
}
@Test
@@ -192,7 +192,7 @@ public class TestVertxServerRequestToHttpServletRequest {
Map<String, String[]> result = request.getParameterMap();
MatcherAssert.assertThat(result.keySet(), Matchers.contains("name"));
MatcherAssert.assertThat(result.get("name"), Matchers.arrayContaining("value"));
- Assert.assertSame(result, request.getParameterMap());
+ Assertions.assertSame(result, request.getParameterMap());
}
@Test
@@ -204,7 +204,7 @@ public class TestVertxServerRequestToHttpServletRequest {
}
};
- Assert.assertEquals("abc", request.getScheme());
+ Assertions.assertEquals("abc", request.getScheme());
}
@Test
@@ -216,7 +216,7 @@ public class TestVertxServerRequestToHttpServletRequest {
}
};
- Assert.assertEquals("host", request.getRemoteAddr());
+ Assertions.assertEquals("host", request.getRemoteAddr());
}
@Test
@@ -227,7 +227,7 @@ public class TestVertxServerRequestToHttpServletRequest {
result = null;
}
};
- Assert.assertNull(request.getRemoteAddr());
+ Assertions.assertNull(request.getRemoteAddr());
}
@Test
@@ -239,7 +239,7 @@ public class TestVertxServerRequestToHttpServletRequest {
}
};
- Assert.assertEquals("host", request.getRemoteHost());
+ Assertions.assertEquals("host", request.getRemoteHost());
}
@Test
@@ -251,7 +251,7 @@ public class TestVertxServerRequestToHttpServletRequest {
}
};
- Assert.assertEquals(1234, request.getRemotePort());
+ Assertions.assertEquals(1234, request.getRemotePort());
}
@Test
@@ -265,7 +265,7 @@ public class TestVertxServerRequestToHttpServletRequest {
}
};
- Assert.assertEquals("host", request.getLocalAddr());
+ Assertions.assertEquals("host", request.getLocalAddr());
}
@Test
@@ -279,7 +279,7 @@ public class TestVertxServerRequestToHttpServletRequest {
}
};
- Assert.assertEquals(1234, request.getLocalPort());
+ Assertions.assertEquals(1234, request.getLocalPort());
}
@Test
@@ -291,7 +291,7 @@ public class TestVertxServerRequestToHttpServletRequest {
}
};
- Assert.assertEquals("value", request.getHeader("key"));
+ Assertions.assertEquals("value", request.getHeader("key"));
}
@Test
@@ -324,7 +324,7 @@ public class TestVertxServerRequestToHttpServletRequest {
@Test
public void testGetIntHeaderNotExist() {
- Assert.assertEquals(-1, request.getIntHeader("key"));
+ Assertions.assertEquals(-1, request.getIntHeader("key"));
}
@Test
@@ -338,9 +338,9 @@ public class TestVertxServerRequestToHttpServletRequest {
try {
request.getIntHeader("key");
- Assert.fail("must throw exception");
+ Assertions.fail("must throw exception");
} catch (NumberFormatException e) {
- Assert.assertEquals("For input string: \"value\"", e.getMessage());
+ Assertions.assertEquals("For input string: \"value\"", e.getMessage());
}
}
@@ -353,7 +353,7 @@ public class TestVertxServerRequestToHttpServletRequest {
}
};
- Assert.assertEquals(1, request.getIntHeader("key"));
+ Assertions.assertEquals(1, request.getIntHeader("key"));
}
@Test
@@ -365,7 +365,7 @@ public class TestVertxServerRequestToHttpServletRequest {
}
};
- Assert.assertEquals("GET", request.getMethod());
+ Assertions.assertEquals("GET", request.getMethod());
}
@Test
@@ -377,7 +377,7 @@ public class TestVertxServerRequestToHttpServletRequest {
}
};
- Assert.assertEquals("/path", request.getPathInfo());
+ Assertions.assertEquals("/path", request.getPathInfo());
}
@Test
@@ -389,7 +389,7 @@ public class TestVertxServerRequestToHttpServletRequest {
}
};
- Assert.assertEquals("k1=v1&k2=v2", request.getQueryString());
+ Assertions.assertEquals("k1=v1&k2=v2", request.getQueryString());
}
@Test
@@ -401,7 +401,7 @@ public class TestVertxServerRequestToHttpServletRequest {
}
};
- Assert.assertEquals("/path", request.getRequestURI());
+ Assertions.assertEquals("/path", request.getRequestURI());
}
@Test
@@ -413,12 +413,12 @@ public class TestVertxServerRequestToHttpServletRequest {
}
};
- Assert.assertEquals("/path", request.getServletPath());
+ Assertions.assertEquals("/path", request.getServletPath());
}
@Test
public void testGetContextPath() {
- Assert.assertEquals("", request.getContextPath());
+ Assertions.assertEquals("", request.getContextPath());
}
@Test
@@ -434,15 +434,15 @@ public class TestVertxServerRequestToHttpServletRequest {
};
ServletInputStream is1 = request.getInputStream();
- Assert.assertSame(is1, request.getInputStream());
+ Assertions.assertSame(is1, request.getInputStream());
int value = is1.read();
is1.close();
- Assert.assertEquals(1, value);
- Assert.assertSame(is1, request.getInputStream());
+ Assertions.assertEquals(1, value);
+ Assertions.assertSame(is1, request.getInputStream());
request.setBodyBuffer(Buffer.buffer().appendByte((byte)2));
ServletInputStream is2 = request.getInputStream();
- Assert.assertNotSame(is1, is2);
+ Assertions.assertNotSame(is1, is2);
}
@Test
@@ -450,7 +450,7 @@ public class TestVertxServerRequestToHttpServletRequest {
AsyncContext asyncContext =
Deencapsulation.getField(VertxServerRequestToHttpServletRequest.class, "EMPTY_ASYNC_CONTEXT");
- Assert.assertSame(asyncContext, request.getAsyncContext());
+ Assertions.assertSame(asyncContext, request.getAsyncContext());
}
@Test
@@ -464,7 +464,7 @@ public class TestVertxServerRequestToHttpServletRequest {
}
};
- Assert.assertEquals("ce", request.getCharacterEncoding());
+ Assertions.assertEquals("ce", request.getCharacterEncoding());
}
@@ -476,10 +476,10 @@ public class TestVertxServerRequestToHttpServletRequest {
request.setParameter("k1", "v1");
request.setParameter("k2", "v2");
- Assert.assertEquals("v1", request.getParameter("k1"));
- Assert.assertEquals("v2", request.getParameter("k2"));
+ Assertions.assertEquals("v1", request.getParameter("k1"));
+ Assertions.assertEquals("v2", request.getParameter("k2"));
- Assert.assertSame(parameterMap, request.getParameterMap());
+ Assertions.assertSame(parameterMap, request.getParameterMap());
MatcherAssert.assertThat(Collections.list(request.getParameterNames()), Matchers.contains("k1", "k2"));
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestVertxServerResponseToHttpServletResponse.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestVertxServerResponseToHttpServletResponse.java
index 78a20bc7e..e98f65691 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestVertxServerResponseToHttpServletResponse.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/http/TestVertxServerResponseToHttpServletResponse.java
@@ -35,7 +35,6 @@ import org.apache.servicecomb.foundation.common.part.FilePart;
import org.apache.servicecomb.foundation.vertx.stream.PumpFromPart;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
@@ -182,24 +181,24 @@ public class TestVertxServerResponseToHttpServletResponse {
@Test
public void setContentType() {
response.setContentType("json");
- Assert.assertEquals("json", headers.get(HttpHeaders.CONTENT_TYPE));
+ Assertions.assertEquals("json", headers.get(HttpHeaders.CONTENT_TYPE));
}
@SuppressWarnings("deprecation")
@Test
public void setStatus() {
response.setStatus(222, "test");
- Assert.assertEquals(222, httpStatus.getStatusCode());
- Assert.assertEquals("test", httpStatus.getReasonPhrase());
+ Assertions.assertEquals(222, httpStatus.getStatusCode());
+ Assertions.assertEquals("test", httpStatus.getReasonPhrase());
}
@Test
public void getStatusType() {
StatusType status = response.getStatusType();
- Assert.assertSame(status, response.getStatusType());
- Assert.assertEquals(123, httpStatus.getStatusCode());
- Assert.assertEquals("default", httpStatus.getReasonPhrase());
+ Assertions.assertSame(status, response.getStatusType());
+ Assertions.assertEquals(123, httpStatus.getStatusCode());
+ Assertions.assertEquals("default", httpStatus.getReasonPhrase());
}
@Test
@@ -208,7 +207,7 @@ public class TestVertxServerResponseToHttpServletResponse {
response.addHeader("n1", "v1_2");
response.addHeader("n2", "v2");
- Assert.assertEquals(2, headers.size());
+ Assertions.assertEquals(2, headers.size());
MatcherAssert.assertThat(headers.getAll("n1"), Matchers.contains("v1_1", "v1_2"));
MatcherAssert.assertThat(headers.getAll("n2"), Matchers.contains("v2"));
}
@@ -219,26 +218,26 @@ public class TestVertxServerResponseToHttpServletResponse {
response.setHeader("n1", "v1_2");
response.setHeader("n2", "v2");
- Assert.assertEquals(2, headers.size());
+ Assertions.assertEquals(2, headers.size());
MatcherAssert.assertThat(headers.getAll("n1"), Matchers.contains("v1_2"));
MatcherAssert.assertThat(headers.getAll("n2"), Matchers.contains("v2"));
}
@Test
public void getStatus() {
- Assert.assertEquals(123, response.getStatus());
+ Assertions.assertEquals(123, response.getStatus());
}
@Test
public void getContentType() {
headers.set(HttpHeaders.CONTENT_TYPE, "json");
- Assert.assertEquals("json", response.getContentType());
+ Assertions.assertEquals("json", response.getContentType());
}
@Test
public void getHeader() {
headers.set(HttpHeaders.CONTENT_TYPE, "json");
- Assert.assertEquals("json", response.getHeader(HttpHeaders.CONTENT_TYPE));
+ Assertions.assertEquals("json", response.getHeader(HttpHeaders.CONTENT_TYPE));
}
@Test
@@ -261,7 +260,7 @@ public class TestVertxServerResponseToHttpServletResponse {
public void flushBuffer_sameContext() throws IOException {
response.flushBuffer();
- Assert.assertFalse(runOnContextInvoked);
+ Assertions.assertFalse(runOnContextInvoked);
}
@Test
@@ -274,14 +273,14 @@ public class TestVertxServerResponseToHttpServletResponse {
};
response.flushBuffer();
- Assert.assertTrue(runOnContextInvoked);
+ Assertions.assertTrue(runOnContextInvoked);
}
@Test
public void internalFlushBufferNoBody() throws IOException {
response.internalFlushBuffer();
- Assert.assertFalse(flushWithBody);
+ Assertions.assertFalse(flushWithBody);
}
@Test
@@ -289,7 +288,7 @@ public class TestVertxServerResponseToHttpServletResponse {
response.setBodyBuffer(Buffer.buffer());
response.internalFlushBuffer();
- Assert.assertTrue(flushWithBody);
+ Assertions.assertTrue(flushWithBody);
}
@Test
@@ -304,9 +303,9 @@ public class TestVertxServerResponseToHttpServletResponse {
};
DownloadUtils.prepareDownloadHeader(response, part);
- Assert.assertTrue(serverResponse.isChunked());
- Assert.assertEquals("type", response.getHeader(HttpHeaders.CONTENT_TYPE));
- Assert.assertEquals(
+ Assertions.assertTrue(serverResponse.isChunked());
+ Assertions.assertEquals("type", response.getHeader(HttpHeaders.CONTENT_TYPE));
+ Assertions.assertEquals(
"attachment;filename=%E6%B5%8B%20%20%20%20%20%E8%AF%95;filename*=utf-8''%E6%B5%8B%20%20%20%20%20%E8%AF%95",
response.getHeader(HttpHeaders.CONTENT_DISPOSITION));
}
@@ -319,9 +318,9 @@ public class TestVertxServerResponseToHttpServletResponse {
DownloadUtils.prepareDownloadHeader(response, part);
- Assert.assertFalse(serverResponse.isChunked());
- Assert.assertEquals("type", response.getHeader(HttpHeaders.CONTENT_TYPE));
- Assert.assertEquals("disposition", response.getHeader(HttpHeaders.CONTENT_DISPOSITION));
+ Assertions.assertFalse(serverResponse.isChunked());
+ Assertions.assertEquals("type", response.getHeader(HttpHeaders.CONTENT_TYPE));
+ Assertions.assertEquals("disposition", response.getHeader(HttpHeaders.CONTENT_DISPOSITION));
}
@Test
@@ -344,7 +343,7 @@ public class TestVertxServerResponseToHttpServletResponse {
@Test
public void sendPart_testPartIsNull(@Mocked Part part) throws InterruptedException, ExecutionException {
CompletableFuture<Void> future1 = response.sendPart(null);
- Assert.assertNull(future1.get());
+ Assertions.assertNull(future1.get());
}
@Test
@@ -376,7 +375,7 @@ public class TestVertxServerResponseToHttpServletResponse {
}
};
- Assert.assertSame(future, response.sendPart(part));
+ Assertions.assertSame(future, response.sendPart(part));
}
@Test
@@ -393,7 +392,7 @@ public class TestVertxServerResponseToHttpServletResponse {
CompletableFuture<Void> future = response.sendPart(part);
- Assert.assertNull(future.get());
+ Assertions.assertNull(future.get());
}
@Test
@@ -402,9 +401,9 @@ public class TestVertxServerResponseToHttpServletResponse {
FileUtils.write(file, "content", StandardCharsets.UTF_8);
FilePart part = new FilePart(null, file).setDeleteAfterFinished(true);
- Assert.assertTrue(file.exists());
+ Assertions.assertTrue(file.exists());
DownloadUtils.clearPartResource(part);
- Assert.assertFalse(file.exists());
+ Assertions.assertFalse(file.exists());
}
@Test
@@ -413,9 +412,9 @@ public class TestVertxServerResponseToHttpServletResponse {
FileUtils.write(file, "content", StandardCharsets.UTF_8);
FilePart part = new FilePart(null, file);
- Assert.assertTrue(file.exists());
+ Assertions.assertTrue(file.exists());
DownloadUtils.clearPartResource(part);
- Assert.assertTrue(file.exists());
+ Assertions.assertTrue(file.exists());
file.delete();
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/metrics/TestDefaultHttpClientMetrics.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/metrics/TestDefaultHttpClientMetrics.java
index df13b60bf..7049fb9aa 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/metrics/TestDefaultHttpClientMetrics.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/metrics/TestDefaultHttpClientMetrics.java
@@ -20,7 +20,6 @@ import org.apache.servicecomb.foundation.vertx.metrics.metric.DefaultClientEndpo
import org.apache.servicecomb.foundation.vertx.metrics.metric.DefaultEndpointMetric;
import org.apache.servicecomb.foundation.vertx.metrics.metric.DefaultRequestMetric;
import org.apache.servicecomb.foundation.vertx.metrics.metric.DefaultTcpSocketMetric;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -35,6 +34,7 @@ import io.vertx.core.spi.observability.HttpRequest;
import mockit.Mock;
import mockit.MockUp;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestDefaultHttpClientMetrics {
@Mocked
@@ -138,19 +138,19 @@ public class TestDefaultHttpClientMetrics {
@Test
public void createMetrics() {
- Assert.assertNotSame(clientMetrics_a, clientMetrics_b);
+ Assertions.assertNotSame(clientMetrics_a, clientMetrics_b);
}
@Test
public void createEndpoint() {
- Assert.assertSame(endpointMetric_a_1, endpointMetric_b_1);
- Assert.assertNotSame(endpointMetric_a_1, endpointMetric_a_2);
+ Assertions.assertSame(endpointMetric_a_1, endpointMetric_b_1);
+ Assertions.assertNotSame(endpointMetric_a_1, endpointMetric_a_2);
- Assert.assertNotSame(endpointMetric_a_2, endpointMetric_b_1);
- Assert.assertSame(endpointMetric_a_2, endpointMetric_b_2);
+ Assertions.assertNotSame(endpointMetric_a_2, endpointMetric_b_1);
+ Assertions.assertSame(endpointMetric_a_2, endpointMetric_b_2);
- Assert.assertEquals(2, endpointMetric_a_1.getCurrentConnectionCount());
- Assert.assertEquals(2, endpointMetric_a_2.getCurrentConnectionCount());
+ Assertions.assertEquals(2, endpointMetric_a_1.getCurrentConnectionCount());
+ Assertions.assertEquals(2, endpointMetric_a_2.getCurrentConnectionCount());
}
@Test
@@ -163,9 +163,9 @@ public class TestDefaultHttpClientMetrics {
nanoTime = 13;
defaultVertxMetrics.getClientEndpointMetricManager().onCheckClientEndpointMetricExpired(0);
- Assert.assertNotNull(
+ Assertions.assertNotNull(
defaultVertxMetrics.getClientEndpointMetricManager().getClientEndpointMetric("http://" + address1.toString()));
- Assert.assertNotNull(
+ Assertions.assertNotNull(
defaultVertxMetrics.getClientEndpointMetricManager().getClientEndpointMetric("http://" + address2.toString()));
clientMetrics_b.disconnected(socketMetric_b_1, null);
@@ -173,95 +173,95 @@ public class TestDefaultHttpClientMetrics {
nanoTime = 23;
defaultVertxMetrics.getClientEndpointMetricManager().onCheckClientEndpointMetricExpired(0);
- Assert.assertNotNull(
+ Assertions.assertNotNull(
defaultVertxMetrics.getClientEndpointMetricManager().getClientEndpointMetric("http://" + address1.toString()));
- Assert.assertNotNull(
+ Assertions.assertNotNull(
defaultVertxMetrics.getClientEndpointMetricManager().getClientEndpointMetric("http://" + address2.toString()));
nanoTime = 24;
defaultVertxMetrics.getClientEndpointMetricManager().onCheckClientEndpointMetricExpired(0);
- Assert
+ Assertions
.assertNull(defaultVertxMetrics.getClientEndpointMetricManager().getClientEndpointMetric(address1.toString()));
- Assert
+ Assertions
.assertNull(defaultVertxMetrics.getClientEndpointMetricManager().getClientEndpointMetric(address2.toString()));
}
@Test
public void connect() {
{
- Assert.assertSame(endpointMetric_a_1, socketMetric_a_1.getEndpointMetric());
- Assert.assertTrue(socketMetric_a_1.isConnected());
- Assert.assertEquals(1, socketMetric_a_1.getConnectedTime());
- Assert.assertEquals(2, socketMetric_a_1.getEndpointMetric().getConnectCount());
- Assert.assertEquals(0, socketMetric_a_1.getEndpointMetric().getDisconnectCount());
- Assert.assertEquals(2, socketMetric_a_1.getEndpointMetric().getCurrentConnectionCount());
+ Assertions.assertSame(endpointMetric_a_1, socketMetric_a_1.getEndpointMetric());
+ Assertions.assertTrue(socketMetric_a_1.isConnected());
+ Assertions.assertEquals(1, socketMetric_a_1.getConnectedTime());
+ Assertions.assertEquals(2, socketMetric_a_1.getEndpointMetric().getConnectCount());
+ Assertions.assertEquals(0, socketMetric_a_1.getEndpointMetric().getDisconnectCount());
+ Assertions.assertEquals(2, socketMetric_a_1.getEndpointMetric().getCurrentConnectionCount());
nanoTime = 2;
clientMetrics_a.disconnected(socketMetric_a_1, null);
- Assert.assertEquals(2, ((DefaultClientEndpointMetric) endpointMetric_a_1).getLastNanoTime());
- Assert.assertFalse(socketMetric_a_1.isConnected());
- Assert.assertEquals(1, socketMetric_a_1.getConnectedTime());
- Assert.assertEquals(2, socketMetric_a_1.getEndpointMetric().getConnectCount());
- Assert.assertEquals(1, socketMetric_a_1.getEndpointMetric().getDisconnectCount());
- Assert.assertEquals(1, socketMetric_a_1.getEndpointMetric().getCurrentConnectionCount());
+ Assertions.assertEquals(2, ((DefaultClientEndpointMetric) endpointMetric_a_1).getLastNanoTime());
+ Assertions.assertFalse(socketMetric_a_1.isConnected());
+ Assertions.assertEquals(1, socketMetric_a_1.getConnectedTime());
+ Assertions.assertEquals(2, socketMetric_a_1.getEndpointMetric().getConnectCount());
+ Assertions.assertEquals(1, socketMetric_a_1.getEndpointMetric().getDisconnectCount());
+ Assertions.assertEquals(1, socketMetric_a_1.getEndpointMetric().getCurrentConnectionCount());
}
{
- Assert.assertSame(endpointMetric_a_2, socketMetric_a_2.getEndpointMetric());
- Assert.assertTrue(socketMetric_a_2.isConnected());
- Assert.assertEquals(1, socketMetric_a_2.getConnectedTime());
- Assert.assertEquals(2, socketMetric_a_2.getEndpointMetric().getConnectCount());
- Assert.assertEquals(0, socketMetric_a_2.getEndpointMetric().getDisconnectCount());
- Assert.assertEquals(2, socketMetric_a_2.getEndpointMetric().getCurrentConnectionCount());
+ Assertions.assertSame(endpointMetric_a_2, socketMetric_a_2.getEndpointMetric());
+ Assertions.assertTrue(socketMetric_a_2.isConnected());
+ Assertions.assertEquals(1, socketMetric_a_2.getConnectedTime());
+ Assertions.assertEquals(2, socketMetric_a_2.getEndpointMetric().getConnectCount());
+ Assertions.assertEquals(0, socketMetric_a_2.getEndpointMetric().getDisconnectCount());
+ Assertions.assertEquals(2, socketMetric_a_2.getEndpointMetric().getCurrentConnectionCount());
nanoTime = 4;
clientMetrics_a.disconnected(socketMetric_a_2, null);
- Assert.assertEquals(4, ((DefaultClientEndpointMetric) endpointMetric_a_2).getLastNanoTime());
- Assert.assertFalse(socketMetric_a_2.isConnected());
- Assert.assertEquals(1, socketMetric_a_2.getConnectedTime());
- Assert.assertEquals(2, socketMetric_a_2.getEndpointMetric().getConnectCount());
- Assert.assertEquals(1, socketMetric_a_2.getEndpointMetric().getDisconnectCount());
- Assert.assertEquals(1, socketMetric_a_2.getEndpointMetric().getCurrentConnectionCount());
+ Assertions.assertEquals(4, ((DefaultClientEndpointMetric) endpointMetric_a_2).getLastNanoTime());
+ Assertions.assertFalse(socketMetric_a_2.isConnected());
+ Assertions.assertEquals(1, socketMetric_a_2.getConnectedTime());
+ Assertions.assertEquals(2, socketMetric_a_2.getEndpointMetric().getConnectCount());
+ Assertions.assertEquals(1, socketMetric_a_2.getEndpointMetric().getDisconnectCount());
+ Assertions.assertEquals(1, socketMetric_a_2.getEndpointMetric().getCurrentConnectionCount());
}
{
- Assert.assertSame(endpointMetric_b_1, socketMetric_b_1.getEndpointMetric());
- Assert.assertTrue(socketMetric_b_1.isConnected());
- Assert.assertEquals(1, socketMetric_b_1.getConnectedTime());
- Assert.assertEquals(2, socketMetric_b_1.getEndpointMetric().getConnectCount());
- Assert.assertEquals(1, socketMetric_b_1.getEndpointMetric().getDisconnectCount());
- Assert.assertEquals(1, socketMetric_b_1.getEndpointMetric().getCurrentConnectionCount());
+ Assertions.assertSame(endpointMetric_b_1, socketMetric_b_1.getEndpointMetric());
+ Assertions.assertTrue(socketMetric_b_1.isConnected());
+ Assertions.assertEquals(1, socketMetric_b_1.getConnectedTime());
+ Assertions.assertEquals(2, socketMetric_b_1.getEndpointMetric().getConnectCount());
+ Assertions.assertEquals(1, socketMetric_b_1.getEndpointMetric().getDisconnectCount());
+ Assertions.assertEquals(1, socketMetric_b_1.getEndpointMetric().getCurrentConnectionCount());
nanoTime = 6;
clientMetrics_b.disconnected(socketMetric_b_1, null);
- Assert.assertEquals(6, ((DefaultClientEndpointMetric) endpointMetric_b_1).getLastNanoTime());
- Assert.assertFalse(socketMetric_b_1.isConnected());
- Assert.assertEquals(1, socketMetric_b_1.getConnectedTime());
- Assert.assertEquals(2, socketMetric_b_1.getEndpointMetric().getConnectCount());
- Assert.assertEquals(2, socketMetric_b_1.getEndpointMetric().getDisconnectCount());
- Assert.assertEquals(0, socketMetric_b_1.getEndpointMetric().getCurrentConnectionCount());
+ Assertions.assertEquals(6, ((DefaultClientEndpointMetric) endpointMetric_b_1).getLastNanoTime());
+ Assertions.assertFalse(socketMetric_b_1.isConnected());
+ Assertions.assertEquals(1, socketMetric_b_1.getConnectedTime());
+ Assertions.assertEquals(2, socketMetric_b_1.getEndpointMetric().getConnectCount());
+ Assertions.assertEquals(2, socketMetric_b_1.getEndpointMetric().getDisconnectCount());
+ Assertions.assertEquals(0, socketMetric_b_1.getEndpointMetric().getCurrentConnectionCount());
}
{
- Assert.assertSame(endpointMetric_b_2, socketMetric_b_2.getEndpointMetric());
- Assert.assertTrue(socketMetric_b_2.isConnected());
- Assert.assertEquals(1, socketMetric_b_2.getConnectedTime());
- Assert.assertEquals(2, socketMetric_b_2.getEndpointMetric().getConnectCount());
- Assert.assertEquals(1, socketMetric_b_2.getEndpointMetric().getDisconnectCount());
- Assert.assertEquals(1, socketMetric_b_2.getEndpointMetric().getCurrentConnectionCount());
+ Assertions.assertSame(endpointMetric_b_2, socketMetric_b_2.getEndpointMetric());
+ Assertions.assertTrue(socketMetric_b_2.isConnected());
+ Assertions.assertEquals(1, socketMetric_b_2.getConnectedTime());
+ Assertions.assertEquals(2, socketMetric_b_2.getEndpointMetric().getConnectCount());
+ Assertions.assertEquals(1, socketMetric_b_2.getEndpointMetric().getDisconnectCount());
+ Assertions.assertEquals(1, socketMetric_b_2.getEndpointMetric().getCurrentConnectionCount());
nanoTime = 7;
clientMetrics_b.disconnected(socketMetric_b_2, null);
- Assert.assertEquals(7, ((DefaultClientEndpointMetric) endpointMetric_b_2).getLastNanoTime());
- Assert.assertFalse(socketMetric_b_2.isConnected());
- Assert.assertEquals(1, socketMetric_b_2.getConnectedTime());
- Assert.assertEquals(2, socketMetric_b_2.getEndpointMetric().getConnectCount());
- Assert.assertEquals(2, socketMetric_b_2.getEndpointMetric().getDisconnectCount());
- Assert.assertEquals(0, socketMetric_b_2.getEndpointMetric().getCurrentConnectionCount());
+ Assertions.assertEquals(7, ((DefaultClientEndpointMetric) endpointMetric_b_2).getLastNanoTime());
+ Assertions.assertFalse(socketMetric_b_2.isConnected());
+ Assertions.assertEquals(1, socketMetric_b_2.getConnectedTime());
+ Assertions.assertEquals(2, socketMetric_b_2.getEndpointMetric().getConnectCount());
+ Assertions.assertEquals(2, socketMetric_b_2.getEndpointMetric().getDisconnectCount());
+ Assertions.assertEquals(0, socketMetric_b_2.getEndpointMetric().getCurrentConnectionCount());
}
}
@@ -287,10 +287,10 @@ public class TestDefaultHttpClientMetrics {
clientMetrics_b.bytesRead(socketMetric, address2, 1);
clientMetrics_b.bytesWritten(socketMetric, address2, 1);
- Assert.assertEquals(2, endpointMetric_a_1.getBytesRead());
- Assert.assertEquals(2, endpointMetric_a_2.getBytesRead());
- Assert.assertEquals(2, endpointMetric_a_1.getBytesWritten());
- Assert.assertEquals(2, endpointMetric_a_2.getBytesWritten());
+ Assertions.assertEquals(2, endpointMetric_a_1.getBytesRead());
+ Assertions.assertEquals(2, endpointMetric_a_2.getBytesRead());
+ Assertions.assertEquals(2, endpointMetric_a_1.getBytesWritten());
+ Assertions.assertEquals(2, endpointMetric_a_2.getBytesWritten());
}
@Test
@@ -302,7 +302,7 @@ public class TestDefaultHttpClientMetrics {
nanoTime = 3;
clientMetrics_a_1.requestEnd(requestMetric);
- Assert.assertEquals(2, requestMetric.getRequestBeginTime());
- Assert.assertEquals(3, requestMetric.getRequestEndTime());
+ Assertions.assertEquals(2, requestMetric.getRequestBeginTime());
+ Assertions.assertEquals(3, requestMetric.getRequestEndTime());
}
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/metrics/TestDefaultHttpServerMetrics.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/metrics/TestDefaultHttpServerMetrics.java
index 092c52849..2c64f1408 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/metrics/TestDefaultHttpServerMetrics.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/metrics/TestDefaultHttpServerMetrics.java
@@ -21,7 +21,6 @@ import java.util.Map;
import org.apache.servicecomb.foundation.vertx.metrics.metric.DefaultEndpointMetric;
import org.apache.servicecomb.foundation.vertx.metrics.metric.DefaultTcpSocketMetric;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -31,6 +30,7 @@ import io.vertx.core.http.HttpServer;
import io.vertx.core.http.HttpServerOptions;
import io.vertx.core.net.SocketAddress;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestDefaultHttpServerMetrics {
@Mocked
@@ -51,12 +51,6 @@ public class TestDefaultHttpServerMetrics {
@Mocked
SocketAddress listen1_addr;
- @Mocked
- HttpServer listen2_server1;
-
- @Mocked
- HttpServer listen2_server2;
-
@Mocked
SocketAddress listen2_addr;
@@ -121,11 +115,11 @@ public class TestDefaultHttpServerMetrics {
instances.put(metrics_listen1_server2, null);
instances.put(metrics_listen2_server1, null);
instances.put(metrics_listen2_server2, null);
- Assert.assertEquals(4, instances.size());
+ Assertions.assertEquals(4, instances.size());
- Assert.assertSame(metrics_listen1_server1.getEndpointMetric(), metrics_listen1_server2.getEndpointMetric());
- Assert.assertNotSame(metrics_listen1_server1.getEndpointMetric(), metrics_listen2_server1.getEndpointMetric());
- Assert.assertSame(metrics_listen2_server1.getEndpointMetric(), metrics_listen2_server2.getEndpointMetric());
+ Assertions.assertSame(metrics_listen1_server1.getEndpointMetric(), metrics_listen1_server2.getEndpointMetric());
+ Assertions.assertNotSame(metrics_listen1_server1.getEndpointMetric(), metrics_listen2_server1.getEndpointMetric());
+ Assertions.assertSame(metrics_listen2_server1.getEndpointMetric(), metrics_listen2_server2.getEndpointMetric());
}
@Test
@@ -136,16 +130,16 @@ public class TestDefaultHttpServerMetrics {
instances.put(socketMetric_listen2_1, null);
instances.put(socketMetric_listen2_2, null);
instances.put(socketMetric_listen2_3, null);
- Assert.assertEquals(5, instances.size());
+ Assertions.assertEquals(5, instances.size());
- Assert.assertTrue(socketMetric_listen1_1.isConnected());
- Assert.assertTrue(socketMetric_listen1_2.isConnected());
- Assert.assertTrue(socketMetric_listen2_1.isConnected());
- Assert.assertTrue(socketMetric_listen2_2.isConnected());
- Assert.assertTrue(socketMetric_listen2_3.isConnected());
+ Assertions.assertTrue(socketMetric_listen1_1.isConnected());
+ Assertions.assertTrue(socketMetric_listen1_2.isConnected());
+ Assertions.assertTrue(socketMetric_listen2_1.isConnected());
+ Assertions.assertTrue(socketMetric_listen2_2.isConnected());
+ Assertions.assertTrue(socketMetric_listen2_3.isConnected());
- Assert.assertEquals(2, endpointMetric1.getCurrentConnectionCount());
- Assert.assertEquals(3, endpointMetric2.getCurrentConnectionCount());
+ Assertions.assertEquals(2, endpointMetric1.getCurrentConnectionCount());
+ Assertions.assertEquals(3, endpointMetric2.getCurrentConnectionCount());
// disconnect
metrics_listen1_server1.disconnected(socketMetric_listen1_1, anyRemoteAddr);
@@ -154,14 +148,14 @@ public class TestDefaultHttpServerMetrics {
metrics_listen2_server2.disconnected(socketMetric_listen2_2, anyRemoteAddr);
metrics_listen2_server2.disconnected(socketMetric_listen2_3, anyRemoteAddr);
- Assert.assertFalse(socketMetric_listen1_1.isConnected());
- Assert.assertFalse(socketMetric_listen1_2.isConnected());
- Assert.assertFalse(socketMetric_listen2_1.isConnected());
- Assert.assertFalse(socketMetric_listen2_2.isConnected());
- Assert.assertFalse(socketMetric_listen2_3.isConnected());
+ Assertions.assertFalse(socketMetric_listen1_1.isConnected());
+ Assertions.assertFalse(socketMetric_listen1_2.isConnected());
+ Assertions.assertFalse(socketMetric_listen2_1.isConnected());
+ Assertions.assertFalse(socketMetric_listen2_2.isConnected());
+ Assertions.assertFalse(socketMetric_listen2_3.isConnected());
- Assert.assertEquals(0, endpointMetric1.getCurrentConnectionCount());
- Assert.assertEquals(0, endpointMetric2.getCurrentConnectionCount());
+ Assertions.assertEquals(0, endpointMetric1.getCurrentConnectionCount());
+ Assertions.assertEquals(0, endpointMetric2.getCurrentConnectionCount());
}
@Test
@@ -172,8 +166,8 @@ public class TestDefaultHttpServerMetrics {
metrics_listen2_server2.bytesRead(socketMetric_listen2_2, anyRemoteAddr, 4);
metrics_listen2_server2.bytesRead(socketMetric_listen2_3, anyRemoteAddr, 5);
- Assert.assertEquals(3, endpointMetric1.getBytesRead());
- Assert.assertEquals(12, endpointMetric2.getBytesRead());
+ Assertions.assertEquals(3, endpointMetric1.getBytesRead());
+ Assertions.assertEquals(12, endpointMetric2.getBytesRead());
}
@Test
@@ -184,7 +178,7 @@ public class TestDefaultHttpServerMetrics {
metrics_listen2_server2.bytesWritten(socketMetric_listen2_2, anyRemoteAddr, 4);
metrics_listen2_server2.bytesWritten(socketMetric_listen2_3, anyRemoteAddr, 5);
- Assert.assertEquals(3, endpointMetric1.getBytesWritten());
- Assert.assertEquals(12, endpointMetric2.getBytesWritten());
+ Assertions.assertEquals(3, endpointMetric1.getBytesWritten());
+ Assertions.assertEquals(12, endpointMetric2.getBytesWritten());
}
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/metrics/TestDefaultTcpClientMetrics.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/metrics/TestDefaultTcpClientMetrics.java
index 6ad08cf4e..8c893b60c 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/metrics/TestDefaultTcpClientMetrics.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/metrics/TestDefaultTcpClientMetrics.java
@@ -19,7 +19,6 @@ package org.apache.servicecomb.foundation.vertx.metrics;
import org.apache.servicecomb.foundation.vertx.metrics.metric.DefaultClientEndpointMetric;
import org.apache.servicecomb.foundation.vertx.metrics.metric.DefaultEndpointMetric;
import org.apache.servicecomb.foundation.vertx.metrics.metric.DefaultTcpSocketMetric;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -32,6 +31,7 @@ import io.vertx.core.net.impl.SocketAddressImpl;
import mockit.Mock;
import mockit.MockUp;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestDefaultTcpClientMetrics {
@Mocked
@@ -115,19 +115,19 @@ public class TestDefaultTcpClientMetrics {
@Test
public void createMetrics() {
- Assert.assertNotSame(clientMetrics_a, clientMetrics_b);
+ Assertions.assertNotSame(clientMetrics_a, clientMetrics_b);
}
@Test
public void createEndpoint() {
- Assert.assertSame(endpointMetric_a_1, endpointMetric_b_1);
- Assert.assertNotSame(endpointMetric_a_1, endpointMetric_a_2);
+ Assertions.assertSame(endpointMetric_a_1, endpointMetric_b_1);
+ Assertions.assertNotSame(endpointMetric_a_1, endpointMetric_a_2);
- Assert.assertNotSame(endpointMetric_a_2, endpointMetric_b_1);
- Assert.assertSame(endpointMetric_a_2, endpointMetric_b_2);
+ Assertions.assertNotSame(endpointMetric_a_2, endpointMetric_b_1);
+ Assertions.assertSame(endpointMetric_a_2, endpointMetric_b_2);
- Assert.assertEquals(2, endpointMetric_a_1.getCurrentConnectionCount());
- Assert.assertEquals(2, endpointMetric_a_2.getCurrentConnectionCount());
+ Assertions.assertEquals(2, endpointMetric_a_1.getCurrentConnectionCount());
+ Assertions.assertEquals(2, endpointMetric_a_2.getCurrentConnectionCount());
}
@Test
@@ -140,9 +140,9 @@ public class TestDefaultTcpClientMetrics {
nanoTime = 13;
defaultVertxMetrics.getClientEndpointMetricManager().onCheckClientEndpointMetricExpired(0);
- Assert.assertNotNull(
+ Assertions.assertNotNull(
defaultVertxMetrics.getClientEndpointMetricManager().getClientEndpointMetric("tcp://" + address1.toString()));
- Assert.assertNotNull(
+ Assertions.assertNotNull(
defaultVertxMetrics.getClientEndpointMetricManager().getClientEndpointMetric("tcp://" + address2.toString()));
clientMetrics_b.disconnected(socketMetric_b_1, null);
@@ -150,95 +150,95 @@ public class TestDefaultTcpClientMetrics {
nanoTime = 23;
defaultVertxMetrics.getClientEndpointMetricManager().onCheckClientEndpointMetricExpired(0);
- Assert.assertNotNull(
+ Assertions.assertNotNull(
defaultVertxMetrics.getClientEndpointMetricManager().getClientEndpointMetric("tcp://" + address1.toString()));
- Assert.assertNotNull(
+ Assertions.assertNotNull(
defaultVertxMetrics.getClientEndpointMetricManager().getClientEndpointMetric("tcp://" + address2.toString()));
nanoTime = 24;
defaultVertxMetrics.getClientEndpointMetricManager().onCheckClientEndpointMetricExpired(0);
- Assert
+ Assertions
.assertNull(defaultVertxMetrics.getClientEndpointMetricManager().getClientEndpointMetric(address1.toString()));
- Assert
+ Assertions
.assertNull(defaultVertxMetrics.getClientEndpointMetricManager().getClientEndpointMetric(address2.toString()));
}
@Test
public void connect() {
{
- Assert.assertSame(endpointMetric_a_1, socketMetric_a_1.getEndpointMetric());
- Assert.assertTrue(socketMetric_a_1.isConnected());
- Assert.assertEquals(1, socketMetric_a_1.getConnectedTime());
- Assert.assertEquals(2, socketMetric_a_1.getEndpointMetric().getConnectCount());
- Assert.assertEquals(0, socketMetric_a_1.getEndpointMetric().getDisconnectCount());
- Assert.assertEquals(2, socketMetric_a_1.getEndpointMetric().getCurrentConnectionCount());
+ Assertions.assertSame(endpointMetric_a_1, socketMetric_a_1.getEndpointMetric());
+ Assertions.assertTrue(socketMetric_a_1.isConnected());
+ Assertions.assertEquals(1, socketMetric_a_1.getConnectedTime());
+ Assertions.assertEquals(2, socketMetric_a_1.getEndpointMetric().getConnectCount());
+ Assertions.assertEquals(0, socketMetric_a_1.getEndpointMetric().getDisconnectCount());
+ Assertions.assertEquals(2, socketMetric_a_1.getEndpointMetric().getCurrentConnectionCount());
nanoTime = 2;
clientMetrics_a.disconnected(socketMetric_a_1, null);
- Assert.assertEquals(2, ((DefaultClientEndpointMetric) endpointMetric_a_1).getLastNanoTime());
- Assert.assertFalse(socketMetric_a_1.isConnected());
- Assert.assertEquals(1, socketMetric_a_1.getConnectedTime());
- Assert.assertEquals(2, socketMetric_a_1.getEndpointMetric().getConnectCount());
- Assert.assertEquals(1, socketMetric_a_1.getEndpointMetric().getDisconnectCount());
- Assert.assertEquals(1, socketMetric_a_1.getEndpointMetric().getCurrentConnectionCount());
+ Assertions.assertEquals(2, ((DefaultClientEndpointMetric) endpointMetric_a_1).getLastNanoTime());
+ Assertions.assertFalse(socketMetric_a_1.isConnected());
+ Assertions.assertEquals(1, socketMetric_a_1.getConnectedTime());
+ Assertions.assertEquals(2, socketMetric_a_1.getEndpointMetric().getConnectCount());
+ Assertions.assertEquals(1, socketMetric_a_1.getEndpointMetric().getDisconnectCount());
+ Assertions.assertEquals(1, socketMetric_a_1.getEndpointMetric().getCurrentConnectionCount());
}
{
- Assert.assertSame(endpointMetric_a_2, socketMetric_a_2.getEndpointMetric());
- Assert.assertTrue(socketMetric_a_2.isConnected());
- Assert.assertEquals(1, socketMetric_a_2.getConnectedTime());
- Assert.assertEquals(2, socketMetric_a_2.getEndpointMetric().getConnectCount());
- Assert.assertEquals(0, socketMetric_a_2.getEndpointMetric().getDisconnectCount());
- Assert.assertEquals(2, socketMetric_a_2.getEndpointMetric().getCurrentConnectionCount());
+ Assertions.assertSame(endpointMetric_a_2, socketMetric_a_2.getEndpointMetric());
+ Assertions.assertTrue(socketMetric_a_2.isConnected());
+ Assertions.assertEquals(1, socketMetric_a_2.getConnectedTime());
+ Assertions.assertEquals(2, socketMetric_a_2.getEndpointMetric().getConnectCount());
+ Assertions.assertEquals(0, socketMetric_a_2.getEndpointMetric().getDisconnectCount());
+ Assertions.assertEquals(2, socketMetric_a_2.getEndpointMetric().getCurrentConnectionCount());
nanoTime = 4;
clientMetrics_a.disconnected(socketMetric_a_2, null);
- Assert.assertEquals(4, ((DefaultClientEndpointMetric) endpointMetric_a_2).getLastNanoTime());
- Assert.assertFalse(socketMetric_a_2.isConnected());
- Assert.assertEquals(1, socketMetric_a_2.getConnectedTime());
- Assert.assertEquals(2, socketMetric_a_2.getEndpointMetric().getConnectCount());
- Assert.assertEquals(1, socketMetric_a_2.getEndpointMetric().getDisconnectCount());
- Assert.assertEquals(1, socketMetric_a_2.getEndpointMetric().getCurrentConnectionCount());
+ Assertions.assertEquals(4, ((DefaultClientEndpointMetric) endpointMetric_a_2).getLastNanoTime());
+ Assertions.assertFalse(socketMetric_a_2.isConnected());
+ Assertions.assertEquals(1, socketMetric_a_2.getConnectedTime());
+ Assertions.assertEquals(2, socketMetric_a_2.getEndpointMetric().getConnectCount());
+ Assertions.assertEquals(1, socketMetric_a_2.getEndpointMetric().getDisconnectCount());
+ Assertions.assertEquals(1, socketMetric_a_2.getEndpointMetric().getCurrentConnectionCount());
}
{
- Assert.assertSame(endpointMetric_b_1, socketMetric_b_1.getEndpointMetric());
- Assert.assertTrue(socketMetric_b_1.isConnected());
- Assert.assertEquals(1, socketMetric_b_1.getConnectedTime());
- Assert.assertEquals(2, socketMetric_b_1.getEndpointMetric().getConnectCount());
- Assert.assertEquals(1, socketMetric_b_1.getEndpointMetric().getDisconnectCount());
- Assert.assertEquals(1, socketMetric_b_1.getEndpointMetric().getCurrentConnectionCount());
+ Assertions.assertSame(endpointMetric_b_1, socketMetric_b_1.getEndpointMetric());
+ Assertions.assertTrue(socketMetric_b_1.isConnected());
+ Assertions.assertEquals(1, socketMetric_b_1.getConnectedTime());
+ Assertions.assertEquals(2, socketMetric_b_1.getEndpointMetric().getConnectCount());
+ Assertions.assertEquals(1, socketMetric_b_1.getEndpointMetric().getDisconnectCount());
+ Assertions.assertEquals(1, socketMetric_b_1.getEndpointMetric().getCurrentConnectionCount());
nanoTime = 6;
clientMetrics_b.disconnected(socketMetric_b_1, null);
- Assert.assertEquals(6, ((DefaultClientEndpointMetric) endpointMetric_b_1).getLastNanoTime());
- Assert.assertFalse(socketMetric_b_1.isConnected());
- Assert.assertEquals(1, socketMetric_b_1.getConnectedTime());
- Assert.assertEquals(2, socketMetric_b_1.getEndpointMetric().getConnectCount());
- Assert.assertEquals(2, socketMetric_b_1.getEndpointMetric().getDisconnectCount());
- Assert.assertEquals(0, socketMetric_b_1.getEndpointMetric().getCurrentConnectionCount());
+ Assertions.assertEquals(6, ((DefaultClientEndpointMetric) endpointMetric_b_1).getLastNanoTime());
+ Assertions.assertFalse(socketMetric_b_1.isConnected());
+ Assertions.assertEquals(1, socketMetric_b_1.getConnectedTime());
+ Assertions.assertEquals(2, socketMetric_b_1.getEndpointMetric().getConnectCount());
+ Assertions.assertEquals(2, socketMetric_b_1.getEndpointMetric().getDisconnectCount());
+ Assertions.assertEquals(0, socketMetric_b_1.getEndpointMetric().getCurrentConnectionCount());
}
{
- Assert.assertSame(endpointMetric_b_2, socketMetric_b_2.getEndpointMetric());
- Assert.assertTrue(socketMetric_b_2.isConnected());
- Assert.assertEquals(1, socketMetric_b_2.getConnectedTime());
- Assert.assertEquals(2, socketMetric_b_2.getEndpointMetric().getConnectCount());
- Assert.assertEquals(1, socketMetric_b_2.getEndpointMetric().getDisconnectCount());
- Assert.assertEquals(1, socketMetric_b_2.getEndpointMetric().getCurrentConnectionCount());
+ Assertions.assertSame(endpointMetric_b_2, socketMetric_b_2.getEndpointMetric());
+ Assertions.assertTrue(socketMetric_b_2.isConnected());
+ Assertions.assertEquals(1, socketMetric_b_2.getConnectedTime());
+ Assertions.assertEquals(2, socketMetric_b_2.getEndpointMetric().getConnectCount());
+ Assertions.assertEquals(1, socketMetric_b_2.getEndpointMetric().getDisconnectCount());
+ Assertions.assertEquals(1, socketMetric_b_2.getEndpointMetric().getCurrentConnectionCount());
nanoTime = 7;
clientMetrics_b.disconnected(socketMetric_b_2, null);
- Assert.assertEquals(7, ((DefaultClientEndpointMetric) endpointMetric_b_2).getLastNanoTime());
- Assert.assertFalse(socketMetric_b_2.isConnected());
- Assert.assertEquals(1, socketMetric_b_2.getConnectedTime());
- Assert.assertEquals(2, socketMetric_b_2.getEndpointMetric().getConnectCount());
- Assert.assertEquals(2, socketMetric_b_2.getEndpointMetric().getDisconnectCount());
- Assert.assertEquals(0, socketMetric_b_2.getEndpointMetric().getCurrentConnectionCount());
+ Assertions.assertEquals(7, ((DefaultClientEndpointMetric) endpointMetric_b_2).getLastNanoTime());
+ Assertions.assertFalse(socketMetric_b_2.isConnected());
+ Assertions.assertEquals(1, socketMetric_b_2.getConnectedTime());
+ Assertions.assertEquals(2, socketMetric_b_2.getEndpointMetric().getConnectCount());
+ Assertions.assertEquals(2, socketMetric_b_2.getEndpointMetric().getDisconnectCount());
+ Assertions.assertEquals(0, socketMetric_b_2.getEndpointMetric().getCurrentConnectionCount());
}
}
@@ -256,9 +256,9 @@ public class TestDefaultTcpClientMetrics {
clientMetrics_b.bytesRead(socketMetric_b_2, address2, 1);
clientMetrics_b.bytesWritten(socketMetric_b_2, address2, 1);
- Assert.assertEquals(2, endpointMetric_a_1.getBytesRead());
- Assert.assertEquals(2, endpointMetric_a_2.getBytesRead());
- Assert.assertEquals(2, endpointMetric_a_1.getBytesWritten());
- Assert.assertEquals(2, endpointMetric_a_2.getBytesWritten());
+ Assertions.assertEquals(2, endpointMetric_a_1.getBytesRead());
+ Assertions.assertEquals(2, endpointMetric_a_2.getBytesRead());
+ Assertions.assertEquals(2, endpointMetric_a_1.getBytesWritten());
+ Assertions.assertEquals(2, endpointMetric_a_2.getBytesWritten());
}
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/metrics/TestDefaultTcpServerMetrics.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/metrics/TestDefaultTcpServerMetrics.java
index 8eda63317..12f3a1663 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/metrics/TestDefaultTcpServerMetrics.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/metrics/TestDefaultTcpServerMetrics.java
@@ -21,7 +21,6 @@ import java.util.Map;
import org.apache.servicecomb.foundation.vertx.metrics.metric.DefaultEndpointMetric;
import org.apache.servicecomb.foundation.vertx.metrics.metric.DefaultTcpSocketMetric;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -30,6 +29,7 @@ import io.vertx.core.VertxOptions;
import io.vertx.core.net.NetServerOptions;
import io.vertx.core.net.SocketAddress;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestDefaultTcpServerMetrics {
@Mocked
@@ -108,11 +108,11 @@ public class TestDefaultTcpServerMetrics {
instances.put(metrics_listen1_server2, null);
instances.put(metrics_listen2_server1, null);
instances.put(metrics_listen2_server2, null);
- Assert.assertEquals(4, instances.size());
+ Assertions.assertEquals(4, instances.size());
- Assert.assertSame(metrics_listen1_server1.getEndpointMetric(), metrics_listen1_server2.getEndpointMetric());
- Assert.assertNotSame(metrics_listen1_server1.getEndpointMetric(), metrics_listen2_server1.getEndpointMetric());
- Assert.assertSame(metrics_listen2_server1.getEndpointMetric(), metrics_listen2_server2.getEndpointMetric());
+ Assertions.assertSame(metrics_listen1_server1.getEndpointMetric(), metrics_listen1_server2.getEndpointMetric());
+ Assertions.assertNotSame(metrics_listen1_server1.getEndpointMetric(), metrics_listen2_server1.getEndpointMetric());
+ Assertions.assertSame(metrics_listen2_server1.getEndpointMetric(), metrics_listen2_server2.getEndpointMetric());
}
@Test
@@ -123,16 +123,16 @@ public class TestDefaultTcpServerMetrics {
instances.put(socketMetric_listen2_1, null);
instances.put(socketMetric_listen2_2, null);
instances.put(socketMetric_listen2_3, null);
- Assert.assertEquals(5, instances.size());
+ Assertions.assertEquals(5, instances.size());
- Assert.assertTrue(socketMetric_listen1_1.isConnected());
- Assert.assertTrue(socketMetric_listen1_2.isConnected());
- Assert.assertTrue(socketMetric_listen2_1.isConnected());
- Assert.assertTrue(socketMetric_listen2_2.isConnected());
- Assert.assertTrue(socketMetric_listen2_3.isConnected());
+ Assertions.assertTrue(socketMetric_listen1_1.isConnected());
+ Assertions.assertTrue(socketMetric_listen1_2.isConnected());
+ Assertions.assertTrue(socketMetric_listen2_1.isConnected());
+ Assertions.assertTrue(socketMetric_listen2_2.isConnected());
+ Assertions.assertTrue(socketMetric_listen2_3.isConnected());
- Assert.assertEquals(2, endpointMetric1.getCurrentConnectionCount());
- Assert.assertEquals(3, endpointMetric2.getCurrentConnectionCount());
+ Assertions.assertEquals(2, endpointMetric1.getCurrentConnectionCount());
+ Assertions.assertEquals(3, endpointMetric2.getCurrentConnectionCount());
// disconnect
metrics_listen1_server1.disconnected(socketMetric_listen1_1, anyRemoteAddr);
@@ -141,14 +141,14 @@ public class TestDefaultTcpServerMetrics {
metrics_listen2_server2.disconnected(socketMetric_listen2_2, anyRemoteAddr);
metrics_listen2_server2.disconnected(socketMetric_listen2_3, anyRemoteAddr);
- Assert.assertFalse(socketMetric_listen1_1.isConnected());
- Assert.assertFalse(socketMetric_listen1_2.isConnected());
- Assert.assertFalse(socketMetric_listen2_1.isConnected());
- Assert.assertFalse(socketMetric_listen2_2.isConnected());
- Assert.assertFalse(socketMetric_listen2_3.isConnected());
+ Assertions.assertFalse(socketMetric_listen1_1.isConnected());
+ Assertions.assertFalse(socketMetric_listen1_2.isConnected());
+ Assertions.assertFalse(socketMetric_listen2_1.isConnected());
+ Assertions.assertFalse(socketMetric_listen2_2.isConnected());
+ Assertions.assertFalse(socketMetric_listen2_3.isConnected());
- Assert.assertEquals(0, endpointMetric1.getCurrentConnectionCount());
- Assert.assertEquals(0, endpointMetric2.getCurrentConnectionCount());
+ Assertions.assertEquals(0, endpointMetric1.getCurrentConnectionCount());
+ Assertions.assertEquals(0, endpointMetric2.getCurrentConnectionCount());
}
@Test
@@ -159,8 +159,8 @@ public class TestDefaultTcpServerMetrics {
metrics_listen2_server2.bytesRead(socketMetric_listen2_2, anyRemoteAddr, 4);
metrics_listen2_server2.bytesRead(socketMetric_listen2_3, anyRemoteAddr, 5);
- Assert.assertEquals(3, endpointMetric1.getBytesRead());
- Assert.assertEquals(12, endpointMetric2.getBytesRead());
+ Assertions.assertEquals(3, endpointMetric1.getBytesRead());
+ Assertions.assertEquals(12, endpointMetric2.getBytesRead());
}
@Test
@@ -171,7 +171,7 @@ public class TestDefaultTcpServerMetrics {
metrics_listen2_server2.bytesWritten(socketMetric_listen2_2, anyRemoteAddr, 4);
metrics_listen2_server2.bytesWritten(socketMetric_listen2_3, anyRemoteAddr, 5);
- Assert.assertEquals(3, endpointMetric1.getBytesWritten());
- Assert.assertEquals(12, endpointMetric2.getBytesWritten());
+ Assertions.assertEquals(3, endpointMetric1.getBytesWritten());
+ Assertions.assertEquals(12, endpointMetric2.getBytesWritten());
}
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/metrics/TestDefaultVertxMetricsFactory.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/metrics/TestDefaultVertxMetricsFactory.java
index a08a64532..9db33b09f 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/metrics/TestDefaultVertxMetricsFactory.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/metrics/TestDefaultVertxMetricsFactory.java
@@ -16,7 +16,6 @@
*/
package org.apache.servicecomb.foundation.vertx.metrics;
-import org.junit.Assert;
import org.junit.Test;
import io.vertx.core.Vertx;
@@ -24,6 +23,7 @@ import io.vertx.core.VertxOptions;
import io.vertx.core.metrics.MetricsOptions;
import io.vertx.core.spi.metrics.VertxMetrics;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestDefaultVertxMetricsFactory {
@Mocked
@@ -40,10 +40,10 @@ public class TestDefaultVertxMetricsFactory {
options.setMetricsOptions(metricsOptions);
VertxMetrics vertxMetrics = factory.metrics(options);
- Assert.assertSame(factory, metricsOptions.getFactory());
- Assert.assertTrue(metricsOptions.isEnabled());
+ Assertions.assertSame(factory, metricsOptions.getFactory());
+ Assertions.assertTrue(metricsOptions.isEnabled());
- Assert.assertSame(factory.getVertxMetrics(), vertxMetrics);
- Assert.assertTrue(vertxMetrics.isMetricsEnabled());
+ Assertions.assertSame(factory.getVertxMetrics(), vertxMetrics);
+ Assertions.assertTrue(vertxMetrics.isMetricsEnabled());
}
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/metrics/TestMetricsOptionsEx.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/metrics/TestMetricsOptionsEx.java
index 19f3241ac..ced6ecb29 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/metrics/TestMetricsOptionsEx.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/metrics/TestMetricsOptionsEx.java
@@ -18,30 +18,30 @@ package org.apache.servicecomb.foundation.vertx.metrics;
import java.util.concurrent.TimeUnit;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestMetricsOptionsEx {
MetricsOptionsEx metricsOptionsEx = new MetricsOptionsEx();
@Test
public void interval() {
- Assert.assertEquals(TimeUnit.MINUTES.toMillis(1),
+ Assertions.assertEquals(TimeUnit.MINUTES.toMillis(1),
metricsOptionsEx.getCheckClientEndpointMetricIntervalInMilliseconds());
metricsOptionsEx.setCheckClientEndpointMetricIntervalInMinute(2);
- Assert.assertEquals(TimeUnit.MINUTES.toMillis(2),
+ Assertions.assertEquals(TimeUnit.MINUTES.toMillis(2),
metricsOptionsEx.getCheckClientEndpointMetricIntervalInMilliseconds());
}
@Test
public void expired() {
- Assert.assertEquals(TimeUnit.MINUTES.toNanos(15), metricsOptionsEx.getCheckClientEndpointMetricExpiredInNano());
+ Assertions.assertEquals(TimeUnit.MINUTES.toNanos(15), metricsOptionsEx.getCheckClientEndpointMetricExpiredInNano());
metricsOptionsEx.setCheckClientEndpointMetricExpiredInNano(10);
- Assert.assertEquals(10, metricsOptionsEx.getCheckClientEndpointMetricExpiredInNano());
+ Assertions.assertEquals(10, metricsOptionsEx.getCheckClientEndpointMetricExpiredInNano());
metricsOptionsEx.setCheckClientEndpointMetricExpiredInMinute(60);
- Assert.assertEquals(TimeUnit.MINUTES.toNanos(60), metricsOptionsEx.getCheckClientEndpointMetricExpiredInNano());
+ Assertions.assertEquals(TimeUnit.MINUTES.toNanos(60), metricsOptionsEx.getCheckClientEndpointMetricExpiredInNano());
}
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/server/TestTcpParser.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/server/TestTcpParser.java
index 167ff0406..244d67af7 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/server/TestTcpParser.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/server/TestTcpParser.java
@@ -19,10 +19,10 @@ package org.apache.servicecomb.foundation.vertx.server;
import java.io.UnsupportedEncodingException;
import org.apache.servicecomb.foundation.vertx.tcp.TcpOutputStream;
-import org.junit.Assert;
-import org.junit.Test;
import io.vertx.core.buffer.Buffer;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestTcpParser {
long msgId;
@@ -54,8 +54,8 @@ public class TestTcpParser {
parser.handle(os.getBuffer());
os.close();
- Assert.assertEquals(1, msgId);
- Assert.assertArrayEquals(header, headerBuffer.getBytes());
- Assert.assertArrayEquals(body, bodyBuffer.getBytes());
+ Assertions.assertEquals(1, msgId);
+ Assertions.assertArrayEquals(header, headerBuffer.getBytes());
+ Assertions.assertArrayEquals(body, bodyBuffer.getBytes());
}
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/server/TestTcpServer.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/server/TestTcpServer.java
index b95bfc30a..2e1446c9e 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/server/TestTcpServer.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/server/TestTcpServer.java
@@ -23,7 +23,6 @@ import org.apache.servicecomb.foundation.common.net.URIEndpointObject;
import org.apache.servicecomb.foundation.vertx.AsyncResultCallback;
import org.apache.servicecomb.foundation.vertx.metrics.DefaultTcpServerMetrics;
import org.apache.servicecomb.foundation.vertx.metrics.metric.DefaultServerEndpointMetric;
-import org.junit.Assert;
import org.junit.Test;
import io.vertx.core.Handler;
@@ -36,6 +35,7 @@ import mockit.Expectations;
import mockit.Mock;
import mockit.MockUp;
import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
public class TestTcpServer {
static class TcpServerForTest extends TcpServer {
@@ -141,7 +141,7 @@ public class TestTcpServer {
// reject
endpointMetric.onConnect();
connectHandler.handle(netSocket);
- Assert.assertTrue(netSocketClosed);
- Assert.assertEquals(1, endpointMetric.getRejectByConnectionLimitCount());
+ Assertions.assertTrue(netSocketClosed);
+ Assertions.assertEquals(1, endpointMetric.getRejectByConnectionLimitCount());
}
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/server/TestTcpServerConnection.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/server/TestTcpServerConnection.java
index 3047042f2..ac15a8e6b 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/server/TestTcpServerConnection.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/server/TestTcpServerConnection.java
@@ -16,21 +16,24 @@
*/
package org.apache.servicecomb.foundation.vertx.server;
-import org.junit.Assert;
-import org.junit.Test;
-
+import io.vertx.core.net.SocketAddress;
import io.vertx.core.net.impl.NetSocketImpl;
-import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
public class TestTcpServerConnection {
@Test
- public void test(@Mocked NetSocketImpl netSocket) {
+ public void test() {
+ SocketAddress socketAddress = Mockito.mock(SocketAddress.class);
+ NetSocketImpl netSocket = Mockito.mock(NetSocketImpl.class);
+ Mockito.when(netSocket.remoteAddress()).thenReturn(socketAddress);
TcpServerConnection connection = new TcpServerConnection();
connection.setProtocol("p");
connection.setZipName("z");
connection.init(netSocket);
- Assert.assertEquals(netSocket, connection.getNetSocket());
+ Assertions.assertEquals(netSocket, connection.getNetSocket());
}
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/stream/TestBufferInputStream.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/stream/TestBufferInputStream.java
index 0614c9412..fe7d10c82 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/stream/TestBufferInputStream.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/stream/TestBufferInputStream.java
@@ -24,9 +24,9 @@ import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
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;
import io.netty.buffer.ByteBuf;
@@ -49,7 +49,7 @@ public class TestBufferInputStream {
@Test
public void testRead() {
- Assert.assertEquals(0, instance.read());
+ Assertions.assertEquals(0, instance.read());
}
@Test
@@ -73,29 +73,29 @@ public class TestBufferInputStream {
}
gzipInputStream.close();
- Assert.assertEquals(text, sb.toString());
+ Assertions.assertEquals(text, sb.toString());
}
@Test
public void testReadByteArray() {
byte[] b = "csr".getBytes(StandardCharsets.UTF_8);
- Assert.assertEquals(-1, instance.read(b));
+ Assertions.assertEquals(-1, instance.read(b));
}
@Test
public void testReadByteArrayIntInt() {
byte[] b = "csr".getBytes(StandardCharsets.UTF_8);
- Assert.assertEquals(-1, instance.read(b, 1, 0));
+ Assertions.assertEquals(-1, instance.read(b, 1, 0));
}
@Test
public void testSkip() {
- Assert.assertEquals(0, instance.skip(1));
+ Assertions.assertEquals(0, instance.skip(1));
}
@Test
public void testAvailable() {
- Assert.assertEquals(0, instance.available());
+ Assertions.assertEquals(0, instance.available());
}
@Test
@@ -103,42 +103,42 @@ public class TestBufferInputStream {
try {
instance.close();
} catch (Exception e) {
- Assert.assertTrue(false); // This assertion is made to fail the test case in case the close() throws exception
+ Assertions.assertTrue(false); // This assertion is made to fail the test case in case the close() throws exception
}
}
@Test
public void testBufferInputStream() {
- Assert.assertNotNull(instance);
+ Assertions.assertNotNull(instance);
}
@Test
public void testReadBoolean() {
- Assert.assertEquals(false, instance.readBoolean());
+ Assertions.assertEquals(false, instance.readBoolean());
}
@Test
public void testReadShort() {
- Assert.assertEquals(0, instance.readShort());
+ Assertions.assertEquals(0, instance.readShort());
}
@Test
public void testReadInt() {
- Assert.assertEquals(0, instance.readInt());
+ Assertions.assertEquals(0, instance.readInt());
}
@Test
public void testReadLong() {
- Assert.assertEquals(0, instance.readLong());
+ Assertions.assertEquals(0, instance.readLong());
}
@Test
public void testGetIndex() {
- Assert.assertEquals(0, instance.getIndex());
+ Assertions.assertEquals(0, instance.getIndex());
}
@Test
public void testReadString() {
- Assert.assertNotNull(instance.readString());
+ Assertions.assertNotNull(instance.readString());
}
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/stream/TestPumpFromPart.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/stream/TestPumpFromPart.java
index 49bbcae6d..dd391c4f9 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/stream/TestPumpFromPart.java
+++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/stream/TestPumpFromPart.java
@@ -30,7 +30,6 @@ import org.apache.servicecomb.foundation.common.part.InputStreamPart;
import org.apache.servicecomb.foundation.vertx.stream.InputStreamToReadStream.ReadResult;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
-import org.junit.Assert;
import org.junit.Test;
import io.vertx.core.Context;
@@ -39,6 +38,7 @@ import io.vertx.core.impl.SyncContext;
import mockit.Expectations;
import mockit.Mock;
import mockit.MockUp;
+import org.junit.jupiter.api.Assertions;
public class TestPumpFromPart {
String src = RandomStringUtils.random(100);
@@ -81,9 +81,9 @@ public class TestPumpFromPart {
public void do_pump_succ(Context context) throws Throwable {
run(context, true);
- Assert.assertEquals(src, outputStream.getBuffer().toString());
- Assert.assertTrue(inputStreamClosed);
- Assert.assertTrue(outputStreamClosed);
+ Assertions.assertEquals(src, outputStream.getBuffer().toString());
+ Assertions.assertTrue(inputStreamClosed);
+ Assertions.assertTrue(outputStreamClosed);
}
@Test
@@ -95,8 +95,8 @@ public class TestPumpFromPart {
public void do_pump_outputNotClose(Context context) throws Throwable {
run(context, false);
- Assert.assertEquals(src, outputStream.getBuffer().toString());
- Assert.assertFalse(outputStreamClosed);
+ Assertions.assertEquals(src, outputStream.getBuffer().toString());
+ Assertions.assertFalse(outputStreamClosed);
}
@Test
@@ -108,14 +108,14 @@ public class TestPumpFromPart {
public void pump_error(Context context) {
try {
run(context, true);
- Assert.fail("must throw exception");
+ Assertions.fail("must throw exception");
} catch (Throwable e) {
MatcherAssert.assertThat(e, Matchers.instanceOf(ExecutionException.class));
MatcherAssert.assertThat(e.getCause(), Matchers.sameInstance(error));
}
- Assert.assertTrue(inputStreamClosed);
- Assert.assertTrue(outputStreamClosed);
+ Assertions.assertTrue(inputStreamClosed);
+ Assertions.assertTrue(outputStreamClosed);
}
@Test
@@ -134,14 +134,14 @@ public class TestPumpFromPart {
};
pump_error(null);
- Assert.assertTrue(inputStreamClosed);
- Assert.assertTrue(outputStreamClosed);
+ Assertions.assertTrue(inputStreamClosed);
+ Assertions.assertTrue(outputStreamClosed);
inputStreamClosed = false;
outputStreamClosed = false;
pump_error(context);
- Assert.assertTrue(inputStreamClosed);
- Assert.assertTrue(outputStreamClosed);
+ Assertions.assertTrue(inputStreamClosed);
+ Assertions.assertTrue(outputStreamClosed);
}
@Test
@@ -160,13 +160,13 @@ public class TestPumpFromPart {
};
pump_error(null);
- Assert.assertTrue(inputStreamClosed);
- Assert.assertTrue(outputStreamClosed);
+ Assertions.assertTrue(inputStreamClosed);
+ Assertions.assertTrue(outputStreamClosed);
inputStreamClosed = false;
outputStreamClosed = false;
pump_error(context);
- Assert.assertTrue(inputStreamClosed);
- Assert.assertTrue(outputStreamClosed);
+ Assertions.assertTrue(inputStreamClosed);
+ Assertions.assertTrue(outputStreamClosed);
}
}
diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestSharedVertxFactory.java b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/AssertUtil.java
similarity index 66%
copy from foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestSharedVertxFactory.java
copy to metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/AssertUtil.java
index a27c47f15..f89216299 100644
--- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestSharedVertxFactory.java
+++ b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/AssertUtil.java
@@ -14,17 +14,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.servicecomb.foundation.vertx;
+package org.apache.servicecomb.metrics.core;
-import org.junit.Assert;
-import org.junit.Test;
+import com.netflix.spectator.api.Measurement;
+import org.junit.jupiter.api.Assertions;
-public class TestSharedVertxFactory {
- @Test
- public void getTransportVertx() {
- Assert.assertNotNull(SharedVertxFactory.getSharedVertx());
- Assert.assertSame(SharedVertxFactory.getSharedVertx(), SharedVertxFactory.getSharedVertx());
+import java.util.List;
+
+public class AssertUtil {
+
+ public static void assertMeasure(List<Measurement> measurements, int index, String expected) {
+ Assertions.assertEquals(String.format("Measurement(%s)", expected), measurements.get(index).toString());
+ }
- SharedVertxFactory.getSharedVertx().close();
- }
}
diff --git a/metrics/metrics-core/src/test/resources/log4j2.xml b/metrics/metrics-core/src/test/resources/log4j2.xml
new file mode 100644
index 000000000..8cee07220
--- /dev/null
+++ b/metrics/metrics-core/src/test/resources/log4j2.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<Configuration status="INFO">
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n" />
+ </Console>
+ </Appenders>
+ <Loggers>
+ <Root level="INFO">
+ <AppenderRef ref="Console" />
+ </Root>
+ </Loggers>
+</Configuration>