Add tests.
diff --git a/.gitignore b/.gitignore
index fbdf7eb..721dfeb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
-/.classpath
-/.project
-/.settings/
+**/.classpath
+**/.project
+**/.settings/
+**/target/
diff --git a/commons-testing-junit4/src/main/java/org/apache/commons/testing/junit4/AbstractAvailableLocalesTest.java b/commons-testing-junit4/src/main/java/org/apache/commons/testing/junit4/AbstractAvailableLocalesTest.java
index 23459a3..160c384 100644
--- a/commons-testing-junit4/src/main/java/org/apache/commons/testing/junit4/AbstractAvailableLocalesTest.java
+++ b/commons-testing-junit4/src/main/java/org/apache/commons/testing/junit4/AbstractAvailableLocalesTest.java
@@ -81,12 +81,12 @@
private final Locale locale;
@Rule
- public final SetDefaultLocaleTestRule rule;
+ public final DefaultLocaleTestRule rule;
public AbstractAvailableLocalesTest(final Locale locale) {
super();
this.locale = locale;
- this.rule = new SetDefaultLocaleTestRule(locale);
+ this.rule = new DefaultLocaleTestRule(locale);
}
public Locale getLocale() {
diff --git a/commons-testing-junit4/src/main/java/org/apache/commons/testing/junit4/SetDefaultLocaleTestRule.java b/commons-testing-junit4/src/main/java/org/apache/commons/testing/junit4/DefaultLocaleTestRule.java
similarity index 92%
rename from commons-testing-junit4/src/main/java/org/apache/commons/testing/junit4/SetDefaultLocaleTestRule.java
rename to commons-testing-junit4/src/main/java/org/apache/commons/testing/junit4/DefaultLocaleTestRule.java
index 4b7dbd9..31e3f38 100644
--- a/commons-testing-junit4/src/main/java/org/apache/commons/testing/junit4/SetDefaultLocaleTestRule.java
+++ b/commons-testing-junit4/src/main/java/org/apache/commons/testing/junit4/DefaultLocaleTestRule.java
@@ -25,12 +25,14 @@
/**
* Sets the default {@code Locale} to the given locale for the duration of the test.
+ *
+ * @since 1.0.0
*/
-public class SetDefaultLocaleTestRule implements TestRule {
+public class DefaultLocaleTestRule implements TestRule {
private final Locale locale;
- public SetDefaultLocaleTestRule(final Locale locale) {
+ public DefaultLocaleTestRule(final Locale locale) {
super();
this.locale = locale;
}
diff --git a/commons-testing-junit4/src/main/java/org/apache/commons/testing/junit4/ObjectToStringComparator.java b/commons-testing-junit4/src/main/java/org/apache/commons/testing/junit4/ObjectToStringComparator.java
index c04bacf..3e2861b 100644
--- a/commons-testing-junit4/src/main/java/org/apache/commons/testing/junit4/ObjectToStringComparator.java
+++ b/commons-testing-junit4/src/main/java/org/apache/commons/testing/junit4/ObjectToStringComparator.java
@@ -20,6 +20,11 @@
import java.io.Serializable;
import java.util.Comparator;
+/**
+ * Compares objects based on their {@code toString()} values.
+ *
+ * @since 1.0.0
+ */
public final class ObjectToStringComparator implements Comparator<Object>, Serializable {
private static final long serialVersionUID = 1L;
diff --git a/commons-testing-junit4/src/test/java/org/apache/commons/testing/junit4/AvailableLocalesTest.java b/commons-testing-junit4/src/test/java/org/apache/commons/testing/junit4/AvailableLocalesTest.java
new file mode 100644
index 0000000..17eea73
--- /dev/null
+++ b/commons-testing-junit4/src/test/java/org/apache/commons/testing/junit4/AvailableLocalesTest.java
@@ -0,0 +1,58 @@
+/*
+ * 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.testing.junit4;
+
+import java.util.Collections;
+import java.util.Locale;
+import java.util.Set;
+import java.util.concurrent.ConcurrentSkipListSet;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class AvailableLocalesTest extends AbstractAvailableLocalesTest {
+
+ private static Set<Locale> found;
+
+ @AfterClass
+ public static void afterClass() {
+ final ConcurrentSkipListSet<Locale> expected = createSet();
+ Collections.addAll(expected, Locale.getAvailableLocales());
+ Assert.assertEquals(expected, found);
+ }
+
+ @BeforeClass
+ public static void beforeClass() {
+ found = createSet();
+ }
+
+ private static ConcurrentSkipListSet<Locale> createSet() {
+ return new ConcurrentSkipListSet<>(new ObjectToStringComparator());
+ }
+
+ public AvailableLocalesTest(final Locale locale) {
+ super(locale);
+ }
+
+ @Test
+ public void test() {
+ found.add(getLocale());
+ }
+}
diff --git a/commons-testing-junit4/src/test/java/org/apache/commons/testing/junit4/DefaultLocaleTestRuleTest.java b/commons-testing-junit4/src/test/java/org/apache/commons/testing/junit4/DefaultLocaleTestRuleTest.java
new file mode 100644
index 0000000..514cc80
--- /dev/null
+++ b/commons-testing-junit4/src/test/java/org/apache/commons/testing/junit4/DefaultLocaleTestRuleTest.java
@@ -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.testing.junit4;
+
+import java.util.Locale;
+
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+
+/**
+ * Sets the default {@code Locale} to the given Locale for the duration of the test.
+ *
+ * @since 1.0.0
+ */
+public class DefaultLocaleTestRuleTest {
+
+ @Rule
+ public DefaultLocaleTestRule testRule = new DefaultLocaleTestRule(Locale.CANADA);
+
+ @Test
+ public void test() {
+ Assert.assertEquals(Locale.CANADA, Locale.getDefault());
+ }
+
+}
diff --git a/commons-testing-junit4/src/test/java/org/apache/commons/testing/junit4/ObjectToStringComparatorTest.java b/commons-testing-junit4/src/test/java/org/apache/commons/testing/junit4/ObjectToStringComparatorTest.java
new file mode 100644
index 0000000..a3b720e
--- /dev/null
+++ b/commons-testing-junit4/src/test/java/org/apache/commons/testing/junit4/ObjectToStringComparatorTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.testing.junit4;
+
+import java.util.Collections;
+import java.util.Locale;
+import java.util.concurrent.ConcurrentSkipListSet;
+
+import org.junit.Assert;
+
+public class ObjectToStringComparatorTest {
+
+ public static void afterClass() {
+ final ConcurrentSkipListSet<Locale> expected = createSet();
+ final Locale[] availableLocales = Locale.getAvailableLocales();
+ Collections.addAll(expected, availableLocales);
+ Assert.assertEquals(expected.size(), availableLocales.length);
+ }
+
+ private static ConcurrentSkipListSet<Locale> createSet() {
+ return new ConcurrentSkipListSet<>(new ObjectToStringComparator());
+ }
+
+}