001package org.apache.maven.wagon.providers.webdav; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import junit.framework.TestCase; 023 024/** 025 * @author <a href="mailto:james@atlassian.com">James William Dumay</a> 026 */ 027public class PathNavigatorTest extends TestCase 028{ 029 private static final String TEST_PATH = "foo/bar/baz"; 030 031 public void testBackAndForward() 032 { 033 PathNavigator navigator = new PathNavigator( TEST_PATH ); 034 035 assertEquals( "foo/bar/baz/", navigator.getPath() ); 036 037 // Nav backward 038 assertTrue( navigator.backward() ); 039 assertEquals( "foo/bar/", navigator.getPath() ); 040 041 assertTrue( navigator.backward() ); 042 assertEquals( "foo/", navigator.getPath() ); 043 044 assertTrue( navigator.backward() ); 045 assertEquals( "", navigator.getPath() ); 046 047 assertFalse( navigator.backward() ); 048 assertEquals( "", navigator.getPath() ); 049 050 // Nav forward 051 assertTrue( navigator.forward() ); 052 assertEquals( "foo/", navigator.getPath() ); 053 054 assertTrue( navigator.forward() ); 055 assertEquals( "foo/bar/", navigator.getPath() ); 056 057 assertTrue( navigator.forward() ); 058 assertEquals( "foo/bar/baz/", navigator.getPath() ); 059 060 assertFalse( navigator.forward() ); 061 assertEquals( "foo/bar/baz/", navigator.getPath() ); 062 } 063}