Search in sources :

Example 1 with AttachmentReferenceResolver

use of org.xwiki.model.reference.AttachmentReferenceResolver in project xwiki-platform by xwiki.

the class IntegrationTests method initialize.

@RenderingTestSuite.Initialized
public void initialize(ComponentManager componentManager) throws Exception {
    Mockery mockery = new JUnit4Mockery();
    // Attachment Reference Resolver Mock
    final AttachmentReferenceResolver<String> mockResolver = mockery.mock(AttachmentReferenceResolver.class);
    mockery.checking(new Expectations() {

        {
            allowing(mockResolver).resolve("Space.ExistingPage@my.png");
            will(returnValue(new AttachmentReference("my.png", new DocumentReference("wiki", "Space", "ExistingPage"))));
        }
    });
    DefaultComponentDescriptor<AttachmentReferenceResolver<String>> descriptorARS = new DefaultComponentDescriptor<AttachmentReferenceResolver<String>>();
    descriptorARS.setRoleType(AttachmentReferenceResolver.TYPE_STRING);
    descriptorARS.setRoleHint("current");
    componentManager.registerComponent(descriptorARS, mockResolver);
    // WikiModel Mock
    componentManager.registerComponent(MockWikiModel.getComponentDescriptor());
}
Also used : Expectations(org.jmock.Expectations) AttachmentReference(org.xwiki.model.reference.AttachmentReference) JUnit4Mockery(org.jmock.integration.junit4.JUnit4Mockery) DefaultComponentDescriptor(org.xwiki.component.descriptor.DefaultComponentDescriptor) AttachmentReferenceResolver(org.xwiki.model.reference.AttachmentReferenceResolver) JUnit4Mockery(org.jmock.integration.junit4.JUnit4Mockery) Mockery(org.jmock.Mockery) DocumentReference(org.xwiki.model.reference.DocumentReference)

Aggregations

Expectations (org.jmock.Expectations)1 Mockery (org.jmock.Mockery)1 JUnit4Mockery (org.jmock.integration.junit4.JUnit4Mockery)1 DefaultComponentDescriptor (org.xwiki.component.descriptor.DefaultComponentDescriptor)1 AttachmentReference (org.xwiki.model.reference.AttachmentReference)1 AttachmentReferenceResolver (org.xwiki.model.reference.AttachmentReferenceResolver)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1