use of org.eclipse.che.api.machine.server.model.impl.ServerPropertiesImpl in project che by eclipse.
the class ServerEvaluationStrategyTest method shouldPreferMachineConfOverDockerLabels.
@Test
public void shouldPreferMachineConfOverDockerLabels() throws Exception {
// given
prepareStrategyAndContainerInfoMocks();
labels.put(String.format(SERVER_CONF_LABEL_REF_KEY, "8080/tcp"), "myserv1label");
labels.put(String.format(SERVER_CONF_LABEL_PROTOCOL_KEY, "8080/tcp"), "https");
labels.put(String.format(SERVER_CONF_LABEL_REF_KEY, "9090/udp"), "myserv2label");
labels.put(String.format(SERVER_CONF_LABEL_PROTOCOL_KEY, "9090/udp"), "dhcp");
labels.put(String.format(SERVER_CONF_LABEL_PATH_KEY, "9090/udp"), "/path");
serverConfs.put("8080/tcp", new ServerConfImpl("myserv1conf", "8080/tcp", "http", null));
final HashMap<String, ServerImpl> expectedServers = new HashMap<>();
expectedServers.put("8080/tcp", new ServerImpl("myserv1conf", "http", DEFAULT_HOSTNAME + ":32100", "http://" + DEFAULT_HOSTNAME + ":32100", new ServerPropertiesImpl(null, DEFAULT_HOSTNAME + ":32100", "http://" + DEFAULT_HOSTNAME + ":32100")));
expectedServers.put("9090/udp", new ServerImpl("myserv2label", "dhcp", DEFAULT_HOSTNAME + ":32101", "dhcp://" + DEFAULT_HOSTNAME + ":32101/path", new ServerPropertiesImpl("/path", DEFAULT_HOSTNAME + ":32101", "dhcp://" + DEFAULT_HOSTNAME + ":32101/path")));
// when
final Map<String, ServerImpl> servers = strategy.getServers(containerInfo, DEFAULT_HOSTNAME, serverConfs);
// then
assertEquals(servers, expectedServers);
}
use of org.eclipse.che.api.machine.server.model.impl.ServerPropertiesImpl in project che by eclipse.
the class ServerEvaluationStrategyTest method shouldAddPathCorrectlyWithoutLeadingSlash.
@Test
public void shouldAddPathCorrectlyWithoutLeadingSlash() throws Exception {
// given
prepareStrategyAndContainerInfoMocks();
serverConfs.put("8080", new ServerConfImpl("myserv1", "8080", "http", "some"));
serverConfs.put("9090/udp", new ServerConfImpl("myserv1-tftp", "9090/udp", "tftp", "some/path"));
final HashMap<String, ServerImpl> expectedServers = new HashMap<>();
expectedServers.put("8080/tcp", new ServerImpl("myserv1", "http", DEFAULT_HOSTNAME + ":32100", "http://" + DEFAULT_HOSTNAME + ":32100/some", new ServerPropertiesImpl("some", DEFAULT_HOSTNAME + ":32100", "http://" + DEFAULT_HOSTNAME + ":32100/some")));
expectedServers.put("9090/udp", new ServerImpl("myserv1-tftp", "tftp", DEFAULT_HOSTNAME + ":32101", "tftp://" + DEFAULT_HOSTNAME + ":32101/some/path", new ServerPropertiesImpl("some/path", DEFAULT_HOSTNAME + ":32101", "tftp://" + DEFAULT_HOSTNAME + ":32101/some/path")));
// when
final Map<String, ServerImpl> servers = strategy.getServers(containerInfo, DEFAULT_HOSTNAME, serverConfs);
// then
assertEquals(servers, expectedServers);
}
use of org.eclipse.che.api.machine.server.model.impl.ServerPropertiesImpl in project che by eclipse.
the class ServerEvaluationStrategyTest method shouldAddRefUrlPathToServerFromLabels.
@Test
public void shouldAddRefUrlPathToServerFromLabels() throws Exception {
// given
Map<String, List<PortBinding>> ports = prepareStrategyAndContainerInfoMocks();
Map<String, String> labels = new HashMap<>();
when(containerConfig.getLabels()).thenReturn(labels);
ports.put("8080/tcp", Collections.singletonList(new PortBinding().withHostIp(ALL_IP_ADDRESS).withHostPort("32100")));
ports.put("9090/udp", Collections.singletonList(new PortBinding().withHostIp(ALL_IP_ADDRESS).withHostPort("32101")));
labels.put(String.format(SERVER_CONF_LABEL_REF_KEY, "8080/tcp"), "myserv1");
labels.put(String.format(SERVER_CONF_LABEL_PROTOCOL_KEY, "8080/tcp"), "http");
labels.put(String.format(SERVER_CONF_LABEL_PATH_KEY, "8080/tcp"), "/some/path");
labels.put(String.format(SERVER_CONF_LABEL_PROTOCOL_KEY, "9090/udp"), "dhcp");
labels.put(String.format(SERVER_CONF_LABEL_PATH_KEY, "9090/udp"), "some/path");
final HashMap<String, ServerImpl> expectedServers = new HashMap<>();
expectedServers.put("8080/tcp", new ServerImpl("myserv1", "http", DEFAULT_HOSTNAME + ":32100", "http://" + DEFAULT_HOSTNAME + ":32100/some/path", new ServerPropertiesImpl("/some/path", DEFAULT_HOSTNAME + ":32100", "http://" + DEFAULT_HOSTNAME + ":32100/some/path")));
expectedServers.put("9090/udp", new ServerImpl("Server-9090-udp", "dhcp", DEFAULT_HOSTNAME + ":32101", "dhcp://" + DEFAULT_HOSTNAME + ":32101/some/path", new ServerPropertiesImpl("some/path", DEFAULT_HOSTNAME + ":32101", "dhcp://" + DEFAULT_HOSTNAME + ":32101/some/path")));
// when
final Map<String, ServerImpl> servers = strategy.getServers(containerInfo, DEFAULT_HOSTNAME, serverConfs);
// then
assertEquals(servers, expectedServers);
}
use of org.eclipse.che.api.machine.server.model.impl.ServerPropertiesImpl in project che by eclipse.
the class ServerEvaluationStrategyTest method shouldAddDefaultReferenceIfReferenceIsNotSet.
@Test
public void shouldAddDefaultReferenceIfReferenceIsNotSet() throws Exception {
// given
prepareStrategyAndContainerInfoMocks();
final HashMap<String, ServerImpl> expectedServers = new HashMap<>();
expectedServers.put("8080/tcp", new ServerImpl("Server-8080-tcp", null, DEFAULT_HOSTNAME + ":32100", null, new ServerPropertiesImpl(null, DEFAULT_HOSTNAME + ":32100", null)));
expectedServers.put("9090/udp", new ServerImpl("Server-9090-udp", null, DEFAULT_HOSTNAME + ":32101", null, new ServerPropertiesImpl(null, DEFAULT_HOSTNAME + ":32101", null)));
// when
final Map<String, ServerImpl> servers = strategy.getServers(containerInfo, DEFAULT_HOSTNAME, serverConfs);
// then
assertEquals(servers, expectedServers);
}
use of org.eclipse.che.api.machine.server.model.impl.ServerPropertiesImpl in project che by eclipse.
the class ServerEvaluationStrategyTest method shouldAllowToUsePortFromMachineConfigWithoutTransportProtocol.
@Test
public void shouldAllowToUsePortFromMachineConfigWithoutTransportProtocol() throws Exception {
// given
prepareStrategyAndContainerInfoMocks();
serverConfs.put("8080", new ServerConfImpl("myserv1", "8080", "http", "/some"));
serverConfs.put("9090/udp", new ServerConfImpl("myserv1-tftp", "9090/udp", "tftp", "/path"));
final HashMap<String, ServerImpl> expectedServers = new HashMap<>();
expectedServers.put("8080/tcp", new ServerImpl("myserv1", "http", DEFAULT_HOSTNAME + ":32100", "http://" + DEFAULT_HOSTNAME + ":32100/some", new ServerPropertiesImpl("/some", DEFAULT_HOSTNAME + ":32100", "http://" + DEFAULT_HOSTNAME + ":32100/some")));
expectedServers.put("9090/udp", new ServerImpl("myserv1-tftp", "tftp", DEFAULT_HOSTNAME + ":32101", "tftp://" + DEFAULT_HOSTNAME + ":32101/path", new ServerPropertiesImpl("/path", DEFAULT_HOSTNAME + ":32101", "tftp://" + DEFAULT_HOSTNAME + ":32101/path")));
// when
final Map<String, ServerImpl> servers = strategy.getServers(containerInfo, DEFAULT_HOSTNAME, serverConfs);
// then
assertEquals(servers, expectedServers);
}
Aggregations