Modified: sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/VerticalDatum (GML 3.1).xml URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/VerticalDatum%20%28GML%203.1%29.xml?rev=1701516&r1=1701515&r2=1701516&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/VerticalDatum (GML 3.1).xml (original) +++ sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/VerticalDatum (GML 3.1).xml Sun Sep 6 19:10:30 2015 @@ -17,6 +17,7 @@ specific language governing permissions and limitations under the License. --> + <gml:VerticalDatum xsi:schemaLocation = "http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/base/datums.xsd" xmlns:gml = "http://www.opengis.net/gml" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
Modified: sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/VerticalDatum.xml URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/VerticalDatum.xml?rev=1701516&r1=1701515&r2=1701516&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/VerticalDatum.xml (original) +++ sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/VerticalDatum.xml Sun Sep 6 19:10:30 2015 @@ -17,6 +17,7 @@ specific language governing permissions and limitations under the License. --> + <gml:VerticalDatum xsi:schemaLocation = "http://www.opengis.net/gml/3.2 http://schemas.opengis.net/gml/3.2.1/datums.xsd" xmlns:gml = "http://www.opengis.net/gml/3.2" xmlns:gmd = "http://www.isotc211.org/2005/gmd" Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java?rev=1701516&r1=1701515&r2=1701516&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java [UTF-8] Sun Sep 6 19:10:30 2015 @@ -46,7 +46,7 @@ import org.apache.sis.xml.ReferenceResol * * @author Martin Desruisseaux (Geomatys) * @since 0.3 - * @version 0.5 + * @version 0.6 * @module */ public final class Context extends MarshalContext { @@ -530,16 +530,16 @@ public final class Context extends Marsh * Convenience method for sending a warning for the given exception. * The logger will be {@code "org.apache.sis.xml"}. * - * @param context The current context, or {@code null} if none. - * @param classe The class to declare as the warning source. - * @param method The name of the method to declare as the warning source. - * @param cause The exception which occurred. - * @param warning {@code true} for {@link Level#WARNING}, or {@code false} for {@link Level#FINE}. + * @param context The current context, or {@code null} if none. + * @param classe The class to declare as the warning source. + * @param method The name of the method to declare as the warning source. + * @param cause The exception which occurred. + * @param isWarning {@code true} for {@link Level#WARNING}, or {@code false} for {@link Level#FINE}. */ public static void warningOccured(final Context context, final Class<?> classe, - final String method, final Exception cause, final boolean warning) + final String method, final Exception cause, final boolean isWarning) { - warningOccured(context, warning ? Level.WARNING : Level.FINE, classe, method, cause, + warningOccured(context, isWarning ? Level.WARNING : Level.FINE, classe, method, cause, null, (short) 0, (Object[]) null); } Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java?rev=1701516&r1=1701515&r2=1701516&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java [UTF-8] Sun Sep 6 19:10:30 2015 @@ -19,7 +19,6 @@ package org.apache.sis.internal.jaxb.gco import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlSeeAlso; -import org.opengis.util.InternationalString; import org.apache.sis.xml.Namespaces; import org.apache.sis.internal.jaxb.Context; import org.apache.sis.internal.jaxb.gmx.Anchor; @@ -156,19 +155,7 @@ public class GO_CharacterString { */ @XmlElement(name = "CharacterString") public final String getCharacterString() { - if (type == 0) { - final CharSequence text = this.text; - if (text != null && !(text instanceof Anchor)) { - if (text instanceof InternationalString) { - final Context context = Context.current(); - if (context != null) { - return ((InternationalString) text).toString(context.getLocale()); - } - } - return text.toString(); - } - } - return null; + return (type == 0 && !(text instanceof Anchor)) ? StringAdapter.toString(text) : null; } /** Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java?rev=1701516&r1=1701515&r2=1701516&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java [UTF-8] Sun Sep 6 19:10:30 2015 @@ -53,7 +53,7 @@ public class StringAdapter extends XmlAd * * @see org.apache.sis.xml.XML#LOCALE */ - static String toString(final CharSequence text) { + public static String toString(final CharSequence text) { if (text == null) { return null; } Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod.java?rev=1701516&r1=1701515&r2=1701516&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod.java [UTF-8] Sun Sep 6 19:10:30 2015 @@ -49,8 +49,8 @@ public final class TimePeriod extends GM * The GML2 way is more verbose. */ @XmlElements({ - @XmlElement(type=TimePeriodBound.GML3.class, name="beginPosition"), - @XmlElement(type=TimePeriodBound.GML2.class, name="begin") + @XmlElement(type = TimePeriodBound.GML3.class, name = "beginPosition"), + @XmlElement(type = TimePeriodBound.GML2.class, name = "begin") }) TimePeriodBound begin; @@ -59,8 +59,8 @@ public final class TimePeriod extends GM * The GML2 way is more verbose. */ @XmlElements({ - @XmlElement(type=TimePeriodBound.GML3.class, name="endPosition"), - @XmlElement(type=TimePeriodBound.GML2.class, name="end") + @XmlElement(type = TimePeriodBound.GML3.class, name = "endPosition"), + @XmlElement(type = TimePeriodBound.GML2.class, name = "end") }) TimePeriodBound end; Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/simple/CitationConstant.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/simple/CitationConstant.java?rev=1701516&r1=1701515&r2=1701516&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/simple/CitationConstant.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/simple/CitationConstant.java [UTF-8] Sun Sep 6 19:10:30 2015 @@ -127,6 +127,7 @@ public class CitationConstant extends Si * since that module is required by {@code sis-referencing} which is itself required by * almost all other SIS modules.</p> */ + @SuppressWarnings("DoubleCheckedLocking") private Citation delegate() { Citation c = delegate; if (c == null) { Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java?rev=1701516&r1=1701515&r2=1701516&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java [UTF-8] Sun Sep 6 19:10:30 2015 @@ -20,6 +20,7 @@ import java.util.*; import java.lang.reflect.Array; import org.opengis.util.CodeList; import org.apache.sis.util.Static; +import org.apache.sis.util.Numbers; import org.apache.sis.util.collection.CodeListSet; import org.apache.sis.util.resources.Errors; import org.opengis.parameter.InvalidParameterCardinalityException; @@ -606,6 +607,27 @@ public final class CollectionsExt extend } /** + * Returns the elements of the given collection as an array. This method can be used when the {@code valueClass} + * argument is not known at compile-time. If the {@code valueClass} is known at compile-time, then callers should + * use {@link Collection#toArray(T[])} instead. + * + * @param <T> The compile-time value of {@code valueClass}. + * @param collection The collection from which to get the elements. + * @param valueClass The runtime type of collection elements. + * @return The collection elements as an array, or {@code null} if {@code collection} is null. + * + * @since 0.6 + */ + @SuppressWarnings("unchecked") + public static <T> T[] toArray(final Collection<T> collection, final Class<T> valueClass) { + assert Numbers.primitiveToWrapper(valueClass) == valueClass : valueClass; + if (collection != null) { + return collection.toArray((T[]) Array.newInstance(valueClass, collection.size())); + } + return null; + } + + /** * Adds a value in a pseudo multi-values map. The multi-values map is simulated by a map of lists. * The map can be initially empty - lists will be created as needed. * Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java?rev=1701516&r1=1701515&r2=1701516&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java [UTF-8] Sun Sep 6 19:10:30 2015 @@ -62,6 +62,7 @@ public class MetadataServices extends Op * * @return The singleton instance. */ + @SuppressWarnings("DoubleCheckedLocking") public static MetadataServices getInstance() { MetadataServices c = instance; if (c == null) { Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java?rev=1701516&r1=1701515&r2=1701516&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java [UTF-8] Sun Sep 6 19:10:30 2015 @@ -651,6 +651,7 @@ search: for (; fromIndex <= toIndex; * * @see String#split(String) */ + @SuppressWarnings("ReturnOfCollectionOrArrayField") public static CharSequence[] split(final CharSequence text, final char separator) { if (text == null) { return EMPTY_ARRAY; @@ -717,6 +718,7 @@ search: for (; fromIndex <= toIndex; * * @see #indexOfLineStart(CharSequence, int, int) */ + @SuppressWarnings("ReturnOfCollectionOrArrayField") public static CharSequence[] splitOnEOL(final CharSequence text) { if (text == null) { return EMPTY_ARRAY; Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/CorruptedObjectException.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/CorruptedObjectException.java?rev=1701516&r1=1701515&r2=1701516&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/CorruptedObjectException.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/CorruptedObjectException.java [UTF-8] Sun Sep 6 19:10:30 2015 @@ -16,6 +16,8 @@ */ package org.apache.sis.util; +import org.opengis.referencing.IdentifiedObject; + /** * May be thrown on attempt to use an object which has been corrupted by a previous operation. @@ -57,7 +59,7 @@ package org.apache.sis.util; * * @author Martin Desruisseaux (Geomatys) * @since 0.5 - * @version 0.5 + * @version 0.6 * @module */ public class CorruptedObjectException extends RuntimeException { @@ -81,4 +83,15 @@ public class CorruptedObjectException ex public CorruptedObjectException(final String message) { super(message); } + + /** + * Constructs a new exception with the name of the given object. + * + * @param object The corrupted object, or {@code null} if unknown. + * + * @since 0.6 + */ + public CorruptedObjectException(final IdentifiedObject object) { + super(object != null ? String.valueOf(object.getName()) : null); + } } Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java?rev=1701516&r1=1701515&r2=1701516&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java [UTF-8] Sun Sep 6 19:10:30 2015 @@ -101,16 +101,6 @@ public class DefaultLocalName extends Ab final CharSequence name; /** - * Empty constructor to be used by JAXB only, or by sub-classes empty constructors - * themselves used only by JAXB. Despite its "final" declaration, the {@link #name} - * field will be set by JAXB during unmarshalling. - */ - DefaultLocalName() { - scope = null; - name = null; - } - - /** * Constructs a local name from the given character sequence. * If the character sequence is an instance of {@link InternationalString}, * then its {@link InternationalString#toString(java.util.Locale) toString(Locale.ROOT)} @@ -341,4 +331,28 @@ public class DefaultLocalName extends Ab } return ns.local(name, this); } + + + + + ////////////////////////////////////////////////////////////////////////////////////////////////// + //////// //////// + //////// XML support with JAXB //////// + //////// //////// + //////// The following methods are invoked by JAXB using reflection (even if //////// + //////// they are private) or are helpers for other methods invoked by JAXB. //////// + //////// Those methods can be safely removed if Geographic Markup Language //////// + //////// (GML) support is not needed. //////// + //////// //////// + ////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Empty constructor to be used by JAXB only, or by sub-classes empty constructors + * themselves used only by JAXB. Despite its "final" declaration, the {@link #name} + * field will be set by JAXB during unmarshalling. + */ + DefaultLocalName() { + scope = null; + name = null; + } } Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultMemberName.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultMemberName.java?rev=1701516&r1=1701515&r2=1701516&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultMemberName.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultMemberName.java [UTF-8] Sun Sep 6 19:10:30 2015 @@ -68,14 +68,6 @@ public class DefaultMemberName extends D private final TypeName attributeType; /** - * Empty constructor to be used by JAXB only. Despite its "final" declaration, - * the {@link #attributeType} field will be set by JAXB during unmarshalling. - */ - private DefaultMemberName() { - attributeType = null; - } - - /** * Constructs a member name from the given character sequence and attribute type. * * @param scope The scope of this name, or {@code null} for a global scope. @@ -141,4 +133,26 @@ public class DefaultMemberName extends D final int computeHashCode() { return super.computeHashCode() + Objects.hashCode(attributeType); } + + + + + ////////////////////////////////////////////////////////////////////////////////////////////////// + //////// //////// + //////// XML support with JAXB //////// + //////// //////// + //////// The following methods are invoked by JAXB using reflection (even if //////// + //////// they are private) or are helpers for other methods invoked by JAXB. //////// + //////// Those methods can be safely removed if Geographic Markup Language //////// + //////// (GML) support is not needed. //////// + //////// //////// + ////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Empty constructor to be used by JAXB only. Despite its "final" declaration, + * the {@link #attributeType} field will be set by JAXB during unmarshalling. + */ + private DefaultMemberName() { + attributeType = null; + } } Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java?rev=1701516&r1=1701515&r2=1701516&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java [UTF-8] Sun Sep 6 19:10:30 2015 @@ -125,14 +125,6 @@ public class DefaultRecordType extends R private transient Type[] memberTypes; /** - * Empty constructor only used by JAXB. - */ - private DefaultRecordType() { - typeName = null; - container = null; - } - - /** * Creates a new record with the same names and members than the given one. * * @param other The {@code RecordType} to copy. @@ -437,4 +429,26 @@ public class DefaultRecordType extends R public int hashCode() { return Objects.hashCode(typeName) + 31*(memberIndices().hashCode() + 31*Arrays.hashCode(memberTypes)); } + + + + + ////////////////////////////////////////////////////////////////////////////////////////////////// + //////// //////// + //////// XML support with JAXB //////// + //////// //////// + //////// The following methods are invoked by JAXB using reflection (even if //////// + //////// they are private) or are helpers for other methods invoked by JAXB. //////// + //////// Those methods can be safely removed if Geographic Markup Language //////// + //////// (GML) support is not needed. //////// + //////// //////// + ////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Empty constructor only used by JAXB. + */ + private DefaultRecordType() { + typeName = null; + container = null; + } } Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultTypeName.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultTypeName.java?rev=1701516&r1=1701515&r2=1701516&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultTypeName.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultTypeName.java [UTF-8] Sun Sep 6 19:10:30 2015 @@ -99,13 +99,6 @@ public class DefaultTypeName extends Def private transient Class<?> valueClass; /** - * Empty constructor to be used by JAXB only. Despite its "final" declaration, - * the {@link #name} field will be set by JAXB during unmarshalling. - */ - private DefaultTypeName() { - } - - /** * Constructs a type name from the given character sequence. The argument are given unchanged to the * {@linkplain DefaultLocalName#DefaultLocalName(NameSpace,CharSequence) super-class constructor}. * @@ -223,4 +216,25 @@ public class DefaultTypeName extends Def } return (c != Void.TYPE) ? c : null; } + + + + + ////////////////////////////////////////////////////////////////////////////////////////////////// + //////// //////// + //////// XML support with JAXB //////// + //////// //////// + //////// The following methods are invoked by JAXB using reflection (even if //////// + //////// they are private) or are helpers for other methods invoked by JAXB. //////// + //////// Those methods can be safely removed if Geographic Markup Language //////// + //////// (GML) support is not needed. //////// + //////// //////// + ////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Empty constructor to be used by JAXB only. Despite its "final" declaration, + * the {@link #name} field will be set by JAXB during unmarshalling. + */ + private DefaultTypeName() { + } } Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/util/CollectionsExtTest.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/util/CollectionsExtTest.java?rev=1701516&r1=1701515&r2=1701516&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/util/CollectionsExtTest.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/util/CollectionsExtTest.java [UTF-8] Sun Sep 6 19:10:30 2015 @@ -44,7 +44,7 @@ import org.apache.sis.internal.jdk8.Func * * @author Martin Desruisseaux (Geomatys) * @since 0.3 - * @version 0.5 + * @version 0.6 * @module */ public final strictfp class CollectionsExtTest extends TestCase { @@ -153,4 +153,16 @@ public final strictfp class CollectionsE assertFalse(CollectionsExt.identityEquals(c2.iterator(), c1.iterator())); assertTrue(CollectionsExt.identityEquals(c1.iterator(), Arrays.asList("A", "B", "C").iterator())); } + + /** + * Tests {@link CollectionsExt#toArray(Collection, Class)}. + * + * @since 0.6 + */ + @Test + public void testToArray() { + final String[] expected = new String[] {"One", "Two", "Three"}; + final String[] actual = CollectionsExt.toArray(Arrays.asList(expected), String.class); + assertArrayEquals(expected, actual); + } } Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/LogRecordCollector.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/LogRecordCollector.java?rev=1701516&r1=1701515&r2=1701516&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/LogRecordCollector.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/LogRecordCollector.java [UTF-8] Sun Sep 6 19:10:30 2015 @@ -118,7 +118,8 @@ final class LogRecordCollector extends H final String lineSeparator = System.lineSeparator(); if (!records.isEmpty()) { out.append(lineSeparator) - .append("The following tests have logged messages at level INFO or higher:").append(lineSeparator); + .append("The following tests have logged messages at level INFO or higher:").append(lineSeparator) + .append("See 'org.apache.sis.test.LoggingWatcher' for information about logging during tests.").append(lineSeparator); final TableAppender table = new TableAppender(out); table.setMultiLinesCells(false); table.nextLine('═'); Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java?rev=1701516&r1=1701515&r2=1701516&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java [UTF-8] Sun Sep 6 19:10:30 2015 @@ -30,6 +30,25 @@ import static org.junit.Assert.*; * Watches the logs sent to the given logger. Logs will be allowed only if the test was * expected to cause some logging events to occur, otherwise a test failure will occurs. * + * <div class="note">Usage example</div> + * Create a rule in the JUnit test class like below: + * + * {@preformat java + * @Rule + * public final LoggingWatcher listener = new LoggingWatcher(Logging.getLogger(Loggers.XML)) { + * @Override protected void verifyMessage(final String message) { + * assertTrue(message.contains("An expected word in the logging message")); + * } + * }; + * } + * + * Then, <em>only</em> in the test which are expected to emit a warning, add the following line + * (replace 1 by a higher value if more than one logging is expected): + * + * {@preformat java + * listener.maximumLogCount = 1; + * } + * * @author Martin Desruisseaux (Geomatys) * @since 0.6 * @version 0.6 @@ -50,6 +69,7 @@ public strictfp class LoggingWatcher ext /** * The logger to watch. */ + @SuppressWarnings("NonConstantLogger") private final Logger logger; /** Modified: sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/internal/profile/fra/DataIdentificationTest.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/internal/profile/fra/DataIdentificationTest.java?rev=1701516&r1=1701515&r2=1701516&view=diff ============================================================================== --- sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/internal/profile/fra/DataIdentificationTest.java [UTF-8] (original) +++ sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/internal/profile/fra/DataIdentificationTest.java [UTF-8] Sun Sep 6 19:10:30 2015 @@ -58,8 +58,8 @@ public final strictfp class DataIdentifi final Object id = XML.unmarshal(xml); assertInstanceOf("Expected an AFNOR instance.", DataIdentification.class, id); - assertEquals("citation", "Main documentation.", ((DataIdentification) id).getCitation().getTitle().toString()); - assertEquals("relatedCitations", "Related documentation.", getSingleton(((DataIdentification) id).getRelatedCitations()).getTitle().toString()); + assertTitleEquals("citation", "Main documentation.", ((DataIdentification) id).getCitation()); + assertTitleEquals("relatedCitations", "Related documentation.", getSingleton(((DataIdentification) id).getRelatedCitations())); final String actual = XML.marshal(id); assertXmlEquals(xml, actual, "xmlns:*");
