use of org.xwiki.url.ExtendedURL in project xwiki-platform by xwiki.
the class IntegrationTest method assertURL.
private void assertURL(String url, ResourceType expectedType, ResourceReference expectedReference) throws Exception {
ExtendedURL extendedURL = new ExtendedURL(new URL(url), "xwiki");
ResourceType resourceType = this.resourceTypeResolver.resolve(extendedURL, Collections.<String, Object>emptyMap());
assertEquals(expectedType.getId(), resourceType.getId());
ResourceReference reference = this.resourceReferenceResolver.resolve(extendedURL, resourceType, Collections.<String, Object>emptyMap());
assertEquals(expectedReference, reference);
}
use of org.xwiki.url.ExtendedURL in project xwiki-platform by xwiki.
the class PathWikiReferenceExtractorTest method testAndAssert.
private void testAndAssert(String urlToTest, String expectedWikiId) throws Exception {
ExtendedURL url = new ExtendedURL(new URL(urlToTest), "xwiki");
// Remove the resource type (i.e. the first segment) since this is what is expected by the extractor
url.getSegments().remove(0);
WikiReference wikiReference = this.mocker.getComponentUnderTest().extract(url);
assertEquals(new WikiReference(expectedWikiId), wikiReference);
}
use of org.xwiki.url.ExtendedURL in project xwiki-platform by xwiki.
the class BinEntityResourceReferenceResolverTest method testCreateResource.
private ResourceReference testCreateResource(String testURL, String expectedActionName, EntityReference expectedReference, EntityReference returnedReference, EntityType expectedEntityType) throws Exception {
when(this.entityReferenceResolver.resolve(expectedReference, expectedEntityType)).thenReturn(returnedReference);
ExtendedURL extendedURL = new ExtendedURL(new URL(testURL), null);
// Remove the resource type segment since this is what gets passed to specific Reference Resolvers.
extendedURL.getSegments().remove(0);
EntityResourceReference entityResource = this.resolver.resolve(extendedURL, new ResourceType("bin"), Collections.<String, Object>emptyMap());
assertEquals(expectedActionName, entityResource.getAction().getActionName());
assertEquals(returnedReference, entityResource.getEntityReference());
return entityResource;
}
use of org.xwiki.url.ExtendedURL in project xwiki-platform by xwiki.
the class WikiEntityResourceReferenceResolverTest method resolve.
@Test
public void resolve() throws Exception {
ExtendedURL url = new ExtendedURL(new URL("http://localhost/wiki/somewiki/view/space/page"), null);
url.getSegments().remove(0);
when(wikiReferenceExtractor.extract(url)).thenReturn(this.wikiReference);
EntityReference reference = buildEntityReference("somewiki", "space", "page");
EntityResourceReference result = (EntityResourceReference) testCreateResource("http://localhost/wiki/somewiki/view/space/page", "view", reference, reference, EntityType.DOCUMENT);
assertEquals(new DocumentReference("somewiki", "space", "page"), result.getEntityReference());
}
use of org.xwiki.url.ExtendedURL in project xwiki-platform by xwiki.
the class VfsResourceReferenceSerializerTest method serializeWhenNoSpecificSchemeSerializer.
@Test
public void serializeWhenNoSpecificSchemeSerializer() throws Exception {
VfsResourceReference reference = new VfsResourceReference(URI.create("somescheme:wiki:space.page@attachment"), "path1/path2/test.txt");
ExtendedURL extendedURL = new ExtendedURL(Arrays.asList("vfs", "somescheme:wiki:space.page@attachment", "path1", "path2", "test.txt"));
URLNormalizer<ExtendedURL> normalizer = this.mocker.getInstance(new DefaultParameterizedType(null, URLNormalizer.class, ExtendedURL.class), "contextpath");
when(normalizer.normalize(extendedURL)).thenReturn(extendedURL);
assertEquals("/vfs/somescheme%3Awiki%3Aspace.page%40attachment/path1/path2/test.txt", this.mocker.getComponentUnderTest().serialize(reference).toString());
}
Aggregations