use of com.enonic.xp.web.vhost.impl.mapping.VirtualHostMapping in project xp by enonic.
the class VirtualHostResolverImplTest method testMatches_host.
@Test
public void testMatches_host() {
this.virtualHostMapping = new VirtualHostMapping("mymapping", "foo.no", "/", "/a", VirtualHostIdProvidersMapping.create().build(), 0);
when(virtualHostService.getVirtualHosts()).thenReturn(List.of(this.virtualHostMapping));
VirtualHostResolver virtualHostResolver = new VirtualHostResolverImpl(virtualHostService);
HttpServletRequest req = mock(HttpServletRequest.class);
when(req.getServerName()).thenReturn("foo.no");
when(req.getRequestURI()).thenReturn("/a/b");
assertNotNull(virtualHostResolver.resolveVirtualHost(req));
}
use of com.enonic.xp.web.vhost.impl.mapping.VirtualHostMapping in project xp by enonic.
the class VirtualHostInternalHelperTest method testGetFullTargetPathWithTrailingSlash.
@Test
public void testGetFullTargetPathWithTrailingSlash() {
final VirtualHostMapping virtualHostMapping = new VirtualHostMapping("host", "foo.no", "/a", "/b/c", VirtualHostIdProvidersMapping.create().build(), 0);
final HttpServletRequest req = mock(HttpServletRequest.class);
when(req.getRequestURI()).thenReturn("/a/other/service/");
final String fullTarget = VirtualHostInternalHelper.getFullTargetPath(virtualHostMapping, req);
assertEquals(fullTarget, "/b/c/other/service/");
}
use of com.enonic.xp.web.vhost.impl.mapping.VirtualHostMapping in project xp by enonic.
the class VirtualHostInternalHelperTest method testGetFullTargetPath.
@Test
public void testGetFullTargetPath() {
final VirtualHostMapping virtualHostMapping = new VirtualHostMapping("host", "foo.no", "/a", "/b/c", VirtualHostIdProvidersMapping.create().build(), 0);
final HttpServletRequest req = mock(HttpServletRequest.class);
when(req.getRequestURI()).thenReturn("/a/other/service");
final String fullTarget = VirtualHostInternalHelper.getFullTargetPath(virtualHostMapping, req);
assertEquals(fullTarget, "/b/c/other/service");
}
Aggregations