sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1497592 - in /sis/branches/JDK6: ./ core/sis-metadata/src/main/java/org/apache/sis/metadata/ core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/ core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/gml/ core/sis-meta...
Date Thu, 27 Jun 2013 22:32:59 GMT
Author: desruisseaux
Date: Thu Jun 27 22:32:59 2013
New Revision: 1497592

URL: http://svn.apache.org/r1497592
Log:
Merge from the JDK7 branch.

Added:
    sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/
      - copied from r1497586, sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/
    sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/xml/
      - copied from r1497586, sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/
    sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/
      - copied from r1497586, sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/
    sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/mock/DataIdentificationMock.java
      - copied unchanged from r1497586, sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/DataIdentificationMock.java
Modified:
    sis/branches/JDK6/   (props changed)
    sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
    sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/CodeListMarshallingTest.java
    sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/gml/TimePeriodTest.java
    sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeChildrenTest.java
    sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
    sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java
    sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/collection/CodeListSet.java
    sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageMarshallingTest.java
    sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java
    sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/mock/IdentifiedObjectMock.java
    sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/mock/package-info.java
    sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
    sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java

Propchange: sis/branches/JDK6/
------------------------------------------------------------------------------
  Merged /sis/branches/JDK7:r1497447-1497586

Modified: sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java?rev=1497592&r1=1497591&r2=1497592&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
[UTF-8] Thu Jun 27 22:32:59 2013
@@ -18,13 +18,16 @@ package org.apache.sis.metadata;
 
 import java.util.Set;
 import java.util.List;
+import java.util.EnumSet;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.NoSuchElementException;
+import java.lang.reflect.Modifier;
 import org.opengis.util.CodeList;
 import org.apache.sis.util.ThreadSafe;
 import org.apache.sis.util.logging.Logging;
 import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.collection.CodeListSet;
 import org.apache.sis.internal.util.CheckedHashSet;
 import org.apache.sis.internal.util.CheckedArrayList;
 
@@ -383,7 +386,7 @@ public abstract class ModifiableMetadata
                 } else {
                     final int capacity = source.size();
                     if (useSet(elementType)) {
-                        target = new CheckedHashSet<E>(elementType, capacity);
+                        target = createSet(elementType, capacity);
                     } else {
                         target = new CheckedArrayList<E>(elementType, capacity);
                     }
@@ -455,7 +458,7 @@ public abstract class ModifiableMetadata
         final Collection<E> target;
         final int capacity = source.size();
         if (useSet(elementType)) {
-            target = new CheckedHashSet<E>(elementType, capacity);
+            target = createSet(elementType, capacity);
         } else {
             target = new CheckedArrayList<E>(elementType, capacity);
         }
@@ -482,7 +485,7 @@ public abstract class ModifiableMetadata
         }
         final Collection<E> collection;
         if (useSet(elementType)) {
-            collection = new CheckedHashSet<E>(elementType, INITIAL_CAPACITY);
+            collection = createSet(elementType, INITIAL_CAPACITY);
         } else {
             collection = new CheckedArrayList<E>(elementType, INITIAL_CAPACITY);
         }
@@ -562,7 +565,7 @@ public abstract class ModifiableMetadata
         final boolean isModifiable = isModifiable();
         if (useSet(elementType)) {
             if (isModifiable) {
-                return new CheckedHashSet<E>(elementType, INITIAL_CAPACITY);
+                return createSet(elementType, INITIAL_CAPACITY);
             } else {
                 return Collections.emptySet();
             }
@@ -576,17 +579,28 @@ public abstract class ModifiableMetadata
     }
 
     /**
+     * Creates a modifiable set for elements of the given type. This method will create an
{@link EnumSet},
+     * {@link CodeListSet} or {@link LinkedHashSet} depending on the {@code elementType}
argument.
+     */
+    @SuppressWarnings({"unchecked","rawtypes"})
+    private <E> Set<E> createSet(final Class<E> elementType, final int
capacity) {
+        if (Enum.class.isAssignableFrom(elementType)) {
+            return EnumSet.noneOf((Class) elementType);
+        }
+        if (CodeList.class.isAssignableFrom(elementType) && Modifier.isFinal(elementType.getModifiers()))
{
+            return new CodeListSet((Class) elementType);
+        }
+        return new CheckedHashSet<E>(elementType, capacity);
+    }
+
+    /**
      * Returns {@code true} if we should use a {@link Set} instead than a {@link List}
      * for elements of the given type.
      */
     private <E> boolean useSet(final Class<E> elementType) {
         final Class<? extends Collection<E>> type = collectionType(elementType);
-        if (Set.class.isAssignableFrom(type)) {
-            return true;
-        }
-        if (List.class.isAssignableFrom(type)) {
-            return false;
-        }
+        if (Set .class == (Class) type) return true;
+        if (List.class == (Class) type) return false;
         throw new NoSuchElementException(Errors.format(Errors.Keys.UnsupportedType_1, type));
     }
 

