Examples of DDMSVersion


Examples of buri.ddmsence.util.DDMSVersion

 
  /**
   * Returns the expected XML output for this unit test
   */
  private String getExpectedXMLOutput() {
    DDMSVersion version = DDMSVersion.getCurrentVersion();
    StringBuffer xml = new StringBuffer();
    xml.append("<ddms:link ").append(getXmlnsDDMS()).append(" ");
    xml.append("xmlns:xlink=\"").append(version.getXlinkNamespace()).append("\" ");
    xml.append("xlink:type=\"locator\" xlink:href=\"http://en.wikipedia.org/wiki/Tank\" ");
    xml.append("xlink:role=\"tank\" xlink:title=\"Tank Page\" xlink:label=\"tank\" />");
    return (xml.toString());
  }
View Full Code Here

Examples of buri.ddmsence.util.DDMSVersion

   * @param type the type
   * @param href the href
   * @return Element
   */
  private Element buildComponentElement(String type, String href) {
    DDMSVersion version = DDMSVersion.getCurrentVersion();
    Element element = Util.buildDDMSElement(Link.getName(version), null);
    String xlinkPrefix = PropertyReader.getPrefix("xlink");
    String xlinkNamespace = version.getXlinkNamespace();
    if (type != null)
      element.addAttribute(Util.buildAttribute(xlinkPrefix, "type", xlinkNamespace, type));
    if (href != null)
      element.addAttribute(Util.buildAttribute(xlinkPrefix, "href", xlinkNamespace, href));
    element.addAttribute(Util.buildAttribute(xlinkPrefix, "role", xlinkNamespace, TEST_ROLE));
View Full Code Here

Examples of buri.ddmsence.util.DDMSVersion

  }

  @Test
  public void testOutput() throws InvalidDDMSException {
    for (String sVersion : getSupportedVersions()) {
      DDMSVersion version = DDMSVersion.setCurrentVersion(sVersion);

      Resource elementComponent = getInstance(getValidElement(sVersion), SUCCESS);
      assertEquals(getExpectedHTMLTextOutput(OutputFormat.HTML), elementComponent.toHTML());
      assertEquals(getExpectedHTMLTextOutput(OutputFormat.TEXT), elementComponent.toText());
      assertEquals(getExpectedXMLOutput(), elementComponent.toXML());
      assertEquals(getExpectedJSONOutput(), elementComponent.toJSON());
      assertValidJSON(elementComponent.toJSON());

      if (!version.isAtLeast("5.0")) {
        // ExtensibleElements
        ExtensibleElement component = new ExtensibleElement(ExtensibleElementTest.getFixtureElement());
        Resource.Builder builder = getBaseBuilder();
        builder.getExtensibleElements().get(0).setXml(component.toXML());
        Resource builderComponent = builder.commit();
View Full Code Here

Examples of buri.ddmsence.util.DDMSVersion

  }

  @Test
  public void testRelatedResourcesMediation() throws InvalidDDMSException {
    for (String sVersion : getSupportedVersions()) {
      DDMSVersion version = DDMSVersion.setCurrentVersion(sVersion);
      createComponents();
      if (version.isAtLeast("4.0.1"))
        continue;

      Element element = getTestResourceMultipleRelated();
      Resource resource = getInstance(element, SUCCESS);
      assertEquals(4, resource.getRelatedResources().size());
View Full Code Here

Examples of buri.ddmsence.util.DDMSVersion

  }

  @Test
  public void testNameAndNamespace() throws InvalidDDMSException {
    for (String sVersion : getSupportedVersions()) {
      DDMSVersion version = DDMSVersion.setCurrentVersion(sVersion);

      assertNameAndNamespace(getInstance(getFixtureElement(), SUCCESS), DEFAULT_DDMS_PREFIX,
        Link.getName(version));
      getInstance(getWrongNameElementFixture(), WRONG_NAME_MESSAGE);
    }
View Full Code Here

Examples of buri.ddmsence.util.DDMSVersion

  }

  @Test
  public void testExtensibleAttributes() throws InvalidDDMSException {
    for (String sVersion : getSupportedVersions()) {
      DDMSVersion version = DDMSVersion.setCurrentVersion(sVersion);
      createComponents();

      // Extensible attribute added
      ExtensibleAttributes attr = ExtensibleAttributesTest.getFixture();
      if (!version.isAtLeast("5.0")) {
        Resource.Builder builder = getBaseBuilder();
        builder.setExtensibleAttributes(new ExtensibleAttributes.Builder(attr));
        getInstance(builder, SUCCESS);
      }
    }
View Full Code Here

Examples of buri.ddmsence.util.DDMSVersion

    }
  }

  @Test
  public void test20ExtensibleSizes() throws InvalidDDMSException {
    DDMSVersion version = DDMSVersion.setCurrentVersion("2.0");
    createComponents();
    String ismPrefix = PropertyReader.getPrefix("ism");

    // Base Case
    Resource component = new Resource(TEST_TOP_LEVEL_COMPONENTS, null);
    assertNull(component.getIsmDESVersion());
    assertTrue(component.getSecurityAttributes().isEmpty());
    assertEquals(0, component.getExtensibleAttributes().getAttributes().size());

    // ism:DESVersion in element
    Element element = getTestResourceNoHeader();
    Util.addAttribute(element, ismPrefix, Resource.DES_VERSION_NAME, version.getIsmNamespace(),
      String.valueOf(getTestIsmDesVersion()));
    component = new Resource(element);
    assertEquals(getTestIsmDesVersion(), component.getIsmDESVersion());
    assertTrue(component.getSecurityAttributes().isEmpty());
    assertEquals(0, component.getExtensibleAttributes().getAttributes().size());

    // ism:classification in element
    element = getTestResourceNoHeader();
    Util.addAttribute(element, ismPrefix, SecurityAttributes.CLASSIFICATION_NAME, version.getIsmNamespace(), "U");
    component = new Resource(element);
    assertFalse(component.getSecurityAttributes().isEmpty());
    assertEquals(0, component.getExtensibleAttributes().getAttributes().size());

    // ddmsence:confidence in element
    element = getTestResourceNoHeader();
    Util.addAttribute(element, "ddmsence", "confidence", "http://ddmsence.urizone.net/", "95");
    component = new Resource(element);
    assertTrue(component.getSecurityAttributes().isEmpty());
    assertEquals(1, component.getExtensibleAttributes().getAttributes().size());

    // This can be a parameter or an extensible.
    Attribute icAttribute = new Attribute("ism:DESVersion", version.getIsmNamespace(), "2");
    // This can be a securityAttribute or an extensible.
    Attribute secAttribute = new Attribute("ism:classification", version.getIsmNamespace(), "U");
    // This can be an extensible.
    Attribute uniqueAttribute = new Attribute("ddmsence:confidence", "http://ddmsence.urizone.net/", "95");
    List<Attribute> exAttr = new ArrayList<Attribute>();

    // icAttribute as parameter, uniqueAttribute as extensibleAttribute
View Full Code Here

Examples of buri.ddmsence.util.DDMSVersion

  /**
   * Returns a fixture object for testing.
   */
  public static NoticeAttributes getFixture() {
    try {
      DDMSVersion version = DDMSVersion.getCurrentVersion();
      Boolean externalNotice = version.isAtLeast("4.1") ? Boolean.FALSE : null;
      return (new NoticeAttributes(TEST_NOTICE_TYPE, TEST_NOTICE_REASON, TEST_NOTICE_DATE,
        TEST_UNREGISTERED_NOTICE_TYPE, externalNotice));
    }
    catch (InvalidDDMSException e) {
      fail("Could not create fixture: " + e.getMessage());
View Full Code Here

Examples of buri.ddmsence.util.DDMSVersion

  }

  @Test
  public void testConstructors() throws InvalidDDMSException {
    for (String sVersion : getSupportedVersions()) {
      DDMSVersion version = DDMSVersion.setCurrentVersion(sVersion);

      // Element-based
      Element element = Util.buildDDMSElement(Resource.getName(version), null);
      getFixture().addTo(element);
      getInstance(element, SUCCESS);
View Full Code Here

Examples of buri.ddmsence.util.DDMSVersion

  }

  @Test
  public void testConstructorsMinimal() throws InvalidDDMSException {
    for (String sVersion : getSupportedVersions()) {
      DDMSVersion version = DDMSVersion.setCurrentVersion(sVersion);

      // Element-based, no optional fields
      Element element = Util.buildDDMSElement(Resource.getName(version), null);
      NoticeAttributes elementAttributes = getInstance(element, SUCCESS);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.