Browse Source

Move config provider tests to the right place.

pull/773/head
Chris Smith 7 years ago
parent
commit
0c4a027b42

+ 48
- 0
bundles/com.dmdirc.config.provider/src/test/java/com/dmdirc/config/provider/ReadOnlyConfigProviderTest.java View File

@@ -0,0 +1,48 @@
1
+/*
2
+ * Copyright (c) 2006-2017 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5
+ * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7
+ * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
+ *
9
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10
+ * Software.
11
+ *
12
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
14
+ * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
+ */
17
+package com.dmdirc.config.provider;
18
+
19
+import org.junit.Test;
20
+
21
+import static org.junit.Assert.*;
22
+
23
+public class ReadOnlyConfigProviderTest {
24
+
25
+    private final TestReadOnlyConfigProvider s = new TestReadOnlyConfigProvider();
26
+
27
+    @Test
28
+    public void testGetBoolean() {
29
+        assertTrue(s.getOptionBool("true", "true"));
30
+        assertFalse(s.getOptionBool("true", "false"));
31
+    }
32
+
33
+    @Test
34
+    public void testGetInt() {
35
+        assertEquals(42, s.getOptionInt("true", "42").intValue());
36
+    }
37
+
38
+    @Test
39
+    public void testGetList() {
40
+        assertTrue(s.getOptionList("false", "moo").isEmpty());
41
+        assertTrue(s.getOptionList("true", "").isEmpty());
42
+        assertTrue(s.getOptionList("true", "\n\n\n").isEmpty());
43
+        assertEquals(4, s.getOptionList("true", "\n\n\na", false).size());
44
+        assertEquals(4, s.getOptionList("true", "a\nb\nc\nd", true).size());
45
+        assertEquals("c", s.getOptionList("true", "a\nb\nc\nd", true).get(2));
46
+    }
47
+
48
+}

+ 39
- 0
bundles/com.dmdirc.config.provider/src/test/java/com/dmdirc/config/provider/TestReadOnlyConfigProvider.java View File

@@ -0,0 +1,39 @@
1
+/*
2
+ * Copyright (c) 2006-2017 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5
+ * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7
+ * permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
+ *
9
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10
+ * Software.
11
+ *
12
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
14
+ * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
+ */
17
+
18
+package com.dmdirc.config.provider;
19
+
20
+import com.dmdirc.util.validators.Validator;
21
+import java.util.Map;
22
+
23
+public class TestReadOnlyConfigProvider implements ReadOnlyConfigProvider {
24
+
25
+    @Override
26
+    public boolean hasOption(final String domain, final String option, final Validator<String> validator) {
27
+        return Boolean.parseBoolean(domain);
28
+    }
29
+
30
+    @Override
31
+    public String getOption(final String domain, final String option, final Validator<String> validator) {
32
+        return option;
33
+    }
34
+
35
+    @Override
36
+    public Map<String, String> getOptions(final String domain) {
37
+        throw new UnsupportedOperationException("Not supported yet.");
38
+    }
39
+}

+ 0
- 55
src/test/java/com/dmdirc/config/ConfigSourceTest.java View File

@@ -1,55 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-package com.dmdirc.config;
23
-
24
-import com.dmdirc.harness.TestConfigSource;
25
-
26
-import org.junit.Test;
27
-
28
-import static org.junit.Assert.*;
29
-
30
-public class ConfigSourceTest {
31
-
32
-    private final TestConfigSource s = new TestConfigSource();
33
-
34
-    @Test
35
-    public void testGetBoolean() {
36
-        assertTrue(s.getOptionBool("true", "true"));
37
-        assertFalse(s.getOptionBool("true", "false"));
38
-    }
39
-
40
-    @Test
41
-    public void testGetInt() {
42
-        assertEquals(42, s.getOptionInt("true", "42").intValue());
43
-    }
44
-
45
-    @Test
46
-    public void testGetList() {
47
-        assertTrue(s.getOptionList("false", "moo").isEmpty());
48
-        assertTrue(s.getOptionList("true", "").isEmpty());
49
-        assertTrue(s.getOptionList("true", "\n\n\n").isEmpty());
50
-        assertEquals(4, s.getOptionList("true", "\n\n\na", false).size());
51
-        assertEquals(4, s.getOptionList("true", "a\nb\nc\nd", true).size());
52
-        assertEquals("c", s.getOptionList("true", "a\nb\nc\nd", true).get(2));
53
-    }
54
-
55
-}

+ 0
- 45
src/test/java/com/dmdirc/harness/TestConfigSource.java View File

@@ -1,45 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.harness;
24
-
25
-import com.dmdirc.config.provider.ReadOnlyConfigProvider;
26
-import com.dmdirc.util.validators.Validator;
27
-import java.util.Map;
28
-
29
-public class TestConfigSource implements ReadOnlyConfigProvider {
30
-
31
-    @Override
32
-    public boolean hasOption(final String domain, final String option, final Validator<String> validator) {
33
-        return Boolean.parseBoolean(domain);
34
-    }
35
-
36
-    @Override
37
-    public String getOption(final String domain, final String option, final Validator<String> validator) {
38
-        return option;
39
-    }
40
-
41
-    @Override
42
-    public Map<String, String> getOptions(final String domain) {
43
-        throw new UnsupportedOperationException("Not supported yet.");
44
-    }
45
-}

Loading…
Cancel
Save