Author: oheger Date: Tue Apr 2 19:08:04 2013 New Revision: 1463691 URL: http://svn.apache.org/r1463691 Log: Added some test implementations for ReloadingDetector.
These classes are used to produce specific reloading behavior in test cases. Added: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/reloading/AlwaysReloadingDetector.java commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/reloading/RandomReloadingDetector.java Added: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/reloading/AlwaysReloadingDetector.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/reloading/AlwaysReloadingDetector.java?rev=1463691&view=auto ============================================================================== --- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/reloading/AlwaysReloadingDetector.java (added) +++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/reloading/AlwaysReloadingDetector.java Tue Apr 2 19:08:04 2013 @@ -0,0 +1,41 @@ +/* + * 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.reloading; + +/** + * A reloading detector implementation which always indicates that a reload is + * required. This is used by some test classes. + * + * @version $Id$ + */ +public class AlwaysReloadingDetector implements ReloadingDetector +{ + /** + * {@inheritDoc} This implementation always returns <b>true</b>. + */ + public boolean isReloadingRequired() + { + return true; + } + + /** + * Empty dummy implementation of this interface method. + */ + public void reloadingPerformed() + { + } +} Added: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/reloading/RandomReloadingDetector.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/reloading/RandomReloadingDetector.java?rev=1463691&view=auto ============================================================================== --- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/reloading/RandomReloadingDetector.java (added) +++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/reloading/RandomReloadingDetector.java Tue Apr 2 19:08:04 2013 @@ -0,0 +1,40 @@ +/* + * 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.reloading; + +import java.util.Random; + +/** + * An implementation of {@code ReloadingDetector} which randomly returns + * true or false. + * + * @version $Id: $ + */ +public class RandomReloadingDetector implements ReloadingDetector +{ + /** The random object.*/ + private final Random random = new Random(); + + public boolean isReloadingRequired() + { + return random.nextBoolean(); + } + + public void reloadingPerformed() + { + } +}