|
|
Choosing A Webhost: |
svn commit: r387516 - in /lenya/trunk/src: targets/test-build.xml test/org/: msg#00183cms.lenya.cvs
Author: andreas Date: Tue Mar 21 04:59:36 2006 New Revision: 387516 URL: http://svn.apache.org/viewcvs?rev=387516&view=rev Log: Added LinkRewriterTest Added: lenya/trunk/src/test/org/apache/lenya/cms/site/ lenya/trunk/src/test/org/apache/lenya/cms/site/usecases/ lenya/trunk/src/test/org/apache/lenya/cms/site/usecases/LinkRewriterTest.java lenya/trunk/src/test/org/apache/lenya/cms/site/usecases/index_en.xml Modified: lenya/trunk/src/targets/test-build.xml Modified: lenya/trunk/src/targets/test-build.xml URL: http://svn.apache.org/viewcvs/lenya/trunk/src/targets/test-build.xml?rev=387516&r1=387515&r2=387516&view=diff ============================================================================== --- lenya/trunk/src/targets/test-build.xml (original) +++ lenya/trunk/src/targets/test-build.xml Tue Mar 21 04:59:36 2006 @@ -155,7 +155,9 @@ <!-- Runs JUnit tests --> <target name="tests.junit" depends="tests.prepare, test.pub.prepare"> - <junit printsummary="yes" showoutput="true" haltonerror="on" haltonfailure="on"> + <junit printsummary="yes" showoutput="true" haltonerror="on" haltonfailure="on" fork="true"> + <jvmarg value="-Djava.endorsed.dirs=${build.webapp}/WEB-INF/lib/endorsed"/> + <jvmarg value="-Dorg.xml.sax.parser=org.apache.xerces.parsers.SAXParser"/> <sysproperty key="junit.test.loglevel" value="${junit.test.loglevel}"/> <sysproperty key="contextRoot" value="${basedir}/build/lenya/webapp"/> <sysproperty key="tempDir" value="${basedir}/build/lenya/temp"/> @@ -171,7 +173,7 @@ </fileset> <pathelement path="${src.test.dir}"/> </classpath> - + <test name="org.apache.lenya.ac.impl.IdentityTest" todir="${junit.dir}"/> <test name="org.apache.lenya.ac.impl.AccessControllerTest" todir="${junit.dir}"/> <test name="org.apache.lenya.ac.impl.AccreditableManagerTest" todir="${junit.dir}"/> @@ -198,7 +200,10 @@ <test name="org.apache.lenya.cms.rc.RCMLTest" todir="${junit.dir}"/> <test name="org.apache.lenya.cms.rc.RevisionControllerTest" todir="${junit.dir}"/> --> + <test name="org.apache.lenya.cms.workflow.WorkflowTest" todir="${junit.dir}"/> + <test name="org.apache.lenya.cms.site.usecases.LinkRewriterTest" todir="${junit.dir}"/> + </junit> </target> Added: lenya/trunk/src/test/org/apache/lenya/cms/site/usecases/LinkRewriterTest.java URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/cms/site/usecases/LinkRewriterTest.java?rev=387516&view=auto ============================================================================== --- lenya/trunk/src/test/org/apache/lenya/cms/site/usecases/LinkRewriterTest.java (added) +++ lenya/trunk/src/test/org/apache/lenya/cms/site/usecases/LinkRewriterTest.java Tue Mar 21 04:59:36 2006 @@ -0,0 +1,104 @@ +/* + * Copyright 1999-2004 The Apache Software Foundation + * + * Licensed 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. + * + */ +package org.apache.lenya.cms.site.usecases; + +import org.apache.lenya.cms.cocoon.source.SourceUtil; +import org.apache.lenya.cms.publication.Document; +import org.apache.lenya.cms.publication.DocumentManager; +import org.apache.lenya.cms.publication.Publication; +import org.apache.lenya.cms.publication.PublicationUtil; +import org.apache.lenya.cms.repository.RepositoryTestCase; +import org.apache.lenya.cms.site.SiteUtil; +import org.apache.lenya.xml.DocumentHelper; +import org.apache.xpath.XPathAPI; +import org.w3c.dom.Attr; +import org.w3c.dom.NodeList; + +/** + * Link rewriter test. + */ +public class LinkRewriterTest extends RepositoryTestCase { + + protected static final String DOCUMENT_ID = "/index"; + protected static final String SOURCE_DOCUMENT_ID = "/concepts"; + protected static final String TARGET_DOCUMENT_ID = "/copied"; + + /** + * Test method. + * @throws Exception + */ + public void testLinkRewriter() throws Exception { + + Publication pub = PublicationUtil.getPublication(getManager(), "test"); + + Document document = getIdentityMap().get(pub, Publication.AUTHORING_AREA, DOCUMENT_ID, "en"); + org.w3c.dom.Document xml = DocumentHelper.readDocument(getClass().getResourceAsStream("index_en.xml")); + document.getRepositoryNode().lock(); + SourceUtil.writeDOM(xml, document.getSourceURI(), getManager()); + + LinkRewriter rewriter = null; + DocumentManager docManager = null; + Document target = null; + try { + docManager = (DocumentManager) getManager().lookup(DocumentManager.ROLE); + + Document source = getIdentityMap().get(pub, + Publication.AUTHORING_AREA, + SOURCE_DOCUMENT_ID, + "en"); + source.getRepositoryNode().lock(); + + target = getIdentityMap().get(pub, Publication.AUTHORING_AREA, TARGET_DOCUMENT_ID, "en"); + target.getRepositoryNode().lock(); + + SiteUtil.getSiteStructure(getManager(), target).getRepositoryNode().lock(); + + docManager.move(source, target); + + rewriter = (LinkRewriter) getManager().lookup(LinkRewriter.ROLE); + rewriter.rewriteLinks(source, target); + + } finally { + if (docManager != null) { + getManager().release(docManager); + } + if (rewriter != null) { + getManager().release(rewriter); + } + } + + String[] xPaths = document.getResourceType().getLinkAttributeXPaths(); + assertTrue(xPaths.length > 0); + + org.w3c.dom.Document xmlDoc = SourceUtil.readDOM(document.getSourceURI(), getManager()); + boolean matched = false; + + for (int i = 0; i < xPaths.length; i++) { + NodeList nodes = XPathAPI.selectNodeList(xmlDoc, xPaths[i]); + for (int nodeIndex = 0; nodeIndex < nodes.getLength(); nodeIndex++) { + Attr attribute = (Attr) nodes.item(nodeIndex); + String targetUrl = attribute.getValue(); + Document targetDoc = getIdentityMap().getFromURL(targetUrl); + if (targetDoc.equals(target)) { + matched = true; + } + } + } + assertTrue(matched); + } + +} Added: lenya/trunk/src/test/org/apache/lenya/cms/site/usecases/index_en.xml URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/cms/site/usecases/index_en.xml?rev=387516&view=auto ============================================================================== --- lenya/trunk/src/test/org/apache/lenya/cms/site/usecases/index_en.xml (added) +++ lenya/trunk/src/test/org/apache/lenya/cms/site/usecases/index_en.xml Tue Mar 21 04:59:36 2006 @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="UTF-8"?> +<html xmlns="http://www.w3.org/1999/xhtml" +xmlns:xhtml="http://www.w3.org/1999/xhtml" +xmlns:lenya="http://apache.org/cocoon/lenya/page-envelope/1.0"> + +<!-- + Copyright 1999-2005 The Apache Software Foundation + + Licensed 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. +--> + +<!-- $Id: index_en.xml 169299 2005-05-09 12:00:43Z jwkaltz $ --> + <head> + <title>Welcome to the Default publication</title> + </head> + <body> + <h1>Hello and welcome to the Lenya default publication!</h1> + + <p>Apache Lenya is a Java Open-Source Content Management System + based on open standards such as XML and XSLT and the Apache + Software Stack, in particular the XML publishing framework Apache + Cocoon.</p> + + <p>For an overview of the concepts and the terminology used in + Apache Lenya please see the <a href="/test/authoring/concepts.html">Concepts + section</a>. To see what you can do with Apache Lenya please + refer to the <a href="/test/authoring/features.html">Features + section</a>.</p> + + <p>If you'd like to get a quick introduction on how to use Apache + Lenya CMS please go through the <a + href="/test/authoring/tutorial.html">tutorial</a>.</p> + + <p>The purpose of this publication is</p> + + <ul> + <li>to show beginners the basic functionality of the Apache + Lenya CMS,</li> + + <li>to provide an "out of the box" publication that can be + easily adapted and used,</li> + + <li>and to provide a basis for reference implementations of new + concepts and best practices.</li> + + </ul> + + <p>This publication does not go to the limit of what's possible + with Apache Lenya CMS, there are no fancy bells and whistles to + confuse you, this publication simply contains everything you need + to get started.</p> + </body> +</html>
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | svn commit: r387515 - /lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/LinkRewriterImpl.java, andreas |
|---|---|
| Next by Date: | svn commit: r387523 - in /lenya/trunk/src/modules/sitetree: config/sitemap/generator-sitetreefragment.xmap sitemap.xmap, edith |
| Previous by Thread: | svn commit: r387515 - /lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/LinkRewriterImpl.java, andreas |
| Next by Thread: | svn commit: r387523 - in /lenya/trunk/src/modules/sitetree: config/sitemap/generator-sitetreefragment.xmap sitemap.xmap, edith |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |