1 17 18 19 20 package org.apache.lenya.cms.authoring; 21 22 import java.io.File ; 23 24 import junit.framework.Test; 25 import junit.framework.TestCase; 26 import junit.framework.TestSuite; 27 import junit.textui.TestRunner; 28 29 import org.apache.lenya.cms.PublicationHelper; 30 import org.apache.lenya.cms.publication.Publication; 31 import org.apache.lenya.cms.publication.SiteTree; 32 import org.apache.lenya.cms.publication.SiteTreeException; 33 import org.apache.lenya.cms.publication.SiteTreeNode; 34 35 36 41 public class DocumentCreatorTest extends TestCase { 42 46 public DocumentCreatorTest(String test) { 47 super(test); 48 } 49 50 56 public static void main(String [] args) { 57 args = PublicationHelper.extractPublicationArguments(args); 58 TestRunner.run(getSuite()); 59 } 60 61 65 public static Test getSuite() { 66 return new TestSuite(DocumentCreatorTest.class); 67 } 68 69 74 public void testCreator() 75 throws CreatorException, SiteTreeException { 76 Publication publication = PublicationHelper.getPublication(); 77 DocumentCreator creator = new DocumentCreator(); 78 File authoringDirectory = new File (publication.getDirectory(), AUTHORING_DIR); 79 80 creator.create(publication, authoringDirectory, AREA, PARENT_ID, CHILD_ID, CHILD_NAME, 81 CHILD_TYPE, DOCUMENT_TYPE, DOCUMENT_LANGUAGE, VISIBLEINNAV); 82 83 File documentFile = new File (authoringDirectory, CREATED_FILE); 84 assertTrue(documentFile.exists()); 85 System.out.println("File was created: " + documentFile.getAbsolutePath()); 86 87 SiteTree sitetree = publication.getTree(AREA); 88 SiteTreeNode node = sitetree.getNode(PARENT_ID + "/" + CHILD_ID); 89 assertNotNull(node); 90 System.out.println("Sitetree node was created: " + node.getId() + " (label: " + 91 node.getLabel(DOCUMENT_LANGUAGE) + ")"); 92 } 93 94 protected static final String AUTHORING_DIR = "content" + File.separator + "authoring"; 95 protected static final String PARENT_ID = "/tutorial"; 96 protected static final String CHILD_ID = "test-document"; 97 protected static final String CHILD_NAME = "Test Document"; 98 protected static final String CHILD_TYPE = "leaf"; 99 protected static final String DOCUMENT_TYPE = "xhtml"; 100 protected static final String CREATED_FILE = "tutorial/test-document/index_en.xml"; 101 protected static final String DOCUMENT_LANGUAGE = "en"; 102 protected static final String AREA = "authoring"; 103 protected static final boolean VISIBLEINNAV =true; 104 105 106 protected void setUp() throws Exception { 107 if (PublicationHelper.getPublication() == null) { 108 String [] args = { "/home/egli/build/jakarta-tomcat-4.1.21-LE-jdk14/webapps/lenya", "test" }; 109 PublicationHelper.extractPublicationArguments(args); 110 } 111 } 112 } 113 | Popular Tags |