use of io.fabric8.gateway.handlers.http.MappedServices in project fabric8 by jboss-fuse.
the class HttpGatewayRequestTimeoutTest method startHttpGateway.
@Override
public HttpGatewayServer startHttpGateway() {
if (restEndpointServer != null) {
LoadBalancer loadBalancer = new RoundRobinLoadBalancer();
ServiceDTO serviceDetails = new ServiceDTO();
serviceDetails.setContainer("local");
serviceDetails.setVersion("1");
mappedServices.put("/hello/world", new MappedServices("http://localhost:8181", serviceDetails, loadBalancer, false));
}
HttpGatewayHandler handler = new HttpGatewayHandler(vertx, new HttpGateway() {
@Override
public void addMappingRuleConfiguration(HttpMappingRule mappingRule) {
}
@Override
public void removeMappingRuleConfiguration(HttpMappingRule mappingRule) {
}
@Override
public Map<String, MappedServices> getMappedServices() {
return mappedServices;
}
@Override
public boolean isEnableIndex() {
return true;
}
@Override
public InetSocketAddress getLocalAddress() {
return new InetSocketAddress("0.0.0.0", 8080);
}
@Override
public void addCallDetailRecord(CallDetailRecord cdr) {
}
});
handler.setRequestTimeout(1000L);
httpGatewayServer = new HttpGatewayServer(vertx, handler, null, 8080);
httpGatewayServer.setHost("localhost");
httpGatewayServer.init();
return httpGatewayServer;
}
use of io.fabric8.gateway.handlers.http.MappedServices in project fabric8 by jboss-fuse.
the class HttpGatewayTest method startHttpGateway.
@Override
public HttpGatewayServer startHttpGateway() {
if (restEndpointServer != null) {
LoadBalancer loadBalancer = new RoundRobinLoadBalancer();
ServiceDTO serviceDetails = new ServiceDTO();
serviceDetails.setContainer("local");
serviceDetails.setVersion("1");
mappedServices.put("/hello/world", new MappedServices("http://localhost:8181", serviceDetails, loadBalancer, false));
}
HttpGatewayHandler handler = new HttpGatewayHandler(vertx, new HttpGateway() {
@Override
public void addMappingRuleConfiguration(HttpMappingRule mappingRule) {
}
@Override
public void removeMappingRuleConfiguration(HttpMappingRule mappingRule) {
}
@Override
public Map<String, MappedServices> getMappedServices() {
return mappedServices;
}
@Override
public boolean isEnableIndex() {
return true;
}
@Override
public InetSocketAddress getLocalAddress() {
return new InetSocketAddress("0.0.0.0", 8080);
}
@Override
public void addCallDetailRecord(CallDetailRecord cdr) {
}
});
httpGatewayServer = new HttpGatewayServer(vertx, handler, null, 8080);
httpGatewayServer.setHost("localhost");
httpGatewayServer.init();
return httpGatewayServer;
}
use of io.fabric8.gateway.handlers.http.MappedServices in project fabric8 by jboss-fuse.
the class MappingConfigurationTest method printMappings.
protected void printMappings(Map<String, MappedServices> mappingRules) {
for (Map.Entry<String, MappedServices> entry : mappingRules.entrySet()) {
String key = entry.getKey();
MappedServices value = entry.getValue();
System.out.println(key + " => " + value.getServiceUrls());
}
}
use of io.fabric8.gateway.handlers.http.MappedServices in project fabric8 by jboss-fuse.
the class MappingConfigurationTest method assertMapping.
protected void assertMapping(String path, String service) {
Map<String, MappedServices> mappingRules = httpGateway.getMappedServices();
assertTrue("Should have some mapping rules", mappingRules.size() > 0);
MappedServices mappedServices = mappingRules.get(path);
assertNotNull("Could not find mapping rule for path " + path, mappedServices);
Collection<String> serviceUrls = mappedServices.getServiceUrls();
assertTrue("Could not find service " + service + " in services " + serviceUrls, serviceUrls.contains(service));
}
Aggregations