You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ni...@apache.org on 2018/06/14 10:29:36 UTC

[incubator-servicecomb-java-chassis] 02/02: [SCB-667] fix test case and small mistake

This is an automated email from the ASF dual-hosted git repository.

ningjiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git

commit 67c9b7f8929205f10e6fc8d2d78014bb4d2fb868
Author: zhengyangyong <ya...@huawei.com>
AuthorDate: Thu Jun 14 16:28:02 2018 +0800

    [SCB-667] fix test case and small mistake
    
    Signed-off-by: zhengyangyong <ya...@huawei.com>
---
 core/src/main/java/org/apache/servicecomb/core/SCBEngine.java       | 2 +-
 .../java/org/apache/servicecomb/core/TestInvocationFactory.java     | 1 +
 core/src/test/java/org/apache/servicecomb/core/TestSCBEngine.java   | 4 ++--
 .../apache/servicecomb/core/provider/consumer/TestInvokerUtils.java | 4 ++--
 .../apache/servicecomb/transport/highway/HighwayServerInvoke.java   | 6 ++++--
 .../servicecomb/transport/highway/TestHighwayServerInvoke.java      | 4 ++++
 6 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java b/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java
index e274a18..aa42ded 100644
--- a/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java
+++ b/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java
@@ -277,7 +277,7 @@ public class SCBEngine {
     SCBStatus currentStatus = getStatus();
     if (!SCBStatus.UP.equals(currentStatus)) {
       throw new IllegalStateException(
-          "System is starting and not ready for remote calls or shutting down in progress, STATUS = " + currentStatus);
+          "The request is rejected, as the service cannot process the request due to STATUS = " + currentStatus);
     }
   }
 
diff --git a/core/src/test/java/org/apache/servicecomb/core/TestInvocationFactory.java b/core/src/test/java/org/apache/servicecomb/core/TestInvocationFactory.java
index 7767ad1..b91cad1 100644
--- a/core/src/test/java/org/apache/servicecomb/core/TestInvocationFactory.java
+++ b/core/src/test/java/org/apache/servicecomb/core/TestInvocationFactory.java
@@ -36,6 +36,7 @@ public class TestInvocationFactory {
     ServiceRegistry serviceRegistry = ServiceRegistryFactory.createLocal();
     serviceRegistry.init();
     RegistryUtils.setServiceRegistry(serviceRegistry);
+    SCBEngine.getInstance().setStatus(SCBStatus.UP);
   }
 
   @Test
diff --git a/core/src/test/java/org/apache/servicecomb/core/TestSCBEngine.java b/core/src/test/java/org/apache/servicecomb/core/TestSCBEngine.java
index 6b72f56..89ffe80 100644
--- a/core/src/test/java/org/apache/servicecomb/core/TestSCBEngine.java
+++ b/core/src/test/java/org/apache/servicecomb/core/TestSCBEngine.java
@@ -106,7 +106,7 @@ public class TestSCBEngine {
 
     expectedException.expect(IllegalStateException.class);
     expectedException.expectMessage(
-        Matchers.is("System is starting and not ready for remote calls or shutting down in progress, STATUS = DOWN"));
+        Matchers.is("The request is rejected, as the service cannot process the request due to STATUS = DOWN"));
     engine.createReferenceConfigForInvoke(null, null, null);
   }
 
@@ -128,7 +128,7 @@ public class TestSCBEngine {
 
     expectedException.expect(IllegalStateException.class);
     expectedException.expectMessage(
-        Matchers.is("System is starting and not ready for remote calls or shutting down in progress, STATUS = DOWN"));
+        Matchers.is("The request is rejected, as the service cannot process the request due to STATUS = DOWN"));
     engine.getReferenceConfigForInvoke(null);
   }
 }
diff --git a/core/src/test/java/org/apache/servicecomb/core/provider/consumer/TestInvokerUtils.java b/core/src/test/java/org/apache/servicecomb/core/provider/consumer/TestInvokerUtils.java
index 784a8a6..ef0b021 100644
--- a/core/src/test/java/org/apache/servicecomb/core/provider/consumer/TestInvokerUtils.java
+++ b/core/src/test/java/org/apache/servicecomb/core/provider/consumer/TestInvokerUtils.java
@@ -126,7 +126,7 @@ public class TestInvokerUtils {
 
     expectedException.expect(IllegalStateException.class);
     expectedException.expectMessage(
-        Matchers.is("System is starting and not ready for remote calls or shutting down in progress, STATUS = DOWN"));
+        Matchers.is("The request is rejected, as the service cannot process the request due to STATUS = DOWN"));
     InvokerUtils.syncInvoke("ms", "schemaId", "opName", null);
   }
 
@@ -136,7 +136,7 @@ public class TestInvokerUtils {
 
     expectedException.expect(IllegalStateException.class);
     expectedException.expectMessage(
-        Matchers.is("System is starting and not ready for remote calls or shutting down in progress, STATUS = DOWN"));
+        Matchers.is("The request is rejected, as the service cannot process the request due to STATUS = DOWN"));
 
     InvokerUtils.syncInvoke("ms", "latest", "rest", "schemaId", "opName", null);
   }
diff --git a/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/HighwayServerInvoke.java b/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/HighwayServerInvoke.java
index 76342e0..fd82cca 100644
--- a/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/HighwayServerInvoke.java
+++ b/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/HighwayServerInvoke.java
@@ -158,7 +158,9 @@ public class HighwayServerInvoke {
           msgId);
       LOGGER.error(msg, e);
     } finally {
-      invocation.onFinish(response);
+      if (invocation != null) {
+        invocation.onFinish(response);
+      }
     }
   }
 
@@ -173,7 +175,7 @@ public class HighwayServerInvoke {
       invocation.onStart();
       operationMeta.getExecutor().execute(() -> runInExecutor());
     } catch (IllegalStateException e) {
-      sendResponse(invocation.getContext(), Response.providerFailResp(e));
+      sendResponse(header.getContext(), Response.providerFailResp(e));
     }
   }
 }
diff --git a/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayServerInvoke.java b/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayServerInvoke.java
index 0dc902c..525b5e0 100644
--- a/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayServerInvoke.java
+++ b/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayServerInvoke.java
@@ -19,6 +19,8 @@ package org.apache.servicecomb.transport.highway;
 
 import javax.xml.ws.Holder;
 
+import org.apache.servicecomb.core.SCBEngine;
+import org.apache.servicecomb.core.SCBStatus;
 import org.apache.servicecomb.core.definition.OperationMeta;
 import org.apache.servicecomb.core.definition.SchemaMeta;
 import org.apache.servicecomb.core.event.InvocationFinishEvent;
@@ -65,11 +67,13 @@ public class TestHighwayServerInvoke {
   @BeforeClass
   public static void classSetup() {
     EventManager.eventBus = new EventBus();
+    SCBEngine.getInstance().setStatus(SCBStatus.UP);
   }
 
   @AfterClass
   public static void classTeardown() {
     EventManager.eventBus = new EventBus();
+    SCBEngine.getInstance().setStatus(SCBStatus.DOWN);
   }
 
   @Before

-- 
To stop receiving notification emails like this one, please contact
ningjiang@apache.org.