You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by gr...@apache.org on 2003/07/25 20:59:04 UTC
cvs commit: cocoon-lenya/src/java/org/apache/lenya/cms/rc RCML.java RevisionController.java
gregor 2003/07/25 11:59:04
Modified: src/java/org/apache/lenya/cms/rc RCML.java
RevisionController.java
Added: src/test/org/apache/lenya/cms/rc RCMLTest.java
RevisionControllerTest.java
Log:
started to factor out rc unit tests
Revision Changes Path
1.1 cocoon-lenya/src/test/org/apache/lenya/cms/rc/RCMLTest.java
Index: RCMLTest.java
===================================================================
/*
$Id: RCMLTest.java,v 1.1 2003/07/25 18:59:04 gregor Exp $
<License>
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Lenya" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Michael Wechner <mi...@apache.org>. For more information on the Apache Soft-
ware Foundation, please see <http://www.apache.org/>.
Lenya includes software developed by the Apache Software Foundation, W3C,
DOM4J Project, BitfluxEditor, Xopus, and WebSHPINX.
</License>
*/
package org.apache.lenya.cms.rc;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
import java.io.PrintWriter;
import java.io.File;
import org.apache.lenya.xml.DOMWriter;
import org.apache.lenya.xml.DOMParserFactory;
import java.util.Date;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
* @author Gregor J. Rothfuss gregor@apache.org
*
*/
public class RCMLTest extends TestCase {
public static final short co = 0;
public static final short ci = 1;
private File rcmlFile;
private Document document = null;
private boolean dirty = false;
private int maximalNumberOfEntries = 5;
/**
* Constructor.
* @param test The test to execute.
*/
public RCMLTest(String test) {
super(test);
}
/**
* The main method.
* @param args The command-line arguments.
*/
public void main(String[] args) {
// TestRunner.run(getSuite());
if (args.length != 1) {
System.out.println("Usage: java RCML rcmlDirectory datafilename rootDirectory");
return;
}
try {
RCML rcml = new RCML(args[0], args[1], args[2]);
rcml.checkOutIn(RCML.co, "michi", new Date().getTime());
new DOMWriter(new PrintWriter(System.out)).print(this.document);
CheckOutEntry coe = rcml.getLatestCheckOutEntry();
System.out.println("\n");
if (coe == null) {
System.out.println("Not checked out");
} else {
System.out.println("Checked out: " + coe.getIdentity() + " " + coe.getTime());
}
} catch (Exception e) {
System.out.println(e);
}
}
/* protected static final Class[] classes = {
};
/**
* Creates a test suite.
* @return a test suite.
*/
/* public static Test getSuite() {
TestSuite suite = new TestSuite();
for (int i = 0; i < classes.length; i++) {
suite.addTestSuite(classes[i]);
}
return suite;
}
*/
/** @see junit.framework.TestCase#setUp() */
protected void setUp() throws Exception {
/**
* initialise the RCML-document. Delete all entries
*/
DOMParserFactory dpf = new DOMParserFactory();
document = dpf.getDocument();
Element root = dpf.newElementNode(document, "XPSRevisionControl");
document.appendChild(root);
}
}
1.1 cocoon-lenya/src/test/org/apache/lenya/cms/rc/RevisionControllerTest.java
Index: RevisionControllerTest.java
===================================================================
/*
$Id: RevisionControllerTest.java,v 1.1 2003/07/25 18:59:04 gregor Exp $
<License>
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Lenya" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Michael Wechner <mi...@apache.org>. For more information on the Apache Soft-
ware Foundation, please see <http://www.apache.org/>.
Lenya includes software developed by the Apache Software Foundation, W3C,
DOM4J Project, BitfluxEditor, Xopus, and WebSHPINX.
</License>
*/
package org.apache.lenya.cms.rc;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
import java.io.FileNotFoundException;
import java.io.File;
import java.io.IOException;
/**
* @author Gregor J. Rothfuss gregor@apache.org
*
*/
public class RevisionControllerTest extends TestCase {
/**
* Constructor.
* @param test The test to execute.
*/
public RevisionControllerTest(String test) {
super(test);
}
/**
* The main method.
* @param args The command-line arguments.
*/
public static void main(String[] args) {
// TestRunner.run(getSuite());
if (args.length != 4) {
System.out.println("Usage: " + new RevisionController().getClass().getName() +
" username(user who checkout) source(filename without the rootDirectory of the document to checkout) username(user who checkin) destination(filename without the rootDirectory of document to checkin)");
return;
}
String identityS = args[0];
String source = args[1];
String identityD = args[2];
String destination = args[3];
RevisionController rc = new RevisionController();
File in = null;
try {
in = rc.reservedCheckOut(source, identityS);
} catch (FileNotFoundException e) // No such source file
{
System.out.println(e.toString());
} catch (FileReservedCheckOutException e) // Source has been checked out already
{
System.out.println(e.toString());
// System.out.println(error(e.source + "is already check out by " + e.checkOutUsername + " since " + e.checkOutDate));
return;
} catch (IOException e) { // Cannot create rcml file
System.out.println(e.toString());
return;
} catch (Exception e) {
System.out.println(e.toString());
return;
}
try {
rc.reservedCheckIn(destination, identityD, true);
} catch (FileReservedCheckInException e) {
System.out.println(e.toString());
} catch (Exception e) {
System.out.println(e.toString());
}
}
/* protected static final Class[] classes = {
};
/**
* Creates a test suite.
* @return a test suite.
*/
/* public static Test getSuite() {
TestSuite suite = new TestSuite();
for (int i = 0; i < classes.length; i++) {
suite.addTestSuite(classes[i]);
}
return suite;
}
*/
/** @see junit.framework.TestCase#setUp() */
protected void setUp() throws Exception {
}
}
1.15 +1 -32 cocoon-lenya/src/java/org/apache/lenya/cms/rc/RCML.java
Index: RCML.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/rc/RCML.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- RCML.java 14 Jul 2003 14:24:20 -0000 1.14
+++ RCML.java 25 Jul 2003 18:59:04 -0000 1.15
@@ -143,37 +143,6 @@
}
/**
- * DOCUMENT ME!
- *
- * @param args DOCUMENT ME!
- */
- public static void main(String[] args) {
- if (args.length != 1) {
- log.info("Usage: java RCML rcmlDirectory datafilename rootDirectory");
-
- return;
- }
-
- try {
- RCML rcml = new RCML(args[0], args[1], args[2]);
- rcml.checkOutIn(RCML.co, "michi", new Date().getTime());
-
- new DOMWriter(new PrintWriter(System.out)).print(rcml.document);
-
- CheckOutEntry coe = rcml.getLatestCheckOutEntry();
- log.info("\n");
-
- if (coe == null) {
- log.info("Not checked out");
- } else {
- log.info("Checked out: " + coe.getIdentity() + " " + coe.getTime());
- }
- } catch (Exception e) {
- log.error(e);
- }
- }
-
- /**
* initialise the RCML-document. Delete all entries
*/
public void initDocument() {
1.20 +3 -56 cocoon-lenya/src/java/org/apache/lenya/cms/rc/RevisionController.java
Index: RevisionController.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/rc/RevisionController.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- RevisionController.java 23 Jul 2003 13:21:35 -0000 1.19
+++ RevisionController.java 25 Jul 2003 18:59:04 -0000 1.20
@@ -125,59 +125,6 @@
}
/**
- * DOCUMENT ME!
- *
- * @param args DOCUMENT ME!
- */
-
- /* FIXME
- public static void main(String[] args) {
- if (args.length != 4) {
- log.info("Usage: " + new RevisionController().getClass().getName() +
- " username(user who checkout) source(filename without the rootDirectory of the document to checkout) username(user who checkin) destination(filename without the rootDirectory of document to checkin)");
-
- return;
- }
-
- String identityS = args[0];
- String source = args[1];
- String identityD = args[2];
- String destination = args[3];
- RevisionController rc = new RevisionController();
- File in = null;
-
- try {
- in = rc.reservedCheckOut(source, identityS);
- } catch (FileNotFoundException e) // No such source file
- {
- log.error(e);
- } catch (FileReservedCheckOutException e) // Source has been checked out already
- {
- log.error(e);
- log.error(e.source + "is already check out by " + e.checkOutUsername + " since " +
- e.checkOutDate);
- return;
-
- } catch (IOException e) { // Cannot create rcml file
- log.error(e);
- return;
-
- } catch (Exception e) {
- log.error(e);
- return;
- }
-
- try {
- rc.reservedCheckIn(destination, identityD, true);
- } catch (FileReservedCheckInException e) {
- log.error(e);
- } catch (Exception e) {
- log.error(e);
- }
- }
- */
-
- /**
* Shows Configuration
*
* @return DOCUMENT ME!
@@ -198,12 +145,12 @@
* @throws Exception DOCUMENT ME!
*/
public RCML getRCML(String source) throws FileNotFoundException, IOException, Exception {
- File file = new File(rootDir + source);
+/* File file = new File(rootDir + source);
if (!file.isFile()) {
throw new FileNotFoundException(file.getAbsolutePath());
}
-
+*/
return new RCML(rcmlDir, source, rootDir);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org