use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.
the class ResourceReferenceHandlerServlet method handleResourceReference.
private void handleResourceReference(ResourceReference resourceReference) throws ServletException {
ResourceReferenceHandlerManager<?> resourceReferenceHandlerManager;
try {
Type role = new DefaultParameterizedType(null, ResourceReferenceHandlerManager.class, ResourceType.class);
resourceReferenceHandlerManager = this.rootComponentManager.getInstance(role);
} catch (ComponentLookupException e) {
// Should not happen since a Resource Reference Handler should always exist on the system.
throw new ServletException("Failed to locate a Resource Reference Handler Manager component", e);
}
try {
resourceReferenceHandlerManager.handle(resourceReference);
} catch (ResourceReferenceHandlerException e) {
throw new ServletException(String.format("Failed to handle Resource Reference [%s]", resourceReference), e);
}
}
use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.
the class ResourceReferenceHandlerServlet method getResourceReferenceResolver.
private ResourceReferenceResolver<ExtendedURL> getResourceReferenceResolver() throws ServletException {
ResourceReferenceResolver<ExtendedURL> urlResolver;
try {
Type role = new DefaultParameterizedType(null, ResourceReferenceResolver.class, ExtendedURL.class);
urlResolver = this.rootComponentManager.getInstance(role);
} catch (ComponentLookupException e) {
// Should not happen since a URL provider should exist on the system.
throw new ServletException("Failed to locate an ExtendedURL Resource Reference Resolver component", e);
}
return urlResolver;
}
use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.
the class DefaultEntityResourceActionListerTest method configure.
@Before
public void configure() throws Exception {
Provider<ComponentManager> componentManagerProvider = this.mocker.registerMockComponent(new DefaultParameterizedType(null, Provider.class, ComponentManager.class), "context");
when(componentManagerProvider.get()).thenReturn(this.mocker);
}
use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.
the class SVGScriptServiceTest method setup.
@Before
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
this.internal = this.mocker.getInstance(SVGRasterizer.class);
when(this.internal.rasterizeToTemporaryResource(SVG, 0, 0)).thenReturn(this.tref);
when(this.internal.rasterizeToTemporaryResource(SVG, 100, 200)).thenReturn(this.tref);
when(this.internal.rasterizeToTemporaryResource(SVG, 0, 0, this.dref)).thenReturn(this.tref);
when(this.internal.rasterizeToTemporaryResource(SVG, 100, 200, this.dref)).thenReturn(this.tref);
Type stype = new DefaultParameterizedType(null, ResourceReferenceSerializer.class, TemporaryResourceReference.class, ExtendedURL.class);
this.serializer = this.mocker.getInstance(stype, "standard/tmp");
when(this.serializer.serialize(this.tref)).thenReturn(this.eurl);
}
use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.
the class WikiUserManagerScriptServiceTest method setUp.
@Before
public void setUp() throws Exception {
// Components mocks
wikiUserManager = mocker.getInstance(WikiUserManager.class);
wikiDescriptorManager = mocker.getInstance(WikiDescriptorManager.class);
authorizationManager = mocker.getInstance(AuthorizationManager.class);
xcontextProvider = mocker.registerMockComponent(XWikiContext.TYPE_PROVIDER);
documentReferenceResolver = mocker.getInstance(new DefaultParameterizedType(null, DocumentReferenceResolver.class, String.class));
execution = mocker.getInstance(Execution.class);
// Frequent uses
xcontext = mock(XWikiContext.class);
when(xcontextProvider.get()).thenReturn(xcontext);
when(wikiDescriptorManager.getMainWikiId()).thenReturn("mainWiki");
when(wikiDescriptorManager.getCurrentWikiId()).thenReturn("subwiki");
executionContext = new ExecutionContext();
when(execution.getContext()).thenReturn(executionContext);
currentDoc = mock(XWikiDocument.class);
when(xcontext.getDoc()).thenReturn(currentDoc);
userDocRef = new DocumentReference("mainWiki", "XWiki", "User");
when(xcontext.getUserReference()).thenReturn(userDocRef);
DocumentReference userReference = new DocumentReference("mainWiki", "XWiki", "User");
when(documentReferenceResolver.resolve("mainWiki:XWiki.User")).thenReturn(userReference);
DocumentReference otherUser = new DocumentReference("mainWiki", "XWiki", "OtherUser");
when(documentReferenceResolver.resolve("mainWiki:XWiki.OtherUser")).thenReturn(otherUser);
}
Aggregations