01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.openejb.assembler.classic;
17:
18: import java.net.URI;
19:
20: import junit.framework.TestCase;
21: import org.apache.openejb.util.LinkResolver;
22:
23: public class LinkResolverTest extends TestCase {
24:
25: public void test() throws Exception {
26: LinkResolver<Thing> resolver = new LinkResolver<Thing>();
27:
28: resolver.add("my/module.jar", "one", Thing.ONE);
29: resolver.add("some/other.jar", "two", Thing.TWO);
30:
31: URI moduleUri = URI.create("my/module.jar");
32:
33: assertEquals(Thing.ONE, resolver.resolveLink("one", moduleUri));
34: assertEquals(Thing.ONE, resolver.resolveLink("module.jar#one",
35: moduleUri));
36: assertEquals(Thing.ONE, resolver.resolveLink(
37: "../my/module.jar#one", moduleUri));
38: assertEquals(Thing.ONE, resolver.resolveLink(
39: "../my/./module.jar#one", moduleUri));
40:
41: assertEquals(Thing.TWO, resolver.resolveLink("two", moduleUri));
42: assertEquals(Thing.TWO, resolver.resolveLink(
43: "../some/./other.jar#two", moduleUri));
44: }
45:
46: private static enum Thing {
47: ONE, TWO
48: }
49: }
|