From 54c4c84888b840be561565f79654e59f80766ecc Mon Sep 17 00:00:00 2001 From: Mark Donszelmann Date: Tue, 15 Dec 2009 22:53:33 +0100 Subject: Fixed NAR-90 and NAR-118 --- .../maven/plugin/nar/test/TestNarFileLayout10.java | 77 +++++++++++++ .../maven/plugin/nar/test/TestNarLayout20.java | 118 +++++++++++++++++++ .../maven/plugin/nar/test/TestNarLayout21.java | 125 +++++++++++++++++++++ 3 files changed, 320 insertions(+) create mode 100644 src/test/java/org/apache/maven/plugin/nar/test/TestNarFileLayout10.java create mode 100644 src/test/java/org/apache/maven/plugin/nar/test/TestNarLayout20.java create mode 100644 src/test/java/org/apache/maven/plugin/nar/test/TestNarLayout21.java (limited to 'src/test') diff --git a/src/test/java/org/apache/maven/plugin/nar/test/TestNarFileLayout10.java b/src/test/java/org/apache/maven/plugin/nar/test/TestNarFileLayout10.java new file mode 100644 index 0000000..e75736b --- /dev/null +++ b/src/test/java/org/apache/maven/plugin/nar/test/TestNarFileLayout10.java @@ -0,0 +1,77 @@ +/* + * 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.maven.plugin.nar.test; + +import java.io.File; + +import org.apache.maven.plugin.nar.Library; +import org.apache.maven.plugin.nar.NarFileLayout; +import org.apache.maven.plugin.nar.NarFileLayout10; + +import junit.framework.Assert; +import junit.framework.TestCase; + +/** + * @author Mark Donszelmann (Mark.Donszelmann@gmail.com) + * @version $Id$ + */ +public class TestNarFileLayout10 + extends TestCase +{ + private NarFileLayout fileLayout; + + private String artifactId; + + private String version; + + private String aol; + + private String type; + + /* + * (non-Javadoc) + * @see junit.framework.TestCase#setUp() + */ + protected void setUp() + throws Exception + { + fileLayout = new NarFileLayout10(); + artifactId = "artifactId"; + version = "version"; + aol = "x86_64-MacOSX-g++"; + type = Library.SHARED; + } + + public final void testGetIncludeDirectory() + { + Assert.assertEquals( "include", fileLayout.getIncludeDirectory() ); + } + + public final void testGetLibDirectory() + { + Assert.assertEquals( "lib" + File.separator + aol + File.separator + type, fileLayout.getLibDirectory( aol, + type ) ); + } + + public final void testGetBinDirectory() + { + Assert.assertEquals( "bin" + File.separator + aol, fileLayout.getBinDirectory( aol ) ); + } +} diff --git a/src/test/java/org/apache/maven/plugin/nar/test/TestNarLayout20.java b/src/test/java/org/apache/maven/plugin/nar/test/TestNarLayout20.java new file mode 100644 index 0000000..f78e45c --- /dev/null +++ b/src/test/java/org/apache/maven/plugin/nar/test/TestNarLayout20.java @@ -0,0 +1,118 @@ +/* + * 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.maven.plugin.nar.test; + +import java.io.File; + +import junit.framework.Assert; +import junit.framework.TestCase; + +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.logging.Log; +import org.apache.maven.plugin.logging.SystemStreamLog; +import org.apache.maven.plugin.nar.AbstractNarLayout; +import org.apache.maven.plugin.nar.Library; +import org.apache.maven.plugin.nar.NarFileLayout; +import org.apache.maven.plugin.nar.NarFileLayout10; +import org.apache.maven.plugin.nar.NarLayout; +import org.apache.maven.plugin.nar.NarLayout20; + +/** + * @author Mark Donszelmann (Mark.Donszelmann@gmail.com) + */ +public class TestNarLayout20 + extends TestCase +{ + private NarFileLayout fileLayout; + + private Log log; + + private NarLayout layout; + + private File baseDir; + + private String aol; + + private String type; + + /* + * (non-Javadoc) + * @see junit.framework.TestCase#setUp() + */ + protected void setUp() + throws Exception + { + log = new SystemStreamLog(); + fileLayout = new NarFileLayout10(); + layout = new NarLayout20( log ); + baseDir = new File( "/Users/maven" ); + aol = "x86_64-MacOSX-g++"; + type = Library.SHARED; + } + + public final void testGetLayout() + throws MojoExecutionException + { + AbstractNarLayout.getLayout( "NarLayout20", log ); + } + + /** + * Test method for {@link org.apache.maven.plugin.nar.NarLayout20#getIncludeDirectory(java.io.File)}. + * + * @throws MojoFailureException + * @throws MojoExecutionException + */ + public final void testGetIncludeDirectory() + throws MojoExecutionException, MojoFailureException + { + Assert.assertEquals( new File( baseDir, fileLayout.getIncludeDirectory() ), + layout.getIncludeDirectory( baseDir, null, null ) ); + } + + /** + * Test method for + * {@link org.apache.maven.plugin.nar.NarLayout20#getLibDirectory(java.io.File, java.lang.String, java.lang.String)} + * . + * + * @throws MojoFailureException + * @throws MojoExecutionException + */ + public final void testGetLibDirectory() + throws MojoExecutionException, MojoFailureException + { + Assert.assertEquals( new File( baseDir, fileLayout.getLibDirectory( aol, type ) ), + layout.getLibDirectory( baseDir, null, null, aol, type ) ); + } + + /** + * Test method for {@link org.apache.maven.plugin.nar.NarLayout20#getBinDirectory(java.io.File, java.lang.String)}. + * + * @throws MojoFailureException + * @throws MojoExecutionException + */ + public final void testGetBinDirectory() + throws MojoExecutionException, MojoFailureException + { + Assert.assertEquals( new File( baseDir, fileLayout.getBinDirectory( aol ) ), layout.getBinDirectory( baseDir, + null, + null, aol ) ); + } +} diff --git a/src/test/java/org/apache/maven/plugin/nar/test/TestNarLayout21.java b/src/test/java/org/apache/maven/plugin/nar/test/TestNarLayout21.java new file mode 100644 index 0000000..794fbaa --- /dev/null +++ b/src/test/java/org/apache/maven/plugin/nar/test/TestNarLayout21.java @@ -0,0 +1,125 @@ +/* + * 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.maven.plugin.nar.test; + +import java.io.File; + +import junit.framework.Assert; +import junit.framework.TestCase; + +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.logging.Log; +import org.apache.maven.plugin.logging.SystemStreamLog; +import org.apache.maven.plugin.nar.AbstractNarLayout; +import org.apache.maven.plugin.nar.Library; +import org.apache.maven.plugin.nar.NarConstants; +import org.apache.maven.plugin.nar.NarFileLayout; +import org.apache.maven.plugin.nar.NarFileLayout10; +import org.apache.maven.plugin.nar.NarLayout; +import org.apache.maven.plugin.nar.NarLayout21; + +/** + * @author Mark Donszelmann (Mark.Donszelmann@gmail.com) + */ +public class TestNarLayout21 + extends TestCase +{ + private NarFileLayout fileLayout; + + private Log log; + + private NarLayout layout; + + private File baseDir; + + private String artifactId; + + private String version; + + private String aol; + + private String type; + + /* + * (non-Javadoc) + * @see junit.framework.TestCase#setUp() + */ + protected void setUp() + throws Exception + { + fileLayout = new NarFileLayout10(); + artifactId = "artifactId"; + version = "version"; + baseDir = new File( "/Users/maven" ); + aol = "x86_64-MacOSX-g++"; + type = Library.SHARED; + + log = new SystemStreamLog(); + layout = new NarLayout21( log ); + } + + public final void testGetLayout() + throws MojoExecutionException + { + AbstractNarLayout.getLayout( "NarLayout21", log ); + } + + /** + * Test method for {@link org.apache.maven.plugin.nar.NarLayout20#getIncludeDirectory(java.io.File)}. + * + * @throws MojoFailureException + * @throws MojoExecutionException + */ + public final void testGetIncludeDirectory() + throws MojoExecutionException, MojoFailureException + { + Assert.assertEquals( new File( baseDir, artifactId + "-" + version + "-" + NarConstants.NAR_NO_ARCH + + File.separator + fileLayout.getIncludeDirectory() ), layout.getIncludeDirectory( baseDir, artifactId, version ) ); + } + + /** + * Test method for + * {@link org.apache.maven.plugin.nar.NarLayout20#getLibDirectory(java.io.File, java.lang.String, java.lang.String)} + * . + * + * @throws MojoFailureException + * @throws MojoExecutionException + */ + public final void testGetLibDirectory() + throws MojoExecutionException, MojoFailureException + { + Assert.assertEquals( new File( baseDir, artifactId + "-" + version + "-" + aol + "-" + type + File.separator + + fileLayout.getLibDirectory( aol, type ) ), layout.getLibDirectory( baseDir, artifactId, version, aol, type ) ); + } + + /** + * Test method for {@link org.apache.maven.plugin.nar.NarLayout20#getBinDirectory(java.io.File, java.lang.String)}. + * + * @throws MojoFailureException + * @throws MojoExecutionException + */ + public final void testGetBinDirectory() + throws MojoExecutionException, MojoFailureException + { + Assert.assertEquals( new File( baseDir, artifactId + "-" + version + "-" + aol + "-" + "executable" + + File.separator + fileLayout.getBinDirectory( aol ) ), layout.getBinDirectory( baseDir, artifactId, version, aol ) ); + } +} -- cgit v1.2.3