KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lenya > cms > task > PublisherTest


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17
18 /* $Id: PublisherTest.java 42625 2004-03-04 15:45:03Z egli $ */
19
20 package org.apache.lenya.cms.task;
21
22 import java.io.File JavaDoc;
23 import java.io.IOException JavaDoc;
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     /**
38      * Create a test.
39      *
40      * @param test the test
41      */

42     public PublisherTest(String JavaDoc test) {
43         super(test);
44     }
45
46     /**
47      * Creates a test suite.
48      *
49      * @return a test
50      */

51     public static Test getSuite() {
52         return new TestSuite(PublisherTest.class);
53     }
54
55     /**
56      * The main program for the PublisherTest class
57      *
58      * @param args The command line arguments
59      */

60     public static void main(String JavaDoc[] args) {
61         AntTaskTest.initialize(args);
62         TestRunner.run(getSuite());
63     }
64
65     public static final String JavaDoc DOCUMENT_ID = "/tutorial";
66     public static final String JavaDoc DOCUMENT_LANGUAGE = "en";
67
68     /**
69      * (non-Javadoc)
70      * @see org.apache.lenya.cms.task.AntTaskTest#evaluateTest()
71      */

72     protected void evaluateTest() throws IOException JavaDoc {
73         Publication pub = PublicationHelper.getPublication();
74         DocumentIdToPathMapper mapper = pub.getPathMapper();
75         File JavaDoc 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     /**
82      * (non-Javadoc)
83      * @see org.apache.lenya.cms.task.AntTaskTest#getTaskParameters()
84      */

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     /**
97      * (non-Javadoc)
98      * @see org.apache.lenya.cms.task.AntTaskTest#getTarget()
99      */

100     protected String JavaDoc getTarget() {
101         return "publish";
102     }
103 }
104
Popular Tags