Author: desruisseaux
Date: Thu Feb 28 11:28:47 2013
New Revision: 1451174
URL: http://svn.apache.org/r1451174
Log:
Added test directory and first test case for metadata.
Implies little Maven and IDE configuration.
Added:
sis/branches/JDK7/sis-metadata/src/test/
sis/branches/JDK7/sis-metadata/src/test/java/
sis/branches/JDK7/sis-metadata/src/test/java/org/
sis/branches/JDK7/sis-metadata/src/test/java/org/apache/
sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/
sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/
sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyDescriptorTest.java
(with props)
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/simple/
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/simple/SimpleReferenceIdentifierTest.java
(with props)
Modified:
sis/branches/JDK7/ide-project/NetBeans/nbproject/build-impl.xml
sis/branches/JDK7/ide-project/NetBeans/nbproject/genfiles.properties
sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties
sis/branches/JDK7/ide-project/NetBeans/nbproject/project.xml
sis/branches/JDK7/sis-metadata/pom.xml
sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyDescriptor.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/measure/NumberRangeTest.java
Modified: sis/branches/JDK7/ide-project/NetBeans/nbproject/build-impl.xml
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/ide-project/NetBeans/nbproject/build-impl.xml?rev=1451174&r1=1451173&r2=1451174&view=diff
==============================================================================
--- sis/branches/JDK7/ide-project/NetBeans/nbproject/build-impl.xml (original)
+++ sis/branches/JDK7/ide-project/NetBeans/nbproject/build-impl.xml Thu Feb 28
11:28:47 2013
@@ -136,6 +136,7 @@ is divided into following sections:
<condition property="have.tests">
<or>
<available file="${test.referencing.dir}"/>
+ <available file="${test.metadata.dir}"/>
<available file="${test.utility.dir}"/>
</or>
</condition>
@@ -241,6 +242,7 @@ is divided into following sections:
<fail unless="src.metadata.dir">Must set src.metadata.dir</fail>
<fail unless="src.utility.dir">Must set src.utility.dir</fail>
<fail unless="test.referencing.dir">Must set
test.referencing.dir</fail>
+ <fail unless="test.metadata.dir">Must set test.metadata.dir</fail>
<fail unless="test.utility.dir">Must set test.utility.dir</fail>
<fail unless="build.dir">Must set build.dir</fail>
<fail unless="dist.dir">Must set dist.dir</fail>
@@ -424,6 +426,9 @@ is divided into following sections:
<fileset dir="${test.referencing.dir}"
excludes="@{excludes},${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
+ <fileset dir="${test.metadata.dir}"
excludes="@{excludes},${excludes}" includes="@{includes}">
+ <filename name="@{testincludes}"/>
+ </fileset>
<fileset dir="${test.utility.dir}"
excludes="@{excludes},${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
@@ -459,6 +464,9 @@ is divided into following sections:
<fileset dir="${test.referencing.dir}"
excludes="@{excludes},**/*.xml,${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
+ <fileset dir="${test.metadata.dir}"
excludes="@{excludes},**/*.xml,${excludes}" includes="@{includes}">
+ <filename name="@{testincludes}"/>
+ </fileset>
<fileset dir="${test.utility.dir}"
excludes="@{excludes},**/*.xml,${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
@@ -574,6 +582,9 @@ is divided into following sections:
<fileset dir="${test.referencing.dir}"
excludes="@{excludes},${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
+ <fileset dir="${test.metadata.dir}"
excludes="@{excludes},${excludes}" includes="@{includes}">
+ <filename name="@{testincludes}"/>
+ </fileset>
<fileset dir="${test.utility.dir}"
excludes="@{excludes},${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
@@ -1298,12 +1309,13 @@ is divided into following sections:
<!-- You can override this target in the ../build.xml file. -->
</target>
<target if="do.depend.true" name="-compile-test-depend">
- <j2seproject3:depend classpath="${javac.test.classpath}"
destdir="${build.test.classes.dir}"
srcdir="${test.referencing.dir}:${test.utility.dir}"/>
+ <j2seproject3:depend classpath="${javac.test.classpath}"
destdir="${build.test.classes.dir}"
srcdir="${test.referencing.dir}:${test.metadata.dir}:${test.utility.dir}"/>
</target>
<target
depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend"
if="have.tests" name="-do-compile-test">
- <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}"
classpath="${javac.test.classpath}" debug="true"
destdir="${build.test.classes.dir}" processorpath="${javac.test.processorpath}"
srcdir="${test.referencing.dir}:${test.utility.dir}"/>
+ <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}"
classpath="${javac.test.classpath}" debug="true"
destdir="${build.test.classes.dir}" processorpath="${javac.test.processorpath}"
srcdir="${test.referencing.dir}:${test.metadata.dir}:${test.utility.dir}"/>
<copy todir="${build.test.classes.dir}">
<fileset dir="${test.referencing.dir}"
excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+ <fileset dir="${test.metadata.dir}"
excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
<fileset dir="${test.utility.dir}"
excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
</copy>
</target>
@@ -1319,9 +1331,10 @@ is divided into following sections:
<target
depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test-single"
if="have.tests" name="-do-compile-test-single">
<fail unless="javac.includes">Must select some files in the IDE or set
javac.includes</fail>
<j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
- <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}"
classpath="${javac.test.classpath}" debug="true"
destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}"
processorpath="${javac.test.processorpath}"
sourcepath="${test.referencing.dir}:${test.utility.dir}"
srcdir="${test.referencing.dir}:${test.utility.dir}"/>
+ <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}"
classpath="${javac.test.classpath}" debug="true"
destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}"
processorpath="${javac.test.processorpath}"
sourcepath="${test.referencing.dir}:${test.metadata.dir}:${test.utility.dir}"
srcdir="${test.referencing.dir}:${test.metadata.dir}:${test.utility.dir}"/>
<copy todir="${build.test.classes.dir}">
<fileset dir="${test.referencing.dir}"
excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+ <fileset dir="${test.metadata.dir}"
excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
<fileset dir="${test.utility.dir}"
excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
</copy>
</target>
Modified: sis/branches/JDK7/ide-project/NetBeans/nbproject/genfiles.properties
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/ide-project/NetBeans/nbproject/genfiles.properties?rev=1451174&r1=1451173&r2=1451174&view=diff
==============================================================================
--- sis/branches/JDK7/ide-project/NetBeans/nbproject/genfiles.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK7/ide-project/NetBeans/nbproject/genfiles.properties
[ISO-8859-1] Thu Feb 28 11:28:47 2013
@@ -3,6 +3,6 @@
build.xml.data.CRC32=58e6b21c
build.xml.script.CRC32=462eaba0
[email protected]
-nbproject/build-impl.xml.data.CRC32=e8191a2a
-nbproject/build-impl.xml.script.CRC32=2ddb9051
+nbproject/build-impl.xml.data.CRC32=af14ca0b
+nbproject/build-impl.xml.script.CRC32=d26a4b87
nbproject/[email protected]
Modified: sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties?rev=1451174&r1=1451173&r2=1451174&view=diff
==============================================================================
--- sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties
[ISO-8859-1] Thu Feb 28 11:28:47 2013
@@ -7,6 +7,7 @@ application.vendor = Apache
application.homepage = http://sis.apache.org/
application.desc = Apache SIS is a toolkit for describing location
information, including points, bounding boxes, polygons, and for computing
distances on that information.
+file.reference.site-resources=../../../JDK6/sis-metadata/src/site/resources
#
# Some global configuration.
#
@@ -31,6 +32,7 @@ src.app.dir = ${project.root}/s
src.referencing.dir = ${project.root}/sis-referencing/src/main/java
test.referencing.dir = ${project.root}/sis-referencing/src/test/java
src.metadata.dir = ${project.root}/sis-metadata/src/main/java
+test.metadata.dir = ${project.root}/sis-metadata/src/test/java
src.utility.dir = ${project.root}/sis-utility/src/main/java
test.utility.dir = ${project.root}/sis-utility/src/test/java
Modified: sis/branches/JDK7/ide-project/NetBeans/nbproject/project.xml
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/ide-project/NetBeans/nbproject/project.xml?rev=1451174&r1=1451173&r2=1451174&view=diff
==============================================================================
--- sis/branches/JDK7/ide-project/NetBeans/nbproject/project.xml (original)
+++ sis/branches/JDK7/ide-project/NetBeans/nbproject/project.xml Thu Feb 28
11:28:47 2013
@@ -14,6 +14,7 @@
</source-roots>
<test-roots>
<root id="test.referencing.dir" name="Referencing tests"/>
+ <root id="test.metadata.dir" name="Metadata tests"/>
<root id="test.utility.dir" name="Utility tests"/>
</test-roots>
</data>
Modified: sis/branches/JDK7/sis-metadata/pom.xml
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/pom.xml?rev=1451174&r1=1451173&r2=1451174&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/pom.xml (original)
+++ sis/branches/JDK7/sis-metadata/pom.xml Thu Feb 28 11:28:47 2013
@@ -112,6 +112,15 @@ Implementations of metadata derived from
<groupId>org.opengis</groupId>
<artifactId>geoapi-conformance</artifactId>
</dependency>
+
+ <!-- Test dependencies -->
+ <dependency>
+ <groupId>org.apache.sis</groupId>
+ <artifactId>sis-utility</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
Modified:
sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyDescriptor.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyDescriptor.java?rev=1451174&r1=1451173&r2=1451174&view=diff
==============================================================================
---
sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyDescriptor.java
[UTF-8] (original)
+++
sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyDescriptor.java
[UTF-8] Thu Feb 28 11:28:47 2013
@@ -19,6 +19,7 @@ package org.apache.sis.metadata;
import java.util.Set;
import java.util.Collection;
import java.util.Collections;
+import java.util.Locale;
import java.lang.reflect.Method;
import net.jcip.annotations.Immutable;
import javax.measure.unit.Unit;
@@ -29,9 +30,11 @@ import org.opengis.metadata.citation.Cit
import org.opengis.parameter.ParameterValue;
import org.opengis.parameter.ParameterDescriptor;
import org.opengis.referencing.ReferenceIdentifier;
+import org.apache.sis.internal.simple.SimpleReferenceIdentifier;
+import org.apache.sis.util.iso.AbstractInternationalString;
import org.apache.sis.measure.NumberRange;
import org.apache.sis.measure.ValueRange;
-import org.apache.sis.internal.simple.SimpleReferenceIdentifier;
+import org.apache.sis.util.iso.Types;
// Related to JDK7
import java.util.Objects;
@@ -62,11 +65,11 @@ class PropertyDescriptor<T> extends Simp
private static final long serialVersionUID = 888961503200860655L;
/**
- * ISO name of the interface which contain this property.
+ * The interface which contain this property.
*
* @see #getCodeSpace()
*/
- private final String container;
+ final Class<?> container;
/**
* The value type, either the method return type if not a collection,
@@ -108,10 +111,10 @@ class PropertyDescriptor<T> extends Simp
private final NumberRange<T> range;
/** Creates a new descriptor for the given range of values. */
- Bounded(final String container, final Class<T> type, final Citation
standard,
+ Bounded(final Class<T> type, final Citation standard,
final String property, final Method getter, final ValueRange
range)
{
- super(container, type, standard, property, getter);
+ super(type, standard, property, getter);
this.range = new NumberRange<>(type, range);
}
@@ -141,7 +144,6 @@ class PropertyDescriptor<T> extends Simp
* Creates a new {@code PropertyDescriptor} instance from the annotations
on the given
* getter method. If there is no restriction, then this method returns
{@code null}.
*
- * @param container ISO name of the interface which contain this
property.
* @param elementType The value type, either the method return type if
not a collection,
* or the type of elements in the collection otherwise.
* @param standard The international standard that define the
property, or {@code null} if none.
@@ -149,14 +151,12 @@ class PropertyDescriptor<T> extends Simp
* @param getter The getter method defined in the interface.
*/
@SuppressWarnings({"unchecked","rawtypes"})
- PropertyDescriptor(final String container, final Class<T> elementType,
- final Citation standard, final String property, final Method
getter)
- {
+ PropertyDescriptor(final Class<T> elementType, final Citation standard,
final String property, final Method getter) {
super(standard, property);
- this.container = container;
+ container = getter.getDeclaringClass();
this.elementType = elementType;
final UML uml = getter.getAnnotation(UML.class);
- byte cardinality = 2;
+ byte cardinality = 2; // minOccurs = 0, maxOccurs = 1;
if (uml != null) {
switch (uml.obligation()) {
case MANDATORY: cardinality = 3; break; // minOccurs =
1, maxOccurs = 1;
@@ -184,11 +184,16 @@ class PropertyDescriptor<T> extends Simp
}
/**
- * Returns the code space of the property name.
+ * Returns the ISO name of the class containing the property,
+ * or the simple class name if the ISO name is undefined.
*/
@Override
public final String getCodeSpace() {
- return container;
+ String codespace = Types.getStandardName(container);
+ if (codespace == null) {
+ codespace = container.getSimpleName();
+ }
+ return codespace;
}
/**
@@ -203,7 +208,9 @@ class PropertyDescriptor<T> extends Simp
/**
* An alternative name by which this object is identified.
* The current implementation returns an empty set.
- * Future implementation may return the JavaBeans property name.
+ *
+ * <p>Future implementation may return the JavaBeans property name,
+ * if different than the ISO name.</p>
*/
@Override
public final Collection<GenericName> getAlias() {
@@ -211,11 +218,15 @@ class PropertyDescriptor<T> extends Simp
}
/**
- * Comments about this property, or {@code null} if none.
+ * Returns comments about this property, or {@code null} if none.
*/
@Override
- public InternationalString getRemarks() {
- return null; // TODO use Types.getDescription
+ public final InternationalString getRemarks() {
+ return new AbstractInternationalString() {
+ @Override public String toString(final Locale locale) {
+ return Types.getDescription(container, code, locale);
+ }
+ };
}
/**
@@ -232,7 +243,7 @@ class PropertyDescriptor<T> extends Simp
* Current implementation unconditionally return {@code null}.
*/
@Override
- public T getDefaultValue() {
+ public final T getDefaultValue() {
return null;
}
@@ -266,7 +277,7 @@ class PropertyDescriptor<T> extends Simp
* that here using {@link org.apache.sis.util.collection.CodeListSet}.
*/
@Override
- public Set<T> getValidValues() {
+ public final Set<T> getValidValues() {
return null;
}
@@ -274,31 +285,35 @@ class PropertyDescriptor<T> extends Simp
* Returns the unit of measurement. The current implementation returns
{@code null}.
*/
@Override
- public Unit<?> getUnit() {
+ public final Unit<?> getUnit() {
return null;
}
/**
- * The minimum number of times that values for this parameter group or
- * parameter are required.
+ * Returns the minimum number of times that values are required.
+ * This method returns 1 if the property is mandatory, or 0 otherwise.
*/
@Override
- public int getMinimumOccurs() {
+ public final int getMinimumOccurs() {
return cardinality & 1;
}
/**
- * The maximum number of times that values for this parameter group or
- * parameter are required.
+ * Returns the maximum number of times that values are required.
+ * This method returns 0 if the property is forbidden, {@link
Integer#MAX_VALUE}
+ * if the property is an array or a collection, or 1 otherwise.
*/
@Override
- public int getMaximumOccurs() {
+ public final int getMaximumOccurs() {
+ // The cast to (int) propagate the sign bit on all bytes.
+ // Using unsigned shift, the 1111…111_ bit pattern become
+ // 0111…1111, which is Integer.MAX_VALUE.
return ((int) cardinality) >>> 1;
}
@Override
public ParameterValue<T> createValue() {
- throw new UnsupportedOperationException("Not supported yet."); //To
change body of generated methods, choose Tools | Templates.
+ throw new UnsupportedOperationException("Not supported yet.");
}
/**
@@ -309,11 +324,15 @@ class PropertyDescriptor<T> extends Simp
*/
@Override
public boolean equals(final Object obj) {
+ if (obj == this) {
+ return true;
+ }
if (super.equals(obj)) {
final PropertyDescriptor<?> that = (PropertyDescriptor<?>) obj;
- return (this.cardinality == that.cardinality) &&
- Objects.equals(this.container, that.container) &&
- Objects.equals(this.elementType, that.elementType);
+ return this.container == that.container &&
+ this.elementType == that.elementType &&
+ this.cardinality == that.cardinality;
+
}
return false;
}
Added:
sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyDescriptorTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyDescriptorTest.java?rev=1451174&view=auto
==============================================================================
---
sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyDescriptorTest.java
(added)
+++
sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyDescriptorTest.java
[UTF-8] Thu Feb 28 11:28:47 2013
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.metadata;
+
+import java.util.Locale;
+import org.opengis.util.InternationalString;
+import org.opengis.metadata.citation.Citation;
+import org.opengis.metadata.citation.PresentationForm;
+import org.apache.sis.internal.simple.SimpleCitation;
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * Tests {@link PropertyDescriptor}.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.3
+ * @version 0.3
+ * @module
+ */
+public final strictfp class PropertyDescriptorTest extends TestCase {
+ /**
+ * Creates a property descriptor instance for the given method of the
{@link Citation} interface.
+ *
+ * @param elementType The type of elements returned by the given method.
+ * @param method The name of the method.
+ * @param property The ISO 19115 name of the property.
+ * @throws NoSuchMethodException If the {@code method} name is invalid.
+ */
+ private static <T> PropertyDescriptor<T> create(final Class<T>
elementType, final String method,
+ final String property) throws NoSuchMethodException
+ {
+ return new PropertyDescriptor<>(elementType, new SimpleCitation("ISO
19115"), property,
+ Citation.class.getMethod(method));
+ }
+
+ /**
+ * Tests the properties of {@link Citation#getTitle()}.
+ * The element type is an {@link InternationalString} singleton, which is
mandatory.
+ *
+ * @throws NoSuchMethodException Should never happen.
+ */
+ @Test
+ public void testTitle() throws NoSuchMethodException {
+ final PropertyDescriptor<?> descriptor =
create(InternationalString.class, "getTitle", "title");
+ assertEquals("ISO 19115",
descriptor.getName().getAuthority().getTitle().toString());
+ assertEquals("CI_Citation", descriptor.getCodeSpace());
+ assertEquals("title", descriptor.getCode());
+ final InternationalString remarks = descriptor.getRemarks();
+ assertEquals("Name by which the cited resource is known.",
remarks.toString(Locale.ENGLISH));
+ // Test other locale here, if any.
+
+ assertEquals(InternationalString.class, descriptor.getValueClass());
+ assertEquals(1, descriptor.getMinimumOccurs());
+ assertEquals(1, descriptor.getMaximumOccurs());
+ }
+
+ /**
+ * Tests the properties of {@link Citation#getPresentationForms()}.
+ * The element type is {@link PresentationForm} in a collection.
+ *
+ * @throws NoSuchMethodException Should never happen.
+ */
+ @Test
+ public void testPresentationForm() throws NoSuchMethodException {
+ final PropertyDescriptor<?> descriptor =
create(PresentationForm.class, "getPresentationForms", "presentationForm");
+ assertEquals("ISO 19115",
descriptor.getName().getAuthority().getTitle().toString());
+ assertEquals("CI_Citation", descriptor.getCodeSpace());
+ assertEquals("presentationForm", descriptor.getCode());
+ final InternationalString remarks = descriptor.getRemarks();
+ assertEquals("Mode in which the resource is represented.",
remarks.toString(Locale.ENGLISH));
+ // Test other locale here, if any.
+
+ assertEquals(PresentationForm.class, descriptor.getValueClass());
+ assertEquals(0, descriptor.getMinimumOccurs());
+ assertEquals(Integer.MAX_VALUE, descriptor.getMaximumOccurs());
+ }
+}
Propchange:
sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyDescriptorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyDescriptorTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
Modified:
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java?rev=1451174&r1=1451173&r2=1451174&view=diff
==============================================================================
---
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java
[UTF-8] (original)
+++
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java
[UTF-8] Thu Feb 28 11:28:47 2013
@@ -24,12 +24,17 @@ import org.apache.sis.internal.util.Cita
import org.apache.sis.util.CharSequences;
import org.apache.sis.util.Classes;
+import static org.apache.sis.util.iso.DefaultNameSpace.DEFAULT_SEPARATOR;
+
// Related to JDK7
import java.util.Objects;
/**
* An implementation of {@link ReferenceIdentifier} as a wrapper around a
{@link Citation}.
+ * {@code ReferenceIdentifier} is defined by the ISO 19111 standard and is
implemented publicly
+ * in the {@link org.apache.sis.referencing} package. This class is provided
for non-referencing
+ * code that need a lightweight version.
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
@@ -44,7 +49,8 @@ public class SimpleReferenceIdentifier i
/**
* Organization or party responsible for definition and maintenance of the
- * {@linkplain #code}, or {@code null} if none.
+ * {@linkplain #code}, or {@code null} if none. It can be a bibliographical
+ * reference to an international standard such as ISO 19115.
*
* @see #getAuthority()
* @see #getCodeSpace()
@@ -53,7 +59,9 @@ public class SimpleReferenceIdentifier i
protected final Citation authority;
/**
- * The property name as defined by the international {@linkplain
#authority}.
+ * Alphanumeric value identifying an instance in the namespace.
+ * It can be for example the name of a class defined by the international
standard
+ * referenced by the {@linkplain #authority} citation.
*
* @see #getCode()
*/
@@ -72,7 +80,10 @@ public class SimpleReferenceIdentifier i
/**
* Organization or party responsible for definition and maintenance of the
- * {@linkplain #getCode() code}, or {@code null} if none.
+ * {@linkplain #getCode() code}, or {@code null} if none. It can be a
+ * bibliographical reference to an international standard such as ISO
19115.
+ *
+ * <p>The default implementation returns the citation specified at
construction time;</p>
*/
@Override
public Citation getAuthority() {
@@ -80,8 +91,9 @@ public class SimpleReferenceIdentifier i
}
/**
- * Returns the shortest identifier of the {@linkplain #getAuthority()
authority}.
- * May be {@code null}.
+ * Returns the name or identifier of the person or organization
responsible for namespace,
+ * or {@code null} if none. The default implementation returns the
shortest identifier of
+ * the {@linkplain #getAuthority() authority}, if any.
*/
@Override
public String getCodeSpace() {
@@ -89,8 +101,11 @@ public class SimpleReferenceIdentifier i
}
/**
- * Alphanumeric value identifying an instance in the namespace.
- * This is defined by the international standard given by {@link
#getAuthority()}.
+ * Returns the alphanumeric value identifying an instance in the namespace.
+ * It can be for example the name of a class defined by the international
standard
+ * referenced by the {@linkplain #getAuthority() authority} citation.
+ *
+ * <p>The default implementation returns the code specified at
construction time;</p>
*/
@Override
public String getCode() {
@@ -154,7 +169,7 @@ public class SimpleReferenceIdentifier i
open = true;
}
if (code != null) {
- buffer.append(open ? '.' : '“').append(code);
+ buffer.append(open ? DEFAULT_SEPARATOR : '“').append(code);
open = true;
}
if (open) {
@@ -165,6 +180,8 @@ public class SimpleReferenceIdentifier i
/**
* Returns a pseudo Well Known Text for this identifier.
+ * While this method is not defined in the {@link ReferenceIdentifier}
interface, it is often
+ * defined in related interfaces like {@link
org.opengis.referencing.IdentifiedObject}.
*
* @return Pseudo Well Known Text for this identifier.
*/
Added:
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/simple/SimpleReferenceIdentifierTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/simple/SimpleReferenceIdentifierTest.java?rev=1451174&view=auto
==============================================================================
---
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/simple/SimpleReferenceIdentifierTest.java
(added)
+++
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/simple/SimpleReferenceIdentifierTest.java
[UTF-8] Thu Feb 28 11:28:47 2013
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.simple;
+
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * Tests {@link SimpleReferenceIdentifier}.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.3
+ * @version 0.3
+ * @module
+ */
+public final strictfp class SimpleReferenceIdentifierTest extends TestCase {
+ /**
+ * Tests {@link SimpleReferenceIdentifier#toString()}.
+ */
+ @Test
+ public void testToString() {
+ final SimpleCitation authority = new SimpleCitation("EPSG");
+ assertEquals("SimpleReferenceIdentifier[“EPSG:4326”]", new
SimpleReferenceIdentifier(authority, "4326").toString());
+ assertEquals("SimpleReferenceIdentifier[“EPSG”]", new
SimpleReferenceIdentifier(authority, null ).toString());
+ assertEquals("SimpleReferenceIdentifier[“4326”]", new
SimpleReferenceIdentifier(null, "4326").toString());
+ assertEquals("SimpleReferenceIdentifier[]", new
SimpleReferenceIdentifier(null, null ).toString());
+ }
+
+ /**
+ * Tests {@link SimpleReferenceIdentifier#toWKT()}.
+ */
+ @Test
+ public void testToWKT() {
+ final SimpleCitation authority = new SimpleCitation("EPSG");
+ assertEquals("AUTHORITY[\"EPSG\",\"4326\"]", new
SimpleReferenceIdentifier(authority, "4326").toWKT());
+ assertEquals("AUTHORITY[\"EPSG\",null]", new
SimpleReferenceIdentifier(authority, null ).toWKT());
+ assertEquals("AUTHORITY[null,\"4326\"]", new
SimpleReferenceIdentifier(null, "4326").toWKT());
+ assertEquals("AUTHORITY[null,null]", new
SimpleReferenceIdentifier(null, null ).toWKT());
+ }
+}
Propchange:
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/simple/SimpleReferenceIdentifierTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/simple/SimpleReferenceIdentifierTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
Modified:
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/measure/NumberRangeTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/measure/NumberRangeTest.java?rev=1451174&r1=1451173&r2=1451174&view=diff
==============================================================================
---
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/measure/NumberRangeTest.java
[UTF-8] (original)
+++
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/measure/NumberRangeTest.java
[UTF-8] Thu Feb 28 11:28:47 2013
@@ -31,7 +31,10 @@ import static org.junit.Assert.*;
* @version 0.3
* @module
*/
-@DependsOn(RangeTest.class)
+@DependsOn({
+ RangeTest.class,
+ org.apache.sis.util.NumbersTest.class
+})
public final strictfp class NumberRangeTest extends TestCase {
/**
* Tests the endpoint values of a range of integers.