Author: desruisseaux
Date: Tue Sep 1 12:01:41 2015
New Revision: 1700507
URL: http://svn.apache.org/r1700507
Log:
Add tests for CC_GeneralOperationParameter.java JAXB adapter.
Added:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameterTest.java
(with props)
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterMarshallingTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/LogRecordCollector.java
sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java?rev=1700507&r1=1700506&r2=1700507&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
[UTF-8] Tue Sep 1 12:01:41 2015
@@ -18,8 +18,9 @@ package org.apache.sis.internal.jaxb.ref
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.HashMap;
-import java.util.IdentityHashMap;
+import java.util.HashSet;
import javax.xml.bind.annotation.XmlElementRef;
import org.opengis.parameter.ParameterDescriptor;
import org.opengis.parameter.ParameterDescriptorGroup;
@@ -30,6 +31,7 @@ import org.apache.sis.parameter.DefaultP
import org.apache.sis.parameter.DefaultParameterDescriptorGroup;
import org.apache.sis.parameter.Parameters;
import org.apache.sis.referencing.IdentifiedObjects;
+import org.apache.sis.util.collection.Containers;
import org.apache.sis.internal.util.CollectionsExt;
import org.apache.sis.internal.jaxb.gco.PropertyType;
import org.apache.sis.internal.jaxb.Context;
@@ -167,8 +169,8 @@ public final class CC_GeneralOperationPa
* @param complete The descriptor to use for completing missing
information.
* @return The descriptor to use. May be one of the arguments given to
this method, or a new instance.
*/
- public static GeneralParameterDescriptor replacement(final
GeneralParameterDescriptor provided,
- final
GeneralParameterDescriptor complete)
+ static GeneralParameterDescriptor replacement(final
GeneralParameterDescriptor provided,
+ final
GeneralParameterDescriptor complete)
{
if (provided == complete) {
return complete;
@@ -212,7 +214,7 @@ public final class CC_GeneralOperationPa
merged.putAll(actual); // May overwrite pre-defined properties.
if (isGroup) {
final List<GeneralParameterDescriptor> descriptors =
((ParameterDescriptorGroup) provided).descriptors();
- return merge(actual, merged, minimumOccurs, maximumOccurs,
+ return merge(merged, merged, minimumOccurs, maximumOccurs,
descriptors.toArray(new
GeneralParameterDescriptor[descriptors.size()]),
(ParameterDescriptorGroup) complete, canSubstitute);
} else {
@@ -242,7 +244,7 @@ public final class CC_GeneralOperationPa
boolean
canSubstitute)
{
boolean isCompatible = true;
- final Map<GeneralParameterDescriptor,Boolean> included = new
IdentityHashMap<>(provided.length);
+ final Set<GeneralParameterDescriptor> included = new
HashSet<>(Containers.hashMapCapacity(provided.length));
for (int i=0; i<provided.length; i++) {
final GeneralParameterDescriptor p = provided[i];
try {
@@ -253,7 +255,7 @@ public final class CC_GeneralOperationPa
GeneralParameterDescriptor predefined =
complete.descriptor(p.getName().getCode());
if (predefined != null) { // Safety in case 'complete' is a
user's implementation.
canSubstitute &= (provided[i] = replacement(p,
predefined)) == predefined;
- included.put(predefined, Boolean.TRUE);
+ included.add(predefined);
continue;
}
} catch (ParameterNotFoundException e) {
@@ -274,7 +276,7 @@ public final class CC_GeneralOperationPa
* document were optional.
*/
for (final GeneralParameterDescriptor descriptor :
complete.descriptors()) {
- if (!included.containsKey(descriptor) &&
descriptor.getMinimumOccurs() != 0
+ if (!included.contains(descriptor) &&
descriptor.getMinimumOccurs() != 0
&& !CC_OperationMethod.isImplicitParameter(descriptor))
{
canSubstitute = false;
Added:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameterTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameterTest.java?rev=1700507&view=auto
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameterTest.java
(added)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameterTest.java
[UTF-8] Tue Sep 1 12:01:41 2015
@@ -0,0 +1,342 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.jaxb.referencing;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+import javax.xml.bind.JAXBException;
+import org.opengis.parameter.ParameterDescriptor;
+import org.opengis.parameter.ParameterDescriptorGroup;
+import org.opengis.parameter.GeneralParameterDescriptor;
+import org.apache.sis.internal.system.Loggers;
+import org.apache.sis.parameter.DefaultParameterDescriptor;
+import org.apache.sis.parameter.DefaultParameterDescriptorGroup;
+import org.apache.sis.xml.Namespaces;
+import org.apache.sis.test.XMLTestCase;
+import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.DependsOnMethod;
+import org.apache.sis.test.LoggingWatcher;
+import org.apache.sis.util.logging.Logging;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * Tests {@link CC_GeneralOperationParameter} static methods.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.6
+ * @version 0.6
+ * @module
+ */
+@DependsOn(org.apache.sis.parameter.DefaultParameterDescriptorTest.class)
+public final strictfp class CC_GeneralOperationParameterTest extends
XMLTestCase {
+ /**
+ * A JUnit rule for listening to log events emitted during execution of
{@link #testGroupMergeBecauseExtraParameter()}.
+ * This rule verifies that the log message contains the expected
information. The expected message is something like
+ * "No parameter named "Parameter B" was found".
+ *
+ * <p>This field is public because JUnit requires us to do so, but should
be considered as an implementation details
+ * (it should have been a private field).</p>
+ */
+ @Rule
+ public final LoggingWatcher listener = new
LoggingWatcher(Logging.getLogger(Loggers.XML)) {
+ @Override protected void verifyMessage(final String message) {
+ assertTrue(message, message.contains("Parameter B"));
+ assertTrue(message, message.contains("Group"));
+ }
+ };
+
+ /**
+ * Creates a parameter descriptor as unmarshalled by JAXB, without {@code
valueClass}.
+ *
+ * @throws JAXBException if this method failed to create test data.
+ */
+ private DefaultParameterDescriptor<?> unmarshal(final String name, final
String remarks) throws JAXBException {
+ final StringBuilder buffer = new StringBuilder(256);
+ buffer.append("<gml:OperationParameter xmlns:gml=\"" + Namespaces.GML
+ "\">\n"
+ + " <gml:name>").append(name).append("</gml:name>\n");
+ if (remarks != null) {
+ buffer.append("
<gml:remarks>").append(remarks).append("</gml:remarks>\n");
+ }
+ buffer.append(" <gml:minimumOccurs>0</gml:minimumOccurs>\n"
+ + "</gml:OperationParameter>");
+ final DefaultParameterDescriptor<?> p =
unmarshal(DefaultParameterDescriptor.class, buffer.toString());
+ /*
+ * Following assertions are not really the purpose of this class, but
are done on an opportunist way.
+ * We need the unmarshalled descriptor to have those property values
for the remaining of this test.
+ * The most noticeable assertion is the 'valueClass', which is
required to be null (despite being an
+ * illegal value) for this test.
+ */
+ assertEquals("name", name, p.getName().getCode());
+ assertEquals("remarks", remarks, (remarks == null) ? null :
p.getRemarks().toString());
+ assertNull ("description", p.getDescription());
+ assertNull ("valueClass", p.getValueClass());
+ assertEquals("minimumOccurs", 0, p.getMinimumOccurs());
+ assertEquals("maximumOccurs", 1, p.getMaximumOccurs());
+ return p;
+ }
+
+ /**
+ * Creates a parameter descriptor from the given properties.
+ * All properties except {@code defaultValue} can be part of GML documents.
+ *
+ * @param name The parameter descriptor name.
+ * @param remarks The remarks, or {@code null} if none.
+ * @param mandatory {@code true} for a mandatory parameter, or {@code
false} for an optional one.
+ * @param defaultValue The default value, or {@code null} if none.
+ * @return The parameter descriptor.
+ */
+ private static DefaultParameterDescriptor<Integer> create(final String
name, final String remarks,
+ final boolean mandatory, final Integer defaultValue)
+ {
+ final Map<String,String> properties = new HashMap<>(4);
+ assertNull(properties.put(DefaultParameterDescriptor.NAME_KEY, name));
+ assertNull(properties.put(DefaultParameterDescriptor.REMARKS_KEY,
remarks));
+ return new DefaultParameterDescriptor<>(properties, mandatory ? 1 : 0,
1, Integer.class, null, null, defaultValue);
+ }
+
+ /**
+ * Tests cases where the unmarshalled parameter can be substituted by the
complete parameter.
+ * The cases tested in this method should not create any new {@code
ParameterDescriptor} instance.
+ *
+ * @throws JAXBException if this method failed to create test data.
+ */
+ @Test
+ public void testParameterSubstitution() throws JAXBException {
+ ParameterDescriptor<?> provided = unmarshal("Optional parameter",
null);
+ ParameterDescriptor<?> complete = create("Optional parameter", null,
false, null);
+ assertSame("Trivial case.", complete,
CC_GeneralOperationParameter.replacement(complete, complete));
+ assertSame("Same properties.", complete,
CC_GeneralOperationParameter.replacement(provided, complete));
+
+ complete = create("OptionalParameter", null, false, null);
+ assertSame("Slightly different name.", complete,
CC_GeneralOperationParameter.replacement(provided, complete));
+
+ complete = create("Optional parameter", null, false, 3);
+ assertSame("With default value.", complete,
CC_GeneralOperationParameter.replacement(provided, complete));
+
+ complete = create("Optional parameter", "More details here.", false,
null);
+ assertSame("With additional property.", complete,
CC_GeneralOperationParameter.replacement(provided, complete));
+
+ provided = unmarshal("Optional parameter", "More details here.");
+ assertSame("With same remark.", complete,
CC_GeneralOperationParameter.replacement(provided, complete));
+ }
+
+ /**
+ * Tests cases where the unmarshalled parameter needs to be merged with
the complete parameter.
+ * All cases tested in this method should create a new {@link
ParameterDescriptor} instance.
+ *
+ * @throws JAXBException if this method failed to create test data.
+ */
+ @Test
+ @DependsOnMethod("testParameterSubstitution")
+ public void testParameterMerge() throws JAXBException {
+ ParameterDescriptor<?> provided = unmarshal("Test parameter", null);
+ ParameterDescriptor<?> complete = create("Test parameter", null, true,
null);
+ ParameterDescriptor<?> merged = (ParameterDescriptor<?>)
CC_GeneralOperationParameter.replacement(provided, complete);
+ assertNotSame("Different obligation.", complete, merged);
+ assertSame ("name", complete.getName(),
merged.getName());
+ assertEquals ("minimumOccurs", 0,
merged.getMinimumOccurs()); // From provided descriptor.
+ assertEquals ("maximumOccurs", 1,
merged.getMaximumOccurs());
+ assertEquals ("valueClass", Integer.class,
merged.getValueClass()); // From complete descriptor.
+ assertNull ("remarks",
merged.getRemarks());
+
+ complete = create("Test parameter", null, false, null);
+ assertSame(complete,
CC_GeneralOperationParameter.replacement(provided, complete));
+ // Above assertion was tested by testParameterSubstitutions(), but was
verified again here
+ // for making sure that the following assertion verifies the effect of
the remarks alone.
+ provided = unmarshal("Test parameter", "More details here.");
+ merged = (ParameterDescriptor<?>)
CC_GeneralOperationParameter.replacement(provided, complete);
+ assertNotSame("Different remark.", complete, merged);
+ assertSame ("name", complete.getName(),
merged.getName());
+ assertEquals ("minimumOccurs", 0,
merged.getMinimumOccurs());
+ assertEquals ("maximumOccurs", 1,
merged.getMaximumOccurs());
+ assertEquals ("valueClass", Integer.class,
merged.getValueClass());
+ assertSame ("remarks", provided.getRemarks(),
merged.getRemarks());
+ }
+
+ /**
+ * Tests case where the unmarshalled parameter group can be substituted by
the complete parameter group.
+ * The cases tested in this method should not create any new {@link
ParameterDescriptorGroup} instance.
+ *
+ * @throws JAXBException if this method failed to create test data.
+ */
+ @Test
+ @DependsOnMethod("testParameterSubstitution")
+ public void testGroupSubstitution() throws JAXBException {
+ final Map<String,String> properties = new HashMap<>(4);
+ assertNull(properties.put(DefaultParameterDescriptor.NAME_KEY,
"Group"));
+ final ParameterDescriptorGroup provided = new
DefaultParameterDescriptorGroup(properties, 1, 2,
+ unmarshal("Parameter A", null),
+ unmarshal("Parameter B", "Remarks B."),
+ unmarshal("Parameter C", null));
+
+ assertNull(properties.put(DefaultParameterDescriptor.REMARKS_KEY,
"More details here."));
+ final ParameterDescriptorGroup complete = new
DefaultParameterDescriptorGroup(properties, 1, 2,
+ create("Parameter A", "Remarks A.", false, 3),
+ create("Parameter B", "Remarks B.", false, 4),
+ create("Parameter C", "Remarks C.", false, 5),
+ create("Parameter D", "Remarks D.", false, 6));
+
+ assertSame(complete,
CC_GeneralOperationParameter.replacement(provided, complete));
+ }
+
+ /**
+ * Tests case where the unmarshalled parameter group needs to be merged
with the complete parameter group.
+ * The reason for the group merge in this test is because the unmarshalled
parameters have different remarks
+ * or different obligation.
+ *
+ * @throws JAXBException if this method failed to create test data.
+ */
+ @Test
+ @DependsOnMethod({"testGroupSubstitution", "testParameterMerge"})
+ public void testGroupMergeBecauseDifferentProperties() throws
JAXBException {
+ final Map<String,String> properties = new HashMap<>(4);
+ assertNull(properties.put(DefaultParameterDescriptor.NAME_KEY,
"Group"));
+ final ParameterDescriptorGroup provided = new
DefaultParameterDescriptorGroup(properties, 1, 2,
+ unmarshal("Parameter A", "Remarks A."),
+ unmarshal("Parameter B", "Remarks B."),
+ unmarshal("Parameter C", "Remarks C."));
+
+ assertNull(properties.put(DefaultParameterDescriptor.REMARKS_KEY,
"More details here."));
+ final ParameterDescriptorGroup complete = new
DefaultParameterDescriptorGroup(properties, 1, 2,
+ create("Parameter A", "Remarks A.", true, 3),
+ create("Parameter B", "Remarks B.", false, 4),
+ create("Parameter C", "Different.", false, 5),
+ create("Parameter D", "Remarks D.", false, 6));
+
+ final ParameterDescriptorGroup merged =
+ (ParameterDescriptorGroup)
CC_GeneralOperationParameter.replacement(provided, complete);
+ assertNotSame(complete, provided);
+ assertSame ("name", complete.getName(),
merged.getName());
+ assertSame ("remarks", complete.getRemarks(),
merged.getRemarks());
+ assertEquals ("minimumOccurs", 1,
merged.getMinimumOccurs());
+ assertEquals ("maximumOccurs", 2,
merged.getMaximumOccurs());
+
+ final Iterator<GeneralParameterDescriptor> itc =
complete.descriptors().iterator();
+ final Iterator<GeneralParameterDescriptor> itm = merged
.descriptors().iterator();
+ verifyParameter(itc.next(), itm.next(), false, "Remarks A."); // Not
same because different obligation.
+ verifyParameter(itc.next(), itm.next(), true, "Remarks B."); //
Same ParameterDescriptor instance.
+ verifyParameter(itc.next(), itm.next(), false, "Remarks C."); // Not
same because different remarks.
+ assertTrue ("Missing descriptor.", itc.hasNext());
+ assertFalse("Unexpected descriptor.", itm.hasNext());
+ }
+
+ /**
+ * Tests case where the unmarshalled parameter group needs to be merged
with the complete parameter group.
+ * The reason for the group merge in this test is because the unmarshalled
parameters is missing a mandatory
+ * parameter.
+ *
+ * @throws JAXBException if this method failed to create test data.
+ */
+ @Test
+ @DependsOnMethod("testGroupMergeBecauseDifferentProperties")
+ public void testGroupMergeBecauseMissingParameter() throws JAXBException {
+ final Map<String,String> properties = new HashMap<>(4);
+ assertNull(properties.put(DefaultParameterDescriptor.NAME_KEY,
"Group"));
+ final ParameterDescriptorGroup provided = new
DefaultParameterDescriptorGroup(properties, 1, 2,
+ unmarshal("Parameter A", null),
+ unmarshal("Parameter C", null));
+
+ assertNull(properties.put(DefaultParameterDescriptor.REMARKS_KEY,
"More details here."));
+ final ParameterDescriptorGroup complete = new
DefaultParameterDescriptorGroup(properties, 1, 2,
+ create("Parameter A", null, false, 3),
+ create("Parameter B", null, true, 4),
+ create("Parameter C", null, false, 5));
+
+ final ParameterDescriptorGroup merged =
+ (ParameterDescriptorGroup)
CC_GeneralOperationParameter.replacement(provided, complete);
+ assertNotSame(complete, provided);
+ assertSame ("name", complete.getName(),
merged.getName());
+ assertSame ("remarks", complete.getRemarks(),
merged.getRemarks());
+ assertEquals ("minimumOccurs", 1,
merged.getMinimumOccurs());
+ assertEquals ("maximumOccurs", 2,
merged.getMaximumOccurs());
+
+ final Iterator<GeneralParameterDescriptor> itc =
complete.descriptors().iterator();
+ final Iterator<GeneralParameterDescriptor> itm = merged
.descriptors().iterator();
+ verifyParameter(itc.next(), itm.next(), true, null);
+
+ // Skip the parameter which is missing in the unmarshalled descriptor
group.
+ assertEquals("Missing parameter.", "Parameter B",
itc.next().getName().getCode());
+
+ verifyParameter(itc.next(), itm.next(), true, null);
+ assertFalse("Unexpected descriptor.", itc.hasNext());
+ assertFalse("Unexpected descriptor.", itm.hasNext());
+ }
+
+ /**
+ * Tests case where the unmarshalled parameter group needs to be merged
with the complete parameter group.
+ * The reason for the group merge in this test is because the unmarshalled
parameters have a parameter not
+ * present in the "complete" group.
+ *
+ * @throws JAXBException if this method failed to create test data.
+ */
+ @Test
+ @DependsOnMethod("testGroupMergeBecauseDifferentProperties")
+ public void testGroupMergeBecauseExtraParameter() throws JAXBException {
+ final Map<String,String> properties = new HashMap<>(4);
+ assertNull(properties.put(DefaultParameterDescriptor.NAME_KEY,
"Group"));
+ final ParameterDescriptorGroup provided = new
DefaultParameterDescriptorGroup(properties, 1, 2,
+ unmarshal("Parameter A", "Remarks A."),
+ unmarshal("Parameter B", "Remarks B."),
+ unmarshal("Parameter C", "Remarks C."));
+
+ assertNull(properties.put(DefaultParameterDescriptor.REMARKS_KEY,
"More details here."));
+ final ParameterDescriptorGroup complete = new
DefaultParameterDescriptorGroup(properties, 1, 2,
+ create("Parameter A", "Remarks A.", false, 3),
+ create("Parameter C", "Remarks C.", false, 4));
+
+ listener.maximumLogCount = 1;
+ final ParameterDescriptorGroup merged =
+ (ParameterDescriptorGroup)
CC_GeneralOperationParameter.replacement(provided, complete);
+ assertNotSame(complete, provided);
+ assertSame ("name", complete.getName(),
merged.getName());
+ assertSame ("remarks", complete.getRemarks(),
merged.getRemarks());
+ assertEquals ("minimumOccurs", 1,
merged.getMinimumOccurs());
+ assertEquals ("maximumOccurs", 2,
merged.getMaximumOccurs());
+
+ final Iterator<GeneralParameterDescriptor> itc =
complete.descriptors().iterator();
+ final Iterator<GeneralParameterDescriptor> itm = merged
.descriptors().iterator();
+ verifyParameter(itc.next(), itm.next(), true, "Remarks A.");
+
+ final GeneralParameterDescriptor extra = itm.next();
+ assertEquals("name", "Parameter B", extra.getName().getCode());
+ assertEquals("remark", "Remarks B.", extra.getRemarks().toString());
+
+ verifyParameter(itc.next(), itm.next(), true, "Remarks C.");
+ assertFalse("Unexpected descriptor.", itc.hasNext());
+ assertFalse("Unexpected descriptor.", itm.hasNext());
+ }
+
+ /**
+ * Verifies the properties of the given member of a {@link
DefaultParameterDescriptorGroup}.
+ */
+ private static void verifyParameter(final GeneralParameterDescriptor
complete,
+ final GeneralParameterDescriptor
merged,
+ final boolean same, final String
remarks)
+ {
+ assertEquals("same", same, merged == complete);
+ assertSame ("name", complete.getName(), merged.getName());
+ assertEquals("minimumOccurs", 0,
merged.getMinimumOccurs());
+ assertEquals("maximumOccurs", 1,
merged.getMaximumOccurs());
+ assertEquals("valueClass", Integer.class,
((ParameterDescriptor<?>) merged).getValueClass());
+ assertEquals("remarks", remarks, (remarks == null) ?
null : merged.getRemarks().toString());
+ }
+}
Propchange:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameterTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterMarshallingTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterMarshallingTest.java?rev=1700507&r1=1700506&r2=1700507&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterMarshallingTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterMarshallingTest.java
[UTF-8] Tue Sep 1 12:01:41 2015
@@ -53,7 +53,10 @@ import java.util.Objects;
* @version 0.6
* @module
*/
-@DependsOn(DefaultParameterValueTest.class)
+@DependsOn({
+ DefaultParameterValueTest.class,
+ DefaultParameterValueGroupTest.class
+})
public final strictfp class ParameterMarshallingTest extends XMLTestCase {
/**
* Creates a parameter value for marshalling test.
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1700507&r1=1700506&r2=1700507&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] Tue Sep 1 12:01:41 2015
@@ -71,6 +71,7 @@ import org.junit.BeforeClass;
org.apache.sis.parameter.TensorValuesTest.class,
org.apache.sis.parameter.MapProjectionParametersTest.class,
org.apache.sis.parameter.ParameterMarshallingTest.class,
+
org.apache.sis.internal.jaxb.referencing.CC_GeneralOperationParameterTest.class,
// Test transforms other than map projections.
org.apache.sis.referencing.operation.transform.CoordinateDomainTest.class,
Modified:
sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/LogRecordCollector.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/LogRecordCollector.java?rev=1700507&r1=1700506&r2=1700507&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/LogRecordCollector.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/LogRecordCollector.java
[UTF-8] Tue Sep 1 12:01:41 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/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java?rev=1700507&r1=1700506&r2=1700507&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java
[UTF-8] Tue Sep 1 12:01:41 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;
/**