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:
19: package org.apache.lenya.cms.publication;
20:
21: import org.apache.lenya.ac.AccessControlException;
22: import org.apache.lenya.ac.impl.AbstractAccessControlTest;
23: import org.apache.lenya.cms.metadata.MetaData;
24: import org.apache.lenya.cms.metadata.MetaDataException;
25: import org.apache.lenya.cms.metadata.dublincore.DublinCore;
26: import org.apache.lenya.cms.repository.RepositoryException;
27:
28: /**
29: * Dublin Core test.
30: *
31: * @version $Id: DublinCoreTest.java 485769 2006-12-11 17:41:23Z andreas $
32: */
33: public class DublinCoreTest extends AbstractAccessControlTest {
34:
35: private static final String AREA = "authoring";
36: private static final String PATH = "/tutorial";
37: private static final String LANGUAGE = "de";
38:
39: /**
40: * Test the fetching, modification and refetching of a dc core object.
41: * @throws PublicationException
42: * @throws MetaDataException
43: * @throws RepositoryException
44: * @throws AccessControlException
45: * @throws RepositoryException
46: */
47: final public void testModifySaveAndReload()
48: throws PublicationException, MetaDataException,
49: AccessControlException, RepositoryException {
50:
51: login("lenya");
52:
53: Publication publication = getPublication("test");
54:
55: Document doc = publication.getArea(AREA).getSite()
56: .getNode(PATH).getLink(LANGUAGE).getDocument();
57:
58: doc.getRepositoryNode().lock();
59:
60: MetaData dcCore = doc.getMetaData(DublinCore.DC_NAMESPACE);
61: String title = dcCore.getFirstValue(DublinCore.ELEMENT_TITLE);
62: String subject = dcCore
63: .getFirstValue(DublinCore.ELEMENT_SUBJECT);
64: String creator = dcCore
65: .getFirstValue(DublinCore.ELEMENT_CREATOR);
66:
67: if (creator == null) {
68: creator = "test";
69: }
70:
71: String newCreator = creator + "-test";
72: dcCore.setValue(DublinCore.ELEMENT_CREATOR, newCreator);
73:
74: Document doc2 = publication.getArea(AREA).getSite().getNode(
75: PATH).getLink(LANGUAGE).getDocument();
76:
77: MetaData dcCore2 = doc2.getMetaData(DublinCore.DC_NAMESPACE);
78: assertEquals(title, dcCore2
79: .getFirstValue(DublinCore.ELEMENT_TITLE));
80: assertEquals(subject, dcCore2
81: .getFirstValue(DublinCore.ELEMENT_SUBJECT));
82: assertFalse(creator.equals(dcCore2
83: .getFirstValue(DublinCore.ELEMENT_CREATOR)));
84: assertEquals(newCreator, dcCore2
85: .getFirstValue(DublinCore.ELEMENT_CREATOR));
86:
87: doc.getRepositoryNode().unlock();
88: }
89:
90: }
|