use of org.apache.knox.gateway.ha.provider.HaProvider in project knox by apache.
the class ServiceSchemeFunctionProcessorTest method setUp.
@Before
public void setUp() {
reg = EasyMock.createNiceMock(ServiceRegistry.class);
EasyMock.expect(reg.lookupServiceURL("test-cluster", "test-service")).andReturn("test-scheme://test-host:777/test-path").anyTimes();
svc = EasyMock.createNiceMock(GatewayServices.class);
EasyMock.expect(svc.getService(GatewayServices.SERVICE_REGISTRY_SERVICE)).andReturn(reg).anyTimes();
env = EasyMock.createNiceMock(UrlRewriteEnvironment.class);
EasyMock.expect(env.getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE)).andReturn(svc).anyTimes();
EasyMock.expect(env.getAttribute(GatewayServices.GATEWAY_CLUSTER_ATTRIBUTE)).andReturn("test-cluster").anyTimes();
ctx = EasyMock.createNiceMock(UrlRewriteContext.class);
desc = EasyMock.createNiceMock(ServiceSchemeFunctionDescriptor.class);
HaProvider haProvider = EasyMock.createNiceMock(HaProvider.class);
EasyMock.expect(env.getAttribute(HaServletContextListener.PROVIDER_ATTRIBUTE_NAME)).andReturn(haProvider).anyTimes();
EasyMock.expect(haProvider.isHaEnabled(EasyMock.anyObject(String.class))).andReturn(Boolean.FALSE).anyTimes();
EasyMock.replay(reg, svc, env, desc, ctx, haProvider);
}
use of org.apache.knox.gateway.ha.provider.HaProvider in project knox by apache.
the class ServiceAddressFunctionProcessorTest method setUp.
@Before
public void setUp() {
reg = EasyMock.createNiceMock(ServiceRegistry.class);
EasyMock.expect(reg.lookupServiceURL("test-cluster", "test-service")).andReturn("test-scheme://test-host:777/test-path").anyTimes();
svc = EasyMock.createNiceMock(GatewayServices.class);
EasyMock.expect(svc.getService(GatewayServices.SERVICE_REGISTRY_SERVICE)).andReturn(reg).anyTimes();
env = EasyMock.createNiceMock(UrlRewriteEnvironment.class);
EasyMock.expect(env.getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE)).andReturn(svc).anyTimes();
EasyMock.expect(env.getAttribute(GatewayServices.GATEWAY_CLUSTER_ATTRIBUTE)).andReturn("test-cluster").anyTimes();
ctx = EasyMock.createNiceMock(UrlRewriteContext.class);
desc = EasyMock.createNiceMock(ServiceAddressFunctionDescriptor.class);
HaProvider haProvider = EasyMock.createNiceMock(HaProvider.class);
EasyMock.expect(env.getAttribute(HaServletContextListener.PROVIDER_ATTRIBUTE_NAME)).andReturn(haProvider).anyTimes();
EasyMock.expect(haProvider.isHaEnabled(EasyMock.anyObject(String.class))).andReturn(Boolean.FALSE).anyTimes();
EasyMock.replay(reg, svc, env, desc, ctx, haProvider);
}
use of org.apache.knox.gateway.ha.provider.HaProvider in project knox by apache.
the class ServiceMappedAddressFunctionProcessorTest method setUp.
@Before
public void setUp() {
hm = EasyMock.createNiceMock(HostMapper.class);
EasyMock.expect(hm.resolveInboundHostName("test-host")).andReturn("test-internal-host").anyTimes();
hms = EasyMock.createNiceMock(HostMapperService.class);
EasyMock.expect(hms.getHostMapper("test-cluster")).andReturn(hm).anyTimes();
reg = EasyMock.createNiceMock(ServiceRegistry.class);
EasyMock.expect(reg.lookupServiceURL("test-cluster", "test-service")).andReturn("test-scheme://test-host:777/test-path").anyTimes();
svc = EasyMock.createNiceMock(GatewayServices.class);
EasyMock.expect(svc.getService(GatewayServices.SERVICE_REGISTRY_SERVICE)).andReturn(reg).anyTimes();
EasyMock.expect(svc.getService(GatewayServices.HOST_MAPPING_SERVICE)).andReturn(hms).anyTimes();
env = EasyMock.createNiceMock(UrlRewriteEnvironment.class);
EasyMock.expect(env.getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE)).andReturn(svc).anyTimes();
EasyMock.expect(env.getAttribute(GatewayServices.GATEWAY_CLUSTER_ATTRIBUTE)).andReturn("test-cluster").anyTimes();
ctx = EasyMock.createNiceMock(UrlRewriteContext.class);
EasyMock.expect(ctx.getDirection()).andReturn(UrlRewriter.Direction.IN).anyTimes();
desc = EasyMock.createNiceMock(ServiceMappedAddressFunctionDescriptor.class);
HaProvider haProvider = EasyMock.createNiceMock(HaProvider.class);
EasyMock.expect(env.getAttribute(HaServletContextListener.PROVIDER_ATTRIBUTE_NAME)).andReturn(haProvider).anyTimes();
EasyMock.expect(haProvider.isHaEnabled(EasyMock.anyObject(String.class))).andReturn(Boolean.FALSE).anyTimes();
EasyMock.replay(hm, hms, reg, svc, env, desc, ctx, haProvider);
}
use of org.apache.knox.gateway.ha.provider.HaProvider in project knox by apache.
the class ServiceMappedUrlFunctionProcessorTest method setUp.
@Before
public void setUp() {
hm = EasyMock.createNiceMock(HostMapper.class);
EasyMock.expect(hm.resolveInboundHostName("test-host")).andReturn("test-internal-host").anyTimes();
hms = EasyMock.createNiceMock(HostMapperService.class);
EasyMock.expect(hms.getHostMapper("test-cluster")).andReturn(hm).anyTimes();
reg = EasyMock.createNiceMock(ServiceRegistry.class);
EasyMock.expect(reg.lookupServiceURL("test-cluster", "test-service")).andReturn("test-scheme://test-host:777/test-path").anyTimes();
svc = EasyMock.createNiceMock(GatewayServices.class);
EasyMock.expect(svc.getService(GatewayServices.SERVICE_REGISTRY_SERVICE)).andReturn(reg).anyTimes();
EasyMock.expect(svc.getService(GatewayServices.HOST_MAPPING_SERVICE)).andReturn(hms).anyTimes();
env = EasyMock.createNiceMock(UrlRewriteEnvironment.class);
EasyMock.expect(env.getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE)).andReturn(svc).anyTimes();
EasyMock.expect(env.getAttribute(GatewayServices.GATEWAY_CLUSTER_ATTRIBUTE)).andReturn("test-cluster").anyTimes();
ctx = EasyMock.createNiceMock(UrlRewriteContext.class);
EasyMock.expect(ctx.getDirection()).andReturn(UrlRewriter.Direction.IN).anyTimes();
desc = EasyMock.createNiceMock(ServiceMappedUrlFunctionDescriptor.class);
HaProvider haProvider = EasyMock.createNiceMock(HaProvider.class);
EasyMock.expect(env.getAttribute(HaServletContextListener.PROVIDER_ATTRIBUTE_NAME)).andReturn(haProvider).anyTimes();
EasyMock.expect(haProvider.isHaEnabled(EasyMock.anyObject(String.class))).andReturn(Boolean.FALSE).anyTimes();
EasyMock.replay(hm, hms, reg, svc, env, desc, ctx, haProvider);
}
use of org.apache.knox.gateway.ha.provider.HaProvider in project knox by apache.
the class DefaultHaProviderTest method testDescriptor.
@Test
public void testDescriptor() {
try {
new DefaultHaProvider(null);
fail("provider construction should have failed with null descriptor");
} catch (IllegalArgumentException e) {
}
HaDescriptor descriptor = new DefaultHaDescriptor();
HaProvider provider = new DefaultHaProvider(descriptor);
assertNotNull(provider.getHaDescriptor());
descriptor.addServiceConfig(new DefaultHaServiceConfig("foo"));
assertTrue(provider.isHaEnabled("foo"));
}
Aggregations