use of org.apache.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 org.apache.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class TestBizkeeperCommand method testConstructConsumer.
@Test
public void testConstructConsumer() {
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> response = bizkeeperCommand.construct();
Assert.assertNotNull(response);
}
use of org.apache.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class TestBizkeeperCommand method testConstructProvider.
@Test
public void testConstructProvider() {
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 ProviderBizkeeperCommand("groupname", invocation, HystrixObservableCommand.Setter.withGroupKey(CommandKey.toHystrixCommandGroupKey("groupname", invocation)).andCommandKey(CommandKey.toHystrixCommandKey("groupname", invocation)).andCommandPropertiesDefaults(setter));
Observable<Response> response = bizkeeperCommand.construct();
Assert.assertNotNull(response);
}
use of org.apache.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class TestBizkeeperCommand method testGetCacheKeyWithContextInitializedProvider.
@Test
public void testGetCacheKeyWithContextInitializedProvider() {
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 ProviderBizkeeperCommand("groupname", invocation, HystrixObservableCommand.Setter.withGroupKey(CommandKey.toHystrixCommandGroupKey("groupname", invocation)).andCommandKey(CommandKey.toHystrixCommandKey("groupname", invocation)).andCommandPropertiesDefaults(setter));
HystrixRequestContext.initializeContext();
String cacheKey = bizkeeperCommand.getCacheKey();
Assert.assertNotNull(cacheKey);
}
use of org.apache.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class TestBizkeeperCommand method testGetCacheKeyWithContextInitializedConsumer.
@Test
public void testGetCacheKeyWithContextInitializedConsumer() {
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));
HystrixRequestContext.initializeContext();
String cacheKey = bizkeeperCommand.getCacheKey();
Assert.assertNotNull(cacheKey);
}
Aggregations