Modified: sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/CodeListMarshallingTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/CodeListMarshallingTest.java?rev=1497592&r1=1497586&r2=1497592&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/CodeListMarshallingTest.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/CodeListMarshallingTest.java
[UTF-8] Thu Jun 27 22:32:59 2013
@@ -68,7 +68,7 @@ public final strictfp class CodeListMars
      */
     @BeforeClass
     public static void createMarshallerPool() throws JAXBException {
-        final Map<String,Object> properties = new HashMap<>(4);
+        final Map<String,Object> properties = new HashMap<String,Object>(4);
         assertNull(properties.put(XML.LOCALE, Locale.FRANCE));
         assertNull(properties.put(XML.TIMEZONE, "CET"));
         pool = new MarshallerPool(properties);

Modified: sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/gml/TimePeriodTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/gml/TimePeriodTest.java?rev=1497592&r1=1497591&r2=1497592&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/gml/TimePeriodTest.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/gml/TimePeriodTest.java
[UTF-8] Thu Jun 27 22:32:59 2013
@@ -19,8 +19,6 @@ package org.apache.sis.internal.jaxb.gml
 import java.util.Map;
 import java.util.HashMap;
 import java.util.Locale;
-import java.io.StringReader;
-import java.io.StringWriter;
 import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;
 import javax.xml.bind.JAXBContext;
@@ -55,11 +53,6 @@ public final strictfp class TimePeriodTe
     private static MarshallerPool pool;
 
     /**
-     * A buffer where to marshal.
-     */
-    private final StringWriter buffer = new StringWriter();
-
-    /**
      * Set the marshalling context to a fixed locale and timezone before to create the
      * JAXB wrappers for temporal objects. Callers shall invoke {@link #clearContext()}
      * after this method.
@@ -114,14 +107,13 @@ public final strictfp class TimePeriodTe
         final Unmarshaller unmarshaller = pool.acquireUnmarshaller();
 
         final TimeInstant instant = createTimeInstant("1992-01-01 00:00:00");
-        marshaller.marshal(instant, buffer);
-        final String actual = buffer.toString();
+        final String actual = marshal(marshaller, instant);
         assertXmlEquals(
                 "<gml:TimeInstant>\n" +
                 "  <gml:timePosition>1992-01-01T01:00:00.000+01:00</gml:timePosition>\n"
+
-                "</gml:TimeInstant>\n", actual, "xmlns:*", "xsi:schemaLocation");
+                "</gml:TimeInstant>\n", actual, "xmlns:*");
 
-        final TimeInstant test = (TimeInstant) unmarshaller.unmarshal(new StringReader(actual));
+        final TimeInstant test = (TimeInstant) unmarshal(unmarshaller, actual);
         assertEquals("1992-01-01 00:00:00", format(XmlUtilities.toDate(test.timePosition)));
 
         pool.recycle(marshaller);
@@ -170,10 +162,9 @@ public final strictfp class TimePeriodTe
         final TimePeriod period = new TimePeriod();
         period.begin = begin;
         period.end   = end;
-        marshaller.marshal(period, buffer);
-        final String actual = buffer.toString();
-        assertXmlEquals(expected, actual, "xmlns:*", "xsi:schemaLocation");
-        final TimePeriod test = (TimePeriod) unmarshaller.unmarshal(new StringReader(actual));
+        final String actual = marshal(marshaller, period);
+        assertXmlEquals(expected, actual, "xmlns:*");
+        final TimePeriod test = (TimePeriod) unmarshal(unmarshaller, actual);
         if (verifyValues) {
             assertEquals("1992-01-01 00:00:00", format(XmlUtilities.toDate(test.begin.calendar())));
             assertEquals("2007-12-31 00:00:00", format(XmlUtilities.toDate(test.end  .calendar())));

Modified: sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeChildrenTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeChildrenTest.java?rev=1497592&r1=1497591&r2=1497592&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeChildrenTest.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeChildrenTest.java
[UTF-8] Thu Jun 27 22:32:59 2013
@@ -200,9 +200,9 @@ public final strictfp class TreeNodeChil
             "Second alternate title",
             "Third alternate title",  // After addition
             "New edition", // After "addition" (actually change).
+            "PresentationForm[IMAGE_DIGITAL]", // After addition
             "PresentationForm[MAP_DIGITAL]",
             "PresentationForm[MAP_HARDCOPY]",
-            "PresentationForm[IMAGE_DIGITAL]", // After addition
             "Some other details"
         };
         toAdd.setValue(TableColumn.IDENTIFIER, "edition");

Modified: sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java?rev=1497592&r1=1497591&r2=1497592&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
[UTF-8] Thu Jun 27 22:32:59 2013
@@ -55,7 +55,11 @@ import org.junit.BeforeClass;
     org.apache.sis.metadata.AbstractMetadataTest.class,
     org.apache.sis.metadata.iso.AllMetadataTest.class,
 
-    // XML marshalling
+    // XML marshalling.
+    org.apache.sis.xml.NilReasonMarshallingTest.class,
+    org.apache.sis.xml.FreeTextMarshallingTest.class,
+    org.apache.sis.internal.jaxb.code.CodeListMarshallingTest.class,
+    org.apache.sis.internal.jaxb.gmd.LanguageMarshallingTest.class,
     org.apache.sis.internal.jaxb.gml.TimePeriodTest.class
 })
 public final strictfp class MetadataTestSuite extends TestSuite {

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java?rev=1497592&r1=1497591&r2=1497592&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java
[UTF-8] Thu Jun 27 22:32:59 2013
@@ -102,17 +102,12 @@ public final class LanguageCode extends 
                     return new LanguageCode(string);
                 }
             }
-            String codeSpace = null;
-            String value = null;
-            if (context != null) {
-                final Locale marshalLocale = context.getLocale();
-                if (marshalLocale != null) {
-                    codeSpace = Context.converter(context).toLanguageCode(context, locale);
-                    value = locale.getDisplayLanguage(marshalLocale);
-                    if (value.isEmpty()) {
-                        value = null;
-                    }
-                }
+            final Locale marshalLocale = (context != null) ? context.getLocale() : null;
+            final String codeSpace = Context.converter(context).toLanguageCode(context, locale);
+            String value = (marshalLocale != null) ? locale.getDisplayLanguage(marshalLocale)
+                                                   : locale.getDisplayLanguage();
+            if (value.isEmpty()) {
+                value = null;
             }
             if (!codeListValue.isEmpty() || value != null) {
                 return new LanguageCode(context, codeListValue, codeSpace, value);

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/collection/CodeListSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/collection/CodeListSet.java?rev=1497592&r1=1497591&r2=1497592&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/collection/CodeListSet.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/collection/CodeListSet.java
[UTF-8] Thu Jun 27 22:32:59 2013
@@ -126,7 +126,7 @@ public class CodeListSet<E extends CodeL
      * those new elements will <em>not</em> be in this set.
      *
      * @param  elementType The type of code list elements to be included in this set.
-     * @param  fill {@code true} for filling the set with all known elements if the given
type,
+     * @param  fill {@code true} for filling the set with all known elements of the given
type,
      *         or {@code false} for leaving the set empty.
      * @throws IllegalArgumentException If the given class is not final.
      */

Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageMarshallingTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageMarshallingTest.java?rev=1497592&r1=1497586&r2=1497592&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageMarshallingTest.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageMarshallingTest.java
[UTF-8] Thu Jun 27 22:32:59 2013
@@ -61,7 +61,7 @@ public final strictfp class LanguageMars
      */
     @BeforeClass
     public static void createMarshallerPool() throws JAXBException {
-        final Map<String,Object> properties = new HashMap<>(4);
+        final Map<String,Object> properties = new HashMap<String,Object>(4);
         assertNull(properties.put(XML.LOCALE, Locale.UK));
         assertNull(properties.put(XML.TIMEZONE, "UTC"));
         pool = new MarshallerPool(JAXBContext.newInstance(DataIdentificationMock.class),
properties);

Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java?rev=1497592&r1=1497591&r2=1497592&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java
[UTF-8] Thu Jun 27 22:32:59 2013
@@ -18,7 +18,13 @@ package org.apache.sis.test;
 
 import java.util.Locale;
 import java.util.TimeZone;
+import java.io.StringReader;
+import java.io.StringWriter;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.JAXBException;
 import org.apache.sis.internal.jaxb.Context;
+import org.apache.sis.util.ArgumentChecks;
 import org.junit.After;
 
 import static org.junit.Assert.*;
@@ -52,6 +58,11 @@ public abstract strictfp class XMLTestCa
     protected Context context;
 
     /**
+     * A buffer for {@link #marshal(Marshaller, Object)}, created only when first needed.
+     */
+    private StringWriter buffer;
+
+    /**
      * Creates a new test case.
      */
     protected XMLTestCase() {
@@ -84,4 +95,35 @@ public abstract strictfp class XMLTestCa
             context = null;
         }
     }
+
+    /**
+     * Marshals the given object using the given marshaler.
+     *
+     * @param  marshaller The marshaller to use.
+     * @param  object     The object to marshal, or {@code null}.
+     * @return The marshalled object, or {@code null} if and only if the given {@code object}
was null.
+     * @throws JAXBException If an error occurred while marshalling the object.
+     */
+    protected final String marshal(final Marshaller marshaller, final Object object) throws
JAXBException {
+        ArgumentChecks.ensureNonNull("marshaller", marshaller);
+        if (buffer == null) {
+            buffer = new StringWriter();
+        }
+        buffer.getBuffer().setLength(0);
+        marshaller.marshal(object, buffer);
+        return buffer.toString();
+    }
+
+    /**
+     * Unmarshals the given XML using the given unmarshaler.
+     *
+     * @param  unmarshaller The unmarshaller to use.
+     * @param  xml The XML representation of the object to unmarshal, or {@code null}.
+     * @return The unmarshalled object, or {@code null} if and only if the given {@code xml}
was null.
+     * @throws JAXBException If an error occurred while unmarshalling the XML.
+     */
+    protected final Object unmarshal(final Unmarshaller unmarshaller, final String xml) throws
JAXBException {
+        ArgumentChecks.ensureNonNull("unmarshaller", unmarshaller);
+        return unmarshaller.unmarshal(new StringReader(xml));
+    }
 }

Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/mock/IdentifiedObjectMock.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/mock/IdentifiedObjectMock.java?rev=1497592&r1=1497591&r2=1497592&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/mock/IdentifiedObjectMock.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/mock/IdentifiedObjectMock.java
[UTF-8] Thu Jun 27 22:32:59 2013
@@ -23,7 +23,6 @@ import org.opengis.util.GenericName;
 import org.opengis.util.InternationalString;
 import org.opengis.referencing.IdentifiedObject;
 import org.opengis.referencing.ReferenceIdentifier;
