source: java/main/src/test/java/com/framsticks/core/PathTest.java @ 193

Last change on this file since 193 was 193, checked in by Maciej Komosinski, 10 years ago

Set svn:eol-style native for all textual files

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1package com.framsticks.core;
2
3// import static org.mutabilitydetector.unittesting.MutabilityAssert.*;
4// import static org.mutabilitydetector.unittesting.MutabilityMatchers.*;
5// import static org.mutabilitydetector.unittesting.AllowedReason.*;
6
7// import java.util.LinkedList;
8
9import org.testng.annotations.BeforeClass;
10import org.testng.annotations.DataProvider;
11import org.testng.annotations.Test;
12
13import com.framsticks.structure.Path;
14import com.framsticks.test.TestConfiguration;
15import com.framsticks.util.lang.Pair;
16
17import static org.fest.assertions.Assertions.*;
18
19@Test
20public class PathTest extends TestConfiguration {
21
22        @BeforeClass
23        public void setUp() {
24                // assertInstancesOf(Path.class,
25                //              areImmutable(),
26                //              allowingNonFinalFields(),
27                //              provided(String.class).isAlsoImmutable(),
28                //              provided(LinkedList.class).isAlsoImmutable()
29                //              );
30        }
31
32        @Test(dataProvider = "pathValidationProvider")
33        public void pathValidation(String path, boolean ok) {
34                assertThat(Path.isValidString(path)).describedAs(path).isEqualTo(ok);
35        }
36
37        @Test(dataProvider = "pathSplitingProvider")
38        public void pathSpliting(String path, String prefix, String suffix) {
39                Pair<String, String> p = Path.removeLastElement(path);
40                assertThat(p.first).isEqualTo(prefix);
41                assertThat(p.second).isEqualTo(suffix);
42        }
43
44        @DataProvider
45        public Object[][] pathValidationProvider() {
46                return new Object[][] {
47                        { "/", true },
48                        { "/path", true },
49                        { "path", false },
50                        { "/path/to/", false },
51                        { "/path/to", true },
52                        { "/testClass/history_changed", true },
53                        { "/cli/events/e0", true }
54
55                };
56        }
57
58        @DataProvider
59        public Object[][] pathSplitingProvider() {
60                return new Object[][] {
61                        { "/event", "/", "event" },
62                        { "/path/event", "/path", "event" }
63                };
64        }
65
66}
Note: See TracBrowser for help on using the repository browser.