Skip to content

Commit

Permalink
[SCB-667] fix test case and small mistake
Browse files Browse the repository at this point in the history
Signed-off-by: zhengyangyong <yangyong.zheng@huawei.com>
  • Loading branch information
zhengyangyong authored and WillemJiang committed Jun 14, 2018
1 parent 7a947a4 commit e981fcc
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public void ensureStatusUp() {
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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public static void setUp() {
ServiceRegistry serviceRegistry = ServiceRegistryFactory.createLocal();
serviceRegistry.init();
RegistryUtils.setServiceRegistry(serviceRegistry);
SCBEngine.getInstance().setStatus(SCBStatus.UP);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void createReferenceConfigForInvoke_down(@Mocked ConsumerProviderManager

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);
}

Expand All @@ -128,7 +128,7 @@ public void getReferenceConfigForInvoke_down(@Mocked ConsumerProviderManager con

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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void testSyncInvoke_4param_NotReady() {

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);
}

Expand All @@ -136,7 +136,7 @@ public void testSyncInvoke_6param_NotReady() {

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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ private void sendResponse(Map<String, String> context, Response response) {
msgId);
LOGGER.error(msg, e);
} finally {
invocation.onFinish(response);
if (invocation != null) {
invocation.onFinish(response);
}
}
}

Expand All @@ -173,7 +175,7 @@ public void execute() {
invocation.onStart();
operationMeta.getExecutor().execute(() -> runInExecutor());
} catch (IllegalStateException e) {
sendResponse(invocation.getContext(), Response.providerFailResp(e));
sendResponse(header.getContext(), Response.providerFailResp(e));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

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;
Expand Down Expand Up @@ -65,11 +67,13 @@ public int add(int x, int y) {
@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
Expand Down

0 comments on commit e981fcc

Please sign in to comment.