maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vsive...@apache.org
Subject svn commit: r585746 - in /maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-utils/src: main/java/org/apache/maven/jxr/util/DotTask.java test/java/org/apache/maven/jxr/util/DotTaskTest.java
Date Wed, 17 Oct 2007 22:56:14 GMT
Author: vsiveton
Date: Wed Oct 17 15:56:12 2007
New Revision: 585746

URL: http://svn.apache.org/viewvc?rev=585746&view=rev
Log:
o fixed exception signature
o readd test due to 585744

Added:
    maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-utils/src/test/java/org/apache/maven/jxr/util/DotTaskTest.java
  (with props)
Modified:
    maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-utils/src/main/java/org/apache/maven/jxr/util/DotTask.java

Modified: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-utils/src/main/java/org/apache/maven/jxr/util/DotTask.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-utils/src/main/java/org/apache/maven/jxr/util/DotTask.java?rev=585746&r1=585745&r2=585746&view=diff
==============================================================================
--- maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-utils/src/main/java/org/apache/maven/jxr/util/DotTask.java
(original)
+++ maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-utils/src/main/java/org/apache/maven/jxr/util/DotTask.java
Wed Oct 17 15:56:12 2007
@@ -398,7 +398,7 @@
     /**
      * Signals that the dot executable is not present in the path
      */
-    protected class DotNotPresentInPathBuildException
+    public class DotNotPresentInPathBuildException
         extends BuildException
     {
         /**

Added: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-utils/src/test/java/org/apache/maven/jxr/util/DotTaskTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-utils/src/test/java/org/apache/maven/jxr/util/DotTaskTest.java?rev=585746&view=auto
==============================================================================
--- maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-utils/src/test/java/org/apache/maven/jxr/util/DotTaskTest.java
(added)
+++ maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-utils/src/test/java/org/apache/maven/jxr/util/DotTaskTest.java
Wed Oct 17 15:56:12 2007
@@ -0,0 +1,129 @@
+package org.apache.maven.jxr.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.apache.maven.jxr.util.DotTask.DotNotPresentInPathBuildException;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+
+/**
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ */
+public class DotTaskTest
+    extends TestCase
+{
+    /**
+     * Call Dot task
+     *
+     * @throws Exception if any.
+     */
+    public void testDefaultExecute()
+        throws Exception
+    {
+        final String basedir = new File( "" ).getAbsolutePath();
+
+        File in = new File( basedir, "src/test/resources/dot/target.dot" );
+        File out = new File( basedir, "target/unit/dot-default/" );
+
+        Project antProject = new Project();
+        antProject.setBasedir( basedir );
+
+        DotTask task = new DotTask();
+        task.setProject( antProject );
+        task.setIn( in );
+        task.setDestDir( out );
+        try
+        {
+            task.execute();
+            assertTrue( "DOT exists in the path", true );
+        }
+        catch ( DotNotPresentInPathBuildException e )
+        {
+            assertTrue( "DOT doesnt exist in the path. Ignored test", true );
+            return;
+        }
+        catch ( BuildException e )
+        {
+            if ( e.getMessage().indexOf( "Execute failed" ) != -1 )
+            {
+                assertTrue( "Uncatch error:" + e.getMessage(), false );
+            }
+
+            assertEquals( "Error when calling dot.", e.getMessage() );
+        }
+
+        // Generated files
+        File generated = new File( out, "target.dot.svg" );
+        assertTrue( generated.exists() );
+        assertTrue( generated.length() > 0 );
+    }
+
+    /**
+     * Call Dot task
+     *
+     * @throws Exception if any.
+     */
+    public void testErrorExecute()
+        throws Exception
+    {
+        final String basedir = new File( "" ).getAbsolutePath();
+
+        File in = new File( basedir, "src/test/resources/dot/graph.dot" );
+        File out = new File( basedir, "target/unit/dot-default/" );
+
+        Project antProject = new Project();
+        antProject.setBasedir( basedir );
+
+        DotTask task = new DotTask();
+        task.setProject( antProject );
+        task.setIn( in );
+        task.setDestDir( out );
+        try
+        {
+            task.execute();
+            assertTrue( "DOT exists in the path", true );
+            assertTrue( "Doesnt handle dot error", false );
+        }
+        catch ( DotNotPresentInPathBuildException e )
+        {
+            assertTrue( "DOT doesnt exist in the path. Ignored test", true );
+            return;
+        }
+        catch ( BuildException e )
+        {
+            if ( e.getMessage().indexOf( "Execute failed" ) != -1 )
+            {
+                assertTrue( "Uncatch error:" + e.getMessage(), false );
+            }
+
+            assertEquals( "Error when calling dot.", e.getMessage() );
+        }
+
+        // Generated files
+        File generated = new File( out, "graph.dot.svg" );
+        assertFalse( generated.exists() );
+        assertFalse( generated.length() > 0 );
+    }
+}

Propchange: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-utils/src/test/java/org/apache/maven/jxr/util/DotTaskTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-utils/src/test/java/org/apache/maven/jxr/util/DotTaskTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message