1 17 18 19 20 package org.apache.lenya.cms.task; 21 22 import java.io.File ; 23 24 import junit.framework.Test; 25 import junit.framework.TestSuite; 26 import junit.textui.TestRunner; 27 28 import org.apache.avalon.framework.parameters.Parameters; 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.SiteTreeNode; 33 34 35 39 public class DocumentDeactivateTaskTest extends AntTaskTest { 40 41 private long time = 0; 42 43 47 public DocumentDeactivateTaskTest(String test) { 48 super(test); 49 } 50 51 55 public static Test getSuite() { 56 return new TestSuite(DocumentDeactivateTaskTest.class); 57 } 58 59 64 public static void main(String [] args) { 65 AntTaskTest.initialize(args); 66 TestRunner.run(getSuite()); 67 } 68 69 public static final String DOCUMENT_ID = "/tutorial"; 70 public static final String LANGUAGE = "en"; 71 public static final String AUTHORING_PATH = "content/authoring".replace('/', File.separatorChar); 72 public static final String LIVE_PATH = "content/live".replace('/', File.separatorChar); 73 74 77 protected Parameters getTaskParameters() { 78 Parameters parameters = super.getTaskParameters(); 79 parameters.setParameter("properties.node.firstdocumentid", DOCUMENT_ID); 80 parameters.setParameter("properties.node.language", LANGUAGE); 81 return parameters; 82 } 83 84 88 protected String getTarget() { 89 return "deactivateDocument"; 90 } 91 92 95 protected void prepareTest() throws Exception { 96 File publicationDirectory = PublicationHelper.getPublication().getDirectory(); 97 String publicationPath = publicationDirectory.getAbsolutePath()+ File.separator; 98 99 100 } 102 103 106 protected void evaluateTest() throws Exception { 107 File publicationDirectory = PublicationHelper.getPublication().getDirectory(); 108 String publicationPath = publicationDirectory.getAbsolutePath(); 109 File authoringDirectory = new File (publicationPath, AUTHORING_PATH); 110 File liveDirectory = new File (publicationPath, LIVE_PATH); 111 112 String filepath = DOCUMENT_ID.substring(1) + File.separator + "index_en.xml"; 113 114 File authoringDocumentFile = new File (authoringDirectory, filepath); 115 System.out.println("Authoring document: " + authoringDocumentFile.getAbsolutePath()); 116 assertTrue(authoringDocumentFile.exists()); 117 File liveDocumentFile = new File (liveDirectory, filepath); 118 System.out.println("Live document: " + liveDocumentFile.getAbsolutePath()); 119 assertFalse(liveDocumentFile.exists()); 120 121 123 SiteTree authoringSitetree = PublicationHelper.getPublication().getTree(Publication.AUTHORING_AREA); 124 SiteTreeNode node = authoringSitetree.getNode(DOCUMENT_ID); 125 assertNotNull(node); 126 System.out.println("Sitetree node with id ["+node.getId()+"] is always in authoring"); 127 SiteTree liveSitetree = PublicationHelper.getPublication().getTree(Publication.LIVE_AREA); 128 SiteTreeNode livenode = liveSitetree.getNode(DOCUMENT_ID); 129 assertNull(livenode); 130 System.out.println("Sitetree node for document id ["+DOCUMENT_ID+"] was deleted from the live tree"); 131 } 132 } 133 | Popular Tags |