You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2009/02/11 00:14:37 UTC

svn commit: r743160 - in /lenya/trunk: org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/ org.apache.lenya.core.api/src/test/java/org/apache/lenya/cms/ org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/ ...

Author: andreas
Date: Tue Feb 10 23:14:37 2009
New Revision: 743160

URL: http://svn.apache.org/viewvc?rev=743160&view=rev
Log:
Fixing some tests.

Added:
    lenya/trunk/org.apache.lenya.core.impl/src/test/resources/org/apache/lenya/cms/publication/PublicationTest.spring.xml
    lenya/trunk/org.apache.lenya.core.impl/src/test/resources/org/apache/lenya/cms/publication/PublicationTest.xtest
    lenya/trunk/org.apache.lenya.core.impl/src/test/resources/org/apache/lenya/cms/rc/
    lenya/trunk/org.apache.lenya.core.impl/src/test/resources/org/apache/lenya/cms/rc/RevisionControllerTest.spring.xml
    lenya/trunk/org.apache.lenya.core.impl/src/test/resources/org/apache/lenya/cms/rc/RevisionControllerTest.xtest
Modified:
    lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/SourceUtil.java
    lenya/trunk/org.apache.lenya.core.api/src/test/java/org/apache/lenya/cms/AbstractAccessControlTest.java
    lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/RepositoryImpl.java
    lenya/trunk/org.apache.lenya.core.resourcetype/   (props changed)

Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/SourceUtil.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/SourceUtil.java?rev=743160&r1=743159&r2=743160&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/SourceUtil.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/SourceUtil.java Tue Feb 10 23:14:37 2009
@@ -271,12 +271,16 @@
     public static void writeDOM(Document document, String sourceUri, SourceResolver resolver)
             throws TransformerConfigurationException, TransformerException, ServiceException,
             MalformedURLException, IOException {
-        ModifiableSource source = null;
+        Source source = null;
         try {
-            source = (ModifiableSource) resolver.resolveURI(sourceUri);
-
-            OutputStream oStream = source.getOutputStream();
-            writeDOM(document, oStream);
+            source = resolver.resolveURI(sourceUri);
+            if (source instanceof ModifiableSource) {
+                ModifiableSource modifiableSource = (ModifiableSource) source;
+                OutputStream oStream = modifiableSource.getOutputStream();
+                writeDOM(document, oStream);
+            } else {
+                throw new IOException("The source " + sourceUri + " is not modifiable.");
+            }
         } finally {
             if (source != null) {
                 resolver.release(source);

Modified: lenya/trunk/org.apache.lenya.core.api/src/test/java/org/apache/lenya/cms/AbstractAccessControlTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/test/java/org/apache/lenya/cms/AbstractAccessControlTest.java?rev=743160&r1=743159&r2=743160&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/test/java/org/apache/lenya/cms/AbstractAccessControlTest.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/test/java/org/apache/lenya/cms/AbstractAccessControlTest.java Tue Feb 10 23:14:37 2009
@@ -57,8 +57,8 @@
 
     protected Session login(String userId, String pubId) throws AccessControlException {
         
-        Session session = getRepository().startSession(null, true);
-        AccessController ac = getAccessController(session, pubId);
+        final Session anonymousSession = getRepository().startSession(null, false);
+        AccessController ac = getAccessController(anonymousSession, pubId);
         AccreditableManager acMgr = ac.getAccreditableManager();
         User user = acMgr.getUserManager().getUser(userId);
 
@@ -70,6 +70,7 @@
 
         HttpSession cocoonSession = getRequest().getSession();
         Identity identity = (Identity) cocoonSession.getAttribute(Identity.class.getName());
+        final Session userSession = getRepository().startSession(identity, true);
 
         if (!identity.contains(user)) {
             User oldUser = identity.getUser();
@@ -89,8 +90,8 @@
             logger.info("Accreditable: " + accrs[i]);
         }
 
-        getRequest().setAttribute(Session.class.getName(), session);
-        return session;
+        getRequest().setAttribute(Session.class.getName(), userSession);
+        return userSession;
     }
 
     protected AccessController getAccessController() throws AccessControlException {

Modified: lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/RepositoryImpl.java?rev=743160&r1=743159&r2=743160&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/RepositoryImpl.java (original)
+++ lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/RepositoryImpl.java Tue Feb 10 23:14:37 2009
@@ -48,11 +48,16 @@
     }
 
     public Session startSession(Identity identity, boolean modifiable) {
+
+        if (modifiable && identity == null) {
+            throw new IllegalArgumentException(
+                    "Can't start a modifiable session without an identity.");
+        }
+
         IdentityWrapper wrapper = new IdentityWrapper(identity);
         org.apache.lenya.cms.repository.Session repoSession;
         try {
-            repoSession = this.repositoryManager
-                    .createSession(wrapper, modifiable);
+            repoSession = this.repositoryManager.createSession(wrapper, modifiable);
         } catch (RepositoryException e) {
             throw new RuntimeException(e);
         }

Added: lenya/trunk/org.apache.lenya.core.impl/src/test/resources/org/apache/lenya/cms/publication/PublicationTest.spring.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.impl/src/test/resources/org/apache/lenya/cms/publication/PublicationTest.spring.xml?rev=743160&view=auto
==============================================================================
--- lenya/trunk/org.apache.lenya.core.impl/src/test/resources/org/apache/lenya/cms/publication/PublicationTest.spring.xml (added)
+++ lenya/trunk/org.apache.lenya.core.impl/src/test/resources/org/apache/lenya/cms/publication/PublicationTest.spring.xml Tue Feb 10 23:14:37 2009
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+  <import resource="classpath:test-components.xml"/>
+</beans>

Added: lenya/trunk/org.apache.lenya.core.impl/src/test/resources/org/apache/lenya/cms/publication/PublicationTest.xtest
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.impl/src/test/resources/org/apache/lenya/cms/publication/PublicationTest.xtest?rev=743160&view=auto
==============================================================================
--- lenya/trunk/org.apache.lenya.core.impl/src/test/resources/org/apache/lenya/cms/publication/PublicationTest.xtest (added)
+++ lenya/trunk/org.apache.lenya.core.impl/src/test/resources/org/apache/lenya/cms/publication/PublicationTest.xtest Tue Feb 10 23:14:37 2009
@@ -0,0 +1,41 @@
+<?xml version="1.0" ?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<testcase>
+  <roles>
+    <role name="org.apache.excalibur.source.SourceFactorySelector"
+      shorthand="source-factories"
+      default-class="org.apache.cocoon.core.container.DefaultServiceSelector"/>
+    <role name="org.apache.excalibur.source.SourceResolver"
+      shorthand="source-resolver"
+      default-class="org.apache.excalibur.source.impl.SourceResolverImpl"
+    />
+  </roles>
+  
+  <components>
+    
+    <source-factories>
+      <component-instance class="org.apache.cocoon.components.source.impl.XMLizableSourceFactory" name="xml" logger="core.xmlsource"/>
+      <component-instance class="org.apache.excalibur.source.impl.FileSourceFactory" name="file" logger="core.filesource"/>
+      <component-instance class="org.apache.excalibur.source.impl.ResourceSourceFactory" name="resource" logger="core.resourcesource"/>
+      <component-instance class="org.apache.cocoon.components.source.impl.ContextSourceFactory" name="context"/>
+      <component-instance class="org.apache.excalibur.source.impl.URLSourceFactory" name="*"/>
+    </source-factories>
+    
+  </components>
+  
+</testcase>

Added: lenya/trunk/org.apache.lenya.core.impl/src/test/resources/org/apache/lenya/cms/rc/RevisionControllerTest.spring.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.impl/src/test/resources/org/apache/lenya/cms/rc/RevisionControllerTest.spring.xml?rev=743160&view=auto
==============================================================================
--- lenya/trunk/org.apache.lenya.core.impl/src/test/resources/org/apache/lenya/cms/rc/RevisionControllerTest.spring.xml (added)
+++ lenya/trunk/org.apache.lenya.core.impl/src/test/resources/org/apache/lenya/cms/rc/RevisionControllerTest.spring.xml Tue Feb 10 23:14:37 2009
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+  <import resource="classpath:test-components.xml"/>
+</beans>

Added: lenya/trunk/org.apache.lenya.core.impl/src/test/resources/org/apache/lenya/cms/rc/RevisionControllerTest.xtest
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.impl/src/test/resources/org/apache/lenya/cms/rc/RevisionControllerTest.xtest?rev=743160&view=auto
==============================================================================
--- lenya/trunk/org.apache.lenya.core.impl/src/test/resources/org/apache/lenya/cms/rc/RevisionControllerTest.xtest (added)
+++ lenya/trunk/org.apache.lenya.core.impl/src/test/resources/org/apache/lenya/cms/rc/RevisionControllerTest.xtest Tue Feb 10 23:14:37 2009
@@ -0,0 +1,41 @@
+<?xml version="1.0" ?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<testcase>
+  <roles>
+    <role name="org.apache.excalibur.source.SourceFactorySelector"
+      shorthand="source-factories"
+      default-class="org.apache.cocoon.core.container.DefaultServiceSelector"/>
+    <role name="org.apache.excalibur.source.SourceResolver"
+      shorthand="source-resolver"
+      default-class="org.apache.excalibur.source.impl.SourceResolverImpl"
+    />
+  </roles>
+  
+  <components>
+    
+    <source-factories>
+      <component-instance class="org.apache.cocoon.components.source.impl.XMLizableSourceFactory" name="xml" logger="core.xmlsource"/>
+      <component-instance class="org.apache.excalibur.source.impl.FileSourceFactory" name="file" logger="core.filesource"/>
+      <component-instance class="org.apache.excalibur.source.impl.ResourceSourceFactory" name="resource" logger="core.resourcesource"/>
+      <component-instance class="org.apache.cocoon.components.source.impl.ContextSourceFactory" name="context"/>
+      <component-instance class="org.apache.excalibur.source.impl.URLSourceFactory" name="*"/>
+    </source-factories>
+    
+  </components>
+  
+</testcase>

Propchange: lenya/trunk/org.apache.lenya.core.resourcetype/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Feb 10 23:14:37 2009
@@ -0,0 +1,6 @@
+target
+.project
+.classpath
+.settings
+profiles.xml
+



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org