Search in sources :

Example 11 with ServerConfImpl

use of org.eclipse.che.api.machine.server.model.impl.ServerConfImpl 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);
}
Also used : ServerImpl(org.eclipse.che.api.machine.server.model.impl.ServerImpl) HashMap(java.util.HashMap) ServerPropertiesImpl(org.eclipse.che.api.machine.server.model.impl.ServerPropertiesImpl) ServerConfImpl(org.eclipse.che.api.machine.server.model.impl.ServerConfImpl) Test(org.testng.annotations.Test)

Example 12 with ServerConfImpl

use of org.eclipse.che.api.machine.server.model.impl.ServerConfImpl 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);
}
Also used : ServerImpl(org.eclipse.che.api.machine.server.model.impl.ServerImpl) HashMap(java.util.HashMap) ServerPropertiesImpl(org.eclipse.che.api.machine.server.model.impl.ServerPropertiesImpl) ServerConfImpl(org.eclipse.che.api.machine.server.model.impl.ServerConfImpl) Test(org.testng.annotations.Test)

Aggregations

ServerConfImpl (org.eclipse.che.api.machine.server.model.impl.ServerConfImpl)12 ServerImpl (org.eclipse.che.api.machine.server.model.impl.ServerImpl)7 Test (org.testng.annotations.Test)7 HashMap (java.util.HashMap)5 ServerPropertiesImpl (org.eclipse.che.api.machine.server.model.impl.ServerPropertiesImpl)5 Matchers.anyString (org.mockito.Matchers.anyString)3 HashSet (java.util.HashSet)2 List (java.util.List)2 ServerConf (org.eclipse.che.api.core.model.machine.ServerConf)2 ServerConf2 (org.eclipse.che.api.core.model.workspace.ServerConf2)2 PortBinding (org.eclipse.che.plugin.docker.client.json.PortBinding)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 AgentException (org.eclipse.che.api.agent.server.exception.AgentException)1 AgentImpl (org.eclipse.che.api.agent.shared.model.impl.AgentImpl)1 ServerException (org.eclipse.che.api.core.ServerException)1 Machine (org.eclipse.che.api.core.model.machine.Machine)1 ServerProperties (org.eclipse.che.api.core.model.machine.ServerProperties)1