1 17 18 19 20 package org.apache.lenya.cms.task; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 25 import junit.framework.Test; 26 import junit.framework.TestSuite; 27 import junit.textui.TestRunner; 28 29 import org.apache.avalon.framework.parameters.Parameters; 30 import org.apache.lenya.cms.PublicationHelper; 31 import org.apache.lenya.cms.publication.DocumentIdToPathMapper; 32 import org.apache.lenya.cms.publication.Publication; 33 34 35 public class PublisherTest extends AntTaskTest { 36 37 42 public PublisherTest(String test) { 43 super(test); 44 } 45 46 51 public static Test getSuite() { 52 return new TestSuite(PublisherTest.class); 53 } 54 55 60 public static void main(String [] args) { 61 AntTaskTest.initialize(args); 62 TestRunner.run(getSuite()); 63 } 64 65 public static final String DOCUMENT_ID = "/tutorial"; 66 public static final String DOCUMENT_LANGUAGE = "en"; 67 68 72 protected void evaluateTest() throws IOException { 73 Publication pub = PublicationHelper.getPublication(); 74 DocumentIdToPathMapper mapper = pub.getPathMapper(); 75 File publishedFile = mapper.getFile(pub, Publication.LIVE_AREA, DOCUMENT_ID, DOCUMENT_LANGUAGE); 76 System.out.println("Path of file to publish: " + publishedFile); 77 assertTrue(publishedFile.exists()); 78 System.out.println("Published file exists: " + publishedFile.getCanonicalPath()); 79 } 80 81 85 protected Parameters getTaskParameters() { 86 Parameters parameters = super.getTaskParameters(); 87 parameters.setParameter("properties.publish.documentid", DOCUMENT_ID); 88 parameters.setParameter("properties.publish.language", DOCUMENT_LANGUAGE); 89 Publication pub = PublicationHelper.getPublication(); 90 DocumentIdToPathMapper mapper = pub.getPathMapper(); 91 parameters.setParameter("properties.publish.sources", mapper.getPath(DOCUMENT_ID, DOCUMENT_LANGUAGE)); 92 93 return parameters; 94 } 95 96 100 protected String getTarget() { 101 return "publish"; 102 } 103 } 104 | Popular Tags |