You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/10/13 07:40:10 UTC
[dubbo] branch 3.0 updated: Fix AbstractMetadataReportTest and
AbstractMetadataReportFactoryTest (#8807)
This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.0 by this push:
new f784131 Fix AbstractMetadataReportTest and AbstractMetadataReportFactoryTest (#8807)
f784131 is described below
commit f784131cc2dbc97fb63013019092c9dbda112fb3
Author: 灼华 <43...@users.noreply.github.com>
AuthorDate: Wed Oct 13 15:39:52 2021 +0800
Fix AbstractMetadataReportTest and AbstractMetadataReportFactoryTest (#8807)
* Fix AbstractMetadataReportTest and AbstractMetadataReportFactoryTest
* To trigger workflow
* Fix test
---
.../definition/builder/MapTypeBuilder.java | 3 +-
.../dubbo/metadata/definition/util/ClassUtils.java | 2 +-
.../report/support/AbstractMetadataReport.java | 2 +-
.../definition/TypeDefinitionBuilderTest.java | 4 +-
.../support/AbstractMetadataReportFactoryTest.java | 269 ++++++++++-----------
.../report/support/AbstractMetadataReportTest.java | 138 ++---------
.../metadata/store/InterfaceNameTestService.java | 2 +-
.../protobuf/ProtobufTypeBuilderTest.java | 2 +-
8 files changed, 166 insertions(+), 256 deletions(-)
diff --git a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/definition/builder/MapTypeBuilder.java b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/definition/builder/MapTypeBuilder.java
index fc13ff2..121198c 100755
--- a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/definition/builder/MapTypeBuilder.java
+++ b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/definition/builder/MapTypeBuilder.java
@@ -18,6 +18,7 @@ package org.apache.dubbo.metadata.definition.builder;
import org.apache.dubbo.metadata.definition.TypeDefinitionBuilder;
import org.apache.dubbo.metadata.definition.model.TypeDefinition;
+import org.apache.dubbo.metadata.definition.util.ClassUtils;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
@@ -58,7 +59,7 @@ public class MapTypeBuilder implements TypeBuilder {
+ Arrays.toString(actualTypeArgs), type, actualTypeArgs));
}
- String mapType = type.toString();
+ String mapType = ClassUtils.getCanonicalNameForParameterizedType(parameterizedType);
TypeDefinition td = typeCache.get(mapType);
if (td != null) {
diff --git a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/definition/util/ClassUtils.java b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/definition/util/ClassUtils.java
index f09deab..c6f13d5 100755
--- a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/definition/util/ClassUtils.java
+++ b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/definition/util/ClassUtils.java
@@ -118,7 +118,7 @@ public final class ClassUtils {
if (ownerType instanceof Class) {
sb.append(((Class) ownerType).getName());
} else {
- sb.append(ownerType.toString());
+ sb.append(ownerType);
}
sb.append('.');
diff --git a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/support/AbstractMetadataReport.java b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/support/AbstractMetadataReport.java
index f23fc04..986b8a6 100644
--- a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/support/AbstractMetadataReport.java
+++ b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/support/AbstractMetadataReport.java
@@ -159,7 +159,7 @@ public abstract class AbstractMetadataReport implements MetadataReport {
lockfile.createNewFile();
}
try (RandomAccessFile raf = new RandomAccessFile(lockfile, "rw");
- FileChannel channel = raf.getChannel()) {
+ FileChannel channel = raf.getChannel()) {
FileLock lock = channel.tryLock();
if (lock == null) {
throw new IOException("Can not lock the metadataReport cache file " + file.getAbsolutePath() + ", ignore and retry later, maybe multi java process use the file, please config: dubbo.metadata.file=xxx.properties");
diff --git a/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/definition/TypeDefinitionBuilderTest.java b/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/definition/TypeDefinitionBuilderTest.java
index 11d03a1..12b3967 100644
--- a/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/definition/TypeDefinitionBuilderTest.java
+++ b/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/definition/TypeDefinitionBuilderTest.java
@@ -24,11 +24,11 @@ import org.junit.jupiter.api.Test;
public class TypeDefinitionBuilderTest {
@Test
- public void testSortTypeBuilder(){
+ public void testSortTypeBuilder() {
TypeBuilder tb = TypeDefinitionBuilder.BUILDERS.get(0);
Assertions.assertTrue(tb instanceof TestTypeBuilder);
- tb = TypeDefinitionBuilder.BUILDERS.get(TypeDefinitionBuilder.BUILDERS.size()-1);
+ tb = TypeDefinitionBuilder.BUILDERS.get(TypeDefinitionBuilder.BUILDERS.size() - 1);
Assertions.assertTrue(tb instanceof Test3TypeBuilder);
}
}
diff --git a/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/report/support/AbstractMetadataReportFactoryTest.java b/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/report/support/AbstractMetadataReportFactoryTest.java
index 5b0ffd7..4a9acc9 100644
--- a/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/report/support/AbstractMetadataReportFactoryTest.java
+++ b/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/report/support/AbstractMetadataReportFactoryTest.java
@@ -1,135 +1,134 @@
-///*
-// * Licensed to the Apache Software Foundation (ASF) under one or more
-// * contributor license agreements. See the NOTICE file distributed with
-// * this work for additional information regarding copyright ownership.
-// * The ASF licenses this file to You under the Apache License, Version 2.0
-// * (the "License"); you may not use this file except in compliance with
-// * the License. You may obtain a copy of the License at
-// *
-// * http://www.apache.org/licenses/LICENSE-2.0
-// *
-// * Unless required by applicable law or agreed to in writing, software
-// * distributed under the License is distributed on an "AS IS" BASIS,
-// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// * See the License for the specific language governing permissions and
-// * limitations under the License.
-// */
-//package org.apache.dubbo.metadata.report.support;
-//
-//import org.apache.dubbo.common.URL;
-//import org.apache.dubbo.common.utils.NetUtils;
-//import org.apache.dubbo.metadata.definition.model.ServiceDefinition;
-//import org.apache.dubbo.metadata.report.MetadataReport;
-//import org.apache.dubbo.metadata.report.identifier.MetadataIdentifier;
-//import org.apache.dubbo.metadata.report.identifier.ServiceMetadataIdentifier;
-//import org.apache.dubbo.metadata.report.identifier.SubscriberMetadataIdentifier;
-//
-//import com.alibaba.fastjson.JSON;
-//import org.junit.jupiter.api.Assertions;
-//import org.junit.jupiter.api.Test;
-//
-//import java.util.Collection;
-//import java.util.List;
-//import java.util.Map;
-//import java.util.concurrent.ConcurrentHashMap;
-//
-///**
-// * 2018/9/14
-// */
-//public class AbstractMetadataReportFactoryTest {
-//
-// private AbstractMetadataReportFactory metadataReportFactory = new AbstractMetadataReportFactory() {
-// @Override
-// protected MetadataReport createMetadataReport(URL url) {
-// return new MetadataReport() {
-//
-// @Override
-// public void storeProviderMetadata(MetadataIdentifier providerMetadataIdentifier, ServiceDefinition serviceDefinition) {
-// store.put(providerMetadataIdentifier.getIdentifierKey(), JSON.toJSONString(serviceDefinition));
-// }
-//
-// @Override
-// public void saveServiceMetadata(ServiceMetadataIdentifier metadataIdentifier, URL url) {
-//
-// }
-//
-// @Override
-// public void removeServiceMetadata(ServiceMetadataIdentifier metadataIdentifier) {
-//
-// }
-//
-// @Override
-// public List<String> getExportedURLs(ServiceMetadataIdentifier metadataIdentifier) {
-// return null;
-// }
-//
-// @Override
-// public void saveSubscribedData(SubscriberMetadataIdentifier subscriberMetadataIdentifier,
-// Collection<String> urls) {
-//
-// }
-//
-// @Override
-// public List<String> getSubscribedURLs(SubscriberMetadataIdentifier subscriberMetadataIdentifier) {
-// return null;
-// }
-//
-// @Override
-// public String getServiceDefinition(MetadataIdentifier consumerMetadataIdentifier) {
-// return null;
-// }
-//
-// @Override
-// public void storeConsumerMetadata(MetadataIdentifier consumerMetadataIdentifier, Map serviceParameterMap) {
-// store.put(consumerMetadataIdentifier.getIdentifierKey(), JSON.toJSONString(serviceParameterMap));
-// }
-//
-// @Override
-// public void close() throws Exception {
-//
-// }
-//
-// Map<String, String> store = new ConcurrentHashMap<>();
-//
-//
-// };
-// }
-// };
-//
-// @Test
-// public void testGetOneMetadataReport() {
-// URL url = URL.valueOf("zookeeper://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.TestService?version=1.0.0&application=vic");
-// MetadataReport metadataReport1 = metadataReportFactory.getMetadataReport(url);
-// MetadataReport metadataReport2 = metadataReportFactory.getMetadataReport(url);
-// Assertions.assertEquals(metadataReport1, metadataReport2);
-// }
-//
-// @Test
-// public void testGetOneMetadataReportForIpFormat() {
-// String hostName = NetUtils.getLocalAddress().getHostName();
-// String ip = NetUtils.getIpByHost(hostName);
-// URL url1 = URL.valueOf("zookeeper://" + hostName + ":4444/org.apache.dubbo.TestService?version=1.0.0&application=vic");
-// URL url2 = URL.valueOf("zookeeper://" + ip + ":4444/org.apache.dubbo.TestService?version=1.0.0&application=vic");
-// MetadataReport metadataReport1 = metadataReportFactory.getMetadataReport(url1);
-// MetadataReport metadataReport2 = metadataReportFactory.getMetadataReport(url2);
-// Assertions.assertEquals(metadataReport1, metadataReport2);
-// }
-//
-// @Test
-// public void testGetForDiffService() {
-// URL url1 = URL.valueOf("zookeeper://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.TestService1?version=1.0.0&application=vic");
-// URL url2 = URL.valueOf("zookeeper://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.TestService2?version=1.0.0&application=vic");
-// MetadataReport metadataReport1 = metadataReportFactory.getMetadataReport(url1);
-// MetadataReport metadataReport2 = metadataReportFactory.getMetadataReport(url2);
-// Assertions.assertEquals(metadataReport1, metadataReport2);
-// }
-//
-// @Test
-// public void testGetForDiffGroup() {
-// URL url1 = URL.valueOf("zookeeper://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.TestService?version=1.0.0&application=vic&group=aaa");
-// URL url2 = URL.valueOf("zookeeper://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.TestService?version=1.0.0&application=vic&group=bbb");
-// MetadataReport metadataReport1 = metadataReportFactory.getMetadataReport(url1);
-// MetadataReport metadataReport2 = metadataReportFactory.getMetadataReport(url2);
-// Assertions.assertNotEquals(metadataReport1, metadataReport2);
-// }
-//}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.metadata.report.support;
+
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.utils.NetUtils;
+import org.apache.dubbo.metadata.definition.model.ServiceDefinition;
+import org.apache.dubbo.metadata.report.MetadataReport;
+import org.apache.dubbo.metadata.report.identifier.MetadataIdentifier;
+import org.apache.dubbo.metadata.report.identifier.ServiceMetadataIdentifier;
+import org.apache.dubbo.metadata.report.identifier.SubscriberMetadataIdentifier;
+
+import com.alibaba.fastjson.JSON;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * 2018/9/14
+ */
+public class AbstractMetadataReportFactoryTest {
+
+ private AbstractMetadataReportFactory metadataReportFactory = new AbstractMetadataReportFactory() {
+ @Override
+ protected MetadataReport createMetadataReport(URL url) {
+ return new MetadataReport() {
+
+ @Override
+ public void storeProviderMetadata(MetadataIdentifier providerMetadataIdentifier, ServiceDefinition serviceDefinition) {
+ store.put(providerMetadataIdentifier.getIdentifierKey(), JSON.toJSONString(serviceDefinition));
+ }
+
+ @Override
+ public void saveServiceMetadata(ServiceMetadataIdentifier metadataIdentifier, URL url) {
+
+ }
+
+ @Override
+ public void removeServiceMetadata(ServiceMetadataIdentifier metadataIdentifier) {
+
+ }
+
+ @Override
+ public void saveSubscribedData(SubscriberMetadataIdentifier subscriberMetadataIdentifier, Set<String> urls) {
+
+ }
+
+ @Override
+ public List<String> getExportedURLs(ServiceMetadataIdentifier metadataIdentifier) {
+ return null;
+ }
+
+ @Override
+ public void destroy() {
+
+ }
+
+ @Override
+ public List<String> getSubscribedURLs(SubscriberMetadataIdentifier subscriberMetadataIdentifier) {
+ return null;
+ }
+
+ @Override
+ public String getServiceDefinition(MetadataIdentifier consumerMetadataIdentifier) {
+ return null;
+ }
+
+ @Override
+ public void storeConsumerMetadata(MetadataIdentifier consumerMetadataIdentifier, Map serviceParameterMap) {
+ store.put(consumerMetadataIdentifier.getIdentifierKey(), JSON.toJSONString(serviceParameterMap));
+ }
+
+ Map<String, String> store = new ConcurrentHashMap<>();
+
+
+ };
+ }
+ };
+
+ @Test
+ public void testGetOneMetadataReport() {
+ URL url = URL.valueOf("zookeeper://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.TestService?version=1.0.0&application=vic");
+ MetadataReport metadataReport1 = metadataReportFactory.getMetadataReport(url);
+ MetadataReport metadataReport2 = metadataReportFactory.getMetadataReport(url);
+ Assertions.assertEquals(metadataReport1, metadataReport2);
+ }
+
+ @Test
+ public void testGetOneMetadataReportForIpFormat() {
+ String hostName = NetUtils.getLocalAddress().getHostName();
+ String ip = NetUtils.getIpByHost(hostName);
+ URL url1 = URL.valueOf("zookeeper://" + hostName + ":4444/org.apache.dubbo.TestService?version=1.0.0&application=vic");
+ URL url2 = URL.valueOf("zookeeper://" + ip + ":4444/org.apache.dubbo.TestService?version=1.0.0&application=vic");
+ MetadataReport metadataReport1 = metadataReportFactory.getMetadataReport(url1);
+ MetadataReport metadataReport2 = metadataReportFactory.getMetadataReport(url2);
+ Assertions.assertEquals(metadataReport1, metadataReport2);
+ }
+
+ @Test
+ public void testGetForDiffService() {
+ URL url1 = URL.valueOf("zookeeper://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.TestService1?version=1.0.0&application=vic");
+ URL url2 = URL.valueOf("zookeeper://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.TestService2?version=1.0.0&application=vic");
+ MetadataReport metadataReport1 = metadataReportFactory.getMetadataReport(url1);
+ MetadataReport metadataReport2 = metadataReportFactory.getMetadataReport(url2);
+ Assertions.assertEquals(metadataReport1, metadataReport2);
+ }
+
+ @Test
+ public void testGetForDiffGroup() {
+ URL url1 = URL.valueOf("zookeeper://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.TestService?version=1.0.0&application=vic&group=aaa");
+ URL url2 = URL.valueOf("zookeeper://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.TestService?version=1.0.0&application=vic&group=bbb");
+ MetadataReport metadataReport1 = metadataReportFactory.getMetadataReport(url1);
+ MetadataReport metadataReport2 = metadataReportFactory.getMetadataReport(url2);
+ Assertions.assertNotEquals(metadataReport1, metadataReport2);
+ }
+}
diff --git a/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/report/support/AbstractMetadataReportTest.java b/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/report/support/AbstractMetadataReportTest.java
index 1d7ae6c..9d20e91 100644
--- a/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/report/support/AbstractMetadataReportTest.java
+++ b/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/report/support/AbstractMetadataReportTest.java
@@ -13,61 +13,43 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *//*
+ */
package org.apache.dubbo.metadata.report.support;
+import com.google.gson.Gson;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.metadata.definition.ServiceDefinitionBuilder;
import org.apache.dubbo.metadata.definition.model.FullServiceDefinition;
-import org.apache.dubbo.metadata.report.MetadataReport;
import org.apache.dubbo.metadata.report.identifier.KeyTypeEnum;
import org.apache.dubbo.metadata.report.identifier.MetadataIdentifier;
import org.apache.dubbo.metadata.report.identifier.ServiceMetadataIdentifier;
import org.apache.dubbo.metadata.report.identifier.SubscriberMetadataIdentifier;
import org.apache.dubbo.rpc.model.ApplicationModel;
-
-import com.google.gson.Gson;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.Calendar;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.SortedSet;
import java.util.concurrent.ConcurrentHashMap;
-import static java.util.Collections.emptySet;
import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER_SIDE;
import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER_SIDE;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
-*/
-/**
- * Test {@link MetadataReport#saveExportedURLs(String, String, String)} method
- *
- * @since 2.7.8
- * <p>
- * Test {@link MetadataReport#getExportedURLs(String, String)} method
- * @since 2.7.8
- * <p>
- * Test {@link MetadataReport#getExportedURLsContent(String, String)} method
- * @since 2.7.8
- *//*
-
public class AbstractMetadataReportTest {
private NewMetadataReport abstractMetadataReport;
-
@BeforeEach
public void before() {
URL url = URL.valueOf("zookeeper://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.TestService?version=1.0.0&application=vic");
@@ -99,7 +81,7 @@ public class AbstractMetadataReportTest {
String version = "1.0.0";
String group = null;
String application = "vic";
- MetadataIdentifier providerMetadataIdentifier = storePrivider(abstractMetadataReport, interfaceName, version, group, application);
+ MetadataIdentifier providerMetadataIdentifier = storeProvider(abstractMetadataReport, interfaceName, version, group, application);
Thread.sleep(1500);
Assertions.assertNotNull(abstractMetadataReport.store.get(providerMetadataIdentifier.getUniqueKey(KeyTypeEnum.UNIQUE_KEY)));
}
@@ -111,7 +93,7 @@ public class AbstractMetadataReportTest {
String group = null;
String application = "vic";
abstractMetadataReport.syncReport = true;
- MetadataIdentifier providerMetadataIdentifier = storePrivider(abstractMetadataReport, interfaceName, version, group, application);
+ MetadataIdentifier providerMetadataIdentifier = storeProvider(abstractMetadataReport, interfaceName, version, group, application);
Assertions.assertNotNull(abstractMetadataReport.store.get(providerMetadataIdentifier.getUniqueKey(KeyTypeEnum.UNIQUE_KEY)));
}
@@ -121,16 +103,16 @@ public class AbstractMetadataReportTest {
URL singleUrl = URL.valueOf("redis://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.metadata.store.InterfaceNameTestService?version=1.0.0&application=singleTest");
NewMetadataReport singleMetadataReport = new NewMetadataReport(singleUrl);
- Assertions.assertFalse(singleMetadataReport.localCacheFile.exists());
+ assertFalse(singleMetadataReport.file.exists());
String interfaceName = "org.apache.dubbo.metadata.store.InterfaceNameTestService";
String version = "1.0.0";
String group = null;
String application = "vic";
- MetadataIdentifier providerMetadataIdentifier = storePrivider(singleMetadataReport, interfaceName, version, group, application);
+ MetadataIdentifier providerMetadataIdentifier = storeProvider(singleMetadataReport, interfaceName, version, group, application);
Thread.sleep(2000);
- assertTrue(singleMetadataReport.localCacheFile.exists());
+ assertTrue(singleMetadataReport.file.exists());
assertTrue(singleMetadataReport.properties.containsKey(providerMetadataIdentifier.getUniqueKey(KeyTypeEnum.UNIQUE_KEY)));
}
@@ -150,16 +132,16 @@ public class AbstractMetadataReportTest {
assertTrue(retryReport.failedReports.isEmpty());
- storePrivider(retryReport, interfaceName, version, group, application);
+ storeProvider(retryReport, interfaceName, version, group, application);
Thread.sleep(150);
assertTrue(retryReport.store.isEmpty());
- Assertions.assertFalse(retryReport.failedReports.isEmpty());
- Assertions.assertNotNull(retryReport.metadataReportRetry.retryScheduledFuture);
+ assertFalse(retryReport.failedReports.isEmpty());
+ assertNotNull(retryReport.metadataReportRetry.retryScheduledFuture);
Thread.sleep(2000L);
assertTrue(retryReport.metadataReportRetry.retryCounter.get() != 0);
assertTrue(retryReport.metadataReportRetry.retryCounter.get() >= 3);
- Assertions.assertFalse(retryReport.store.isEmpty());
+ assertFalse(retryReport.store.isEmpty());
assertTrue(retryReport.failedReports.isEmpty());
}
@@ -174,20 +156,22 @@ public class AbstractMetadataReportTest {
retryReport.metadataReportRetry.retryPeriod = 150L;
retryReport.metadataReportRetry.retryTimesIfNonFail = 2;
- storePrivider(retryReport, interfaceName, version, group, application);
- Thread.sleep(80);
+ storeProvider(retryReport, interfaceName, version, group, application);
- Assertions.assertFalse(retryReport.metadataReportRetry.retryScheduledFuture.isCancelled());
- Assertions.assertFalse(retryReport.metadataReportRetry.retryExecutor.isShutdown());
+ // Wait for the assignment of retryScheduledFuture to complete
+ while (retryReport.metadataReportRetry.retryScheduledFuture == null) {
+ }
+ assertFalse(retryReport.metadataReportRetry.retryScheduledFuture.isCancelled());
+ assertFalse(retryReport.metadataReportRetry.retryExecutor.isShutdown());
Thread.sleep(1000L);
assertTrue(retryReport.metadataReportRetry.retryScheduledFuture.isCancelled());
assertTrue(retryReport.metadataReportRetry.retryExecutor.isShutdown());
}
- private MetadataIdentifier storePrivider(AbstractMetadataReport abstractMetadataReport, String interfaceName, String version, String group, String application) throws ClassNotFoundException {
+ private MetadataIdentifier storeProvider(AbstractMetadataReport abstractMetadataReport, String interfaceName, String version, String group, String application) throws ClassNotFoundException {
URL url = URL.valueOf("xxx://" + NetUtils.getLocalAddress().getHostName() + ":4444/" + interfaceName + "?version=" + version + "&application="
- + application + (group == null ? "" : "&group=" + group) + "&testPKey=8989");
+ + application + (group == null ? "" : "&group=" + group) + "&testPKey=8989");
MetadataIdentifier providerMetadataIdentifier = new MetadataIdentifier(interfaceName, version, group, PROVIDER_SIDE, application);
Class interfaceClass = Class.forName(interfaceName);
@@ -200,7 +184,7 @@ public class AbstractMetadataReportTest {
private MetadataIdentifier storeConsumer(AbstractMetadataReport abstractMetadataReport, String interfaceName, String version, String group, String application, Map<String, String> tmp) throws ClassNotFoundException {
URL url = URL.valueOf("xxx://" + NetUtils.getLocalAddress().getHostName() + ":4444/" + interfaceName + "?version=" + version + "&application="
- + application + (group == null ? "" : "&group=" + group) + "&testPKey=9090");
+ + application + (group == null ? "" : "&group=" + group) + "&testPKey=9090");
tmp.putAll(url.getParameters());
MetadataIdentifier consumerMetadataIdentifier = new MetadataIdentifier(interfaceName, version, group, CONSUMER_SIDE, application);
@@ -219,12 +203,12 @@ public class AbstractMetadataReportTest {
String version = "1.0.0";
String group = null;
String application = "vic";
- MetadataIdentifier providerMetadataIdentifier1 = storePrivider(abstractMetadataReport, interfaceName, version, group, application);
+ MetadataIdentifier providerMetadataIdentifier1 = storeProvider(abstractMetadataReport, interfaceName, version, group, application);
Thread.sleep(1000);
assertEquals(abstractMetadataReport.allMetadataReports.size(), 1);
assertTrue(((FullServiceDefinition) abstractMetadataReport.allMetadataReports.get(providerMetadataIdentifier1)).getParameters().containsKey("testPKey"));
- MetadataIdentifier providerMetadataIdentifier2 = storePrivider(abstractMetadataReport, interfaceName, version + "_2", group + "_2", application);
+ MetadataIdentifier providerMetadataIdentifier2 = storeProvider(abstractMetadataReport, interfaceName, version + "_2", group + "_2", application);
Thread.sleep(1000);
assertEquals(abstractMetadataReport.allMetadataReports.size(), 2);
assertTrue(((FullServiceDefinition) abstractMetadataReport.allMetadataReports.get(providerMetadataIdentifier2)).getParameters().containsKey("testPKey"));
@@ -277,85 +261,12 @@ public class AbstractMetadataReportTest {
}
}
- */
-/**
- * Test {@link MetadataReport#saveExportedURLs(String, String, String)} method
- *
- * @since 2.7.8
- * <p>
- * Test {@link MetadataReport#getExportedURLs(String, String)} method
- * @since 2.7.8
- * <p>
- * Test {@link MetadataReport#getExportedURLsContent(String, String)} method
- * @since 2.7.8
- *//*
-
- @Test
- public void testSaveExportedURLs() {
- String serviceName = null;
- String exportedServiceRevision = null;
- String exportedURLsContent = null;
- SortedSet<String> exportedURLs = null;
- // Default methods return true
- assertTrue(abstractMetadataReport.saveExportedURLs(exportedURLs));
- assertTrue(abstractMetadataReport.saveExportedURLs(exportedServiceRevision, exportedURLs));
- assertTrue(abstractMetadataReport.saveExportedURLs(serviceName, exportedServiceRevision, exportedURLs));
- assertTrue(abstractMetadataReport.saveExportedURLs(serviceName, exportedServiceRevision, exportedURLsContent));
- }
-
- */
-/**
- * Test {@link MetadataReport#getExportedURLs(String, String)} method
- *
- * @since 2.7.8
- *//*
-
- @Test
- public void testGetExportedURLs() {
- String serviceName = null;
- String exportedServiceRevision = null;
- assertEquals(emptySet(), abstractMetadataReport.getExportedURLs(serviceName, exportedServiceRevision));
- }
-
- */
-/**
- * Test {@link MetadataReport#getExportedURLsContent(String, String)} method
- *
- * @since 2.7.8
- *//*
-
- @Test
- public void testGetExportedURLsContent() {
- String serviceName = null;
- String exportedServiceRevision = null;
- assertNull(abstractMetadataReport.getExportedURLsContent(serviceName, exportedServiceRevision));
- }
-
- private FullServiceDefinition toServiceDefinition(String v) {
- Gson gson = new Gson();
- FullServiceDefinition data = gson.fromJson(v, FullServiceDefinition.class);
- return data;
- }
private void checkParam(Map<String, String> map, String application, String version) {
assertEquals(map.get("application"), application);
assertEquals(map.get("version"), version);
}
- private Map<String, String> queryUrlToMap(String urlQuery) {
- if (urlQuery == null) {
- return Collections.emptyMap();
- }
- String[] pairs = urlQuery.split("&");
- Map<String, String> map = new HashMap<>();
- for (String pairStr : pairs) {
- String[] pair = pairStr.split("=");
- map.put(pair[0], pair[1]);
- }
- return map;
- }
-
-
private static class NewMetadataReport extends AbstractMetadataReport {
Map<String, String> store = new ConcurrentHashMap<>();
@@ -469,4 +380,3 @@ public class AbstractMetadataReportTest {
}
-*/
diff --git a/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/store/InterfaceNameTestService.java b/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/store/InterfaceNameTestService.java
index e45fc38..7074f79 100644
--- a/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/store/InterfaceNameTestService.java
+++ b/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/store/InterfaceNameTestService.java
@@ -21,5 +21,5 @@ package org.apache.dubbo.metadata.store;
*/
public interface InterfaceNameTestService {
- public void test();
+ void test();
}
diff --git a/dubbo-metadata/dubbo-metadata-definition-protobuf/src/test/java/org/apache/dubbo/metadata/definition/protobuf/ProtobufTypeBuilderTest.java b/dubbo-metadata/dubbo-metadata-definition-protobuf/src/test/java/org/apache/dubbo/metadata/definition/protobuf/ProtobufTypeBuilderTest.java
index e10ffa3..0919410 100644
--- a/dubbo-metadata/dubbo-metadata-definition-protobuf/src/test/java/org/apache/dubbo/metadata/definition/protobuf/ProtobufTypeBuilderTest.java
+++ b/dubbo-metadata/dubbo-metadata-definition-protobuf/src/test/java/org/apache/dubbo/metadata/definition/protobuf/ProtobufTypeBuilderTest.java
@@ -71,7 +71,7 @@ public class ProtobufTypeBuilderTest {
equalTo("java.util.List<org.apache.dubbo.metadata.definition.protobuf.model.GooglePB.PhoneNumber>"));
assertThat(propertiesMap.containsKey("doubleMap"), is(true));
assertThat(getTypeName(propertiesMap.get("doubleMap"), types),
- equalTo("java.util.Map<java.lang.String,org.apache.dubbo.metadata.definition.protobuf.model.GooglePB$PhoneNumber>"));
+ equalTo("java.util.Map<java.lang.String,org.apache.dubbo.metadata.definition.protobuf.model.GooglePB.PhoneNumber>"));
assertThat(getTypeName(propertiesMap.get("bytesList"), types),
equalTo("java.util.List<com.google.protobuf.ByteString>"));
assertThat(getTypeName(propertiesMap.get("bytesMap"), types),