1 package org.apache.maven.wagon.providers.webdav;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import junit.framework.TestCase;
23
24 /**
25 * @author <a href="mailto:james@atlassian.com">James William Dumay</a>
26 */
27 public class PathNavigatorTest extends TestCase
28 {
29 private static final String TEST_PATH = "foo/bar/baz";
30
31 public void testBackAndForward()
32 {
33 PathNavigator navigator = new PathNavigator( TEST_PATH );
34
35 assertEquals( "foo/bar/baz/", navigator.getPath() );
36
37 // Nav backward
38 assertTrue( navigator.backward() );
39 assertEquals( "foo/bar/", navigator.getPath() );
40
41 assertTrue( navigator.backward() );
42 assertEquals( "foo/", navigator.getPath() );
43
44 assertTrue( navigator.backward() );
45 assertEquals( "", navigator.getPath() );
46
47 assertFalse( navigator.backward() );
48 assertEquals( "", navigator.getPath() );
49
50 // Nav forward
51 assertTrue( navigator.forward() );
52 assertEquals( "foo/", navigator.getPath() );
53
54 assertTrue( navigator.forward() );
55 assertEquals( "foo/bar/", navigator.getPath() );
56
57 assertTrue( navigator.forward() );
58 assertEquals( "foo/bar/baz/", navigator.getPath() );
59
60 assertFalse( navigator.forward() );
61 assertEquals( "foo/bar/baz/", navigator.getPath() );
62 }
63 }