Author: desruisseaux
Date: Fri Feb 20 16:02:23 2015
New Revision: 1661147
URL: http://svn.apache.org/r1661147
Log:
Replaced a few String litteral by static final value from the Constants
internal class.
Modified:
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorValuesTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java
sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/TypeNamesTest.java
Modified:
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java?rev=1661147&r1=1661146&r2=1661147&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
[UTF-8] Fri Feb 20 16:02:23 2015
@@ -79,7 +79,7 @@ public final class Citations extends Sta
*
* @since 0.4
*/
- public static final Citation SIS = new SimpleCitation("SIS");
+ public static final Citation SIS = new SimpleCitation(Constants.SIS);
/**
* The <a href="http://www.esri.com">ESRI</a> organization.
Modified:
sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java?rev=1661147&r1=1661146&r2=1661147&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java
[UTF-8] Fri Feb 20 16:02:23 2015
@@ -23,6 +23,7 @@ import org.opengis.metadata.citation.OnL
import org.opengis.metadata.citation.PresentationForm;
import org.apache.sis.metadata.iso.DefaultIdentifier;
import org.apache.sis.util.iso.SimpleInternationalString;
+import org.apache.sis.internal.util.Constants;
import org.apache.sis.util.Static;
import static java.util.Collections.singleton;
@@ -52,7 +53,7 @@ public final strictfp class HardCodedCit
final DefaultCitation c = new DefaultCitation("Open Geospatial
consortium");
c.setAlternateTitles(singleton(new SimpleInternationalString("OGC")));
c.setPresentationForms(singleton(PresentationForm.DOCUMENT_DIGITAL));
- c.setIdentifiers(singleton(new DefaultIdentifier("OGC")));
+ c.setIdentifiers(singleton(new DefaultIdentifier(Constants.OGC)));
c.freeze();
OGC = c;
}
@@ -134,7 +135,7 @@ public final strictfp class HardCodedCit
final DefaultCitation c = new DefaultCitation("European Petroleum
Survey Group");
c.setAlternateTitles(singleton(new SimpleInternationalString("EPSG")));
c.setPresentationForms(singleton(PresentationForm.TABLE_DIGITAL));
- c.setIdentifiers(singleton(new DefaultIdentifier("EPSG")));
+ c.setIdentifiers(singleton(new DefaultIdentifier(Constants.EPSG)));
c.setCitedResponsibleParties(singleton(p));
c.freeze();
EPSG = c;
@@ -156,7 +157,7 @@ public final strictfp class HardCodedCit
*/
public static final DefaultCitation SIS;
static {
- final DefaultCitation c = new DefaultCitation("SIS");
+ final DefaultCitation c = new DefaultCitation(Constants.SIS);
c.freeze();
SIS = c;
}
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java?rev=1661147&r1=1661146&r2=1661147&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java
[UTF-8] Fri Feb 20 16:02:23 2015
@@ -324,8 +324,8 @@ public strictfp class TensorParametersTe
final ParameterValueGroup group = param.createValueGroup(
singletonMap(GeneralParameterDescriptor.NAME_KEY,
"Test"), matrix);
validate(group);
- assertEquals("num_row", numRow,
group.parameter("num_row").intValue());
- assertEquals("num_col", numCol,
group.parameter("num_col").intValue());
+ assertEquals(NUM_ROW, numRow,
group.parameter(NUM_ROW).intValue());
+ assertEquals(NUM_COL, numCol,
group.parameter(NUM_COL).intValue());
assertEquals("elements", matrix, param.toMatrix(group));
assertEquals("elements", matrix, param.toMatrix(new
ParameterValueGroupWrapper(group)));
}
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorValuesTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorValuesTest.java?rev=1661147&r1=1661146&r2=1661147&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorValuesTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorValuesTest.java
[UTF-8] Fri Feb 20 16:02:23 2015
@@ -34,6 +34,8 @@ import org.junit.Test;
import static java.util.Collections.singletonMap;
import static org.opengis.test.Validators.validate;
import static org.apache.sis.test.MetadataAssert.*;
+import static org.apache.sis.internal.util.Constants.NUM_ROW;
+import static org.apache.sis.internal.util.Constants.NUM_COL;
/**
@@ -102,19 +104,19 @@ public final strictfp class TensorValues
final Integer N3 = 3;
final ParameterValueGroup group = createWKT1();
- group.parameter("num_row").setValue(1);
- group.parameter("num_col").setValue(1);
+ group.parameter(NUM_ROW).setValue(1);
+ group.parameter(NUM_COL).setValue(1);
List<GeneralParameterDescriptor> descriptors =
group.getDescriptor().descriptors();
- assertDescriptorEquals("num_row", N3, descriptors.get(0));
- assertDescriptorEquals("num_col", N3, descriptors.get(1));
+ assertDescriptorEquals( NUM_ROW, N3, descriptors.get(0));
+ assertDescriptorEquals( NUM_COL, N3, descriptors.get(1));
assertDescriptorEquals("elt_0_0", N1, descriptors.get(2));
assertEquals("size", 3, descriptors.size());
- group.parameter("num_row").setValue(2);
- group.parameter("num_col").setValue(3);
+ group.parameter(NUM_ROW).setValue(2);
+ group.parameter(NUM_COL).setValue(3);
descriptors = group.getDescriptor().descriptors();
- assertDescriptorEquals("num_row", N3, descriptors.get(0));
- assertDescriptorEquals("num_col", N3, descriptors.get(1));
+ assertDescriptorEquals( NUM_ROW, N3, descriptors.get(0));
+ assertDescriptorEquals( NUM_COL, N3, descriptors.get(1));
assertDescriptorEquals("elt_0_0", N1, descriptors.get(2));
assertDescriptorEquals("elt_0_1", N0, descriptors.get(3));
assertDescriptorEquals("elt_0_2", N0, descriptors.get(4));
@@ -137,10 +139,10 @@ public final strictfp class TensorValues
* Use non-standard matrix size. The "num_row" and "num_col"
* parameters shall be included in the list of descriptors.
*/
- group.parameter("num_row").setValue(2);
+ group.parameter(NUM_ROW).setValue(2);
descriptors = group.getDescriptor().descriptors();
- assertDescriptorEquals("num_row", N3, descriptors.get(0));
- assertDescriptorEquals("num_col", N3, descriptors.get(1));
+ assertDescriptorEquals(NUM_ROW, N3, descriptors.get(0));
+ assertDescriptorEquals(NUM_COL, N3, descriptors.get(1));
verifyDescriptorsEPSG(descriptors, 2);
}
@@ -167,11 +169,11 @@ public final strictfp class TensorValues
@DependsOnMethod("testParameter")
public void testValues() {
final ParameterValueGroup group = createWKT1();
- group.parameter("num_row").setValue(2);
- group.parameter("num_col").setValue(3);
+ group.parameter(NUM_ROW).setValue(2);
+ group.parameter(NUM_COL).setValue(3);
List<GeneralParameterValue> values = group.values();
- assertValueEquals("num_row", 2, values.get(0));
- assertValueEquals("num_col", 3, values.get(1));
+ assertValueEquals(NUM_ROW, 2, values.get(0));
+ assertValueEquals(NUM_COL, 3, values.get(1));
assertEquals("size", 2, values.size());
/*
* Above list had no explicit parameters, since all of them had their
default values.
@@ -182,8 +184,8 @@ public final strictfp class TensorValues
group.parameter("elt_1_1").setValue(7);
group.parameter("elt_1_2").setValue(6);
values = group.values();
- assertValueEquals("num_row", 2, values.get(0));
- assertValueEquals("num_col", 3, values.get(1));
+ assertValueEquals( NUM_ROW, 2, values.get(0));
+ assertValueEquals( NUM_COL, 3, values.get(1));
assertValueEquals("elt_0_1", 8.0, values.get(2));
assertValueEquals("elt_1_1", 7.0, values.get(3));
assertValueEquals("elt_1_2", 6.0, values.get(4));
@@ -200,8 +202,8 @@ public final strictfp class TensorValues
final Integer N3 = 3;
final ParameterValueGroup group = createWKT1();
final ParameterDescriptorGroup d = group.getDescriptor();
- assertDescriptorEquals("num_row", N3, d.descriptor("num_row"));
- assertDescriptorEquals("num_col", N3, d.descriptor("num_col"));
+ assertDescriptorEquals( NUM_ROW, N3, d.descriptor( NUM_ROW ));
+ assertDescriptorEquals( NUM_COL, N3, d.descriptor( NUM_COL ));
assertDescriptorEquals("elt_0_0", N1, d.descriptor("elt_0_0"));
assertDescriptorEquals("elt_0_1", N0, d.descriptor("elt_0_1"));
assertDescriptorEquals("elt_0_2", N0, d.descriptor("elt_0_2"));
@@ -227,7 +229,7 @@ public final strictfp class TensorValues
* If we reduce the matrix size, than it shall not be possible
* anymore to get the descriptor in the row that we removed.
*/
- group.parameter("num_col").setValue(2);
+ group.parameter(NUM_COL).setValue(2);
try {
d.descriptor("elt_2_2");
fail("elt_2_2 should not exist.");
@@ -247,8 +249,8 @@ public final strictfp class TensorValues
final Double N1 = 1.0;
final Integer N3 = 3;
final ParameterValueGroup group = createWKT1();
- assertValueEquals("num_row", N3, group.parameter("num_row"));
- assertValueEquals("num_col", N3, group.parameter("num_col"));
+ assertValueEquals( NUM_ROW, N3, group.parameter( NUM_ROW ));
+ assertValueEquals( NUM_COL, N3, group.parameter( NUM_COL ));
assertValueEquals("elt_0_0", N1, group.parameter("elt_0_0"));
assertValueEquals("elt_0_1", N0, group.parameter("elt_0_1"));
assertValueEquals("elt_2_2", N1, group.parameter("elt_2_2"));
@@ -270,7 +272,7 @@ public final strictfp class TensorValues
* If we reduce the matrix size, than it shall not be possible
* anymore to get the descriptor in the row that we removed.
*/
- group.parameter("num_col").setValue(2);
+ group.parameter(NUM_COL).setValue(2);
try {
group.parameter("elt_2_2");
fail("elt_2_2 should not exist.");
@@ -288,21 +290,21 @@ public final strictfp class TensorValues
@DependsOnMethod("testParameter")
public void testClone() {
final ParameterValueGroup group = createWKT1();
- group.parameter("num_row").setValue(2);
+ group.parameter(NUM_ROW).setValue(2);
group.parameter("elt_0_1").setValue(4);
group.parameter("elt_1_0").setValue(2);
/*
* Creates a clone, modify some values, keep other values.
*/
final ParameterValueGroup clone = group.clone();
- clone.parameter("num_row").setValue(4);
+ clone.parameter(NUM_ROW).setValue(4);
clone.parameter("elt_0_1").setValue(3);
/*
* Verify that changes in cloned values did not affected
* values in the original object.
*/
- assertEquals(2, group.parameter("num_row").intValue());
- assertEquals(4, clone.parameter("num_row").intValue());
+ assertEquals(2, group.parameter(NUM_ROW).intValue());
+ assertEquals(4, clone.parameter(NUM_ROW).intValue());
assertEquals(4, group.parameter("elt_0_1").intValue());
assertEquals(3, clone.parameter("elt_0_1").intValue());
assertEquals(2, group.parameter("elt_1_0").intValue());
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java?rev=1661147&r1=1661146&r2=1661147&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java
[UTF-8] Fri Feb 20 16:02:23 2015
@@ -31,6 +31,7 @@ import org.opengis.referencing.datum.Tem
import org.opengis.referencing.datum.VerticalDatum;
import org.opengis.referencing.datum.VerticalDatumType;
import org.apache.sis.internal.referencing.VerticalDatumTypes;
+import org.apache.sis.internal.util.Constants;
import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
@@ -211,24 +212,24 @@ public final strictfp class CommonCRSTes
*/
@Test
public void testForCode() throws FactoryException {
- verifyForCode(CommonCRS.WGS84 .geographic(), "EPSG",
"4326");
- verifyForCode(CommonCRS.WGS72 .geographic(), "EPSG",
"4322");
- verifyForCode(CommonCRS.SPHERE.geographic(), "EPSG",
"4047");
- verifyForCode(CommonCRS.NAD83 .geographic(), "EPSG",
"4269");
- verifyForCode(CommonCRS.NAD27 .geographic(), "EPSG",
"4267");
- verifyForCode(CommonCRS.ETRS89.geographic(), "EPSG",
"4258");
- verifyForCode(CommonCRS.ED50 .geographic(), "EPSG",
"4230");
- verifyForCode(CommonCRS.WGS84 .geocentric(), "EPSG",
"4978");
- verifyForCode(CommonCRS.WGS72 .geocentric(), "EPSG",
"4984");
- verifyForCode(CommonCRS.ETRS89.geocentric(), "EPSG",
"4936");
- verifyForCode(CommonCRS.WGS84 .geographic3D(), "EPSG",
"4979");
- verifyForCode(CommonCRS.WGS72 .geographic3D(), "EPSG",
"4985");
- verifyForCode(CommonCRS.ETRS89.geographic3D(), "EPSG",
"4937");
- verifyForCode(CommonCRS.Vertical.MEAN_SEA_LEVEL.crs(), "EPSG",
"5714");
- verifyForCode(CommonCRS.Vertical.DEPTH.crs(), "EPSG",
"5715");
- verifyForCode(CommonCRS.WGS84.normalizedGeographic(), "CRS", "84");
- verifyForCode(CommonCRS.NAD83.normalizedGeographic(), "CRS", "83");
- verifyForCode(CommonCRS.NAD27.normalizedGeographic(), "CRS", "27");
+ verifyForCode(CommonCRS.WGS84 .geographic(),
Constants.EPSG, "4326");
+ verifyForCode(CommonCRS.WGS72 .geographic(),
Constants.EPSG, "4322");
+ verifyForCode(CommonCRS.SPHERE.geographic(),
Constants.EPSG, "4047");
+ verifyForCode(CommonCRS.NAD83 .geographic(),
Constants.EPSG, "4269");
+ verifyForCode(CommonCRS.NAD27 .geographic(),
Constants.EPSG, "4267");
+ verifyForCode(CommonCRS.ETRS89.geographic(),
Constants.EPSG, "4258");
+ verifyForCode(CommonCRS.ED50 .geographic(),
Constants.EPSG, "4230");
+ verifyForCode(CommonCRS.WGS84 .geocentric(),
Constants.EPSG, "4978");
+ verifyForCode(CommonCRS.WGS72 .geocentric(),
Constants.EPSG, "4984");
+ verifyForCode(CommonCRS.ETRS89.geocentric(),
Constants.EPSG, "4936");
+ verifyForCode(CommonCRS.WGS84 .geographic3D(),
Constants.EPSG, "4979");
+ verifyForCode(CommonCRS.WGS72 .geographic3D(),
Constants.EPSG, "4985");
+ verifyForCode(CommonCRS.ETRS89.geographic3D(),
Constants.EPSG, "4937");
+ verifyForCode(CommonCRS.Vertical.MEAN_SEA_LEVEL.crs(),
Constants.EPSG, "5714");
+ verifyForCode(CommonCRS.Vertical.DEPTH.crs(),
Constants.EPSG, "5715");
+ verifyForCode(CommonCRS.WGS84.normalizedGeographic(), Constants.CRS,
"84");
+ verifyForCode(CommonCRS.NAD83.normalizedGeographic(), Constants.CRS,
"83");
+ verifyForCode(CommonCRS.NAD27.normalizedGeographic(), Constants.CRS,
"27");
}
/**
Modified:
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java?rev=1661147&r1=1661146&r2=1661147&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java
[UTF-8] Fri Feb 20 16:02:23 2015
@@ -23,6 +23,13 @@ import org.apache.sis.util.Static;
* Hard coded values (typically identifiers).
* The set of constants defined in this class may change in any SIS version -
do not rely on them.
*
+ * {@section When to use}
+ * Those constants should be used mostly for names, aliases or identifiers.
They should generally
+ * not be used for abbreviations for instance, even if the abbreviation result
in the same string.
+ *
+ * Those constants do not need to be used systematically in tests neither,
especially when the test
+ * builds its tested object itself.
+ *
* @author Martin Desruisseaux (Geomatys)
* @since 0.5
* @version 0.6
Modified:
sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/TypeNamesTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/TypeNamesTest.java?rev=1661147&r1=1661146&r2=1661147&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/TypeNamesTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/TypeNamesTest.java
[UTF-8] Fri Feb 20 16:02:23 2015
@@ -29,6 +29,7 @@ import org.apache.sis.test.TestCase;
import org.junit.Test;
import static org.junit.Assert.*;
+import static org.apache.sis.internal.util.Constants.OGC;
/**
@@ -74,14 +75,14 @@ public final strictfp class TypeNamesTes
*/
@Test
public void testBasicTypes() throws ClassNotFoundException {
- verifyLookup("OGC", "URI", URI.class);
- verifyLookup("OGC", "PT_Locale", Locale.class);
- verifyLookup("OGC", "DateTime", Date.class);
- verifyLookup("OGC", "FreeText", InternationalString.class);
- verifyLookup("OGC", "CharacterString", String.class);
- verifyLookup("OGC", "Boolean", Boolean.class);
- verifyLookup("OGC", "Real", Double.class);
- verifyLookup("OGC", "Integer", Integer.class);
+ verifyLookup(OGC, "URI", URI.class);
+ verifyLookup(OGC, "PT_Locale", Locale.class);
+ verifyLookup(OGC, "DateTime", Date.class);
+ verifyLookup(OGC, "FreeText", InternationalString.class);
+ verifyLookup(OGC, "CharacterString", String.class);
+ verifyLookup(OGC, "Boolean", Boolean.class);
+ verifyLookup(OGC, "Real", Double.class);
+ verifyLookup(OGC, "Integer", Integer.class);
}
/**
@@ -89,10 +90,10 @@ public final strictfp class TypeNamesTes
*/
@Test
public void testNumbers() {
- assertEquals("Short", "OGC:Integer", toTypeName(Short .class));
- assertEquals("Long", "OGC:Integer", toTypeName(Long .class));
- assertEquals("Float", "OGC:Real", toTypeName(Float .class));
- assertEquals("Double", "OGC:Real", toTypeName(Double.class));
+ assertEquals("Short", OGC+":Integer", toTypeName(Short .class));
+ assertEquals("Long", OGC+":Integer", toTypeName(Long .class));
+ assertEquals("Float", OGC+":Real", toTypeName(Float .class));
+ assertEquals("Double", OGC+":Real", toTypeName(Double.class));
}
/**
@@ -102,8 +103,8 @@ public final strictfp class TypeNamesTes
*/
@Test
public void testMetadataClasses() throws ClassNotFoundException {
- verifyLookup("OGC", "MD_Metadata", Metadata.class);
- verifyLookup("OGC", "SC_CRS", CoordinateReferenceSystem.class);
+ verifyLookup(OGC, "MD_Metadata", Metadata.class);
+ verifyLookup(OGC, "SC_CRS", CoordinateReferenceSystem.class);
}
/**
@@ -124,9 +125,9 @@ public final strictfp class TypeNamesTes
@Test
public void testInvalidNames() throws ClassNotFoundException {
assertEquals("Dummy:Real", Void.TYPE, TypeNames.toClass("Dummy",
"Real"));
- assertEquals("OGC:Real", Double.class, TypeNames.toClass("OGC",
"Real"));
+ assertEquals(OGC+":Real", Double.class, TypeNames.toClass(OGC,
"Real"));
assertEquals("Real", Double.class, TypeNames.toClass(null,
"Real"));
assertEquals("Dummy", Void.TYPE, TypeNames.toClass(null,
"Dummy")); // Considered not an error.
- assertNull ("OGC:Dummy", TypeNames.toClass("OGC",
"Dummy")); // Considered an error.
+ assertNull (OGC+":Dummy", TypeNames.toClass(OGC,
"Dummy")); // Considered an error.
}
}