@Test public void should_resolve_internal_ip_of_container_with_default_port() { final DockerCompositions compositions = ConfigUtil.load(SIMPLE_SCENARIO); when(cubeDockerConfiguration.getDockerContainersContent()).thenReturn(compositions); when(grapheneConfiguration.getUrl()).thenReturn("http://helloworld/context"); final URL url = (URL) dockerCubeCustomizableURLResourceProvider.lookup(null); assertThat(url) .hasProtocol("http") .hasHost("192.168.99.100") .hasPort(80) .hasPath("/context"); }
@Test public void should_resolve_internal_ip_of_container() { final DockerCompositions compositions = ConfigUtil.load(SIMPLE_SCENARIO); when(cubeDockerConfiguration.getDockerContainersContent()).thenReturn(compositions); when(grapheneConfiguration.getUrl()).thenReturn("http://helloworld:80/context"); final URL url = (URL) dockerCubeCustomizableURLResourceProvider.lookup(null); assertThat(url) .hasProtocol("http") .hasHost("192.168.99.100") .hasPort(80) .hasPath("/context"); }
@Test public void should_resolve_docker_host_in_relative_url() { final DockerCompositions compositions = ConfigUtil.load(SIMPLE_SCENARIO); when(cubeDockerConfiguration.getDockerContainersContent()).thenReturn(compositions); when(grapheneConfiguration.getUrl()).thenReturn("http://dockerHost:80/context"); final URL url = (URL) dockerCubeCustomizableURLResourceProvider.lookup(null); assertThat(url) .hasProtocol("http") .hasHost("192.168.99.100") .hasPort(80) .hasPath("/context"); }
@Test public void should_not_resolve_ip() { final DockerCompositions compositions = ConfigUtil.load(SIMPLE_SCENARIO); when(cubeDockerConfiguration.getDockerContainersContent()).thenReturn(compositions); when(grapheneConfiguration.getUrl()).thenReturn("http://192.168.99.101:80/context"); final URL url = (URL) dockerCubeCustomizableURLResourceProvider.lookup(null); assertThat(url) .hasProtocol("http") .hasHost("192.168.99.101") .hasPort(80) .hasPath("/context"); }
@Test public void should_resolve_docker_host_in_relative_url_with_default_port() { final DockerCompositions compositions = ConfigUtil.load(SIMPLE_SCENARIO); when(cubeDockerConfiguration.getDockerContainersContent()).thenReturn(compositions); when(grapheneConfiguration.getUrl()).thenReturn("http://dockerHost/context"); final URL url = (URL) dockerCubeCustomizableURLResourceProvider.lookup(null); assertThat(url) .hasProtocol("http") .hasHost("192.168.99.100") .hasPort(80) .hasPath("/context"); } }