1 package org.apache.maven.archiva.webdav;
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
22 import junit.framework.TestCase;
25 * @author <a href="mailto:james@atlassian.com">James William Dumay</a>
27 public class ArchivaDavResourceLocatorTest extends TestCase
29 ArchivaDavLocatorFactory factory;
32 protected void setUp()
36 factory = new ArchivaDavLocatorFactory();
39 public void testLocatorWithPrefixHref()
42 String prefix = "http://myproxy/";
43 String href = "repository/internal";
44 ArchivaDavResourceLocator locator = (ArchivaDavResourceLocator)factory.createResourceLocator(prefix, href);
46 assertEquals("internal", locator.getRepositoryId());
47 assertEquals("", locator.getWorkspaceName());
48 assertEquals("", locator.getWorkspacePath());
49 assertEquals("http://myproxy/", locator.getPrefix());
50 assertEquals("http://myproxy/repository/internal", locator.getHref(false));
51 assertEquals("http://myproxy/repository/internal/", locator.getHref(true));
52 assertEquals("repository/internal", locator.getResourcePath());
53 assertEquals("repository/internal", locator.getRepositoryPath());
56 public void testLocatorWithHrefThatContainsPrefix()
59 String prefix = "http://myproxy/";
60 String href = "http://myproxy/repository/internal";
61 ArchivaDavResourceLocator locator = (ArchivaDavResourceLocator)factory.createResourceLocator(prefix, href);
63 assertEquals("internal", locator.getRepositoryId());
64 assertEquals("", locator.getWorkspaceName());
65 assertEquals("", locator.getWorkspacePath());
66 assertEquals("http://myproxy/", locator.getPrefix());
67 assertEquals("http://myproxy/repository/internal", locator.getHref(false));
68 assertEquals("http://myproxy/repository/internal/", locator.getHref(true));
69 assertEquals("repository/internal", locator.getResourcePath());
70 assertEquals("repository/internal", locator.getRepositoryPath());
73 public void testLocatorWithRootHref()
76 String prefix = "http://myproxy/";
78 ArchivaDavResourceLocator locator = (ArchivaDavResourceLocator)factory.createResourceLocator(prefix, href);
80 assertEquals("", locator.getRepositoryId());
81 assertEquals("", locator.getWorkspaceName());
82 assertEquals("", locator.getWorkspacePath());
83 assertEquals("http://myproxy/", locator.getPrefix());
84 assertEquals("http://myproxy//", locator.getHref(false));
85 assertEquals("http://myproxy//", locator.getHref(true));
86 assertEquals("/", locator.getResourcePath());
87 assertEquals("/", locator.getRepositoryPath());