Beispiel #1
0
 public void testGetResourceFile2() throws Exception {
   loadContentPackage1();
   // Bogus Element
   Element element =
       cpCore.getElementByIdentifier(cpCore.getRootManifestElement(), CP_Package1.ORG1_ID);
   assertNull("Resource File should not exist", cpCore.getResourceFile(element));
 }
Beispiel #2
0
 public void testIsReferencingElement1() throws Exception {
   loadContentPackage1();
   // Item - true
   Element element =
       cpCore.getElementByIdentifier(cpCore.getRootManifestElement(), CP_Package1.ITEM1_ID);
   assertTrue("Should be referencing element", cpCore.isReferencingElement(element));
 }
Beispiel #3
0
 public void testGetResourceFile3() throws Exception {
   loadContentPackage1();
   // %20
   Element element =
       cpCore.getElementByIdentifier(cpCore.getRootManifestElement(), CP_Package1.RESOURCE2_ID);
   assertNotNull("Resource File should exist", cpCore.getResourceFile(element));
 }
Beispiel #4
0
 public void testIsReferencingElement2() throws Exception {
   loadContentPackage1();
   // Organization - false
   Element element =
       cpCore.getElementByIdentifier(cpCore.getRootManifestElement(), CP_Package1.ORG1_ID);
   assertFalse("Should not be referencing element", cpCore.isReferencingElement(element));
 }
Beispiel #5
0
 public void testGetResourceElementByHREF4() throws Exception {
   loadContentPackage1();
   // Should be Null if not searching on Resources Element
   Element element =
       cpCore.getResourceElementByHREF("www.reload.ac.uk", cpCore.getRootManifestElement());
   assertNull("Element should be null", element);
 }
Beispiel #6
0
 public void testGetElementBase1() throws Exception {
   loadContentPackage1();
   Element element =
       cpCore.getElementByIdentifier(
           cpCore.getRootManifestElement(), CP_Package1.SUBMANIFEST_RESOURCE1_ID);
   assertEquals("ElementBase not correct", "submanifest1/", cpCore.getElementBase(element));
 }
Beispiel #7
0
 /**
  * Ensure Absolute URL gets "http://" prepended
  *
  * @throws Exception
  */
 public void testGetAbsoluteURL_WebLink() throws Exception {
   loadContentPackage1();
   Element element =
       cpCore.getElementByIdentifier(cpCore.getRootManifestElement(), CP_Package1.ITEM3_ID);
   String url = cpCore.getAbsoluteURL(element);
   assertEquals("Absolute URL not correct", "http://" + CP_Package1.ITEM3_HREF, url);
 }
Beispiel #8
0
 /**
  * Ensure Relative URL is OK with params appended
  *
  * @throws Exception
  */
 public void testGetRelativeURL_Local() throws Exception {
   loadContentPackage1();
   Element element =
       cpCore.getElementByIdentifier(cpCore.getRootManifestElement(), CP_Package1.ITEM1_ID);
   String url = cpCore.getRelativeURL(element);
   assertEquals("Relative URL not correct", CP_Package1.ITEM1_HREF_WITHPARAMS, url);
 }
Beispiel #9
0
 public void testGetFileElementByHREF3() throws Exception {
   loadContentPackage1();
   // Should be Null if not searching on Resource Element
   String href = "Another%20File.txt";
   Element element = cpCore.getFileElementByHREF(href, cpCore.getRootManifestElement());
   assertNull("Element should be null", element);
 }
Beispiel #10
0
 public void testGetElementHREF3() throws Exception {
   loadContentPackage1();
   // Backslash converted to forward
   Element element =
       cpCore.getElementByIdentifier(cpCore.getRootManifestElement(), CP_Package1.ITEM5_ID);
   String url = cpCore.getElementHREF(element);
   assertEquals("ElementHREF not correct", "bogus/backslash", url);
 }
Beispiel #11
0
 public void testGetElementHREF2() throws Exception {
   loadContentPackage1();
   // External
   Element element =
       cpCore.getElementByIdentifier(cpCore.getRootManifestElement(), CP_Package1.ITEM3_ID);
   String url = cpCore.getElementHREF(element);
   assertEquals("ElementHREF not correct", CP_Package1.ITEM3_HREF, url);
 }
