use of com.enonic.xp.portal.url.AssetUrlParams in project xp by enonic.
the class PortalUrlServiceImpl_assetUrlTest method createUrl_absolute.
@Test
public void createUrl_absolute() {
final ResourceKey resourceKey = ResourceKey.from(ApplicationKey.from("myapplication"), "META-INF/MANIFEST.MF");
when(this.resourceService.getResource(resourceKey)).thenReturn(MockResource.empty(resourceKey, 1));
final AssetUrlParams params = new AssetUrlParams().type(UrlTypeConstants.ABSOLUTE).portalRequest(this.portalRequest).path("css/my.css");
when(req.getServerName()).thenReturn("localhost");
when(req.getScheme()).thenReturn("http");
when(req.getServerPort()).thenReturn(80);
final String url = this.service.assetUrl(params);
assertEquals("http://localhost/site/default/draft/_/asset/myapplication:0000000000000001/css/my.css", url);
}
use of com.enonic.xp.portal.url.AssetUrlParams in project xp by enonic.
the class PortalUrlServiceImpl_assetUrlTest method createUrl_encodeChars.
@Test
public void createUrl_encodeChars() {
final ResourceKey resourceKey = ResourceKey.from(ApplicationKey.from("myapplication"), "META-INF/MANIFEST.MF");
when(this.resourceService.getResource(resourceKey)).thenReturn(MockResource.empty(resourceKey, 1));
final AssetUrlParams params = new AssetUrlParams().portalRequest(this.portalRequest).path("css/my other & strange.css");
final String url = this.service.assetUrl(params);
assertEquals("/site/default/draft/_/asset/myapplication:0000000000000001/css/my%20other%20&%20strange.css", url);
}
Aggregations