Search in sources :

Example 96 with WikiReference

use of org.xwiki.model.reference.WikiReference in project celements-blog by celements.

the class BlogCacheTest method testGetCachedDocRefs.

@Test
public void testGetCachedDocRefs() throws Exception {
    WikiReference wikiRef = new WikiReference("wiki");
    SpaceReference spaceRef1 = new SpaceReference("blogSpace1", wikiRef);
    SpaceReference spaceRef2 = new SpaceReference("blogSpace2", wikiRef);
    SpaceReference spaceRef3 = new SpaceReference("blogSpace3", wikiRef);
    DocumentReference docRef1 = new DocumentReference(wikiRef.getName(), "space", "blog1");
    DocumentReference docRef2 = new DocumentReference(wikiRef.getName(), "space", "blog2");
    expectXWQL(wikiRef, Arrays.asList(docRef1, docRef2));
    expect(cache.blogService.getBlogSpaceRef(eq(docRef1))).andReturn(spaceRef1).once();
    expect(cache.blogService.getBlogSpaceRef(eq(docRef2))).andReturn(spaceRef2).once();
    replayDefault();
    assertEquals(ImmutableSet.of(docRef1), cache.getCachedDocRefs(spaceRef1));
    assertEquals(ImmutableSet.of(docRef2), cache.getCachedDocRefs(spaceRef2));
    assertEquals(ImmutableSet.of(), cache.getCachedDocRefs(spaceRef3));
    assertEquals(ImmutableSet.of(docRef1, docRef2), cache.getCachedDocRefs(wikiRef));
    verifyDefault();
}
Also used : SpaceReference(org.xwiki.model.reference.SpaceReference) WikiReference(org.xwiki.model.reference.WikiReference) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 97 with WikiReference

use of org.xwiki.model.reference.WikiReference in project celements-blog by celements.

the class BlogCacheTest method testGetCachedDocRefs_multiWiki.

@Test
public void testGetCachedDocRefs_multiWiki() throws Exception {
    WikiReference wikiRef1 = new WikiReference("wiki1");
    SpaceReference spaceRef1 = new SpaceReference("blogSpace1", wikiRef1);
    DocumentReference docRef1 = new DocumentReference(wikiRef1.getName(), "space", "blog1");
    WikiReference wikiRef2 = new WikiReference("wiki2");
    SpaceReference spaceRef2 = new SpaceReference("blogSpace2", wikiRef2);
    DocumentReference docRef2 = new DocumentReference(wikiRef2.getName(), "space", "blog2");
    SpaceReference spaceRef3 = new SpaceReference("blogSpace3", wikiRef1);
    expectXWQL(wikiRef1, Arrays.asList(docRef1));
    expect(cache.blogService.getBlogSpaceRef(eq(docRef1))).andReturn(spaceRef1).once();
    expectXWQL(wikiRef2, Arrays.asList(docRef2));
    expect(cache.blogService.getBlogSpaceRef(eq(docRef2))).andReturn(spaceRef2).once();
    replayDefault();
    assertEquals(ImmutableSet.of(docRef1), cache.getCachedDocRefs(spaceRef1));
    assertEquals(ImmutableSet.of(docRef2), cache.getCachedDocRefs(spaceRef2));
    assertEquals(ImmutableSet.of(), cache.getCachedDocRefs(spaceRef3));
    assertEquals(ImmutableSet.of(docRef1), cache.getCachedDocRefs(wikiRef1));
    assertEquals(ImmutableSet.of(docRef2), cache.getCachedDocRefs(wikiRef2));
    verifyDefault();
}
Also used : SpaceReference(org.xwiki.model.reference.SpaceReference) WikiReference(org.xwiki.model.reference.WikiReference) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 98 with WikiReference

use of org.xwiki.model.reference.WikiReference in project celements-blog by celements.

the class BlogCacheTest method testGetCachedDocRefs_QueryException.

@Test
public void testGetCachedDocRefs_QueryException() throws Exception {
    WikiReference wikiRef = new WikiReference("wiki");
    SpaceReference spaceRef = new SpaceReference("blogSpace", wikiRef);
    expectXWQL(wikiRef, null);
    replayDefault();
    try {
        cache.getCachedDocRefs(spaceRef);
        fail("expecting CacheLoadingException");
    } catch (CacheLoadingException exc) {
    // expected
    }
    verifyDefault();
}
Also used : SpaceReference(org.xwiki.model.reference.SpaceReference) CacheLoadingException(com.celements.common.cache.CacheLoadingException) WikiReference(org.xwiki.model.reference.WikiReference) Test(org.junit.Test)

Example 99 with WikiReference

use of org.xwiki.model.reference.WikiReference in project celements-blog by celements.

the class BlogCacheTest method testGetCachedDocRefs_nullKey.

@Test
public void testGetCachedDocRefs_nullKey() throws Exception {
    WikiReference wikiRef = new WikiReference("wiki");
    DocumentReference docRef = new DocumentReference(wikiRef.getName(), "space", "blog");
    expectXWQL(wikiRef, Arrays.asList(docRef));
    expect(cache.blogService.getBlogSpaceRef(eq(docRef))).andReturn(null).once();
    replayDefault();
    assertEquals(ImmutableSet.of(), cache.getCachedDocRefs(wikiRef));
    verifyDefault();
}
Also used : WikiReference(org.xwiki.model.reference.WikiReference) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 100 with WikiReference

use of org.xwiki.model.reference.WikiReference in project celements-blog by celements.

the class BlogUpdateListenerTest method testGetRequiredObjClassRef.

@Test
public void testGetRequiredObjClassRef() {
    String wikiName = "myWiki";
    DocumentReference classRef = new DocumentReference(wikiName, BlogClasses.BLOG_CONFIG_CLASS_SPACE, BlogClasses.BLOG_CONFIG_CLASS_DOC);
    assertEquals(classRef, listener.getRequiredObjClassRef(new WikiReference(wikiName)));
}
Also used : WikiReference(org.xwiki.model.reference.WikiReference) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Aggregations

WikiReference (org.xwiki.model.reference.WikiReference)220 DocumentReference (org.xwiki.model.reference.DocumentReference)127 Test (org.junit.Test)106 SpaceReference (org.xwiki.model.reference.SpaceReference)58 XWikiContext (com.xpn.xwiki.XWikiContext)33 XWikiException (com.xpn.xwiki.XWikiException)24 EntityReference (org.xwiki.model.reference.EntityReference)24 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)23 ArrayList (java.util.ArrayList)19 AccessDeniedException (org.xwiki.security.authorization.AccessDeniedException)18 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)15 WikiDescriptor (org.xwiki.wiki.descriptor.WikiDescriptor)11 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)10 WikiManagerException (org.xwiki.wiki.manager.WikiManagerException)10 XWiki (com.xpn.xwiki.XWiki)9 BaseObject (com.xpn.xwiki.objects.BaseObject)9 ComponentManager (org.xwiki.component.manager.ComponentManager)9 Expectations (org.jmock.Expectations)8 Before (org.junit.Before)8 DefaultComponentDescriptor (org.xwiki.component.descriptor.DefaultComponentDescriptor)8