You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by re...@apache.org on 2007/02/12 15:38:59 UTC
svn commit: r506464 - in /cocoon/trunk/core:
cocoon-core/src/test/java/org/apache/cocoon/
cocoon-core/src/test/java/org/apache/cocoon/generation/
cocoon-core/src/test/resources/org/apache/cocoon/generation/
cocoon-pipeline/cocoon-pipeline-components/sr...
Author: reinhard
Date: Mon Feb 12 06:38:58 2007
New Revision: 506464
URL: http://svn.apache.org/viewvc?view=rev&rev=506464
Log:
move file generator test cases to cocoon-core - for some reasons it doesn't work if they are located in cocoon-pipeline-components
Added:
cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/generation/FileGeneratorBeanTestCase.java
- copied unchanged from r504916, cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-components/src/test/java/org/apache/cocoon/generation/FileGeneratorBeanTestCase.java
cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/generation/FileGeneratorTestCase.java
- copied, changed from r504916, cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-components/src/test/java/org/apache/cocoon/generation/FileGeneratorTestCase.java
cocoon/trunk/core/cocoon-core/src/test/resources/org/apache/cocoon/generation/
- copied from r504916, cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-components/src/test/resources/org/apache/cocoon/generation/
Removed:
cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-components/src/test/java/org/apache/cocoon/generation/FileGeneratorBeanTestCase.java
cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-components/src/test/java/org/apache/cocoon/generation/FileGeneratorTestCase.java
cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-components/src/test/resources/org/
Modified:
cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/SitemapTestCase.java
cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-components/src/ (props changed)
cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/ (props changed)
Modified: cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/SitemapTestCase.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/SitemapTestCase.java?view=diff&rev=506464&r1=506463&r2=506464
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/SitemapTestCase.java (original)
+++ cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/SitemapTestCase.java Mon Feb 12 06:38:58 2007
@@ -36,172 +36,9 @@
*/
public class SitemapTestCase extends AbstractTestCase {
- private Logger logger;
- private String classDir;
- private ServiceManager serviceManager;
- private Processor rootProcessor;
- protected void setUp() throws Exception {
- super.setUp();
-
- String level = System.getProperty("junit.test.loglevel", "" + ConsoleLogger.LEVEL_DEBUG);
- this.logger = new ConsoleLogger(Integer.parseInt(level));
-
- this.classDir = this.getClassDirURL().toExternalForm();
- }
-
- /**
- * @see org.apache.cocoon.AbstractTestCase#initBeanFactory()
- */
- protected void initBeanFactory() {
- super.initBeanFactory();
- this.serviceManager = (ServiceManager)this.getBeanFactory().getBean(ServiceManager.class.getName());
- this.rootProcessor = (Processor)this.getBeanFactory().getBean(Processor.ROLE);
- }
-
- /** Return the logger */
- protected Logger getLogger() {
- return this.logger;
- }
-
- protected final Object lookup( final String key ) throws ServiceException {
- return this.serviceManager.lookup(key);
- }
-
- protected final void release( final Object object ) {
- this.serviceManager.release(object);
+ public void testDummy() {
+ // have at least one test in the class so that Surefire doesn't fail
}
- protected String getConfiguration() {
- String className = this.getClass().getName();
- String dir = this.classDir;
- return dir + className.substring(className.lastIndexOf('.') + 1) + ".xconf";
- }
-
- /**
- * Utility method for geting the URL to the directory that this class is in
- */
- protected URL getClassDirURL() throws RuntimeException {
- String className = getClass().getName().replace( '.', '/' ) + ".class";
- String classURL = null;
- String localClassDir = null;
- try {
- classURL =
- getClass().getClassLoader().getResource( className ).toExternalForm();
- getLogger().debug("classURL=" + classURL);
- localClassDir = classURL.substring(0, classURL.lastIndexOf('/') + 1);
- getLogger().debug("classDir=" + localClassDir);
- return new URL(localClassDir);
- } catch (SecurityException e) {
- throw new RuntimeException("Not allowed to access classloader for " + className, e);
- } catch (MalformedURLException e) {
- throw new RuntimeException("Malformed URL for className=" + className +
- " classURL=" + classURL + " classDir=" + localClassDir, e);
- } catch (Exception e) {
- throw new RuntimeException("Couldn't create URL for " + className, e);
- }
- }
-
- /**
- * Load a binary document.
- *
- * @param source Source location.
- *
- * @return Binary data.
- */
- public final byte[] loadByteArray(String source) {
-
- byte[] assertiondocument = null;
-
- try {
- URL url = new URL(source);
- InputStream input = url.openStream();
-
- Vector document = new Vector();
- int i = 0;
- int c;
-
- while ((c = input.read())!=-1) {
- document.add(new Byte((byte) c));
- i++;
- }
- assertiondocument = new byte[document.size()];
- for (i = 0; i < document.size(); i++) {
- assertiondocument[i] = ((Byte)document.get(i)).byteValue();
- }
-
- } catch (Exception e) {
- getLogger().error("Could not execute test", e);
- fail("Could not execute test: "+e);
- }
-
- return assertiondocument;
- }
-
- /**
- * Assert that the result of a byte comparison is identical.
- *
- * @param expected The expected byte array
- * @param actual The actual byte array
- */
- public final void assertIdentical(byte[] expected, byte[] actual) {
- assertEquals("Byte arrays of differing sizes, ", expected.length,
- actual.length);
-
- if (expected.length>0) {
- for (int i = 0; i<expected.length; i++) {
- assertEquals("Byte array differs at index "+i, expected[i],
- actual[i]);
- }
- }
-
- }
-
- protected MockEnvironment getEnvironment(String uri) {
- MockEnvironment env = new MockEnvironment();
- env.setURI("", uri);
- this.getRequest().setEnvironment(env);
- env.setObjectModel(this.getObjectModel());
-
- return env;
- }
-
- protected byte[] process(String uri) throws Exception {
- MockEnvironment env = getEnvironment(uri);
- this.process(env);
- getLogger().info("Output: " + new String(env.getOutput(), "UTF-8"));
-
- return env.getOutput();
- }
-
- protected boolean process(Environment environment) throws Exception {
- environment.startingProcessing();
- final int environmentDepth = EnvironmentHelper.markEnvironment();
- EnvironmentHelper.enterProcessor(this.rootProcessor, environment);
- try {
- boolean result;
-
- result = this.rootProcessor.process(environment);
-
- // commit response on success
- environment.commitResponse();
-
- return result;
- } catch (Exception any) {
- // reset response on error
- environment.tryResetResponse();
- throw any;
- } finally {
- EnvironmentHelper.leaveProcessor();
- environment.finishingProcessing();
-
- EnvironmentHelper.checkEnvironment(environmentDepth, this.getLogger());
- }
- }
-
- protected void pipeTest(String uri, String expectedSource) throws Exception {
- byte[] expected = loadByteArray(this.classDir + expectedSource);
- byte[] actual = process(uri);
- assertIdentical(expected, actual);
- }
}
Copied: cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/generation/FileGeneratorTestCase.java (from r504916, cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-components/src/test/java/org/apache/cocoon/generation/FileGeneratorTestCase.java)
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/generation/FileGeneratorTestCase.java?view=diff&rev=506464&p1=cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-components/src/test/java/org/apache/cocoon/generation/FileGeneratorTestCase.java&r1=504916&p2=cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/generation/FileGeneratorTestCase.java&r2=506464
==============================================================================
--- cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-components/src/test/java/org/apache/cocoon/generation/FileGeneratorTestCase.java (original)
+++ cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/generation/FileGeneratorTestCase.java Mon Feb 12 06:38:58 2007
@@ -53,6 +53,7 @@
private Mock manager = new Mock(ServiceManager.class);
public void setUp() throws SAXException {
+
final XMLReader xmlReader = XMLReaderFactory.createXMLReader();
parser = new SAXParser() {
Propchange: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-components/src/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Feb 12 06:38:58 2007
@@ -0,0 +1 @@
+site
Propchange: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Feb 12 06:38:58 2007
@@ -0,0 +1 @@
+site