directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r607571 - in /directory/sandbox/felixk/studio-plugin: ./ src/test/ src/test/java/ src/test/java/org/ src/test/java/org/apache/ src/test/java/org/apache/directory/ src/test/java/org/apache/directory/studio/ src/test/java/org/apache/directory...
Date Sun, 30 Dec 2007 18:05:53 GMT
Author: felixk
Date: Sun Dec 30 10:05:50 2007
New Revision: 607571

URL: http://svn.apache.org/viewvc?rev=607571&view=rev
Log:
Minimal Testcase for Clean plugin

Added:
    directory/sandbox/felixk/studio-plugin/src/test/
    directory/sandbox/felixk/studio-plugin/src/test/java/
    directory/sandbox/felixk/studio-plugin/src/test/java/org/
    directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/
    directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/
    directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/
    directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/
    directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/
    directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/StudioCleanMojoTest.java
  (with props)
    directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/stubs/
    directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/stubs/StudioCleanProjectStub.java
  (with props)
    directory/sandbox/felixk/studio-plugin/src/test/resources/
    directory/sandbox/felixk/studio-plugin/src/test/resources/unit/
    directory/sandbox/felixk/studio-plugin/src/test/resources/unit/basic-clean-test/
    directory/sandbox/felixk/studio-plugin/src/test/resources/unit/basic-clean-test/.externalToolBuilders
    directory/sandbox/felixk/studio-plugin/src/test/resources/unit/basic-clean-test/lib/
    directory/sandbox/felixk/studio-plugin/src/test/resources/unit/basic-clean-test/lib/dummy.jar
    directory/sandbox/felixk/studio-plugin/src/test/resources/unit/basic-clean-test/maven-eclipse.xml
  (with props)
    directory/sandbox/felixk/studio-plugin/src/test/resources/unit/basic-clean-test/plugin-pom.xml
  (with props)
Modified:
    directory/sandbox/felixk/studio-plugin/pom.xml

Modified: directory/sandbox/felixk/studio-plugin/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-plugin/pom.xml?rev=607571&r1=607570&r2=607571&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-plugin/pom.xml (original)
+++ directory/sandbox/felixk/studio-plugin/pom.xml Sun Dec 30 10:05:50 2007
@@ -81,6 +81,11 @@
           <skip>false</skip>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.3</version>
+      </plugin>
     </plugins>
   </build>
 
@@ -139,6 +144,14 @@
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
       <version>1.4.1</version>
+    </dependency>
+
+    <!-- Test -->
+    <dependency>
+      <groupId>org.apache.maven.shared</groupId>
+      <artifactId>maven-plugin-testing-harness</artifactId>
+      <version>1.1</version>
+      <scope>test</scope>
     </dependency>
   </dependencies>
 