Beispiel #12
0
 public void testGetElementHREF1() throws Exception {
   loadContentPackage1();
   // Local
   Element element =
       cpCore.getElementByIdentifier(cpCore.getRootManifestElement(), CP_Package1.ITEM1_ID);
   String url = cpCore.getElementHREF(element);
   assertEquals("ElementHREF not correct", "zappa/0-intro.html", url);
 }
Beispiel #13
0
 /**
  * Ensure Relative URL is OK with base attribute
  *
  * @throws Exception
  */
 public void testGetRelativeURL_Local_WithBaseAttribute() throws Exception {
   loadContentPackage1();
   Element element =
       cpCore.getElementByIdentifier(
           cpCore.getRootManifestElement(), CP_Package1.SUBMANIFEST_RESOURCE2_ID);
   String url = cpCore.getRelativeURL(element);
   assertEquals("Relative URL not correct", CP_Package1.SUBMANIFEST_RESOURCE2_HREF, url);
 }
Beispiel #14
0
 public void testIsReferencingElement3() throws Exception {
   loadContentPackage1();
   // Dependency Element - true
   Element element =
       cpCore.getElementByIdentifier(cpCore.getRootManifestElement(), CP_Package1.RESOURCE1_ID);
   element = element.getChild(CP_Core.DEPENDENCY, element.getNamespace());
   assertTrue("Should be referencing element", cpCore.isReferencingElement(element));
 }
Beispiel #15
0
 public void testGetReferencedElementsAllowed3() throws Exception {
   loadContentPackage1();
   // Organization - should be empty array
   Element element =
       cpCore.getElementByIdentifier(cpCore.getRootManifestElement(), CP_Package1.ORG1_ID);
   Element[] elements = cpCore.getReferencedElementsAllowed(element);
   assertEquals("Referenced Elements should be Empty", 0, elements.length);
 }
Beispiel #16
0
 public void testGetElementsInManifest4() throws Exception {
   loadContentPackage1();
   // Metadata
   Element[] elements =
       cpCore.getElementsInManifest(
           cpCore.getRootManifestElement(), MD_Core.ROOT_NAME, IMSMD_NAMESPACE_122);
   assertTrue("Metadata Elements should be found", elements.length > 0);
 }
Beispiel #17
0
 public void testGetResourceFiles2() throws Exception {
   loadContentPackage1();
   // Should be empty if using an Item
   Element element =
       cpCore.getElementByIdentifier(cpCore.getRootManifestElement(), CP_Package1.ITEM1_ID);
   File[] files = cpCore.getResourceFiles(element);
   assertEquals("File list should be empty", 0, files.length);
 }
Beispiel #18
0
 public void testGetReferencedElement3() throws Exception {
   loadContentPackage1();
   // Organization -> should not reference anything, should return null
   Element element =
       cpCore.getElementByIdentifier(cpCore.getRootManifestElement(), CP_Package1.ORG1_ID);
   Element refElement = cpCore.getReferencedElement(element);
   assertNull("Referenced Element should be null", refElement);
 }
Beispiel #19
0
 public void testGetElementHREF5() throws Exception {
   loadContentPackage1();
   // External with NO base attribute prefix
   Element element =
       cpCore.getElementByIdentifier(
           cpCore.getRootManifestElement(), CP_Package1.SUBMANIFEST_ITEM1_ID);
   String url = cpCore.getElementHREF(element);
   assertEquals("ElementHREF not correct", CP_Package1.SUBMANIFEST_RESOURCE1_HREF, url);
 }
Beispiel #20
0
 public void testGetElementByIdentifier2() throws Exception {
   loadContentPackage1();
   Element element =
       cpCore.getElementByIdentifier(cpCore.getRootManifestElement(), CP_Package1.ITEM2_ID);
   assertEquals(
       "Could not find Element by Identifier",
       CP_Package1.ITEM2_ID,
       element.getAttributeValue(CP_Core.IDENTIFIER));
 }
Beispiel #21
0
 public void testGetResourceFiles1() throws Exception {
   loadContentPackage1();
   // Should not be empty
   Element element = cpCore.getRootManifestElement();
   File[] files = cpCore.getResourceFiles(element);
   assertTrue("File list should not be empty", files.length > 0);
   for (int i = 0; i < files.length; i++) {
     assertTrue("File should exist", files[i].exists());
   }
 }
