KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lenya > cms > rc > RCMLTest


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: RCMLTest.java 42625 2004-03-04 15:45:03Z egli $ */
19
20 package org.apache.lenya.cms.rc;
21
22 import java.io.File JavaDoc;
23 import java.io.PrintWriter JavaDoc;
24 import java.util.Date JavaDoc;
25
26 import junit.framework.TestCase;
27
28 import org.apache.lenya.xml.DOMParserFactory;
29 import org.apache.lenya.xml.DOMWriter;
30 import org.w3c.dom.Document JavaDoc;
31 import org.w3c.dom.Element JavaDoc;
32
33 public class RCMLTest extends TestCase {
34
35     public static final short co = 0;
36     public static final short ci = 1;
37     
38     private File JavaDoc rcmlFile;
39     private Document JavaDoc document = null;
40     private boolean dirty = false;
41     private int maximalNumberOfEntries = 5;
42
43     /**
44      * Constructor.
45      * @param test The test to execute.
46      */

47     public RCMLTest(String JavaDoc test) {
48         super(test);
49     }
50
51     /**
52      * The main method.
53      * @param args The command-line arguments.
54      */

55     public void main(String JavaDoc[] args) {
56 // TestRunner.run(getSuite());
57

58
59         if (args.length != 1) {
60             System.out.println("Usage: java RCML rcmlDirectory datafilename rootDirectory");
61
62             return;
63         }
64
65         try {
66             RCML rcml = new RCML(args[0], args[1], args[2]);
67             rcml.checkOutIn(RCML.co, "michi", new Date JavaDoc().getTime(), false);
68
69             new DOMWriter(new PrintWriter JavaDoc(System.out)).print(this.document);
70
71             CheckOutEntry coe = rcml.getLatestCheckOutEntry();
72             System.out.println("\n");
73
74             if (coe == null) {
75                 System.out.println("Not checked out");
76             } else {
77                 System.out.println("Checked out: " + coe.getIdentity() + " " + coe.getTime());
78             }
79         } catch (Exception JavaDoc e) {
80             System.out.println(e);
81         }
82         }
83
84 /* protected static final Class[] classes = {
85     };
86
87     /**
88      * Creates a test suite.
89      * @return a test suite.
90      */

91 /* public static Test getSuite() {
92         TestSuite suite = new TestSuite();
93
94         for (int i = 0; i < classes.length; i++) {
95             suite.addTestSuite(classes[i]);
96         }
97
98         return suite;
99     }
100 */

101     /** @see junit.framework.TestCase#setUp() */
102     protected void setUp() throws Exception JavaDoc {
103         /**
104          * initialise the RCML-document. Delete all entries
105          */

106             DOMParserFactory dpf = new DOMParserFactory();
107             document = dpf.getDocument();
108
109             Element JavaDoc root = dpf.newElementNode(document, "XPSRevisionControl");
110             document.appendChild(root);
111
112     }
113 }
114
Popular Tags