Examples of DDMSVersion


Examples of buri.ddmsence.util.DDMSVersion

  }

  @Test
  public void testValidationErrors() throws InvalidDDMSException {
    for (String sVersion : getSupportedVersions()) {
      DDMSVersion version = DDMSVersion.setCurrentVersion(sVersion);
     
      if (version.isAtLeast("3.0")) {
        // Missing excludeFromRollup
        Element element = Util.buildDDMSElement(Security.getName(version), null);
        SecurityAttributesTest.getFixture().addTo(element);
        getInstance(element, "The excludeFromRollup attribute");

        // Incorrect excludeFromRollup
        element = Util.buildDDMSElement(Security.getName(version), null);
        Util.addAttribute(element, PropertyReader.getPrefix("ism"), "excludeFromRollup",
          version.getIsmNamespace(), "false");
        getInstance(element, "The excludeFromRollup attribute");

        // Invalid excludeFromRollup
        element = Util.buildDDMSElement(Security.getName(version), null);
        Util.addAttribute(element, PropertyReader.getPrefix("ism"), "excludeFromRollup",
          version.getIsmNamespace(), "aardvark");
        getInstance(element, "The excludeFromRollup attribute");
      }
    }
  }
View Full Code Here

Examples of buri.ddmsence.util.DDMSVersion

  }
 
  @Test
  public void testValidationWarnings() throws InvalidDDMSException {
    for (String sVersion : getSupportedVersions()) {
      DDMSVersion version = DDMSVersion.setCurrentVersion(sVersion);
      boolean is41 = "4.1".equals(sVersion);
      Security component = getInstance(getValidElement(sVersion), SUCCESS);

      if (!is41) {
        // No warnings
        assertEquals(0, component.getValidationWarnings().size());
      }
      else {
        // 4.1 ism:externalNotice used
        assertEquals(1, component.getValidationWarnings().size());
        String text = "The ism:externalNotice attribute in this DDMS component";
        String locator = "ddms:security/ddms:noticeList/ism:Notice";
        assertWarningEquality(text, locator, component.getValidationWarnings().get(0));
      }

      if (is41) {
        // Nested warnings
        Element element = Util.buildDDMSElement(Security.getName(version), null);
        Util.addAttribute(element, PropertyReader.getPrefix("ism"), "excludeFromRollup",
          version.getIsmNamespace(), "true");
        Element accessElement = Util.buildElement(PropertyReader.getPrefix("ntk"), Access.getName(version),
          version.getNtkNamespace(), null);
        SecurityAttributesTest.getFixture().addTo(accessElement);
        element.appendChild(accessElement);
        SecurityAttributesTest.getFixture().addTo(element);
        component = getInstance(element, SUCCESS);
        assertEquals(1, component.getValidationWarnings().size());
View Full Code Here

Examples of buri.ddmsence.util.DDMSVersion

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

      // Base equality
      Security elementComponent = getInstance(getValidElement(sVersion), SUCCESS);
      Security builderComponent = new Security.Builder(elementComponent).commit();
      assertEquals(elementComponent, builderComponent);
      assertEquals(elementComponent.hashCode(), builderComponent.hashCode());

      // Different values in each field
      if (version.isAtLeast("4.0.1")) {
        Security.Builder builder = getBaseBuilder();
        builder.setAccess(null);
        assertFalse(elementComponent.equals(builder.commit()));
       
        builder = getBaseBuilder();
View Full Code Here

Examples of buri.ddmsence.util.DDMSVersion

  /**
   * Returns a fixture object for testing.
   */
  public static Element getFixtureElement() {
    try {
      DDMSVersion version = DDMSVersion.getCurrentVersion();

      Element element = Util.buildDDMSElement(NoticeList.getName(version), null);
      element.addNamespaceDeclaration(PropertyReader.getPrefix("ddms"), version.getNamespace());
      SecurityAttributesTest.getFixture().addTo(element);
      element.appendChild(NoticeTest.getFixtureElement());
      return (element);
    }
    catch (InvalidDDMSException e) {
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,
        NoticeList.getName(version));
      getInstance(getWrongNameElementFixture(), WRONG_NAME_MESSAGE);
    }
View Full Code Here

Examples of buri.ddmsence.util.DDMSVersion

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

      NoticeList component = getInstance(getFixtureElement(), SUCCESS);
      if (!version.isAtLeast("4.1")) {
        // No warnings
        assertEquals(0, component.getValidationWarnings().size());
      }
      else {
        // 4.1 ism:externalNotice used
View Full Code Here

Examples of buri.ddmsence.util.DDMSVersion

   * Returns a builder, pre-populated with base data from the XML sample.
   *
   * This builder can then be modified to test various conditions.
   */
  private GeographicIdentifier.Builder getBaseBuilder() {
    DDMSVersion version = DDMSVersion.getCurrentVersion();
    GeographicIdentifier component = getInstance(getValidElement(version.getVersion()), SUCCESS);
    return (new GeographicIdentifier.Builder(component));
  }
View Full Code Here

Examples of buri.ddmsence.util.DDMSVersion

      supportedXslt1Processors.add("com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl");
    supportedXslt1Processors.add("net.sf.saxon.TransformerFactoryImpl");
    for (String processor : supportedXslt1Processors) {
      PropertyReader.setProperty("xml.transform.TransformerFactory", processor);
      for (String sVersion : getSupportedVersions()) {
        DDMSVersion version = DDMSVersion.getVersionFor(sVersion);
        Resource resource = versionToResourceMap.get(sVersion);
        String ddmsNamespace = resource.getNamespace();
        String resourceName = Resource.getName(version);
        List<ValidationMessage> messages = resource.validateWithSchematron(new File("data/test/" + sVersion
          + "/testSchematronXslt1.sch"));
        assertEquals(version.isAtLeast("4.0.1") ? 3 : 2, messages.size());

        String text = "A DDMS Resource must have an unknownElement child.";
        String locator = "/*[local-name()='" + resourceName + "' and namespace-uri()='" + ddmsNamespace + "']";
        assertErrorEquality(text, locator, messages.get(0));

        int originalWarningIndex = version.isAtLeast("4.0.1") ? 2 : 1;

        text = "Members of the Uri family cannot be publishers.";
        locator = "/*[local-name()='" + resourceName + "' and namespace-uri()='" + ddmsNamespace + "']"
          + "/*[local-name()='publisher' and namespace-uri()='" + ddmsNamespace + "']" + "/*[local-name()='"
          + Person.getName(version) + "' and namespace-uri()='" + ddmsNamespace + "']"
          + "/*[local-name()='surname' and namespace-uri()='" + ddmsNamespace + "']";
        assertWarningEquality(text, locator, messages.get(originalWarningIndex));

        if (version.isAtLeast("4.0.1")) {
          text = "Members of the Uri family cannot be publishers.";
          locator = "/*[local-name()='" + resourceName + "' and namespace-uri()='" + ddmsNamespace + "']"
            + "/*[local-name()='metacardInfo' and namespace-uri()='" + ddmsNamespace + "']"
            + "/*[local-name()='publisher' and namespace-uri()='" + ddmsNamespace + "']"
            + "/*[local-name()='" + Person.getName(version) + "' and namespace-uri()='" + ddmsNamespace
View Full Code Here

Examples of buri.ddmsence.util.DDMSVersion

  public void testSchematronValidationXslt2() throws InvalidDDMSException, IOException, XSLException {
    String[] supportedXslt1Processors = new String[] { "net.sf.saxon.TransformerFactoryImpl" };
    for (String processor : supportedXslt1Processors) {
      PropertyReader.setProperty("xml.transform.TransformerFactory", processor);
      for (String sVersion : getSupportedVersions()) {
        DDMSVersion version = DDMSVersion.getVersionFor(sVersion);
       
        Resource resource = versionToResourceMap.get(sVersion);
        String ddmsNamespace = resource.getNamespace();
        String gmlNamespace = version.getGmlNamespace();
        String tspiNamespace = version.getTspiNamespace();
        List<ValidationMessage> messages = resource.validateWithSchematron(new File("data/test/" + sVersion
          + "/testSchematronXslt2.sch"));
        assertEquals(1, messages.size());

        String text = "The second coordinate in a gml:pos element must be 40.2 degrees.";
        String extent = version.isAtLeast("4.0.1") ? "" : "/*:GeospatialExtent[namespace-uri()='"
          + ddmsNamespace + "'][1]";
        String resourceName = Resource.getName(version);
        String pointNamespace = (!version.isAtLeast("5.0") ? gmlNamespace : tspiNamespace);
        String locator = "/*:" + resourceName + "[namespace-uri()='" + ddmsNamespace + "'][1]"
          + "/*:geospatialCoverage[namespace-uri()='" + ddmsNamespace + "'][1]" + extent
          + "/*:boundingGeometry[namespace-uri()='" + ddmsNamespace + "'][1]"
          + "/*:Point[namespace-uri()='" + pointNamespace + "'][1]" + "/*:pos[namespace-uri()='" + gmlNamespace + "'][1]";
        assertErrorEquality(text, locator, messages.get(0));
View Full Code Here

Examples of buri.ddmsence.util.DDMSVersion

   *
   * @param name the element name
   * @param includeAllFields true to include optional fields
   */
  public static Element getFixtureElement(String name, boolean includeAllFields) {
    DDMSVersion version = DDMSVersion.getCurrentVersion();
    Element element = Util.buildDDMSElement(name, null);
    element.addNamespaceDeclaration(PropertyReader.getPrefix("ddms"), version.getNamespace());
    if (includeAllFields) {
      Util.addDDMSChildElement(element, "description", TEST_DESCRIPTION);

      Element approximableElment = Util.buildDDMSElement("approximableDate", TEST_APPROXIMABLE_DATE);
      Util.addDDMSAttribute(approximableElment, "approximation", TEST_APPROXIMATION);
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.