Added: directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/StudioCleanMojoTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/StudioCleanMojoTest.java?rev=607571&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/StudioCleanMojoTest.java
(added)
+++ directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/StudioCleanMojoTest.java
Sun Dec 30 10:05:50 2007
@@ -0,0 +1,99 @@
+/*
+ * 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.
+ */
+package org.apache.directory.studio.maven.plugins;
+
+
+import java.io.File;
+import java.io.RandomAccessFile;
+import java.nio.channels.FileChannel;
+import java.nio.channels.FileLock;
+
+import org.apache.directory.studio.maven.plugins.StudioCleanMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.codehaus.plexus.util.FileUtils;
+
+
+/**
+ * Test the studio clean mojo.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StudioCleanMojoTest extends AbstractMojoTestCase
+{
+    /** {@inheritDoc} */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+    }
+
+
+    /** {@inheritDoc} */
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+
+
+    /**
+     * Tests the simple removal of the lib dir and the 2 files 'maven-eclipse.xml' and '.externalToolBuilders'
+     *
+     * @throws Exception
+     */
+    public void testBasicClean() throws Exception
+    {
+        String pluginPom = getBasedir() + "/src/test/resources/unit/basic-clean-test/plugin-pom.xml";
+
+        // safety
+        FileUtils.copyDirectory( new File( getBasedir(), "src/test/resources/unit/basic-clean-test"
), new File(
+            getBasedir(), "target/test-classes/unit/basic-clean-test" ), null, "**/.svn,**/.svn/**"
);
+
+        StudioCleanMojo mojo = ( StudioCleanMojo ) lookupMojo( "clean", pluginPom );
+        assertNotNull( mojo );
+
+        mojo.execute();
+
+        assertFalse( "File maven-eclipse.xml exists", checkExists( getBasedir() + "/target/test-classes/unit/"
+            + "basic-clean-test/maven-eclipse.xml" ) );
+        assertFalse( "File .externalToolBuilder exists", checkExists( getBasedir() + "/target/test-classes/unit/"
+            + "basic-clean-test/.externalToolBuilders" ) );
+        assertFalse( "Directory exists", checkExists( getBasedir() + "/target/test-classes/unit/basic-clean-test/"
+            + "lib" ) );
+    }
+
+
+    /**
+     * @param dir a dir or a file
+     * @return true if a file/dir exists, false otherwise
+     */
+    private boolean checkExists( String dir )
+    {
+        return FileUtils.fileExists( new File( dir ).getAbsolutePath() );
+    }
+
+
+    /**
+     * @param dir a directory
+     * @return true if a dir is empty, false otherwise
+     */
+    private boolean checkEmpty( String dir )
+    {
+        return FileUtils.sizeOfDirectory( new File( dir ).getAbsolutePath() ) == 0;
+    }
+}

Propchange: directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/StudioCleanMojoTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/stubs/StudioCleanProjectStub.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/stubs/StudioCleanProjectStub.java?rev=607571&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/stubs/StudioCleanProjectStub.java
(added)
+++ directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/stubs/StudioCleanProjectStub.java
Sun Dec 30 10:05:50 2007
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+package org.apache.directory.studio.maven.plugins.stubs;
+
+
+import java.io.File;
+
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+
+
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StudioCleanProjectStub extends MavenProjectStub
+{
+    public File getBasedir()
+    {
+        return new File( "target/test-classes/unit/basic-clean-test" );
+    }
+}

Propchange: directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/stubs/StudioCleanProjectStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-plugin/src/test/resources/unit/basic-clean-test/.externalToolBuilders
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-plugin/src/test/resources/unit/basic-clean-test/.externalToolBuilders?rev=607571&view=auto
==============================================================================
    (empty)

Added: directory/sandbox/felixk/studio-plugin/src/test/resources/unit/basic-clean-test/lib/dummy.jar
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-plugin/src/test/resources/unit/basic-clean-test/lib/dummy.jar?rev=607571&view=auto
==============================================================================
    (empty)

Added: directory/sandbox/felixk/studio-plugin/src/test/resources/unit/basic-clean-test/maven-eclipse.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-plugin/src/test/resources/unit/basic-clean-test/maven-eclipse.xml?rev=607571&view=auto
==============================================================================
    (empty)

Propchange: directory/sandbox/felixk/studio-plugin/src/test/resources/unit/basic-clean-test/maven-eclipse.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-plugin/src/test/resources/unit/basic-clean-test/plugin-pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-plugin/src/test/resources/unit/basic-clean-test/plugin-pom.xml?rev=607571&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-plugin/src/test/resources/unit/basic-clean-test/plugin-pom.xml
(added)
+++ directory/sandbox/felixk/studio-plugin/src/test/resources/unit/basic-clean-test/plugin-pom.xml
Sun Dec 30 10:05:50 2007
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<!--
+  @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.directory.studio</groupId>
+        <artifactId>maven-studio-plugin</artifactId>
+        <configuration>
+          <project implementation="org.apache.directory.studio.maven.plugins.stubs.StudioCleanProjectStub"
/>
+          <libraryPath>lib</libraryPath>
+          <skip>false</skip>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: directory/sandbox/felixk/studio-plugin/src/test/resources/unit/basic-clean-test/plugin-pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message