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 2018/08/14 12:52:10 UTC
[incubator-servicecomb-java-chassis] 03/03: remove
CrossappBootListener.java and check test case
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/incubator-servicecomb-java-chassis.git
commit 25d5c4503ac5c94ae5ffde85454e88cd93ad1d69
Author: heyile <he...@huawei.com>
AuthorDate: Tue Aug 14 16:07:03 2018 +0800
remove CrossappBootListener.java and check test case
---
.../demo/crossapp/CrossappBootListener.java | 37 ----------------------
.../metrics/core/TestMetricsBootListener.java | 28 ++++++----------
.../highway/TestHighwayServerConnection.java | 12 +++----
3 files changed, 16 insertions(+), 61 deletions(-)
diff --git a/demo/demo-crossapp/crossapp-client/src/main/java/org/apache/servicecomb/demo/crossapp/CrossappBootListener.java b/demo/demo-crossapp/crossapp-client/src/main/java/org/apache/servicecomb/demo/crossapp/CrossappBootListener.java
deleted file mode 100644
index 5c97bc6..0000000
--- a/demo/demo-crossapp/crossapp-client/src/main/java/org/apache/servicecomb/demo/crossapp/CrossappBootListener.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.demo.crossapp;
-
-import org.apache.servicecomb.core.BootListener;
-import org.apache.servicecomb.serviceregistry.RegistryUtils;
-import org.springframework.stereotype.Component;
-
-@Component
-public class CrossappBootListener implements BootListener {
- @SuppressWarnings("deprecation")
- @Override
- public void onBootEvent(BootEvent event) {
- if (EventType.BEFORE_CONSUMER_PROVIDER.equals(event.getEventType())) {
- // 动态注册schemas目录下面的契约到当前服务
- org.apache.servicecomb.core.definition.loader.DynamicSchemaLoader.INSTANCE
- .registerSchemas(RegistryUtils.getMicroservice().getServiceName(),
- "classpath*:schemas/*.yaml");
- }
- }
-
-}
diff --git a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestMetricsBootListener.java b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestMetricsBootListener.java
index ce2d462..75eabe8 100644
--- a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestMetricsBootListener.java
+++ b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestMetricsBootListener.java
@@ -27,13 +27,11 @@ import org.apache.servicecomb.foundation.common.utils.SPIServiceUtils;
import org.apache.servicecomb.foundation.metrics.MetricsInitializer;
import org.apache.servicecomb.metrics.core.publish.HealthCheckerRestPublisher;
import org.apache.servicecomb.metrics.core.publish.MetricsRestPublisher;
-import org.apache.servicecomb.serviceregistry.RegistryUtils;
import org.apache.servicecomb.serviceregistry.api.registry.Microservice;
import org.junit.Assert;
import org.junit.Test;
import mockit.Deencapsulation;
-import mockit.Expectations;
import mockit.Mock;
import mockit.MockUp;
@@ -46,10 +44,10 @@ public class TestMetricsBootListener {
ProducerSchemaFactory producerSchemaFactory = new MockUp<ProducerSchemaFactory>() {
@Mock
- SchemaMeta getOrCreateProducerSchema(String microserviceName, String schemaId,
+ SchemaMeta getOrCreateProducerSchema(String schemaId,
Class<?> producerClass,
Object producerInstance) {
- argsList.add(new Object[] {microserviceName, schemaId, producerClass, producerInstance});
+ argsList.add(new Object[] {schemaId, producerClass, producerInstance});
return null;
}
}.getMockInstance();
@@ -57,29 +55,23 @@ public class TestMetricsBootListener {
Microservice microservice = new Microservice();
microservice.setServiceName("name");
- new Expectations(RegistryUtils.class) {
- {
- RegistryUtils.getMicroservice();
- result = microservice;
- }
- };
BootEvent event = new BootEvent();
event.setEventType(EventType.BEFORE_PRODUCER_PROVIDER);
listener.onBootEvent(event);
Object[] args = argsList.get(0);
- Assert.assertEquals("name", args[0]);
- Assert.assertEquals("healthEndpoint", args[1]);
- Assert.assertEquals(HealthCheckerRestPublisher.class, args[2]);
- Assert.assertEquals(HealthCheckerRestPublisher.class, args[3].getClass());
+ //we have remove parameter microserviceName
+ Assert.assertEquals("healthEndpoint", args[0]);
+ Assert.assertEquals(HealthCheckerRestPublisher.class, args[1]);
+ Assert.assertEquals(HealthCheckerRestPublisher.class, args[2].getClass());
MetricsRestPublisher metricsRestPublisher =
SPIServiceUtils.getTargetService(MetricsInitializer.class, MetricsRestPublisher.class);
args = argsList.get(1);
- Assert.assertEquals("name", args[0]);
- Assert.assertEquals("metricsEndpoint", args[1]);
- Assert.assertEquals(MetricsRestPublisher.class, args[2]);
- Assert.assertSame(metricsRestPublisher, args[3]);
+ //we have remove parameter microserviceName
+ Assert.assertEquals("metricsEndpoint", args[0]);
+ Assert.assertEquals(MetricsRestPublisher.class, args[1]);
+ Assert.assertSame(metricsRestPublisher, args[2]);
}
}
diff --git a/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayServerConnection.java b/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayServerConnection.java
index d555605..9a18f9a 100644
--- a/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayServerConnection.java
+++ b/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayServerConnection.java
@@ -16,10 +16,11 @@
*/
package org.apache.servicecomb.transport.highway;
-import javax.xml.ws.Holder;
import java.net.InetSocketAddress;
import java.util.concurrent.atomic.AtomicInteger;
+import javax.xml.ws.Holder;
+
import org.apache.servicecomb.codec.protobuf.definition.ProtobufManager;
import org.apache.servicecomb.codec.protobuf.utils.WrapSchema;
import org.apache.servicecomb.core.CseContext;
@@ -35,17 +36,16 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-import mockit.Expectations;
-import mockit.Mock;
-import mockit.MockUp;
-import mockit.Mocked;
-
import io.protostuff.LinkedBuffer;
import io.protostuff.ProtobufOutput;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.net.NetSocket;
import io.vertx.core.net.impl.NetSocketImpl;
import io.vertx.core.net.impl.SocketAddressImpl;
+import mockit.Expectations;
+import mockit.Mock;
+import mockit.MockUp;
+import mockit.Mocked;
public class TestHighwayServerConnection {
private static WrapSchema requestHeaderSchema =