Kaynağa Gözat

Add mockito library

Add some minor validator tests
tags/0.6.3m1rc1
Chris Smith 15 yıl önce
ebeveyn
işleme
891d6d7dbc

BIN
lib/mockito-all-1.6.jar Dosyayı Görüntüle


+ 6
- 1
nbproject/project.properties Dosyayı Görüntüle

@@ -1,3 +1,5 @@
1
+application.title=DMDirc
2
+application.vendor=The DMDirc developers
1 3
 file.reference.fest-assert-1.0a1.jar=lib/fest-assert-1.0a1.jar
2 4
 file.reference.fest-reflect-0.4.jar=lib/fest-reflect-0.4.jar
3 5
 file.reference.fest-swing-1.0b1.jar=lib/fest-swing-1.0b1.jar
@@ -5,6 +7,8 @@ file.reference.fest-swing-junit-1.0b1.jar=lib/fest-swing-junit-1.0b1.jar
5 7
 file.reference.fest-util-0.4.jar=lib/fest-util-0.4.jar
6 8
 file.reference.miglayout.jar=lib/miglayout-3.6.3.jar
7 9
 file.reference.junit-4.jar=lib/junit-4.1.jar
10
+file.reference.junit-3.jar=lib/junit-3.8.1.jar
11
+file.reference.mockito-all-1.6.jar=lib/mockito-all-1.6.jar
8 12
 
9 13
 doccheck.path=doccheck.jar
10 14
 doccheck.dir=reports/doccheck/
@@ -45,7 +49,8 @@ javac.test.classpath=\
45 49
     ${file.reference.fest-swing-1.0b1.jar}:\
46 50
     ${file.reference.fest-assert-1.0a1.jar}:\
47 51
     ${file.reference.fest-reflect-0.4.jar}:\
48
-    ${file.reference.fest-util-0.4.jar}
52
+    ${file.reference.fest-util-0.4.jar}:\
53
+    ${file.reference.mockito-all-1.6.jar}
49 54
 javadoc.additionalparam=-overview ${src.dir}/overview.html
50 55
 javadoc.author=false
51 56
 javadoc.encoding=

+ 48
- 0
test/com/dmdirc/config/prefs/validator/ConditionRuleValidatorTest.java Dosyayı Görüntüle

@@ -0,0 +1,48 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
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.config.prefs.validator;
24
+
25
+import org.junit.Test;
26
+import static org.junit.Assert.*;
27
+
28
+public class ConditionRuleValidatorTest {
29
+
30
+    @Test
31
+    public void testIllegal() {
32
+        final ValidationResponse res = new ConditionRuleValidator(10).validate("|||");
33
+        assertTrue(res.isFailure());
34
+    }
35
+
36
+    @Test
37
+    public void testTooMany() {
38
+        final ValidationResponse res = new ConditionRuleValidator(1).validate("0|1|2");
39
+        assertTrue(res.isFailure());
40
+    }
41
+
42
+    @Test
43
+    public void testGood() {
44
+        final ValidationResponse res = new ConditionRuleValidator(3).validate("0|1|2");
45
+        assertFalse(res.isFailure());
46
+    }
47
+
48
+}

+ 40
- 0
test/com/dmdirc/config/prefs/validator/IdentValidatorTest.java Dosyayı Görüntüle

@@ -0,0 +1,40 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
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.config.prefs.validator;
24
+
25
+import org.junit.Test;
26
+import static org.junit.Assert.*;
27
+
28
+public class IdentValidatorTest {
29
+
30
+    @Test
31
+    public void testPass() {
32
+        assertTrue(new IdentValidator().validate("foo bar").isFailure());
33
+    }
34
+
35
+    @Test
36
+    public void testFail() {
37
+        assertFalse(new IdentValidator().validate("foo[]bar").isFailure());
38
+    }
39
+
40
+}

+ 40
- 0
test/com/dmdirc/config/prefs/validator/NicknameValidatorTest.java Dosyayı Görüntüle

@@ -0,0 +1,40 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
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.config.prefs.validator;
24
+
25
+import org.junit.Test;
26
+import static org.junit.Assert.*;
27
+
28
+public class NicknameValidatorTest {
29
+
30
+    @Test
31
+    public void testPass() {
32
+        assertTrue(new NicknameValidator().validate("foo bar").isFailure());
33
+    }
34
+
35
+    @Test
36
+    public void testFail() {
37
+        assertFalse(new NicknameValidator().validate("foo[]bar").isFailure());
38
+    }
39
+
40
+}

Loading…
İptal
Kaydet