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: *
17: */
18: package org.apache.lenya.cms.publication;
19:
20: import junit.framework.TestCase;
21:
22: /**
23: *
24: */
25: public class DocumentLocatorTest extends TestCase {
26:
27: /**
28: *
29: */
30: public void testDocumentLocator() {
31:
32: String pubId = "pub";
33: String area = "area";
34: String area2 = "area2";
35: String languageDe = "de";
36: String languageEn = "en";
37:
38: DocumentLocator root = DocumentLocator.getLocator(pubId, area,
39: "", languageDe);
40: DocumentLocator foo = DocumentLocator.getLocator(pubId, area,
41: "/foo", languageDe);
42: DocumentLocator fooBar = DocumentLocator.getLocator(pubId,
43: area, "/foo/bar", languageDe);
44: DocumentLocator fooBarBaz = DocumentLocator.getLocator(pubId,
45: area, "/foo/bar/baz", languageDe);
46:
47: DocumentLocator fooEn = DocumentLocator.getLocator(pubId, area,
48: "/foo", languageEn);
49: DocumentLocator foo2 = DocumentLocator.getLocator(pubId, area2,
50: "/foo", languageDe);
51:
52: assertEquals(foo.getParent(), root);
53: assertEquals(fooBar.getParent(), foo);
54: assertEquals(fooBarBaz.getParent(), fooBar);
55:
56: assertEquals(root.getDescendant("foo"), foo);
57: assertEquals(foo.getDescendant("bar/baz"), fooBarBaz);
58:
59: assertEquals(foo.getChild("bar"), fooBar);
60:
61: assertEquals(foo.getLanguageVersion(languageEn), fooEn);
62:
63: assertEquals(foo.getAreaVersion(area2), foo2);
64:
65: }
66:
67: }
|