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.site.tree;
19:
20: import org.apache.lenya.ac.impl.AbstractAccessControlTest;
21: import org.apache.lenya.cms.publication.DocumentFactory;
22: import org.apache.lenya.cms.publication.DocumentUtil;
23: import org.apache.lenya.cms.publication.Publication;
24: import org.apache.lenya.cms.repository.Session;
25: import org.apache.lenya.cms.site.SiteNode;
26: import org.apache.lenya.cms.site.SiteStructure;
27:
28: /**
29: * Test for bug <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=42602">42602</a>.
30: */
31: public class ConcurrentModificationTest extends
32: AbstractAccessControlTest {
33:
34: public void testConcurrentModification() throws Exception {
35:
36: String pubId = "test";
37: String area = "authoring";
38:
39: Session lenyaSession = login("lenya");
40: DocumentFactory lenyaFactory = DocumentUtil
41: .createDocumentFactory(getManager(), lenyaSession);
42: Publication lenyaPub = lenyaFactory.getPublication(pubId);
43:
44: SiteStructure lenyaSite = lenyaPub.getArea(area).getSite();
45: lenyaSite.getRepositoryNode().lock();
46:
47: Session aliceSession = login("alice");
48: DocumentFactory aliceFactory = DocumentUtil
49: .createDocumentFactory(getManager(), aliceSession);
50: Publication alicePub = aliceFactory.getPublication(pubId);
51:
52: SiteStructure aliceSite = alicePub.getArea(area).getSite();
53: aliceSite.getRepositoryNode().lock();
54:
55: SiteNode lenyaNode = lenyaSite.getNodes()[1];
56: lenyaNode.setVisible(!lenyaNode.isVisible());
57: lenyaSession.commit();
58:
59: SiteNode aliceNode = aliceSite.getNodes()[2];
60: aliceNode.setVisible(!aliceNode.isVisible());
61: try {
62: aliceSession.commit();
63: assertTrue("No exception raised", false);
64: } catch (Exception ignore) {
65: }
66:
67: }
68:
69: }
|