-import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@@ -38,7 +37,6 @@ import org.apache.sis.internal.jaxb.gco.
  * @version 0.3
  * @module
  */
-@XmlType(name = "IdentifiedObjectType")
 @XmlRootElement(name = "IO_IdentifiedObject")
 public final strictfp class IdentifiedObjectMock implements IdentifiedObject {
     /**
@@ -82,7 +80,7 @@ public final strictfp class IdentifiedOb
      */
     @Override
     public Collection<GenericName> getAlias() {
-        return Collections.singleton(alias);
+        return (alias != null) ? Collections.singleton(alias) : Collections.<GenericName>emptySet();
     }
 
     /**

Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/mock/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/mock/package-info.java?rev=1497592&r1=1497591&r2=1497592&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/mock/package-info.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/mock/package-info.java
[UTF-8] Thu Jun 27 22:32:59 2013
@@ -29,6 +29,7 @@
  */
 @XmlSchema(elementFormDefault = XmlNsForm.QUALIFIED, namespace = Namespaces.GML, xmlns =
{
     @XmlNs(prefix = "gml", namespaceURI = Namespaces.GML),
+    @XmlNs(prefix = "gmd", namespaceURI = Namespaces.GMD),
     @XmlNs(prefix = "gco", namespaceURI = Namespaces.GCO)
 })
 @XmlAccessorType(XmlAccessType.NONE)

Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java?rev=1497592&r1=1497591&r2=1497592&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
[UTF-8] Thu Jun 27 22:32:59 2013
@@ -99,7 +99,7 @@ import org.junit.BeforeClass;
     org.apache.sis.util.collection.TreeTableFormatTest.class,
     org.apache.sis.util.collection.RangeSetTest.class,
 
-    // Converters
+    // Converters.
     org.apache.sis.internal.converter.AngleConverterTest.class,
     org.apache.sis.internal.converter.StringConverterTest.class,
     org.apache.sis.internal.converter.PathConverterTest.class,

Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java?rev=1497592&r1=1497591&r2=1497592&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java
[UTF-8] Thu Jun 27 22:32:59 2013
@@ -16,8 +16,6 @@
  */
 package org.apache.sis.util.iso;
 
-import java.io.StringReader;
-import java.io.StringWriter;
 import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;
 import javax.xml.bind.JAXBContext;
@@ -59,24 +57,22 @@ public final strictfp class NameMarshall
      * Returns the XML representation of the given name, wrapped
      * in a mock {@code <gml:IO_IdentifiedObject>} element.
      */
-    private static String marshall(final GenericName name) throws JAXBException {
+    private String marshal(final GenericName name) throws JAXBException {
         if (pool == null) {
             pool = new MarshallerPool(JAXBContext.newInstance(IdentifiedObjectMock.class),
null);
         }
         final Marshaller marshaller = pool.acquireMarshaller();
-        final StringWriter out = new StringWriter();
-        marshaller.marshal(new IdentifiedObjectMock(name), out);
+        final String xml = marshal(marshaller, new IdentifiedObjectMock(name));
         pool.recycle(marshaller);
-        return out.toString();
+        return xml;
     }
 
     /**
-     * Converse of {@link #marshall(GenericName)}.
+     * Converse of {@link #marshal(GenericName)}.
      */
-    private static GenericName unmarshall(final String xml) throws JAXBException {
+    private GenericName unmarshall(final String xml) throws JAXBException {
         final Unmarshaller unmarshaller = pool.acquireUnmarshaller();
-        final StringReader in = new StringReader(xml);
-        final Object value = unmarshaller.unmarshal(in);
+        final Object value = unmarshal(unmarshaller, xml);
         pool.recycle(unmarshaller);
         return ((IdentifiedObjectMock) value).alias;
     }
@@ -97,8 +93,8 @@ public final strictfp class NameMarshall
                 "    <gco:LocalName>An ordinary local name</gco:LocalName>\n"
+
                 "  </gml:alias>\n" +
                 "</gml:IO_IdentifiedObject>\n";
-        final String actual = marshall(name);
-        assertXmlEquals(expected, actual, "xmlns:*", "xsi:schemaLocation");
+        final String actual = marshal(name);
+        assertXmlEquals(expected, actual, "xmlns:*");
         assertEquals(name, unmarshall(actual));
     }
 
@@ -119,8 +115,8 @@ public final strictfp class NameMarshall
                 "    <gco:LocalName>A name with &amp; and &gt; and &lt;.</gco:LocalName>\n"
+
                 "  </gml:alias>\n" +
                 "</gml:IO_IdentifiedObject>\n";
-        final String actual = marshall(name);
-        assertXmlEquals(expected, actual, "xmlns:*", "xsi:schemaLocation");
+        final String actual = marshal(name);
+        assertXmlEquals(expected, actual, "xmlns:*");
         assertEquals(name, unmarshall(actual));
     }
 
@@ -144,8 +140,8 @@ public final strictfp class NameMarshall
                 "    </gco:TypeName>\n" +
                 "  </gml:alias>\n" +
                 "</gml:IO_IdentifiedObject>\n";
-        final String actual = marshall(name);
-        assertXmlEquals(expected, actual, "xmlns:*", "xsi:schemaLocation");
+        final String actual = marshal(name);
+        assertXmlEquals(expected, actual, "xmlns:*");
         assertEquals(name, unmarshall(actual));
     }
 
@@ -165,8 +161,8 @@ public final strictfp class NameMarshall
                 "    <gco:ScopedName>myScope:myName</gco:ScopedName>\n" +
                 "  </gml:alias>\n" +
                 "</gml:IO_IdentifiedObject>\n";
-        final String actual = marshall(name);
-        assertXmlEquals(expected, actual, "xmlns:*", "xsi:schemaLocation");
+        final String actual = marshal(name);
+        assertXmlEquals(expected, actual, "xmlns:*");
         assertEquals(name, unmarshall(actual));
     }
 



Mime
View raw message