Author: desruisseaux Date: Tue Apr 10 14:00:35 2018 New Revision: 1828821 URL: http://svn.apache.org/viewvc?rev=1828821&view=rev Log: Set dummy values in the metadata tests. Actually this complete the modifications accidentally committed earlier today.
Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/MarshallingTest.java Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/MarshallingTest.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/MarshallingTest.java?rev=1828821&r1=1828820&r2=1828821&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/MarshallingTest.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/MarshallingTest.java [UTF-8] Tue Apr 10 14:00:35 2018 @@ -24,6 +24,7 @@ import java.util.Collection; import java.util.Collections; import java.util.LinkedHashMap; import java.util.logging.LogRecord; +import java.util.MissingResourceException; import java.net.URI; import java.net.URISyntaxException; import java.io.StringWriter; @@ -59,6 +60,7 @@ import org.apache.sis.xml.MarshallerPool import org.apache.sis.internal.jaxb.gcx.Anchor; import org.apache.sis.internal.jaxb.metadata.replace.ReferenceSystemMetadata; import org.apache.sis.test.XMLTestCase; +import org.apache.sis.util.iso.Names; import org.junit.Test; import static org.junit.Assert.*; @@ -94,6 +96,11 @@ public final class MarshallingTest exten private final StringWriter output; /** + * {@code true} if marshalling legacy XML instead than latest schema. + */ + private boolean legacyXML; + + /** * Initializes a new test case. * * @throws JAXBException if an error occurred while preparing the marshaller. @@ -110,28 +117,28 @@ public final class MarshallingTest exten * Creates a metadata object to marshal. */ @SuppressWarnings("deprecation") - private DefaultMetadata metadata() throws URISyntaxException { + private static DefaultMetadata metadata() throws URISyntaxException { /* * Metadata - * ├─Metadata identifier…… dummy-metadata - * │ └─Code space………………… sis.test + * ├─Metadata identifier…… a-metadata-identifier + * │ └─Code space………………… md.id.ns * ├─Parent metadata……………… A parent metadata - * │ └─Identifier………………… dummy-parent-metadata - * │ └─Code space……… sis.test + * │ └─Identifier………………… a-parent-identifier + * │ └─Code space……… pmd.id.ns * ├─Language (1 de 2)………… English * ├─Language (2 de 2)………… French (Canada) * ├─Character set…………………… ISO-8859-1 * └─Metadata scope * ├─Resource scope……… Dataset - * └─Name………………………………… Metadata for an (imaginary) data set + * └─Name………………………………… Metadata for an imaginary data set * * Some code are indented for readability and more local variable scopes. */ final DefaultMetadata md = new DefaultMetadata(); { // Metadata identifier - final DefaultIdentifier id = new DefaultIdentifier("dummy-metadata"); - id.setCodeSpace("sis.test"); + final DefaultIdentifier id = new DefaultIdentifier("a-metadata-identifier"); + id.setCodeSpace("md.id.ns"); md.setMetadataIdentifier(id); } // Languages — one language only, and one (country, language) tupple. @@ -144,13 +151,13 @@ public final class MarshallingTest exten { // Parent metadata final DefaultCitation parent = new DefaultCitation("A parent metadata"); - final DefaultIdentifier parentId = new DefaultIdentifier("dummy-parent-metadata"); - parentId.setCodeSpace("sis.test"); + final DefaultIdentifier parentId = new DefaultIdentifier("a-parent-identifier"); + parentId.setCodeSpace("pmd.id.ns"); parent.getIdentifiers().add(parentId); md.setParentMetadata(parent); } // mdb:metadataScope (hierarchyLevel and hierarchyLevelName in legacy ISO 19115:2003 model) - md.getMetadataScopes().add(new DefaultMetadataScope(ScopeCode.DATASET, "Metadata for an (imaginary) data set")); + md.getMetadataScopes().add(new DefaultMetadataScope(ScopeCode.DATASET, "Metadata for an imaginary data set")); final DefaultOnlineResource onlineResource; { /* @@ -165,22 +172,22 @@ public final class MarshallingTest exten * │ │ ├─Number………………………………………………… 555-555-5555 * │ │ └─Number type…………………………………… Facsimile * │ ├─Address - * │ │ ├─Delivery point…………………………… At the desk + * │ │ ├─Delivery point…………………………… 123 Main Street * │ │ ├─City……………………………………………………… Metropolis city - * │ │ ├─Administrative area……………… Utopia area + * │ │ ├─Administrative area……………… Utopia province * │ │ ├─Postal code…………………………………… A1A 2C2 * │ │ ├─Country……………………………………………… Atlantis island * │ │ └─Electronic mail address…… t...@example.com * │ ├─Online resource * │ │ ├─Linkage……………………………………………… http://example.com - * │ │ ├─Protocol…………………………………………… Hyper-text - * │ │ ├─Application profile……………… Test only + * │ │ ├─Protocol…………………………………………… Submarine HTTP + * │ │ ├─Application profile……………… Imaginary work * │ │ ├─Name……………………………………………………… Timaeus & Critias * │ │ ├─Description…………………………………… A dialog between philosophers. * │ │ └─Function…………………………………………… Search * │ ├─Hours of service………………………………… Weekdays 9:00 AM - 5:00 PM - * │ ├─Contact instructions……………………… Knock at the door - * │ └─Contact type…………………………………………… Imaginary + * │ ├─Contact instructions……………………… Through thought + * │ └─Contact type…………………………………………… Virtual * └─Individual…………………………………………………………… Socrates * └─Position name………………………………………… Philosopher */ @@ -191,10 +198,10 @@ public final class MarshallingTest exten { // Address information final DefaultAddress address = new DefaultAddress(); - address.setDeliveryPoints(Collections.singleton(new SimpleInternationalString("At the desk"))); + address.setDeliveryPoints(Collections.singleton(new SimpleInternationalString("123 Main Street"))); address.getElectronicMailAddresses().add("t...@example.com"); address.setCity(new SimpleInternationalString("Metropolis city")); - address.setAdministrativeArea(new SimpleInternationalString("Utopia area")); + address.setAdministrativeArea(new SimpleInternationalString("Utopia province")); address.setPostalCode("A1A 2C2"); address.setCountry(new SimpleInternationalString("Atlantis island")); contact.getAddresses().add(address); @@ -207,12 +214,12 @@ public final class MarshallingTest exten onlineResource.setName(new SimpleInternationalString("Timaeus & Critias")); onlineResource.setDescription(description); onlineResource.setProtocol("Submarine HTTP"); - onlineResource.setApplicationProfile("Test only"); + onlineResource.setApplicationProfile("Imaginary work"); onlineResource.setFunction(OnLineFunction.SEARCH); contact.getOnlineResources().add(onlineResource); contact.setHoursOfService(Collections.singleton(new SimpleInternationalString("Weekdays 9:00 AM - 5:00 PM"))); - contact.setContactInstructions(new SimpleInternationalString("Knock at the door")); - contact.setContactType(new SimpleInternationalString("Imaginary")); + contact.setContactInstructions(new SimpleInternationalString("Through thought")); + contact.setContactType(new SimpleInternationalString("Virtual")); } // Create some individuals final DefaultIndividual individual = new DefaultIndividual("Socrates", "Philosopher", null); @@ -232,9 +239,7 @@ public final class MarshallingTest exten } { /* - * Spatial Representation Info - * - * Georectified + * Spatial representation info : Georectified * ├─Number of dimensions………………………………………………… 2 * ├─Axis dimension properties (1 de 2)…………… Row * │ ├─Dimension size……………………………………………………… 7 777 @@ -249,11 +254,11 @@ public final class MarshallingTest exten */ final DefaultGeorectified georectified = new DefaultGeorectified(); georectified.setNumberOfDimensions(2); - final DefaultDimension dim1 = new DefaultDimension(DimensionNameType.ROW, 7777); - final DefaultDimension dim2 = new DefaultDimension(DimensionNameType.COLUMN, 2233); - dim1.setResolution(10.0); - dim2.setResolution( 5.0); - georectified.setAxisDimensionProperties(Arrays.asList(dim1, dim2)); + final DefaultDimension rows = new DefaultDimension(DimensionNameType.ROW, 7777); + final DefaultDimension cols = new DefaultDimension(DimensionNameType.COLUMN, 2233); + rows.setResolution(10.0); + cols.setResolution( 5.0); + georectified.setAxisDimensionProperties(Arrays.asList(rows, cols)); georectified.setCellGeometry(CellGeometry.AREA); georectified.setPointInPixel(PixelOrientation.UPPER_RIGHT); md.getSpatialRepresentationInfo().add(georectified); @@ -272,33 +277,48 @@ public final class MarshallingTest exten // Identifier final DefaultIdentifier id = new DefaultIdentifier("AG9000"); id.setAuthority(cit); - id.setCodeSpace("sis.test"); + id.setCodeSpace("rs.id.ns"); id.setVersion("1.0"); id.setDescription(new SimpleInternationalString("An imaginary reference system.")); refSystem.setName(id); md.getReferenceSystemInfo().add(refSystem); } { - // Metadata extension information. + /* + * Extended element information…… ExtendedElementName + * ├─Parent entity………………………………… VirtualObject + * ├─Definition………………………………………… An extended element not included in the standard. + * ├─Obligation………………………………………… Conditional + * ├─Condition…………………………………………… Presents in “Imaginary work” profile. + * ├─Data type…………………………………………… Meta class + * ├─Maximum occurrence…………………… 3 + * ├─Domain value…………………………………… Alpha, beta or gamma. + * ├─Rule………………………………………………………… Element exists in cited resource. + * └─Rationale…………………………………………… For testing extended elements. + */ final DefaultMetadataExtensionInformation extension = new DefaultMetadataExtensionInformation(); extension.setExtensionOnLineResource(onlineResource); final DefaultExtendedElementInformation elementInfo = new DefaultExtendedElementInformation(); - elementInfo.setName("extendedElementInfoName"); - elementInfo.setDefinition(new SimpleInternationalString("definition")); - elementInfo.setObligation(Obligation.MANDATORY); - elementInfo.setCondition(new SimpleInternationalString("condition")); + elementInfo.setName("ExtendedElementName"); + elementInfo.setDefinition(new SimpleInternationalString("An extended element not included in the standard.")); + elementInfo.setObligation(Obligation.CONDITIONAL); + elementInfo.setCondition(new SimpleInternationalString("Presents in “Imaginary work” profile.")); elementInfo.setDataType(Datatype.META_CLASS); - elementInfo.setMaximumOccurrence(1); - elementInfo.setDomainValue(new SimpleInternationalString("domainValue")); - elementInfo.setShortName("shortName"); + elementInfo.setMaximumOccurrence(3); + elementInfo.setDomainValue(new SimpleInternationalString("Alpha, beta or gamma.")); + elementInfo.setShortName("ExtEltName"); elementInfo.setDomainCode(1234); - elementInfo.setParentEntity(Collections.singleton("parentEntity")); - elementInfo.setRule(new SimpleInternationalString("rule")); - elementInfo.setRationale(new SimpleInternationalString("rationale")); + elementInfo.setParentEntity(Collections.singleton("VirtualObject")); + elementInfo.setRule(new SimpleInternationalString("Element exists in cited resource.")); + elementInfo.setRationale(new SimpleInternationalString("For testing extended elements.")); extension.getExtendedElementInformation().add(elementInfo); md.getMetadataExtensionInfo().add(extension); } - // Data identification info + /* + * Data identification info + * ├─Abstract………………… Méta-données pour une carte imaginaire. + * └─Purpose…………………… For XML (un)marshalling tests. + */ final DefaultDataIdentification dataId = new DefaultDataIdentification(); { final DefaultInternationalString description = new DefaultInternationalString(); @@ -309,31 +329,49 @@ public final class MarshallingTest exten } final Collection<Extent> extents; { - // Extents + /* + * Extent……………………………………………………………… Azores + * ├─Geographic element + * │ ├─West bound longitude…… 24°30′W + * │ ├─East bound longitude…… 32°W + * │ ├─South bound latitude…… 36°45′N + * │ ├─North bound latitude…… 40°N + * │ └─Extent type code……………… true + * └─Temporal element + */ final DefaultExtent extent = new DefaultExtent(); extent.setDescription(new SimpleInternationalString("Azores")); { - // Bounding box - final DefaultGeographicBoundingBox boundingBox = new DefaultGeographicBoundingBox(); - boundingBox.setInclusion(true); - boundingBox.setNorthBoundLatitude( 39); - boundingBox.setEastBoundLongitude(-28); - boundingBox.setSouthBoundLatitude( 35); - boundingBox.setWestBoundLongitude(-22); - extent.getGeographicElements().add(boundingBox); + final DefaultGeographicBoundingBox bbox = new DefaultGeographicBoundingBox(); + bbox.setInclusion(true); + bbox.setNorthBoundLatitude( 40.00); + bbox.setEastBoundLongitude(-32.00); + bbox.setSouthBoundLatitude( 36.75); + bbox.setWestBoundLongitude(-24.50); + extent.getGeographicElements().add(bbox); } - final DefaultTemporalExtent tempExtent = new DefaultTemporalExtent(); - extent.getTemporalElements().add(tempExtent); + final DefaultTemporalExtent temporal = new DefaultTemporalExtent(); + extent.getTemporalElements().add(temporal); extents = Collections.singleton(extent); dataId.setExtents(extents); } - // Resource constraints final Collection<Constraints> resourceConstraints; - final Collection<Citation> emptyCitations = Collections.singleton(new DefaultCitation()); { - DefaultConstraints constraint = new DefaultConstraints(); - constraint.getResponsibleParties().add(new DefaultResponsibility()); - constraint.setReferences(emptyCitations); + /* + * Constraints + * ├─Use limitation…………………………………… Not for navigation. + * ├─Constraint application scope + * │ └─Level………………………………………………… Document + * ├─Graphic + * │ ├─File name……………………………………… ocean.png + * │ ├─File description…………………… Somewhere in the Atlantic ocean + * │ ├─File type……………………………………… PNG image + * │ ├─Linkage + * │ └─Image constraints + * └─Releasability + * └─Statement……………………………………… Public domain + */ + final DefaultConstraints constraint = new DefaultConstraints(); final DefaultBrowseGraphic graphic = new DefaultBrowseGraphic(new URI("ocean.png")); graphic.setFileDescription(new SimpleInternationalString("Somewhere in the Atlantic ocean")); graphic.setFileType("PNG image"); @@ -350,9 +388,6 @@ public final class MarshallingTest exten resourceConstraints = Collections.singleton(constraint); dataId.setResourceConstraints(resourceConstraints); } - // Points of contact - final Collection<Responsibility> pocs = Collections.singleton(new DefaultResponsibility()); - dataId.setPointOfContacts(pocs); dataId.getSpatialRepresentationTypes().add(SpatialRepresentationType.GRID); { // Spatial resolution @@ -362,8 +397,15 @@ public final class MarshallingTest exten } dataId.setTopicCategories(Arrays.asList(TopicCategory.OCEANS, TopicCategory.SOCIETY)); dataId.getStatus().add(Progress.HISTORICAL_ARCHIVE); - - // Citation + /* + * Citation………………………………………………………… A lost island + * ├─Alternate title (1 de 2)…… Island lost again + * ├─Alternate title (2 de 2)…… Map example + * ├─Date………………………………………………………… 2018-04-09 00:00:00 + * │ └─Date type………………………………… Création + * ├─Edition………………………………………………… First edition + * └─Edition date…………………………………… 2018-04-10 00:00:00 + */ final DefaultCitation cit = new DefaultCitation(); cit.setTitle(new SimpleInternationalString("A lost island")); cit.setEdition(new SimpleInternationalString("First edition")); @@ -376,7 +418,16 @@ public final class MarshallingTest exten dataId.setTemporalResolutions(Collections.emptySet()); // TODO: depends on sis-temporal final Collection<MaintenanceInformation> resourceMaintenances; { - // Resource maintenance + /* + * Maintenance information + * ├─Maintenance and update frequency…… Not planned + * ├─Maintenance date……………………………………………… 3000-01-01 00:00:00 + * │ └─Date type……………………………………………………… Révision + * └─Maintenance scope + * ├─Level………………………………………………………………… Model + * └─Level description + * └─Dataset………………………………………………… Imaginary map + */ DefaultMaintenanceInformation maintenanceInfo = new DefaultMaintenanceInformation(); maintenanceInfo.setMaintenanceAndUpdateFrequency(MaintenanceFrequency.NOT_PLANNED); maintenanceInfo.getMaintenanceDates().add(new DefaultCitationDate(new Date(32503676400000L), DateType.REVISION)); @@ -393,48 +444,61 @@ public final class MarshallingTest exten dataId.setResourceMaintenances(resourceMaintenances); } { - // Resource format (MD_Format) + /* + * Format + * ├─Format specification citation…… Portable Network Graphics + * │ ├─Alternate title……………………………… PNG + * │ └─Edition…………………………………………………… November 2003 + * ├─Amendment number……………………………………… Second edition + * └─File decompression technique……… L77 / Huffman coding + */ final DefaultFormat resourceFormat = new DefaultFormat(); - resourceFormat.setName(new SimpleInternationalString("name")); - resourceFormat.setAmendmentNumber(new SimpleInternationalString("amendmentNumber")); - resourceFormat.setVersion(new SimpleInternationalString("version")); - resourceFormat.setSpecification(new SimpleInternationalString("specification")); - resourceFormat.setFileDecompressionTechnique(new SimpleInternationalString("decompressionTechnique")); + resourceFormat.setName(new SimpleInternationalString("PNG")); + resourceFormat.setSpecification(new SimpleInternationalString("Portable Network Graphics")); + resourceFormat.setAmendmentNumber(new SimpleInternationalString("Second edition")); + resourceFormat.setVersion(new SimpleInternationalString("November 2003")); + resourceFormat.setFileDecompressionTechnique(new SimpleInternationalString("L77 / Huffman coding")); dataId.getResourceFormats().add(resourceFormat); } final Collection<Keywords> descriptiveKeywords; { - // Descriptive keywords (MD_Keywords) + /* + * Keywords + * ├─Thesaurus name………… Plato's dialogues + * ├─Keyword class…………… Greek elements + * ├─Keyword (1 de 2)…… Water + * ├─Keyword (2 de 2)…… Aether + * └─Type…………………………………… Theme + */ final DefaultKeywords keywords = new DefaultKeywords(); keywords.setType(KeywordType.THEME); - keywords.setThesaurusName(new DefaultCitation()); + keywords.setThesaurusName(new DefaultCitation("Plato's dialogues")); final DefaultKeywordClass keywordClass = new DefaultKeywordClass(); - keywordClass.setClassName(new SimpleInternationalString("name")); + keywordClass.setClassName(new SimpleInternationalString("Greek elements")); keywords.setKeywordClass(keywordClass); - keywords.setKeywords(Arrays.asList(new SimpleInternationalString("keyword1"), - new SimpleInternationalString("keyword2"))); + keywords.setKeywords(Arrays.asList(new SimpleInternationalString("Water"), + new SimpleInternationalString("Aether"))); descriptiveKeywords = Collections.singleton(keywords); dataId.setDescriptiveKeywords(descriptiveKeywords); } { - // Resource specific usage + /* + * Usage………………………………………………………………………… For testing purpose only. + * ├─Usage date time…………………………………… 2018-04-10 14:00:00 + * ├─User determined limitations…… Not to be used outside MarshallingTest.java test file. + * └─Response……………………………………………………… Random elements + */ final DefaultUsage usage = new DefaultUsage(); - usage.setSpecificUsage(new SimpleInternationalString("specificUsage")); - usage.setUsageDate(new Date()); - usage.setResponses(Collections.singleton(new SimpleInternationalString("response"))); - usage.setAdditionalDocumentation(emptyCitations); - usage.setIdentifiedIssues(emptyCitations); - usage.setUserDeterminedLimitations(new SimpleInternationalString("userDeterminedLimitations")); - final DefaultResponsibility resp = new DefaultResponsibility(); - usage.getUserContactInfo().add(resp); + usage.setSpecificUsage(new SimpleInternationalString("For testing purpose only.")); + usage.setUsageDate(new Date(1523361600000L)); + usage.setResponses(Collections.singleton(new SimpleInternationalString("Random elements"))); + usage.setUserDeterminedLimitations(new SimpleInternationalString("Not to be used outside MarshallingTest.java test file.")); dataId.getResourceSpecificUsages().add(usage); } final Collection<AssociatedResource> associatedResources; { // Associated resources (AggregationInfo in 19139) final DefaultAssociatedResource associatedResource = new DefaultAssociatedResource(); - DefaultCitation associatedResourceCitation = new DefaultCitation(); - associatedResource.setName(associatedResourceCitation); associatedResource.setAssociationType(AssociationType.DEPENDENCY); associatedResource.setInitiativeType(InitiativeType.EXPERIMENT); associatedResources = Collections.singleton(associatedResource); @@ -442,32 +506,29 @@ public final class MarshallingTest exten } dataId.setLanguages(languages); // Locales (ISO 19115:2014) a.k.a Languages and CharacterSets (ISO 19115:2003) dataId.setCharacterSets(charSets); - dataId.setEnvironmentDescription (new SimpleInternationalString("environmentDescription")); - dataId.setSupplementalInformation(new SimpleInternationalString("supplementalInformation")); + dataId.setEnvironmentDescription (new SimpleInternationalString("High humidity.")); + dataId.setSupplementalInformation(new SimpleInternationalString("High water pressure.")); { // Service identification info final DefaultServiceIdentification serviceId = new DefaultServiceIdentification(); serviceId.setCitation(cit); - serviceId.setAbstract(new SimpleInternationalString("abstract")); - serviceId.setPointOfContacts(pocs); + serviceId.setAbstract(new SimpleInternationalString("An inspiration for story tellers.")); serviceId.setExtents(extents); serviceId.setResourceMaintenances(resourceMaintenances); serviceId.setDescriptiveKeywords(descriptiveKeywords); serviceId.setResourceConstraints(resourceConstraints); serviceId.setAssociatedResources(associatedResources); - serviceId.setServiceTypeVersions(Collections.singleton("serviceTypeVersion")); + serviceId.setServiceTypeVersions(Collections.singleton("Version 1000+")); // TODO: Coupled resources final DefaultCoupledResource coupledResource = new DefaultCoupledResource(); serviceId.getCoupledResources().add(coupledResource); - serviceId.setCouplingType(CouplingType.TIGHT); + serviceId.setCouplingType(CouplingType.LOOSE); final DefaultOperationMetadata operationMetadata = new DefaultOperationMetadata(); { - operationMetadata.setOperationName("operationName"); - operationMetadata.setOperationDescription(new SimpleInternationalString("operationDescription")); - operationMetadata.setInvocationName(new SimpleInternationalString("invocationName")); + operationMetadata.setOperationName("Authoring"); + operationMetadata.setOperationDescription(new SimpleInternationalString("Write a book.")); + operationMetadata.setInvocationName(new SimpleInternationalString("someMethodName")); operationMetadata.getDistributedComputingPlatforms().add(DistributedComputingPlatform.JAVA); - operationMetadata.getConnectPoints().add(new DefaultOnlineResource()); - // Parameters are unchanged according to crosswalk. Don't need to do this one. } serviceId.getContainsOperations().add(operationMetadata); serviceId.getOperatesOn().add(dataId); @@ -479,35 +540,42 @@ public final class MarshallingTest exten { coverageDescription = new DefaultCoverageDescription(); // Attribute description - final DefaultRecordSchema schema = new DefaultRecordSchema(null, null, "MySchema"); + final DefaultRecordSchema schema = new DefaultRecordSchema(null, null, "IslandFeatures"); final Map<CharSequence,Class<?>> members = new LinkedHashMap<>(); members.put("city", String.class); members.put("latitude", Double.class); members.put("longitude", Double.class); - final RecordType recordType = schema.createRecordType("MyRecordType", members); + final RecordType recordType = schema.createRecordType("SettledArea", members); coverageDescription.setAttributeDescription(recordType); { - // Attribute group + /* + * Attribute group + * ├─Content type…………………… Auxilliary information + * ├─Attribute (1 de 2)…… 42 + * │ ├─Description…………… Population density + * │ └─Name + * └─Attribute (2 de 2) + * ├─Description…………… Temperature + * ├─Max value………………… 22,22 + * ├─Min value………………… 11,11 + * ├─Units…………………………… °C + * └─Scale factor………… 1,5 + */ final DefaultAttributeGroup attributeGroup = new DefaultAttributeGroup(); attributeGroup.getContentTypes().add(CoverageContentType.AUXILLARY_INFORMATION); // Attributes final DefaultRangeDimension rangeDimension = new DefaultRangeDimension(); - rangeDimension.setDescription(new SimpleInternationalString("descriptor")); - // TODO: Sequence identifier - /*DefaultMemberName memberName = DefaultNameFactory.createMemberName(NameSpace, CharSequence, TypeName); - rangeDimension.setSequenceIdentifier(memberName);*/ - // Names + rangeDimension.setDescription(new SimpleInternationalString("Population density")); + rangeDimension.setSequenceIdentifier(Names.createMemberName(null, null, "42", Integer.class)); rangeDimension.getNames().add(new DefaultIdentifier()); final DefaultSampleDimension sampleDimension = new DefaultSampleDimension(); - sampleDimension.setDescription(new SimpleInternationalString("descriptor")); + sampleDimension.setDescription(new SimpleInternationalString("Temperature")); sampleDimension.setMinValue(11.11); sampleDimension.setMaxValue(22.22); - sampleDimension.setUnits(Units.FAHRENHEIT); - sampleDimension.setScaleFactor(1.0); - final Collection<RangeDimension> rangeDimensions = Arrays.asList(rangeDimension, sampleDimension); - attributeGroup.setAttributes(rangeDimensions); - coverageDescription.setDimensions(rangeDimensions); - // coverageDescription.getAttributeGroups().add(attributeGroup); + sampleDimension.setUnits(Units.CELSIUS); + sampleDimension.setScaleFactor(1.5); + attributeGroup.setAttributes(Arrays.asList(rangeDimension, sampleDimension)); + coverageDescription.getAttributeGroups().add(attributeGroup); } } // Feature Catalogue Description @@ -530,6 +598,7 @@ public final class MarshallingTest exten */ @Test public void testLegacySchema() throws URISyntaxException, JAXBException { + legacyXML = true; final DefaultMetadata md = metadata(); marshaller.setProperty(XML.METADATA_VERSION, VERSION_2007); marshaller.marshal(md, output); @@ -571,17 +640,25 @@ public final class MarshallingTest exten } /** - * Invoked when a warning occurred while marshalling a test XML fragment. - * The only expected warning message is "Can't find resource for bundle - * {@code java.util.PropertyResourceBundle}, key {@code MD_DimensionNameTypeCode.row}". + * Invoked when a warning occurred while marshalling a test XML fragment. Expected warnings are + * "Can't find resource for bundle {@code java.util.PropertyResourceBundle}, key <cite>Foo</cite>". + * When marshalling legacy XML only, additional warnings may occur. * * @param source ignored. * @param warning the warning. */ @Override public void warningOccured(final Object source, final LogRecord warning) { + if (warning.getThrown() instanceof MissingResourceException) { + assertNull("Expected a warning message without parameters.", warning.getParameters()); + return; + } final String message = warning.getMessage(); - assertNotNull(message, message.contains("MD_DimensionNameTypeCode.row")); - assertNull("Expected a warning message without parameters.", warning.getParameters()); + if (legacyXML) { + assertEquals("IgnoredPropertiesAfterFirst_1", message); + assertArrayEquals(new String[] {"RangeDimension"}, warning.getParameters()); + } else { + fail("Unexpected logging message: " + message); + } } }