You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by fe...@apache.org on 2007/12/31 01:18:19 UTC
svn commit: r607628 - in /directory/sandbox/felixk/studio-plugin/src/test:
java/org/apache/directory/studio/maven/plugins/
java/org/apache/directory/studio/maven/plugins/stubs/
resources/unit/basic-unpack-test/
Author: felixk
Date: Sun Dec 30 16:18:18 2007
New Revision: 607628
URL: http://svn.apache.org/viewvc?rev=607628&view=rev
Log:
Minimal Testcase for unpack plugin
Added:
directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/StudioUnpackPrefixedMojoTest.java (with props)
directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/stubs/StudioUnpackPrefixedProjectStub.java (with props)
directory/sandbox/felixk/studio-plugin/src/test/resources/unit/basic-unpack-test/
directory/sandbox/felixk/studio-plugin/src/test/resources/unit/basic-unpack-test/plugin-pom.xml (with props)
Modified:
directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/StudioCopyEclipseDependencyMojoTest.java
Modified: directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/StudioCopyEclipseDependencyMojoTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/StudioCopyEclipseDependencyMojoTest.java?rev=607628&r1=607627&r2=607628&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/StudioCopyEclipseDependencyMojoTest.java (original)
+++ directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/StudioCopyEclipseDependencyMojoTest.java Sun Dec 30 16:18:18 2007
@@ -37,7 +37,7 @@
/**
- * Test the studio clean mojo.
+ * Test the studio copy eclipse dependency mojo.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
Added: directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/StudioUnpackPrefixedMojoTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/StudioUnpackPrefixedMojoTest.java?rev=607628&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/StudioUnpackPrefixedMojoTest.java (added)
+++ directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/StudioUnpackPrefixedMojoTest.java Sun Dec 30 16:18:18 2007
@@ -0,0 +1,167 @@
+/*
+ * 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.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.DefaultArtifactRepository;
+import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.codehaus.plexus.util.FileUtils;
+
+
+/**
+ * Test the studio unpack prefixed mojo.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StudioUnpackPrefixedMojoTest extends AbstractMojoTestCase
+{
+ private Set toDelete = new HashSet();
+ private ArtifactRepositoryFactory repoFactory;
+
+
+ /** {@inheritDoc} */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ repoFactory = ( ArtifactRepositoryFactory ) lookup( ArtifactRepositoryFactory.ROLE );
+ }
+
+
+ /** {@inheritDoc} */
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ for ( Iterator it = toDelete.iterator(); it.hasNext(); )
+ {
+ File f = ( File ) it.next();
+
+ if ( f.exists() )
+ {
+ try
+ {
+ FileUtils.forceDelete( f );
+ }
+ catch ( IOException e )
+ {
+ //the files on windows can still be locked. They were creaed in a temp directory anyway and will get removed in a subsequent clean.
+ //we can safely ignore this error.
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Tests the simple unpacking of a (OSGi) artifact into a directory of it's bundlename (=prefix)
+ *
+ * @throws Exception
+ */
+ public void testUnpackPrefixed() throws Exception
+ {
+ String pluginPom = getBasedir() + "/src/test/resources/unit/basic-unpack-test/plugin-pom.xml";
+ StudioUnpackPrefixedMojo mojo = ( StudioUnpackPrefixedMojo ) lookupMojo( "unpack-with-artifactid-prefix",
+ pluginPom );
+ assertNotNull( mojo );
+
+ File remoteRepoDir = findRemoteRepositoryDirectory();
+ File localRepo = createTempDir();
+
+ List<ArtifactRepository> remoteRepositories = new ArrayList<ArtifactRepository>();
+ remoteRepositories.add( repoFactory.createArtifactRepository( "central", remoteRepoDir.toURI().toURL()
+ .toExternalForm(), new DefaultRepositoryLayout(), null, null ) );
+ mojo.setRemoteRepos( remoteRepositories );
+
+ DefaultArtifactRepository localRepository = new DefaultArtifactRepository( "local",
+ localRepo.getAbsolutePath(), new DefaultRepositoryLayout() );
+ localRepository.setBasedir( localRepo.getAbsolutePath() );
+ mojo.setLocal( localRepository );
+
+ mojo.execute();
+
+ assertTrue( "Directory org.eclipse.core.jobs_3.3.1.R33x_v20070709 not exists", checkExists( getBasedir()
+ + "/target/test-classes/unpack-plugins/" + "org.eclipse.core.jobs_3.3.1.R33x_v20070709" ) );
+ assertTrue( "directory org.eclipse.core.commands_3.3.0.I20070605_0010 not exists", checkExists( getBasedir()
+ + "/target/test-classes/unpack-plugins/" + "org.eclipse.core.commands_3.3.0.I20070605_0010" ) );
+ }
+
+
+ /**
+ * @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;
+ }
+
+
+ private File findRemoteRepositoryDirectory()
+ {
+ String classPath = getClass().getPackage().getName().replace( '.', '/' ) + "/test-copy-repo/repo-marker.txt";
+ ClassLoader cloader = Thread.currentThread().getContextClassLoader();
+
+ URL resource = cloader.getResource( classPath );
+
+ if ( resource == null )
+ {
+ throw new IllegalStateException( "Cannot find repository marker file: " + classPath
+ + " in context classloader!" );
+ }
+
+ File repoDir = new File( resource.getPath() ).getParentFile();
+
+ return repoDir;
+ }
+
+
+ private File createTempDir() throws IOException
+ {
+ File dir = File.createTempFile( "DefaultExtensionManagerTest.", ".dir" );
+ FileUtils.forceDelete( dir );
+
+ dir.mkdirs();
+ toDelete.add( dir );
+
+ return dir;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/StudioUnpackPrefixedMojoTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/stubs/StudioUnpackPrefixedProjectStub.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/stubs/StudioUnpackPrefixedProjectStub.java?rev=607628&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/stubs/StudioUnpackPrefixedProjectStub.java (added)
+++ directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/stubs/StudioUnpackPrefixedProjectStub.java Sun Dec 30 16:18:18 2007
@@ -0,0 +1,31 @@
+/*
+ * 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 org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+
+
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StudioUnpackPrefixedProjectStub extends MavenProjectStub
+{
+ // NOP
+}
Propchange: directory/sandbox/felixk/studio-plugin/src/test/java/org/apache/directory/studio/maven/plugins/stubs/StudioUnpackPrefixedProjectStub.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-plugin/src/test/resources/unit/basic-unpack-test/plugin-pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-plugin/src/test/resources/unit/basic-unpack-test/plugin-pom.xml?rev=607628&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-plugin/src/test/resources/unit/basic-unpack-test/plugin-pom.xml (added)
+++ directory/sandbox/felixk/studio-plugin/src/test/resources/unit/basic-unpack-test/plugin-pom.xml Sun Dec 30 16:18:18 2007
@@ -0,0 +1,48 @@
+<?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.StudioUnpackPrefixedProjectStub" />
+ <outputDirectory>target/test-classes/unpack-plugins</outputDirectory>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.eclipse.core</groupId>
+ <artifactId>jobs</artifactId>
+ <version>3.3.1-R33x_v20070709</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.eclipse.core</groupId>
+ <artifactId>commands</artifactId>
+ <version>3.3.0-I20070605-0010</version>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Propchange: directory/sandbox/felixk/studio-plugin/src/test/resources/unit/basic-unpack-test/plugin-pom.xml
------------------------------------------------------------------------------
svn:eol-style = native