r894 - lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx
Author: tchemit Date: 2008-10-11 14:08:31 +0000 (Sat, 11 Oct 2008) New Revision: 894 Removed: lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/AbstractCompilerTest.java lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompileConfig.java Log: refactor tests of the plugin using maven-plugin-testing-harness plugin Deleted: lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/AbstractCompilerTest.java =================================================================== --- lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/AbstractCompilerTest.java 2008-10-11 14:06:12 UTC (rev 893) +++ lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/AbstractCompilerTest.java 2008-10-11 14:08:31 UTC (rev 894) @@ -1,97 +0,0 @@ -package org.codelutin.jaxx; - -import junit.framework.TestCase; - -import java.io.File; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** @author chemit */ -public abstract class AbstractCompilerTest extends TestCase { - /** log */ - protected static final Log log = LogFactory.getLog(I18nTest.class); - /** mojo goal */ - protected JaxxGeneratorMojo goal; - - protected static final String PREFIX_PACKAGE = "testcases"; - protected static File basedir; - protected static File srcDir; - protected static File outDir; - protected static File ClassOutDir; - protected static File ResourcesOutDir; - - public static File getBasedir() { - if (basedir == null) { - String basedirStr = System.getProperty("basedir"); - basedir = new File(basedirStr == null ? "." : basedirStr); - log.info("use basedir : "+basedir); - } - return basedir; - } - - protected static File getSrcDir() { - if (srcDir == null) { - srcDir = new File(getBasedir(), "src" + File.separator + "test" + File.separator + "java"); - } - return srcDir; - } - - protected static File getOutDir() { - if (outDir == null) { - outDir = new File(getBasedir(), "target" + File.separator + "test-generated-sources" + File.separator + "java"); - outDir.mkdirs(); - } - return outDir; - } - - protected static File getClassOutDir() { - if (ClassOutDir == null) { - ClassOutDir = new File(getBasedir(), "target" + File.separator + "test-classes"); - ClassOutDir.mkdirs(); - } - return ClassOutDir; - } - - protected static File getResourcesOutDir() { - if (ResourcesOutDir == null) { - ResourcesOutDir = new File(getBasedir(), "target" + File.separator + "test-classes"); - ResourcesOutDir.mkdirs(); - } - return ResourcesOutDir; - } - - @Override - public void setUp() throws IOException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, MojoExecutionException, MojoFailureException { - CompileConfig anno = getClass().getMethod(getName()).getAnnotation(CompileConfig.class); - assertNotNull("could not found " + CompileConfig.class.getSimpleName() + " annotation on test " + getClass(), anno); - final File srcDir = getSrcDir(); - assertTrue("could not found srcDir (or not existing) : " + srcDir + " on test " + getClass(), srcDir != null && srcDir.exists()); - final File outDir = getOutDir(); - assertTrue("could not found outDir (or not existing) : " + outDir + " on test " + getClass(), outDir != null && outDir.exists()); - final File classOutDir = getClassOutDir(); - assertTrue("could not found classOutDir (or not existing) : " + classOutDir + " on test " + getClass(), classOutDir != null && classOutDir.exists()); - final File resourcesOutDir = getResourcesOutDir(); - assertTrue("could not found classOutDir (or not existing) : " + resourcesOutDir + " on test " + getClass(), resourcesOutDir != null && resourcesOutDir.exists()); - String packageName = anno.packageName(); - goal = new JaxxGeneratorMojo(); - goal.setSrc(srcDir); - goal.setOutJava(outDir); - goal.setOutClass(classOutDir); - goal.setOutResource(resourcesOutDir); - //goal.setIncludes(new String[]{"**\\/" + PREFIX_PACKAGE + "\\/" + packageName + "\\/*.jaxx"}); - String expression = packageName.replaceAll("\\.", "\\\\/"); - goal.setIncludes(new String[]{"**\\/" + PREFIX_PACKAGE + "\\/" + expression + "\\/*.jaxx"}); - goal.setOptimize(anno.optimize()); - goal.setVerbose(anno.verbose()); - goal.setForce(anno.force()); - goal.setI18nable(anno.i18nable()); - //TODO Use the maven plexus TestCase inorder to include dependencies - goal.setJavaOpts(anno.javaOpts()); - log.info("setUp test " + getName()); - } -} Deleted: lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompileConfig.java =================================================================== --- lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompileConfig.java 2008-10-11 14:06:12 UTC (rev 893) +++ lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompileConfig.java 2008-10-11 14:08:31 UTC (rev 894) @@ -1,46 +0,0 @@ -/* -* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, -* Tony Chemit -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* ##% */ -package org.codelutin.jaxx; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -/** - * Une annotation pour configurer les tests de compilation. - * - * @author chemit - */ -@Retention(java.lang.annotation.RetentionPolicy.RUNTIME) -@Target(value = {java.lang.annotation.ElementType.TYPE, java.lang.annotation.ElementType.METHOD}) -public @interface CompileConfig { - - public String packageName(); - - public boolean optimize() default true; - - public boolean runJavac() default false; - - public boolean verbose() default false; - - public boolean force() default true; - - public boolean i18nable() default false; - - public String javaOpts() default ""; -}
participants (1)
-
tchemit@users.labs.libre-entreprise.org