KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > atlassian > seraph > service > TestPathService


1 package com.atlassian.seraph.service;
2
3 import junit.framework.TestCase;
4
5 /**
6  *
7  * @author greg
8  * @author $Author: jturner $ (last edit)
9  * @version $Revision: 1.1 $
10  */

11 public class TestPathService extends TestCase {
12     public void testParseRolesWorksWithSingleRole() {
13         PathService pathService = new PathService();
14         String JavaDoc[] result = pathService.parseRoles("blah");
15         assertEquals(1, result.length);
16         assertEquals("blah", result[0]);
17     }
18
19     public void testParseRolesPrefixingAndSuffixingSeparatorsShouldBeDiscarded() {
20         PathService pathService = new PathService();
21         String JavaDoc[] result = pathService.parseRoles("; blah,foo; ");
22         assertEquals(2, result.length);
23         assertEquals("blah", result[0]);
24         assertEquals("foo", result[1]);
25     }
26
27     public void testParseRolesJustAQuoteShouldReturnEmptyArray() {
28         PathService pathService = new PathService();
29         String JavaDoc[] result = pathService.parseRoles(",");
30         assertEquals(0, result.length);
31     }
32
33     public void testParseRolesWorksWithExtraSpacesAndIsUserFriendlyEnough() {
34         PathService pathService = new PathService();
35         String JavaDoc[] result = pathService.parseRoles("blah foo, bar; baz idiot ");
36         assertEquals(5, result.length);
37         assertEquals("blah", result[0]);
38         assertEquals("foo", result[1]);
39         assertEquals("bar", result[2]);
40         assertEquals("baz", result[3]);
41         assertEquals("idiot", result[4]);
42     }
43
44     public void testParseRolesAlsoWorksWithNewLinesAndTabs() {
45         PathService pathService = new PathService();
46         String JavaDoc[] result = pathService.parseRoles("blah foo, \t\tbar;\n baz idiot ");
47         assertEquals(5, result.length);
48         assertEquals("blah", result[0]);
49         assertEquals("foo", result[1]);
50         assertEquals("bar", result[2]);
51         assertEquals("baz", result[3]);
52         assertEquals("idiot", result[4]);
53     }
54
55     public void testParseRolesWorksWithNoSpacesToo() {
56         PathService pathService = new PathService();
57         String JavaDoc[] result = pathService.parseRoles("blah,foo,bar,baz,idiot");
58         assertEquals(5, result.length);
59         assertEquals("blah", result[0]);
60         assertEquals("foo", result[1]);
61         assertEquals("bar", result[2]);
62         assertEquals("baz", result[3]);
63         assertEquals("idiot", result[4]);
64     }
65 }
66
Popular Tags