Beispiel #22
0
 public void testGetOrganizations2() throws Exception {
   loadContentPackage1();
   // False
   Element orgs_element =
       cpCore
           .getRootManifestElement()
           .getChild(CP_Core.RESOURCES, cpCore.getRootManifestElement().getNamespace());
   Element[] orgs = cpCore.getOrganizations(orgs_element);
   assertEquals("Organizations should be Empty", 0, orgs.length);
 }
Beispiel #23
0
 public void testGetFileElementByHREF2() throws Exception {
   loadContentPackage1();
   // %20
   Element resource =
       cpCore.getElementByIdentifier(cpCore.getRootManifestElement(), CP_Package1.RESOURCE2_ID);
   String href = "Another%20File.txt";
   Element element = cpCore.getFileElementByHREF(href, resource);
   assertEquals("Wrong File Element", CP_Core.FILE, element.getName());
   assertEquals("Wrong File Element", href, element.getAttributeValue(CP_Core.HREF));
 }
Beispiel #24
0
 public void testGetFileElementByHREF1() throws Exception {
   loadContentPackage1();
   // Normal
   Element resource =
       cpCore.getElementByIdentifier(cpCore.getRootManifestElement(), CP_Package1.RESOURCE1_ID);
   String href = "zappa/assets/bkgrd.jpg";
   Element element = cpCore.getFileElementByHREF(href, resource);
   assertEquals("Wrong File Element", CP_Core.FILE, element.getName());
   assertEquals("Wrong File Element", href, element.getAttributeValue(CP_Core.HREF));
 }
Beispiel #25
0
 public void testGetResourceElementByHREF3() throws Exception {
   loadContentPackage1();
   // URL
   Element resources = cpCore.getResourcesElement(cpCore.getRootManifestElement());
   Element element = cpCore.getResourceElementByHREF("www.reload.ac.uk", resources);
   assertEquals(
       "Wrong Resource Element",
       element.getAttributeValue(CP_Core.IDENTIFIER),
       CP_Package1.RESOURCE3_ID);
 }
Beispiel #26
0
 public void testGetResourceElementByHREF2() throws Exception {
   loadContentPackage1();
   // %20
   Element resources = cpCore.getResourcesElement(cpCore.getRootManifestElement());
   Element element = cpCore.getResourceElementByHREF("Another%20File.txt", resources);
   assertEquals(
       "Wrong Resource Element",
       element.getAttributeValue(CP_Core.IDENTIFIER),
       CP_Package1.RESOURCE2_ID);
 }
Beispiel #27
0
 public void testGetResourceElementByHREF1() throws Exception {
   loadContentPackage1();
   // Normal
   Element resources = cpCore.getResourcesElement(cpCore.getRootManifestElement());
   Element element = cpCore.getResourceElementByHREF("zappa/0-intro.html", resources);
   assertEquals(
       "Wrong Resource Element",
       element.getAttributeValue(CP_Core.IDENTIFIER),
       CP_Package1.RESOURCE1_ID);
 }
Beispiel #28
0
 public void testGetElementsInManifest3() throws Exception {
   loadContentPackage1();
   // Bogus
   Element[] elements =
       cpCore.getElementsInManifest(
           cpCore.getRootManifestElement(),
           "bogus",
           cpCore.getRootManifestElement().getNamespace());
   assertEquals("Elements should be Empty", 0, elements.length);
 }
Beispiel #29
0
 public void testGetResourcesElement1() throws Exception {
   loadContentPackage1();
   // Root manifest
   Element manifest = cpCore.getRootManifestElement();
   Element element = cpCore.getResourcesElement(manifest);
   assertEquals("Wrong Resources Element", CP_Core.RESOURCES, element.getName());
   assertEquals(
       "Wrong Resources Element",
       CP_Package1.MANIFEST1_ID,
       manifest.getAttributeValue(CP_Core.IDENTIFIER));
 }
Beispiel #30
0
 public void testGetReferencedElement2() throws Exception {
   loadContentPackage1();
   // Item -> sub-Manifest
   Element element =
       cpCore.getElementByIdentifier(cpCore.getRootManifestElement(), CP_Package1.ITEM4_ID);
   Element refElement = cpCore.getReferencedElement(element);
   assertEquals(
       "Could not get referenced Element",
       CP_Package1.SUB_MANIFEST1_ID,
       refElement.getAttributeValue(CP_Core.IDENTIFIER));
 }