lenya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andr...@apache.org
Subject cvs commit: cocoon-lenya/src/test/org/apache/lenya/cms/task AntTaskTest.java
Date Fri, 30 May 2003 14:41:07 GMT
andreas     2003/05/30 07:41:07

  Modified:    src/test/org/apache/lenya/cms/task AntTaskTest.java
  Log:
  using servletcontextpath parameter for testing
  
  Revision  Changes    Path
  1.2       +43 -31    cocoon-lenya/src/test/org/apache/lenya/cms/task/AntTaskTest.java
  
  Index: AntTaskTest.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/test/org/apache/lenya/cms/task/AntTaskTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AntTaskTest.java	29 Apr 2003 09:52:12 -0000	1.1
  +++ AntTaskTest.java	30 May 2003 14:41:07 -0000	1.2
  @@ -7,18 +7,16 @@
   package org.apache.lenya.cms.task;
   
   import java.io.File;
  -import java.net.URI;
  -import java.net.URL;
  +import java.io.FileFilter;
  +import java.util.GregorianCalendar;
  +
   import junit.framework.Test;
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
   import junit.textui.TestRunner;
  -import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
  +
   import org.apache.avalon.framework.parameters.Parameters;
  -import org.apache.lenya.cms.task.AntTask;
  -import org.apache.lenya.cms.task.Task;
  -import org.apache.lenya.cms.task.TaskManager;
  +import org.apache.lenya.cms.publication.Publication;
   
   /**
    *
  @@ -33,54 +31,68 @@
        * @param args The command line arguments
        */
       public static void main(String[] args) {
  +        setServletContextPath(args[0]);
           TestRunner.run(getSuite());
       }
  +    
  +    private static String servletContextPath;
   
       /**
        *
        */
       public static Test getSuite() {
  -        TestSuite suite = new TestSuite();
  -        suite.addTest(new AntTaskTest("test"));
  -        return suite;
  +        return new TestSuite(AntTaskTest.class);
       }
   
       /**
  -     *
  +     * Tests the AntTask class.
        */
  -    public AntTaskTest(String test) {
  -        super(test);
  +    public void testAntTask() {
           try {
               
  +            String publicationId = "default";
               String taskId = "ant-test";
  -             
  -            URL tasksConfigurationResource
  -                = getClass().getClassLoader().getResource("org/apache/lenya/cms/task/test-tasks.xconf");
  -            DefaultConfigurationBuilder configurationBuilder = new DefaultConfigurationBuilder();
  -            Configuration configuration
  -                = configurationBuilder.build(tasksConfigurationResource.toString());
  -             
  -            TaskManager manager = new TaskManager();
  -            manager.configure(configuration);
  +            
  +            Publication publication = new Publication(publicationId, getServletContextPath());
  +            TaskManager manager = new TaskManager(publication.getDirectory().getCanonicalPath());
               AntTask task = (AntTask) manager.getTask(taskId);
               
               Parameters parameters = new Parameters();
  -            
  -            URL buildfileResource
  -                = getClass().getClassLoader().getResource("org/apache/lenya/cms/task/tasks.xml");
  -            File buildfile = new File(new URI(buildfileResource.toString()));
  -            parameters.setParameter(AntTask.BUILDFILE, buildfile.getAbsolutePath());
  +            parameters.setParameter(Task.PARAMETER_PUBLICATION_ID, publicationId);
               task.parameterize(parameters);
               
  -            String servletContextPath = task.getParameters().getParameter(Task.PARAMETER_SERVLET_CONTEXT);
  -            task.execute(servletContextPath);
  -             
  +            final GregorianCalendar beforeExecution = new GregorianCalendar();
  +            
  +            task.execute(getServletContextPath());
  +            
  +            File logDirectory = new File(publication.getDirectory(), AntTask.LOG_PATH);
  +            File logFiles[] = logDirectory.listFiles(new FileFilter() {
  +                public boolean accept(File file) {
  +                    return file.lastModified() > beforeExecution.getTimeInMillis();
  +                }
  +            });
  +            
  +            assertTrue(logFiles.length == 1);
  +            File logFile = logFiles[0];
  +            
           } catch (Exception e) {
               e.printStackTrace(System.err);
           }
       }
       
  -    public void test() {
  +
  +    /**
  +     * @return
  +     */
  +    public static String getServletContextPath() {
  +        return servletContextPath;
  +    }
  +
  +    /**
  +     * @param string
  +     */
  +    public static void setServletContextPath(String string) {
  +        servletContextPath = string;
       }
   
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org


Mime
View raw message