Search in sources :

Example 1 with VirtualHostServiceImpl

use of com.enonic.xp.web.vhost.impl.config.VirtualHostServiceImpl in project xp by enonic.

the class VirtualHostServiceImplTest method testEnabled.

@Test
public void testEnabled() {
    final VirtualHostServiceImpl virtualHostService = new VirtualHostServiceImpl(Collections.singletonMap("enabled", "true"));
    assertTrue(virtualHostService.isEnabled());
}
Also used : VirtualHostServiceImpl(com.enonic.xp.web.vhost.impl.config.VirtualHostServiceImpl) Test(org.junit.jupiter.api.Test)

Example 2 with VirtualHostServiceImpl

use of com.enonic.xp.web.vhost.impl.config.VirtualHostServiceImpl in project xp by enonic.

the class VirtualHostServiceImplTest method testOrder.

@Test
public void testOrder() {
    final Map<String, String> configurationMap = new HashMap<>();
    configurationMap.put("enabled", "true");
    configurationMap.put("mapping.a.host", "localhost");
    configurationMap.put("mapping.a.source", "/a");
    configurationMap.put("mapping.a.target", "/other/a");
    configurationMap.put("mapping.b.host", "localhost");
    configurationMap.put("mapping.b.source", "/b");
    configurationMap.put("mapping.b.target", "/other/b");
    configurationMap.put("mapping.c.host", "~localhost");
    configurationMap.put("mapping.c.source", "/a/c");
    configurationMap.put("mapping.c.target", "/other/a/c");
    configurationMap.put("mapping.d.host", "enonic.com");
    configurationMap.put("mapping.d.source", "/d");
    configurationMap.put("mapping.d.target", "/other/d");
    configurationMap.put("mapping.d.order", "1");
    final VirtualHostServiceImpl virtualHostService = new VirtualHostServiceImpl(configurationMap);
    final List<VirtualHost> virtualHosts = virtualHostService.getVirtualHosts();
    assertThat(virtualHosts.stream().map(VirtualHost::getName)).containsExactly("d", "c", "a", "b");
}
Also used : VirtualHostServiceImpl(com.enonic.xp.web.vhost.impl.config.VirtualHostServiceImpl) HashMap(java.util.HashMap) VirtualHost(com.enonic.xp.web.vhost.VirtualHost) Test(org.junit.jupiter.api.Test)

Example 3 with VirtualHostServiceImpl

use of com.enonic.xp.web.vhost.impl.config.VirtualHostServiceImpl in project xp by enonic.

the class VirtualHostServiceImplTest method testGetVirtualHosts.

@Test
public void testGetVirtualHosts() {
    final Map<String, String> configurationMap = new HashMap<>();
    configurationMap.put("enabled", "true");
    configurationMap.put("mapping.a.host", "localhost");
    configurationMap.put("mapping.a.source", "/a");
    configurationMap.put("mapping.a.target", "/other/a");
    final VirtualHostServiceImpl virtualHostService = new VirtualHostServiceImpl(configurationMap);
    final List<VirtualHost> virtualHosts = virtualHostService.getVirtualHosts();
    assertNotNull(virtualHosts);
    assertFalse(virtualHosts.isEmpty());
    assertEquals("a", virtualHosts.get(0).getName());
}
Also used : VirtualHostServiceImpl(com.enonic.xp.web.vhost.impl.config.VirtualHostServiceImpl) HashMap(java.util.HashMap) VirtualHost(com.enonic.xp.web.vhost.VirtualHost) Test(org.junit.jupiter.api.Test)

Example 4 with VirtualHostServiceImpl

use of com.enonic.xp.web.vhost.impl.config.VirtualHostServiceImpl in project xp by enonic.

the class VirtualHostServiceImplTest method testLoadedConfig_none.

@Test
public void testLoadedConfig_none() throws Exception {
    final VirtualHostServiceImpl virtualHostService = new VirtualHostServiceImpl(loadConfig("none"));
    assertFalse(virtualHostService.isEnabled());
    assertNotNull(virtualHostService.getVirtualHosts());
    final List<VirtualHost> mappings = virtualHostService.getVirtualHosts();
    assertEquals(0, mappings.size());
}
Also used : VirtualHostServiceImpl(com.enonic.xp.web.vhost.impl.config.VirtualHostServiceImpl) VirtualHost(com.enonic.xp.web.vhost.VirtualHost) Test(org.junit.jupiter.api.Test)

Example 5 with VirtualHostServiceImpl

use of com.enonic.xp.web.vhost.impl.config.VirtualHostServiceImpl in project xp by enonic.

the class VirtualHostServiceImplTest method testNoConfig.

@Test
public void testNoConfig() {
    final VirtualHostServiceImpl virtualHostService = new VirtualHostServiceImpl(Map.of());
    assertFalse(virtualHostService.isEnabled());
    assertNotNull(virtualHostService.getVirtualHosts());
    final List<VirtualHost> mappings = virtualHostService.getVirtualHosts();
    assertEquals(0, mappings.size());
}
Also used : VirtualHostServiceImpl(com.enonic.xp.web.vhost.impl.config.VirtualHostServiceImpl) VirtualHost(com.enonic.xp.web.vhost.VirtualHost) Test(org.junit.jupiter.api.Test)

Aggregations

VirtualHostServiceImpl (com.enonic.xp.web.vhost.impl.config.VirtualHostServiceImpl)8 Test (org.junit.jupiter.api.Test)8 VirtualHost (com.enonic.xp.web.vhost.VirtualHost)6 HashMap (java.util.HashMap)2