Java Code Examples for io.fabric8.openshift.api.model.RouteSpec#setHost()

The following examples show how to use io.fabric8.openshift.api.model.RouteSpec#setHost() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenShiftPreviewUrlCommandProvisionerTest.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void shouldUpdateCommandWhenServiceAndIngressFound() throws InfrastructureException {
  int port = 8080;
  List<CommandImpl> commands =
      Collections.singletonList(
          new CommandImpl("a", "a", "a", new PreviewUrlImpl(port, null), Collections.emptyMap()));
  OpenShiftEnvironment env =
      OpenShiftEnvironment.builder().setCommands(new ArrayList<>(commands)).build();

  Mockito.when(mockProject.services()).thenReturn(mockServices);
  Service service = new Service();
  ObjectMeta metadata = new ObjectMeta();
  metadata.setName("servicename");
  service.setMetadata(metadata);
  ServiceSpec spec = new ServiceSpec();
  spec.setPorts(
      Collections.singletonList(
          new ServicePort("8080", null, port, "TCP", new IntOrString(port))));
  service.setSpec(spec);
  Mockito.when(mockServices.get()).thenReturn(Collections.singletonList(service));

  Route route = new Route();
  RouteSpec routeSpec = new RouteSpec();
  routeSpec.setPort(new RoutePort(new IntOrString("8080")));
  routeSpec.setTo(new RouteTargetReference("a", "servicename", 1));
  routeSpec.setHost("testhost");
  route.setSpec(routeSpec);

  Mockito.when(mockProject.routes()).thenReturn(mockRoutes);
  Mockito.when(mockRoutes.get()).thenReturn(Collections.singletonList(route));

  previewUrlCommandProvisioner.provision(env, mockProject);

  assertTrue(env.getCommands().get(0).getAttributes().containsKey("previewUrl"));
  assertEquals(env.getCommands().get(0).getAttributes().get("previewUrl"), "testhost");
  assertTrue(env.getWarnings().isEmpty());
}
 
Example 2
Source File: RoutesTest.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
private Route createRoute(IntOrString port) {
  Route route = new Route();
  RouteSpec routeSpec = new RouteSpec();
  routeSpec.setPort(new RoutePort(port));
  routeSpec.setTo(new RouteTargetReference("a", "servicename", 1));
  routeSpec.setHost("testhost");
  route.setSpec(routeSpec);
  return route;
}