예제 #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));
 }
예제 #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));
 }
예제 #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));
 }
예제 #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));
 }
예제 #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);
 }
예제 #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));
 }
예제 #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);
 }
예제 #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);
 }
예제 #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);
 }
예제 #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);
 }
예제 #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);
 }
예제 #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);
 }
예제 #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);
 }
예제 #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));
 }
예제 #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);
 }
예제 #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);
 }
예제 #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);
 }
예제 #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);
 }
예제 #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);
 }
예제 #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));
 }
예제 #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());
   }
 }
예제 #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);
 }
예제 #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));
 }
예제 #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));
 }
예제 #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);
 }
예제 #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);
 }
예제 #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);
 }
예제 #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);
 }
예제 #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));
 }
예제 #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));
 }