use of io.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class TestBizkeeperCommand method testResumeWithFallbackConsumer.
@Test
public void testResumeWithFallbackConsumer() {
Invocation invocation = Mockito.mock(Invocation.class);
Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");
HystrixCommandProperties.Setter setter = HystrixCommandProperties.Setter().withRequestCacheEnabled(true).withRequestLogEnabled(false);
BizkeeperCommand bizkeeperCommand = new ConsumerBizkeeperCommand("groupname", invocation, HystrixObservableCommand.Setter.withGroupKey(CommandKey.toHystrixCommandGroupKey("groupname", invocation)).andCommandKey(CommandKey.toHystrixCommandKey("groupname", invocation)).andCommandPropertiesDefaults(setter));
Observable<Response> observe = bizkeeperCommand.resumeWithFallback();
Assert.assertNotNull(observe);
}
use of io.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class TestConsumerBizkeeperHandler method testCreateBizkeeperCommand.
@Test
public void testCreateBizkeeperCommand() {
HystrixPlugins.reset();
ConsumerBizkeeperHandler consumerBizkeeperHandler = new ConsumerBizkeeperHandler();
Invocation invocation = Mockito.mock(Invocation.class);
Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");
CommandKey.toHystrixCommandGroupKey("groupname", invocation);
CommandKey.toHystrixCommandKey("groupname", invocation);
BizkeeperCommand command = consumerBizkeeperHandler.createBizkeeperCommand(invocation);
Assert.assertNotNull(command);
}
use of io.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class TestHystrixPropertiesStrategyExt method testGetCommandPropertiesCacheKey.
@Test
public void testGetCommandPropertiesCacheKey() {
assertNotNull(HystrixPropertiesStrategyExt.getInstance());
HystrixPropertiesStrategyExt hps = HystrixPropertiesStrategyExt.getInstance();
HystrixCommandKey commandKey = Mockito.mock(HystrixCommandKey.class);
Invocation invocation = Mockito.mock(Invocation.class);
Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
Mockito.when(invocation.getOperationMeta().getMicroserviceName()).thenReturn("testqualify");
HystrixCommandProperties.Setter setter = HystrixCommandProperties.Setter().withRequestCacheEnabled(true).withRequestLogEnabled(false).withFallbackIsolationSemaphoreMaxConcurrentRequests(Configuration.INSTANCE.getFallbackMaxConcurrentRequests("groupname", "testing", invocation.getOperationMeta().getMicroserviceQualifiedName()));
String str1 = hps.getCommandPropertiesCacheKey(commandKey, setter);
Assert.assertNull(str1);
}
use of io.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class TestProviderBizkeeperHandler method testCreateBizkeeperCommand.
@Test
public void testCreateBizkeeperCommand() {
HystrixPlugins.reset();
ProviderBizkeeperHanlder providerBizkeeperHanlder = new ProviderBizkeeperHanlder();
Invocation invocation = Mockito.mock(Invocation.class);
Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");
CommandKey.toHystrixCommandGroupKey("groupname", invocation);
CommandKey.toHystrixCommandKey("groupname", invocation);
BizkeeperCommand command = providerBizkeeperHanlder.createBizkeeperCommand(invocation);
Assert.assertNotNull(command);
}
use of io.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class TestLoadbalanceHandler method testLoadbalanceHandlerHandleWithCseServer.
@Test
public void testLoadbalanceHandlerHandleWithCseServer() throws Exception {
boolean status = true;
new MockUp<LoadbalanceHandler>() {
@Mock
private LoadBalancer createLoadBalancer(String appId, String microserviceName, String microserviceVersionRule, String transportName) {
return lb;
}
};
LoadbalanceHandler lh = new LoadbalanceHandler();
Invocation invocation = Mockito.mock(Invocation.class);
Mockito.when(invocation.getConfigTransportName()).thenReturn("baadshah");
Mockito.when(invocation.getMicroserviceVersionRule()).thenReturn("VERSION_RULE_LATEST");
AsyncResponse asyncResp = Mockito.mock(AsyncResponse.class);
Mockito.when(invocation.getAppId()).thenReturn("test");
Mockito.when(invocation.getMicroserviceName()).thenReturn("test");
CseServer server = Mockito.mock(CseServer.class);
Mockito.when((CseServer) lb.chooseServer()).thenReturn(server);
try {
lh.handle(invocation, asyncResp);
} catch (Exception e) {
status = false;
}
Assert.assertTrue(status);
}
Aggregations