You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2012/12/14 21:47:29 UTC
svn commit: r1422073 - in /commons/proper/configuration/trunk/src:
main/java/org/apache/commons/configuration/builder/
main/java/org/apache/commons/configuration/builder/fluent/
test/java/org/apache/commons/configuration/builder/ test/java/org/apache/c...
Author: oheger
Date: Fri Dec 14 20:47:25 2012
New Revision: 1422073
URL: http://svn.apache.org/viewvc?rev=1422073&view=rev
Log:
Added a parameters object for XML configurations.
Added:
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/XMLBuilderParametersImpl.java (with props)
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/XMLBuilderParametersImplBeanInfo.java (with props)
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/XMLBuilderProperties.java (with props)
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/XMLBuilderParameters.java (with props)
commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestXMLBuilderParametersImpl.java (with props)
Modified:
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicBuilderParameters.java
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/Parameters.java
commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/fluent/TestParameters.java
Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicBuilderParameters.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicBuilderParameters.java?rev=1422073&r1=1422072&r2=1422073&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicBuilderParameters.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicBuilderParameters.java Fri Dec 14 20:47:25 2012
@@ -180,6 +180,19 @@ public class BasicBuilderParameters impl
}
/**
+ * Obtains the value of the specified property from the internal map. This
+ * method can be used by derived classes if a specific property is to be
+ * accessed. If the given key is not found, result is <b>null</b>.
+ *
+ * @param key the key of the property in question
+ * @return the value of the property with this key or <b>null</b>
+ */
+ protected Object fetchProperty(String key)
+ {
+ return properties.get(key);
+ }
+
+ /**
* Sets default parameter values.
*/
private void initDefaults()
Added: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/XMLBuilderParametersImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/XMLBuilderParametersImpl.java?rev=1422073&view=auto
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/XMLBuilderParametersImpl.java (added)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/XMLBuilderParametersImpl.java Fri Dec 14 20:47:25 2012
@@ -0,0 +1,109 @@
+/*
+ * 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.commons.configuration.builder;
+
+import javax.xml.parsers.DocumentBuilder;
+
+import org.xml.sax.EntityResolver;
+
+/**
+ * <p>
+ * A specialized parameters class for XML configuration.
+ * </p>
+ * <p>
+ * This parameters class defines some properties which allow customizing the
+ * parsing of XML documents. The location of the XML document to be loaded can
+ * be specified, too.
+ * </p>
+ * <p>
+ * This class is not thread-safe. It is intended that an instance is constructed
+ * and initialized by a single thread during configuration of a
+ * {@code ConfigurationBuilder}.
+ * </p>
+ *
+ * @version $Id$
+ * @since 2.0
+ */
+public class XMLBuilderParametersImpl extends FileBasedBuilderParametersImpl
+ implements XMLBuilderProperties<XMLBuilderParametersImpl>
+{
+ /** The key for the entity resolver property. */
+ private static final String PROP_ENTITY_RESOLVER = "entityResolver";
+
+ /** The key for the document builder property. */
+ private static final String PROP_DOCUMENT_BUILDER = "documentBuilder";
+
+ /** The key for the public ID property. */
+ private static final String PROP_PUBLIC_ID = "publicID";
+
+ /** The key for the system ID property. */
+ private static final String PROP_SYSTEM_ID = "systemID";
+
+ /** The key for the validating property. */
+ private static final String PROP_VALIDATING = "validating";
+
+ /** The key for the schema validation flag. */
+ private static final String PROP_SCHEMA_VALIDATION = "schemaValidation";
+
+ public XMLBuilderParametersImpl setDocumentBuilder(
+ DocumentBuilder docBuilder)
+ {
+ storeProperty(PROP_DOCUMENT_BUILDER, docBuilder);
+ return this;
+ }
+
+ public XMLBuilderParametersImpl setEntityResolver(EntityResolver resolver)
+ {
+ storeProperty(PROP_ENTITY_RESOLVER, resolver);
+ return this;
+ }
+
+ /**
+ * Returns the {@code EntityResolver} stored in this parameters object.
+ * Result is <b>null</b> if no such object has been set.
+ *
+ * @return the {@code EntityResolver} or <b>null</b>
+ */
+ public EntityResolver getEntityResolver()
+ {
+ return (EntityResolver) fetchProperty(PROP_ENTITY_RESOLVER);
+ }
+
+ public XMLBuilderParametersImpl setPublicID(String pubID)
+ {
+ storeProperty(PROP_PUBLIC_ID, pubID);
+ return this;
+ }
+
+ public XMLBuilderParametersImpl setSystemID(String sysID)
+ {
+ storeProperty(PROP_SYSTEM_ID, sysID);
+ return this;
+ }
+
+ public XMLBuilderParametersImpl setValidating(boolean f)
+ {
+ storeProperty(PROP_VALIDATING, Boolean.valueOf(f));
+ return this;
+ }
+
+ public XMLBuilderParametersImpl setSchemaValidation(boolean f)
+ {
+ storeProperty(PROP_SCHEMA_VALIDATION, Boolean.valueOf(f));
+ return this;
+ }
+}
Propchange: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/XMLBuilderParametersImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/XMLBuilderParametersImpl.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/XMLBuilderParametersImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/XMLBuilderParametersImplBeanInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/XMLBuilderParametersImplBeanInfo.java?rev=1422073&view=auto
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/XMLBuilderParametersImplBeanInfo.java (added)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/XMLBuilderParametersImplBeanInfo.java Fri Dec 14 20:47:25 2012
@@ -0,0 +1,34 @@
+/*
+ * 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.commons.configuration.builder;
+
+/**
+ * An additional {@code BeanInfo} class for {@link XMLBuilderParametersImpl}.
+ *
+ * @version $Id$
+ * @since 2.0
+ */
+public class XMLBuilderParametersImplBeanInfo extends BuilderParametersBeanInfo
+{
+ /**
+ * Creates a new instance of {@code XMLBuilderParametersImplBeanInfo}.
+ */
+ public XMLBuilderParametersImplBeanInfo()
+ {
+ super(XMLBuilderParametersImpl.class);
+ }
+}
Propchange: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/XMLBuilderParametersImplBeanInfo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/XMLBuilderParametersImplBeanInfo.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/XMLBuilderParametersImplBeanInfo.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/XMLBuilderProperties.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/XMLBuilderProperties.java?rev=1422073&view=auto
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/XMLBuilderProperties.java (added)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/XMLBuilderProperties.java Fri Dec 14 20:47:25 2012
@@ -0,0 +1,78 @@
+/*
+ * 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.commons.configuration.builder;
+
+import javax.xml.parsers.DocumentBuilder;
+
+import org.xml.sax.EntityResolver;
+
+/**
+ * <p>Definition of a parameters interface for XML configurations.</p>
+ * <p>The {@code XMLConfiguration} class defines a bunch of additional properties
+ * related to XML processing.</p>
+ *
+ * @version $Id$
+ * @since 2.0
+ * @param <T> the type of the result of all set methods for method chaining
+ */
+public interface XMLBuilderProperties<T>
+{
+ /**
+ * Allows setting the {@code DocumentBuilder} for parsing an XML document.
+ * This is the most flexible way of customizing XML processing.
+ * @param docBuilder the {@code DocumentBuilder} to use
+ * @return a reference to this object for method chaining
+ */
+ T setDocumentBuilder(DocumentBuilder docBuilder);
+
+ /**
+ * Allows setting the {@code EntityResolver} which maps entity references
+ * during XML parsing.
+ * @param resolver the {@code EntityResolver} to use
+ * @return a reference to this object for method chaining
+ */
+ T setEntityResolver(EntityResolver resolver);
+
+ /**
+ * Sets the public ID of the DOCTYPE declaration.
+ * @param pubID the public ID
+ * @return a reference to this object for method chaining
+ */
+ T setPublicID(String pubID);
+
+ /**
+ * Sets the system ID of the DOCTYPE declaration.
+ * @param sysID the system ID
+ * @return a reference to this object for method chaining
+ */
+ T setSystemID(String sysID);
+
+ /**
+ * Sets a flag whether schema/DTD validation should be performed.
+ * @param f the validation flag
+ * @return a reference to this object for method chaining
+ */
+ T setValidating(boolean f);
+
+ /**
+ * Sets the value of the schemaValidation flag. This flag determines whether
+ * DTD or Schema validation should be used.
+ * @param f the flag value, <b>true</b> for schema validation, <b>false</b> for DTD validation
+ * @return a reference to this object for method chaining
+ */
+ T setSchemaValidation(boolean f);
+}
Propchange: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/XMLBuilderProperties.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/XMLBuilderProperties.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/XMLBuilderProperties.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/Parameters.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/Parameters.java?rev=1422073&r1=1422072&r2=1422073&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/Parameters.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/Parameters.java Fri Dec 14 20:47:25 2012
@@ -24,6 +24,7 @@ import org.apache.commons.configuration.
import org.apache.commons.configuration.builder.BuilderParameters;
import org.apache.commons.configuration.builder.FileBasedBuilderParametersImpl;
import org.apache.commons.configuration.builder.JndiBuilderParametersImpl;
+import org.apache.commons.configuration.builder.XMLBuilderParametersImpl;
import org.apache.commons.configuration.builder.combined.CombinedBuilderParametersImpl;
/**
@@ -116,6 +117,17 @@ public final class Parameters
}
/**
+ * Creates a new instance of a parameters object for XML configurations.
+ *
+ * @return the new parameters object
+ */
+ public static XMLBuilderParameters xml()
+ {
+ return createParametersProxy(XMLBuilderParameters.class,
+ new XMLBuilderParametersImpl());
+ }
+
+ /**
* Creates a proxy object for a given parameters interface based on the
* given implementation object.
*
Added: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/XMLBuilderParameters.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/XMLBuilderParameters.java?rev=1422073&view=auto
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/XMLBuilderParameters.java (added)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/XMLBuilderParameters.java Fri Dec 14 20:47:25 2012
@@ -0,0 +1,38 @@
+/*
+ * 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.commons.configuration.builder.fluent;
+
+import org.apache.commons.configuration.builder.BasicBuilderProperties;
+import org.apache.commons.configuration.builder.BuilderParameters;
+import org.apache.commons.configuration.builder.FileBasedBuilderProperties;
+import org.apache.commons.configuration.builder.XMLBuilderProperties;
+
+/**
+ * <p>
+ * Definition of a parameters interface providing a fluent API for setting all
+ * properties for a XML configuration.
+ * </p>
+ *
+ * @version $Id$
+ * @since 2.0
+ */
+public interface XMLBuilderParameters extends
+ BasicBuilderProperties<XMLBuilderParameters>,
+ FileBasedBuilderProperties<XMLBuilderParameters>,
+ XMLBuilderProperties<XMLBuilderParameters>, BuilderParameters
+{
+}
Propchange: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/XMLBuilderParameters.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/XMLBuilderParameters.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/fluent/XMLBuilderParameters.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestXMLBuilderParametersImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestXMLBuilderParametersImpl.java?rev=1422073&view=auto
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestXMLBuilderParametersImpl.java (added)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestXMLBuilderParametersImpl.java Fri Dec 14 20:47:25 2012
@@ -0,0 +1,143 @@
+/*
+ * 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.commons.configuration.builder;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+
+import org.apache.commons.beanutils.PropertyUtils;
+import org.easymock.EasyMock;
+import org.junit.Before;
+import org.junit.Test;
+import org.xml.sax.EntityResolver;
+
+/**
+ * Test class for {@code XMLBuilderParametersImpl}.
+ *
+ * @version $Id$
+ */
+public class TestXMLBuilderParametersImpl
+{
+ /** The parameters object to be tested. */
+ private XMLBuilderParametersImpl params;
+
+ @Before
+ public void setUp() throws Exception
+ {
+ params = new XMLBuilderParametersImpl();
+ }
+
+ /**
+ * Tests whether an entity resolver can be set.
+ */
+ @Test
+ public void testSetEntityResolver()
+ {
+ EntityResolver resolver = EasyMock.createMock(EntityResolver.class);
+ EasyMock.replay(resolver);
+ assertSame("Wrong result", params, params.setEntityResolver(resolver));
+ assertSame("Resolver not set", resolver, params.getEntityResolver());
+ assertSame("Resolver not in parameters", resolver, params
+ .getParameters().get("entityResolver"));
+ }
+
+ /**
+ * Tests whether a document builder can be set.
+ */
+ @Test
+ public void testSetDocumentBuilder()
+ {
+ DocumentBuilder builder = EasyMock.createMock(DocumentBuilder.class);
+ EasyMock.replay(builder);
+ assertSame("Wrong result", params, params.setDocumentBuilder(builder));
+ assertSame("Builder not in parameters", builder, params.getParameters()
+ .get("documentBuilder"));
+ }
+
+ /**
+ * Tests whether a public ID can be set.
+ */
+ @Test
+ public void testSetPublicID()
+ {
+ String pubID = "testPublicID";
+ assertSame("Wrong result", params, params.setPublicID(pubID));
+ assertEquals("ID not in parameters", pubID,
+ params.getParameters().get("publicID"));
+ }
+
+ /**
+ * Tests whether a system ID can be set.
+ */
+ @Test
+ public void testSetSystemID()
+ {
+ String sysID = "testSystemID";
+ assertSame("Wrong result", params, params.setSystemID(sysID));
+ assertEquals("ID not in parameters", sysID,
+ params.getParameters().get("systemID"));
+ }
+
+ /**
+ * Tests whether validating property can be set.
+ */
+ @Test
+ public void testSetValidating()
+ {
+ assertSame("Wrong result", params, params.setValidating(true));
+ assertEquals("Flag not in parameters", Boolean.TRUE, params
+ .getParameters().get("validating"));
+ }
+
+ /**
+ * Tests whether the schema validation flag can be set.
+ */
+ @Test
+ public void testSetSchemaValidation()
+ {
+ assertSame("Wrong result", params, params.setSchemaValidation(false));
+ assertEquals("Flag not in parameters", Boolean.FALSE, params
+ .getParameters().get("schemaValidation"));
+ }
+
+ /**
+ * Tests whether properties can be set through BeanUtils.
+ */
+ @Test
+ public void testBeanPropertiesAccess() throws Exception
+ {
+ EntityResolver resolver = EasyMock.createMock(EntityResolver.class);
+ DocumentBuilder builder = EasyMock.createMock(DocumentBuilder.class);
+ EasyMock.replay(resolver, builder);
+ PropertyUtils.setProperty(params, "throwExceptionOnMissing",
+ Boolean.TRUE);
+ PropertyUtils.setProperty(params, "fileName", "test.xml");
+ PropertyUtils.setProperty(params, "entityResolver", resolver);
+ PropertyUtils.setProperty(params, "documentBuilder", builder);
+ assertEquals("Wrong file name", "test.xml", params.getFileHandler()
+ .getFileName());
+ Map<String, Object> paramsMap = params.getParameters();
+ assertEquals("Wrong exception flag", Boolean.TRUE,
+ paramsMap.get("throwExceptionOnMissing"));
+ assertSame("Wrong resolver", resolver, paramsMap.get("entityResolver"));
+ assertSame("Wrong builder", builder, paramsMap.get("documentBuilder"));
+ }
+}
Propchange: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestXMLBuilderParametersImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestXMLBuilderParametersImpl.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestXMLBuilderParametersImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/fluent/TestParameters.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/fluent/TestParameters.java?rev=1422073&r1=1422072&r2=1422073&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/fluent/TestParameters.java (original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/fluent/TestParameters.java Fri Dec 14 20:47:25 2012
@@ -123,4 +123,27 @@ public class TestParameters
assertEquals("Wrong prefix", "test", map.get("prefix"));
checkBasicProperties(map);
}
+
+ /**
+ * Tests whether a parameters object for an XML configuration can be
+ * created.
+ */
+ @Test
+ public void testXml()
+ {
+ Map<String, Object> map =
+ Parameters.xml().setThrowExceptionOnMissing(true)
+ .setFileName("test.xml").setValidating(true)
+ .setListDelimiter('#').setSchemaValidation(true)
+ .getParameters();
+ checkBasicProperties(map);
+ FileBasedBuilderParametersImpl fbp =
+ FileBasedBuilderParametersImpl.fromParameters(map);
+ assertEquals("Wrong file name", "test.xml", fbp.getFileHandler()
+ .getFileName());
+ assertEquals("Wrong validation flag", Boolean.TRUE,
+ map.get("validating"));
+ assertEquals("Wrong schema flag", Boolean.TRUE,
+ map.get("schemaValidation"));
+ }
}