Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties?rev=1422813&r1=1422812&r2=1422813&view=diff ============================================================================== --- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties (original) +++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties Mon Dec 17 09:26:20 2012 @@ -42,11 +42,15 @@ InfiniteRecursivity = Infini InsufficientArgumentSize_3 = Argument \u2018{0}\u2019 shall contain at least {1} elements. A number of {2} is insufficient. KeyCollision_1 = A different value is already associated to the \u201c{0}\u201d key. MandatoryAttribute_2 = Attribute \u201c{0}\u201d is mandatory for an object of type \u2018{1}\u2019. +MismatchedCRS = The coordinate reference system must be the same for all objects. +MismatchedDimension_2 = Mismatched object dimension: {0}D and {1}D. +MismatchedDimension_3 = Argument \u2018{0}\u2019 has {1} dimension{1,choice,1#|2#s}, while {2} was expected. NegativeArgument_2 = Argument \u2018{0}\u2019 shall not be negative. The given value was {1}. NodeChildOfItself_1 = Node \u201c{0}\u201d can not be a child of itself. NodeHasAnotherParent_1 = Node \u201c{0}\u201d already has another parent. NodeHasNoParent_1 = Node \u201c{0}\u201d has no parent. NodeNotFound_1 = No \u201c{0}\u201d node found. +NonEquilibratedParenthesis_2 = Missing a \u2018{1}\u2019 parenthesis in \u201c{0}\u201d. NonAngularUnit_1 = \u201c{0}\u201d is not an angular unit. NonLinearUnit_1 = \u201c{0}\u201d is not a linear unit. NonScaleUnit_1 = \u201c{0}\u201d is not a scale unit. @@ -54,6 +58,7 @@ NonTemporalUnit_1 = \u201c NotANumber_1 = Argument \u2018{0}\u2019 shall not be NaN (Not-a-Number). NotAPrimitiveWrapper_1 = Class \u2018{0}\u2019 is not a primitive type wrapper. NullArgument_1 = Argument \u2018{0}\u2019 shall not be null. +OddArrayLength_1 = Array length is {0}, while we expected an even length. RecursiveCreateCallForKey_1 = Recursive call while creating an object for the \u201c{0}\u201d key. RequireDecimalSeparator = A decimal separator is required. UnexpectedArgumentDimension_3 = Argument \u2018{0}\u2019 has {1} dimensions, while {2} was expected.
Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties?rev=1422813&r1=1422812&r2=1422813&view=diff ============================================================================== --- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties (original) +++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties Mon Dec 17 09:26:20 2012 @@ -42,11 +42,15 @@ InfiniteRecursivity = R\u00e InsufficientArgumentSize_3 = L\u2019argument \u2018{0}\u2019 doit contenir au moins {1} \u00e9l\u00e9ments. Un nombre de {2} est insuffisant. KeyCollision_1 = Une valeur diff\u00e9rente est d\u00e9j\u00e0 associ\u00e9e \u00e0 la cl\u00e9 \u201c{0}\u201d. MandatoryAttribute_2 = L\u2019attribut \u201c{0}\u201d est obligatoire pour un objet de type \u2018{1}\u2019. +MismatchedCRS = Le syst\u00e8me de r\u00e9f\u00e9rence des coordonn\u00e9es doit \u00eatre le m\u00eame pour tous les objets. +MismatchedDimension_2 = Les dimensions des objets ({0}D et {1}D) ne concordent pas. +MismatchedDimension_3 = L\u2019argument \u2018{0}\u2019 a {1} dimension{1,choice,1#|2#s}, alors qu\u2019on en attendait {2}. NegativeArgument_2 = L\u2019argument \u2018{0}\u2019 ne doit pas \u00eatre n\u00e9gatif. La valeur donn\u00e9e \u00e9tait {1}. NodeChildOfItself_1 = Le n\u0153ud \u201c{0}\u201d ne peut pas \u00eatre un enfant de lui-m\u00eame. NodeHasAnotherParent_1 = Le n\u0153ud \u201c{0}\u201d a d\u00e9j\u00e0 un autre parent. NodeHasNoParent_1 = Le n\u0153ud \u201c{0}\u201d n\u2019a pas de parent. NodeNotFound_1 = Aucun n\u0153ud \u201c{0}\u201d n\u2019a \u00e9t\u00e9 trouv\u00e9. +NonEquilibratedParenthesis_2 = Il manque une parenth\u00e8se \u2018{1}\u2019 dans \u201c{0}\u201d. NonAngularUnit_1 = \u201c{0}\u201d n\u2019est pas une unit\u00e9 d\u2019angles. NonLinearUnit_1 = \u201c{0}\u201d n\u2019est pas une unit\u00e9 de longueurs. NonScaleUnit_1 = \u201c{0}\u201d n\u2019est pas une unit\u00e9 d\u2019\u00e9chelles. @@ -54,6 +58,7 @@ NonTemporalUnit_1 = \u201c NotANumber_1 = L\u2019argument \u2018{0}\u2019 ne doit pas \u00eatre NaN (Not-a-Number). NotAPrimitiveWrapper_1 = La classe \u2018{0}\u2019 n\u2019est pas un adaptateur d\u2019un type primitif. NullArgument_1 = L\u2019argument \u2018{0}\u2019 ne doit pas \u00eatre nul. +OddArrayLength_1 = La longueur du tableau est {0}, alors qu\u2019on attendait une longueur paire. RecursiveCreateCallForKey_1 = Appel r\u00e9cursif lors de la cr\u00e9ation d\u2019un objet pour la cl\u00e9 \u201c{0}\u201d. RequireDecimalSeparator = Un s\u00e9parateur d\u00e9cimal est requis. UnexpectedArgumentDimension_3 = L\u2019argument \u2018{0}\u2019 a {1} dimensions, alors qu\u2019on en attendait {2}. Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/NilObject.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/NilObject.java?rev=1422813&r1=1422812&r2=1422813&view=diff ============================================================================== --- sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/NilObject.java (original) +++ sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/NilObject.java Mon Dec 17 09:26:20 2012 @@ -32,7 +32,7 @@ package org.apache.sis.xml; * shows a {@code CI_Citation} fragment with an ordinary {@code CI_Series} element on the left side, * and an unknown {@code CI_Series} element on the right side:</p> * - * <blockquote><table class="sis" border="1"><tr> + * <table class="sis"><tr> * <th>Normal {@code Series} element</th> * <th>Unknown {@code Series} element</th> * </tr><tr><td> @@ -51,7 +51,7 @@ package org.apache.sis.xml; * <gmd:series nilReason="unknown"/> * </gmd:CI_Citation> * } - * </td></tr></table></blockquote> + * </td></tr></table> * * If the {@code CI_Series} element was completely omitted, then {@link org.opengis.metadata.citation.Citation#getSeries()} * method would return {@code null} in Apache SIS implementation. But since a {@code nilReason} is provided, Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/XLink.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/XLink.java?rev=1422813&r1=1422812&r2=1422813&view=diff ============================================================================== --- sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/XLink.java (original) +++ sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/XLink.java Mon Dec 17 09:26:20 2012 @@ -44,7 +44,7 @@ import org.apache.sis.internal.util.Obje * of whether a value is required (R) or optional (O) * (Source: <a href="http://www.w3.org/TR/xlink/">W3C</a>): * - * <blockquote><table class="sis"> + * <table class="sis"> * <tr> * <th> </th> * <th width="14%">{@link XLink.Type#SIMPLE simple}</th> @@ -64,7 +64,7 @@ import org.apache.sis.internal.util.Obje * <tr align="center"><td><b>{@link #getLabel() label}</b></td> <td> </td><td> </td><td>O</td><td> </td><td>O</td><td> </td></tr> * <tr align="center"><td><b>{@link #getFrom() from}</b></td> <td> </td><td> </td><td> </td><td>O</td><td> </td><td> </td></tr> * <tr align="center"><td><b>{@link #getTo() to}</b></td> <td> </td><td> </td><td> </td><td>O</td><td> </td><td> </td></tr> - * </table></blockquote> + * </table> * * When {@code xlink} attributes are found at unmarshalling time instead of an object definition, * those attributes are given to the {@link ReferenceResolver#resolve(MarshalContext, Class, XLink)} Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java?rev=1422813&r1=1422812&r2=1422813&view=diff ============================================================================== --- sis/trunk/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java (original) +++ sis/trunk/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java Mon Dec 17 09:26:20 2012 @@ -153,7 +153,7 @@ public final strictfp class MathFunction final double y = atanh(x); switch (i) { case -10: assertEquals(Double.NEGATIVE_INFINITY, y, EPS); break; - default: assertEquals(x, Math.tanh(y), EPS); break; + default: assertEquals(x, StrictMath.tanh(y), EPS); break; case +10: assertEquals(Double.POSITIVE_INFINITY, y, EPS); break; } } @@ -171,6 +171,28 @@ public final strictfp class MathFunction } /** + * Tests the {@link MathFunctions#epsilonEqual(float, float, float)} and + * {@link MathFunctions#epsilonEqual(double, double, double)} methods. + */ + @Test + public void testEpsilonEqual() { + assertTrue (epsilonEqual(10.0, 12.0, 2.0)); + assertFalse(epsilonEqual(10.0, 12.0, 1.0)); + assertTrue (epsilonEqual(Double.NaN, Double.NaN, 1.0)); + assertTrue (epsilonEqual(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, 1.0)); + assertTrue (epsilonEqual(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, 1.0)); + assertFalse(epsilonEqual(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 1.0)); + + // Same tests using the 'float' version. + assertTrue (epsilonEqual(10f, 12f, 2f)); + assertFalse(epsilonEqual(10f, 12f, 1f)); + assertTrue (epsilonEqual(Float.NaN, Float.NaN, 1f)); + assertTrue (epsilonEqual(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, 1f)); + assertTrue (epsilonEqual(Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY, 1f)); + assertFalse(epsilonEqual(Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY, 1f)); + } + + /** * Tests the {@link MathFunctions#toNanFloat(int)} method. This will indirectly test the * converse {@link MathFunctions#toNanOrdinal(float)} method through Java assertions. */ Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/test/Assert.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/test/Assert.java?rev=1422813&r1=1422812&r2=1422813&view=diff ============================================================================== --- sis/trunk/sis-utility/src/test/java/org/apache/sis/test/Assert.java (original) +++ sis/trunk/sis-utility/src/test/java/org/apache/sis/test/Assert.java Mon Dec 17 09:26:20 2012 @@ -27,14 +27,12 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.awt.geom.Rectangle2D; -import java.awt.geom.RectangularShape; -import java.awt.image.RenderedImage; import javax.swing.tree.TreeNode; import javax.xml.parsers.ParserConfigurationException; import org.xml.sax.SAXException; - +import org.apache.sis.util.Utilities; import org.apache.sis.util.CharSequences; +import org.apache.sis.util.ComparisonMode; // Related to JDK7 import org.apache.sis.internal.util.Objects; @@ -56,6 +54,52 @@ public strictfp class Assert extends org } /** + * Asserts that the two given objects are not equal. + * This method tests all {@link ComparisonMode} except {@code DEBUG}. + * + * @param o1 The first object. + * @param o2 The second object. + */ + public static void assertNotDeepEquals(final Object o1, final Object o2) { + assertNotSame("same", o1, o2); + assertFalse("equals", Objects .equals (o1, o2)); + assertFalse("deepEquals", Objects .deepEquals(o1, o2)); + assertFalse("deepEquals(STRICT)", Utilities.deepEquals(o1, o2, ComparisonMode.STRICT)); + assertFalse("deepEquals(BY_CONTRACT)", Utilities.deepEquals(o1, o2, ComparisonMode.BY_CONTRACT)); + assertFalse("deepEquals(IGNORE_METADATA)", Utilities.deepEquals(o1, o2, ComparisonMode.IGNORE_METADATA)); + assertFalse("deepEquals(APPROXIMATIVE)", Utilities.deepEquals(o1, o2, ComparisonMode.APPROXIMATIVE)); + } + + /** + * Asserts that the two given objects are approximatively equal, while slightly different. + * More specifically, this method asserts that the given objects are equal according the + * {@link ComparisonMode#APPROXIMATIVE} criterion, but not equal according the + * {@link ComparisonMode#IGNORE_METADATA} criterion. + * + * @param expected The expected object. + * @param actual The actual object. + */ + public static void assertAlmostEquals(final Object expected, final Object actual) { + assertFalse("Shall not be strictly equals", Utilities.deepEquals(expected, actual, ComparisonMode.STRICT)); + assertFalse("Shall be slightly different", Utilities.deepEquals(expected, actual, ComparisonMode.IGNORE_METADATA)); + assertTrue ("Shall be approximatively equals", Utilities.deepEquals(expected, actual, ComparisonMode.DEBUG)); + assertTrue ("DEBUG inconsistent with APPROXIMATIVE", Utilities.deepEquals(expected, actual, ComparisonMode.APPROXIMATIVE)); + } + + /** + * Asserts that the two given objects are equal ignoring metadata. + * See {@link ComparisonMode#IGNORE_METADATA} for more information. + * + * @param expected The expected object. + * @param actual The actual object. + */ + public static void assertEqualsIgnoreMetadata(final Object expected, final Object actual) { + assertTrue("Shall be approximatively equals", Utilities.deepEquals(expected, actual, ComparisonMode.DEBUG)); + assertTrue("DEBUG inconsistent with APPROXIMATIVE", Utilities.deepEquals(expected, actual, ComparisonMode.APPROXIMATIVE)); + assertTrue("Shall be equals, ignoring metadata", Utilities.deepEquals(expected, actual, ComparisonMode.IGNORE_METADATA)); + } + + /** * Asserts that two strings are equal, ignoring the differences in EOL characters. * The comparisons is performed one a line-by-line basis. For each line, leading * and trailing spaces are ignored in order to make the comparison independent of @@ -251,98 +295,6 @@ public strictfp class Assert extends org } /** - * Tests if the given {@code outer} shape contains the given {@code inner} rectangle. - * This method will also verify class consistency by invoking the {@code intersects} - * method, and by interchanging the arguments. - * - * <p>This method can be used for testing the {@code outer} implementation - - * it should not be needed for standard JDK implementations.</p> - * - * @param outer The shape which is expected to contains the given rectangle. - * @param inner The rectangle which should be contained by the shape. - */ - public static void assertContains(final RectangularShape outer, final Rectangle2D inner) { - assertTrue("outer.contains(inner)", outer.contains (inner)); - assertTrue("outer.intersects(inner)", outer.intersects(inner)); - if (outer instanceof Rectangle2D) { - assertTrue ("inner.intersects(outer)", inner.intersects((Rectangle2D) outer)); - assertFalse("inner.contains(outer)", inner.contains ((Rectangle2D) outer)); - } - assertTrue("outer.contains(centerX, centerY)", - outer.contains(inner.getCenterX(), inner.getCenterY())); - } - - /** - * Tests if the given {@code r1} shape is disjoint with the given {@code r2} rectangle. - * This method will also verify class consistency by invoking the {@code contains} - * method, and by interchanging the arguments. - * - * <p>This method can be used for testing the {@code r1} implementation - it should not - * be needed for standard implementations.</p> - * - * @param r1 The first shape to test. - * @param r2 The second rectangle to test. - */ - public static void assertDisjoint(final RectangularShape r1, final Rectangle2D r2) { - assertFalse("r1.intersects(r2)", r1.intersects(r2)); - assertFalse("r1.contains(r2)", r1.contains(r2)); - if (r1 instanceof Rectangle2D) { - assertFalse("r2.intersects(r1)", r2.intersects((Rectangle2D) r1)); - assertFalse("r2.contains(r1)", r2.contains ((Rectangle2D) r1)); - } - for (int i=0; i<9; i++) { - final double x, y; - switch (i % 3) { - case 0: x = r2.getMinX(); break; - case 1: x = r2.getCenterX(); break; - case 2: x = r2.getMaxX(); break; - default: throw new AssertionError(i); - } - switch (i / 3) { - case 0: y = r2.getMinY(); break; - case 1: y = r2.getCenterY(); break; - case 2: y = r2.getMaxY(); break; - default: throw new AssertionError(i); - } - assertFalse("r1.contains(" + x + ", " + y + ')', r1.contains(x, y)); - } - } - - /** - * Asserts that two rectangles have the same location and the same size. - * - * @param expected The expected rectangle. - * @param actual The rectangle to compare with the expected one. - * @param tolx The tolerance threshold on location along the <var>x</var> axis. - * @param toly The tolerance threshold on location along the <var>y</var> axis. - */ - public static void assertRectangleEquals(final RectangularShape expected, - final RectangularShape actual, final double tolx, final double toly) - { - assertEquals("Min X", expected.getMinX(), actual.getMinX(), tolx); - assertEquals("Min Y", expected.getMinY(), actual.getMinY(), toly); - assertEquals("Max X", expected.getMaxX(), actual.getMaxX(), tolx); - assertEquals("Max Y", expected.getMaxY(), actual.getMaxY(), toly); - assertEquals("Center X", expected.getCenterX(), actual.getCenterX(), tolx); - assertEquals("Center Y", expected.getCenterY(), actual.getCenterY(), toly); - assertEquals("Width", expected.getWidth(), actual.getWidth(), tolx*2); - assertEquals("Height", expected.getHeight(), actual.getHeight(), toly*2); - } - - /** - * Asserts that two images have the same origin and the same size. - * - * @param expected The image having the expected size. - * @param actual The image to compare with the expected one. - */ - public static void assertBoundEquals(final RenderedImage expected, final RenderedImage actual) { - assertEquals("Min X", expected.getMinX(), actual.getMinX()); - assertEquals("Min Y", expected.getMinY(), actual.getMinY()); - assertEquals("Width", expected.getWidth(), actual.getWidth()); - assertEquals("Height", expected.getHeight(), actual.getHeight()); - } - - /** * Serializes the given object in memory, deserialize it and ensures that the deserialized * object is equals to the original one. This method doesn't write anything to the disk. * Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java?rev=1422813&r1=1422812&r2=1422813&view=diff ============================================================================== --- sis/trunk/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java (original) +++ sis/trunk/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java Mon Dec 17 09:26:20 2012 @@ -59,7 +59,6 @@ import org.junit.runners.Suite; // GeoAPI most basic types. org.apache.sis.util.iso.TypesTest.class, - org.apache.sis.util.iso.CodeListsTest.class, org.apache.sis.util.iso.SimpleInternationalStringTest.class, org.apache.sis.util.iso.DefaultInternationalStringTest.class, org.apache.sis.internal.util.LocalizedParseExceptionTest.class, Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java?rev=1422813&r1=1422812&r2=1422813&view=diff ============================================================================== --- sis/trunk/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java (original) +++ sis/trunk/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java Mon Dec 17 09:26:20 2012 @@ -100,6 +100,39 @@ public final strictfp class CharSequence } /** + * Tests the {@link CharSequences#indexOf(CharSequence, int, int)} and + * {@link CharSequences#lastIndexOf(CharSequence, int, int)} methods. + * We test two time with different kind of character sequences, in order + * to test the {@link String} optimization case. + */ + @Test + public void testIndexOfChar() { + for (int i=0; i<2; i++) { + CharSequence string = "An ordinary sentence."; + switch (i) { + case 0: /* Test directly on the String instance. */ break; + case 1: string = new StringBuilder((String) string); break; + default: throw new AssertionError(i); + } + final int length = string.length(); + assertEquals(-1, indexOf(string, 'x', 0, length)); + assertEquals(-1, lastIndexOf(string, 'x', 0, length)); + assertEquals( 0, indexOf(string, 'A', 0, length)); + assertEquals( 0, lastIndexOf(string, 'A', 0, length)); + assertEquals(-1, indexOf(string, 'A', 1, length)); + assertEquals(-1, lastIndexOf(string, 'A', 1, length)); + assertEquals(length-1, indexOf(string, '.', 0, length)); + assertEquals(length-1, lastIndexOf(string, '.', 0, length)); + assertEquals(-1, indexOf(string, '.', 0, length-1)); + assertEquals(-1, lastIndexOf(string, '.', 0, length-1)); + assertEquals(10, indexOf(string, 'y', 0, length)); + assertEquals(10, lastIndexOf(string, 'y', 0, length)); + assertEquals(13, indexOf(string, 'e', 0, length)); + assertEquals(19, lastIndexOf(string, 'e', 0, length)); + } + } + + /** * Tests the {@link CharSequences#indexOfLineStart(CharSequence, int, int)} method. */ @Test @@ -118,6 +151,7 @@ public final strictfp class CharSequence * Tests {@link CharSequences#split(CharSequence, char)}. */ @Test + @DependsOnMethod("testIndexOfChar") public void testSplit() { assertArrayEquals(new String[] {"lundi", "mardi", "", "mercredi"}, split("lundi , mardi,,mercredi ", ',')); assertArrayEquals(new String[] {"lundi", "mardi", "", "mercredi"}, split("lundi \n mardi\r\n\nmercredi ", '\n')); @@ -127,6 +161,7 @@ public final strictfp class CharSequence * Tests the {@link CharSequences#splitOnEOL(CharSequence)} method. */ @Test + @DependsOnMethod("testIndexOfChar") public void testSplitOnEOL() { final CharSequence[] splitted = splitOnEOL("\nOne\r\nTwo\rThree \rFour\n Five\n\r Six \n"); assertArrayEquals(new String[] { Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/util/iso/TypesTest.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/util/iso/TypesTest.java?rev=1422813&r1=1422812&r2=1422813&view=diff ============================================================================== --- sis/trunk/sis-utility/src/test/java/org/apache/sis/util/iso/TypesTest.java (original) +++ sis/trunk/sis-utility/src/test/java/org/apache/sis/util/iso/TypesTest.java Mon Dec 17 09:26:20 2012 @@ -16,8 +16,13 @@ */ package org.apache.sis.util.iso; +import java.util.Set; +import java.util.Arrays; +import java.util.HashSet; import java.util.Locale; import org.opengis.metadata.citation.Citation; +import org.opengis.metadata.citation.OnLineFunction; +import org.opengis.metadata.content.ImagingCondition; import org.opengis.metadata.identification.CharacterSet; import org.opengis.referencing.datum.Datum; import org.opengis.referencing.cs.AxisDirection; @@ -59,6 +64,18 @@ public final strictfp class TypesTest ex } /** + * Tests the {@link Types#forCodeName(Class, String, boolean)} method. + */ + @Test + public void testForCodeName() { + assertSame(ImagingCondition.SEMI_DARKNESS, Types.forCodeName(ImagingCondition.class, "SEMI_DARKNESS", false)); + assertSame(ImagingCondition.SEMI_DARKNESS, Types.forCodeName(ImagingCondition.class, "SEMIDARKNESS", false)); + assertSame(ImagingCondition.SEMI_DARKNESS, Types.forCodeName(ImagingCondition.class, "semi darkness", false)); + assertSame(ImagingCondition.SEMI_DARKNESS, Types.forCodeName(ImagingCondition.class, "semi-darkness", false)); + assertNull(Types.forCodeName(ImagingCondition.class, "darkness", false)); + } + + /** * Tests the {@link Types#getDescription(Class, Locale)} method. */ @Test @@ -68,4 +85,66 @@ public final strictfp class TypesTest ex assertEquals("Jeu de caractères.", Types.getDescription(CharacterSet.class, Locale.FRENCH)); } + + /** + * Tests the {@link Types#getDescription(CodeList, Locale)} method. + */ + @Test + public void testGetCodeDescription() { + assertEquals("ISO/IEC 8859-1, Information technology - 8-bit single byte coded graphic character sets - Part 1 : Latin alphabet No.1.", + Types.getDescription(CharacterSet.ISO_8859_1, Locale.ENGLISH)); + assertEquals("ISO/IEC 8859-1, alphabet latin 1.", + Types.getDescription(CharacterSet.ISO_8859_1, Locale.FRENCH)); + } + + /** + * Tests the examples given in {@link Types#getListName(CodeList)} javadoc. + */ + @Test + public void testGetListName() { + assertEquals("CS_AxisDirection", Types.getListName(AxisDirection .NORTH)); + assertEquals("MD_CharacterSetCode", Types.getListName(CharacterSet .UTF_8)); + assertEquals("MD_ImagingConditionCode", Types.getListName(ImagingCondition.BLURRED_IMAGE)); + } + + /** + * Tests the examples given in {@link Types#getCodeName(CodeList)} javadoc. + */ + @Test + public void testGetCodeName() { + assertEquals("north", Types.getCodeName(AxisDirection .NORTH)); + assertEquals("utf8", Types.getCodeName(CharacterSet .UTF_8)); + assertEquals("blurredImage", Types.getCodeName(ImagingCondition.BLURRED_IMAGE)); + } + + /** + * Tests the examples given in {@link Types#getCodeTitle(CodeList)} javadoc. + */ + @Test + public void testGetCodeTitle() { + assertEquals("North", Types.getCodeTitle(AxisDirection .NORTH)); + assertEquals("UTF-8", Types.getCodeTitle(CharacterSet .UTF_8)); + assertEquals("Blurred image", Types.getCodeTitle(ImagingCondition.BLURRED_IMAGE)); + } + + /** + * Tests {@link Types#getCodeTitle(CodeList, Locale)}. + */ + @Test + public void testGetLocalizedCodeTitle() { + assertEquals("Download", Types.getCodeTitle(OnLineFunction.DOWNLOAD, Locale.ENGLISH)); + assertEquals("Téléchargement", Types.getCodeTitle(OnLineFunction.DOWNLOAD, Locale.FRENCH)); + } + + /** + * Tests the {@link Types#getCodeValues(Class)} method. + */ + @Test + public void testGetCodeValues() { + final Set<OnLineFunction> expected = new HashSet<OnLineFunction>(Arrays.asList( + OnLineFunction.INFORMATION, OnLineFunction.SEARCH, OnLineFunction.ORDER, + OnLineFunction.DOWNLOAD, OnLineFunction.OFFLINE_ACCESS)); + final OnLineFunction[] actual = Types.getCodeValues(OnLineFunction.class); + assertTrue(expected.containsAll(Arrays.asList(actual))); + } } Modified: sis/trunk/src/main/javadoc/stylesheet.css URL: http://svn.apache.org/viewvc/sis/trunk/src/main/javadoc/stylesheet.css?rev=1422813&r1=1422812&r2=1422813&view=diff ============================================================================== --- sis/trunk/src/main/javadoc/stylesheet.css (original) +++ sis/trunk/src/main/javadoc/stylesheet.css Mon Dec 17 09:26:20 2012 @@ -17,7 +17,7 @@ table.sis { border-width: 1pt; border-spacing: 0pt; margin: 12pt 0 12pt 0; - padding: 0; + padding: 0pt; width: auto; } @@ -56,10 +56,13 @@ table.sis tr td.sep { /* * Table without vertical space between rows and a little bit of space between columns. - * Other properties are left to their default values. In particular, there is no border. + * This table has no border. */ table.compact { + width: auto; + border: none; border-spacing: 0pt; + padding: 0pt; } table.compact tr td {
