1. opensymphony
  2. xwork

Commits

rainerh  committed e039e07

Removing custom apt stuff.
The apt generation of XXX-conversion.properties is no longer required due to the dependency on Java5 now

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@1203e221344d-f017-0410-9bd5-d282ab1896d7

  • Participants
  • Parent commits 5cec976
  • Branches master

Comments (0)

Files changed (15)

File pom.xml

View file
             <optional>true</optional>
         </dependency>
         <dependency>
+            <groupId>dom4j</groupId>
+            <artifactId>dom4j</artifactId>
+            <version>1.6</version>
+            <optional>true</optional>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <version>3.8.1</version>

File src/java/com/opensymphony/xwork2/apt/AbstractProcessor.java

-/*
- * Copyright (c) 2002-2006 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.xwork2.apt;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.Filer;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintWriter;
-
-/**
- * <code>AbstractProcessor</code>
- *
- * @author Rainer Hermanns
- * @version $Id$
- */
-public abstract class AbstractProcessor implements AnnotationProcessor {
-
-    protected Log log = null;
-
-    protected AnnotationProcessorEnvironment env;
-
-
-    public AbstractProcessor() {
-        log = LogFactory.getLog(this.getClass());
-    }
-
-
-    /**
-     * Sets the AnnotationProcessorEnvironment.
-     *
-     * @param env the AnnotationProcessorEnvironment.
-     */
-    public void setEnv(AnnotationProcessorEnvironment env) {
-        this.env = env;
-    }
-
-    /**
-     * Initializes all annotations types required for processing.
-     */
-    public void init() {
-    }
-
-    /**
-     * Process all program elements supported by this annotations processor.
-     */
-    public abstract void process();
-
-
-    /**
-     * Returns a PrintWriter that writes to META-INF directory within the Filer.Location.SOURCE_TREE.
-     *
-     * @param filename The filename of the file to be written.
-     * @return PrintWriter that writes to META-INF directory within the Filer.Location.SOURCE_TREE.
-     * @throws IOException
-     */
-    protected PrintWriter getSourceMetaInfWriter(String filename) throws IOException {
-        return env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, "", new File("META-INF" + File.separator + filename), "UTF-8");
-    }
-
-    /**
-     * Returns a PrintWriter that writes to META-INF directory within the Filer.Location.CLASS_TREE.
-     *
-     * @param filename The filename of the file to be written.
-     * @return PrintWriter that writes to META-INF directory within the Filer.Location.CLASS_TREE.
-     * @throws IOException
-     */
-    protected PrintWriter getClassesMetaInfWriter(String filename) throws IOException {
-        return env.getFiler().createTextFile(Filer.Location.CLASS_TREE, "", new File("META-INF" + File.separator + filename), "UTF-8");
-    }
-
-    /**
-     * Returns a PrintWriter that writes to WEB-INF directory within the Filer.Location.SOURCE_TREE.
-     *
-     * @param filename The filename of the file to be written.
-     * @return PrintWriter that writes to WEB-INF directory within the Filer.Location.SOURCE_TREE.
-     * @throws IOException
-     */
-    protected PrintWriter getWebInfWriter(String filename) throws IOException {
-        return env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, "", new File("WEB-INF" + File.separator + filename), "UTF-8");
-    }
-}

File src/java/com/opensymphony/xwork2/apt/ConversionGenerator.java

-/*
- * Copyright (c) 2002-2006 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.xwork2.apt;
-
-import com.opensymphony.xwork2.conversion.metadata.ConversionDescription;
-import com.sun.mirror.apt.Filer;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.List;
-import java.util.Map;
-
-/**
- * <code>ConversionGenerator</code>
- *
- * @author Rainer Hermanns
- * @version $Id$
- */
-public class ConversionGenerator extends Generator {
-
-    Map<String, List<ConversionDescription>> conversionsByType = null;
-
-    public ConversionGenerator(Map<String, List<ConversionDescription>> conversionsByType) {
-        this.conversionsByType = conversionsByType;
-
-    }
-
-    /**
-     * Generate the configuration file.
-     * Concrete implementations must override this method.
-     */
-    public void generate(Filer filer) {
-        if (conversionsByType == null) {
-            return;
-        }
-
-        // write property files
-        for (Map.Entry<String, List<ConversionDescription>> descriptionMapping : conversionsByType.entrySet()) {
-
-            String key = descriptionMapping.getKey();
-            String fileName;
-            if (key.equals("")) {
-                fileName = "xwork-conversion.properties";
-            } else {
-                fileName = key.replace('.', File.separatorChar) + "-conversion.properties";
-
-            }
-            final PrintWriter writer;
-            try {
-                writer = filer.createTextFile(Filer.Location.SOURCE_TREE, "", new File(fileName), null);
-                writer.println("# Generated automatically. Do not edit!");
-
-                for (ConversionDescription component : descriptionMapping.getValue()) {
-                    writer.println(component.asProperty());
-                }
-                writer.flush();
-                writer.close();
-
-            } catch (IOException ioe) {
-                throw new RuntimeException("could not generate conversion.properties: " + ioe, ioe);
-            }
-        }
-    }
-}

File src/java/com/opensymphony/xwork2/apt/ConversionProcessor.java

-/*
- * Copyright (c) 2002-2006 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.xwork2.apt;
-
-import com.opensymphony.xwork2.conversion.annotations.Conversion;
-import com.opensymphony.xwork2.conversion.annotations.ConversionType;
-import com.opensymphony.xwork2.conversion.annotations.TypeConversion;
-import com.opensymphony.xwork2.conversion.metadata.ConversionDescription;
-import com.opensymphony.xwork2.util.AnnotationUtils;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.ClassType;
-import com.sun.mirror.type.InterfaceType;
-
-import java.util.*;
-
-/**
- * <code>ConversionProcessor</code>
- *
- * @author Rainer Hermanns
- * @version $Id$
- */
-public class ConversionProcessor extends AbstractProcessor {
-
-    private AnnotationTypeDeclaration conversionAnnotation;
-    private AnnotationTypeDeclaration typeConversionAnnotation;
-
-    /**
-     * Initializes all annotations types required for processing.
-     */
-    public void init() {
-        super.init();
-        this.conversionAnnotation = (AnnotationTypeDeclaration) env.getTypeDeclaration(Conversion.class.getName());
-        this.typeConversionAnnotation = (AnnotationTypeDeclaration) env.getTypeDeclaration(TypeConversion.class.getName());
-    }
-
-
-    /**
-     * Process all program elements supported by this annotations processor.
-     */
-    public void process() {
-
-        final Map<String, List<ConversionDescription>> conversionsByType = new Hashtable<String, List<ConversionDescription>>();
-
-        for (Declaration compDecl : env.getDeclarationsAnnotatedWith(conversionAnnotation)) {
-
-            /*
-            * Get all fields with TypeConversion-Annotation of component
-            */
-            List<ConversionDescription> applicationFields = new ArrayList<ConversionDescription>();
-            List<ConversionDescription> classFields = new ArrayList<ConversionDescription>();
-
-            if ( compDecl instanceof InterfaceDeclaration) {
-
-                final InterfaceDeclaration component = (InterfaceDeclaration) compDecl;
-
-                addConversionFields(component, applicationFields, classFields);
-
-                conversionsByType.put("", applicationFields);
-                conversionsByType.put(component.getQualifiedName(), classFields);
-            } else if ( compDecl instanceof ClassDeclaration) {
-                final ClassDeclaration component = (ClassDeclaration) compDecl;
-
-                addConversionFields(component, applicationFields, classFields);
-
-                conversionsByType.put("", applicationFields);
-                conversionsByType.put(component.getQualifiedName(), classFields);
-
-            }
-
-        }
-
-        /**
-         * Holds all components without usage (="default usage")
-         */
-        List<ConversionDescription> defaultDescriptions = conversionsByType.get("");
-
-        // Add components with default usage to specific components
-        /*
-        for (Map.Entry<String, List<ConversionDescription>> descriptionMapping : conversionsByType.entrySet()) {
-            if (!"".equals(descriptionMapping.getKey())) {
-                addDefaultConversions(defaultDescriptions, descriptionMapping.getValue());
-            }
-        }
-        */
-
-        new ConversionGenerator(conversionsByType).generate(env.getFiler());
-    }
-
-    private void addDefaultConversions(List<ConversionDescription> defaultComponents, List<ConversionDescription> specialComponents) {
-        for (ConversionDescription description : defaultComponents) {
-            if (!specialComponents.contains(description)) {
-                specialComponents.add(description);
-            }
-        }
-    }
-
-    private ConversionDescription createConversionDescription(MethodDeclaration method, AnnotationMirror annotation) {
-
-        Map<AnnotationTypeElementDeclaration, AnnotationValue> values = annotation.getElementValues();
-
-        final ConversionDescription result;
-
-        String property = AnnotationUtils.resolvePropertyName(method);
-
-        if (typeConversionAnnotation.equals(annotation.getAnnotationType().getDeclaration())) {
-
-
-            result = new ConversionDescription(property);
-
-            for (AnnotationTypeElementDeclaration element : typeConversionAnnotation.getMethods()) {
-                AnnotationValue value = values.get(element);
-                if (value == null) {
-                    value = element.getDefaultValue();
-                }
-
-                String name = element.getSimpleName();
-                if ("rule".equals(name)) {
-                    result.setRule(value.getValue().toString());
-                } else if ("converter".equals(name)) {
-                    result.setTypeConverter(value.getValue().toString());
-                } else if ("message".equals(name)) {
-                    result.setValue(value.getValue().toString());
-                } else if ("key".equals(name)) {
-                    String s = value.getValue().toString();
-                    if ( s != null && s.length() > 0 ) {
-                        result.setProperty(s);
-                    }
-                } else if ("type".equals(name)) {
-                    result.setType(value.getValue().toString());
-                }
-            }
-            return result;
-        }
-        return null;
-    }
-
-    /**
-     * Adds all fields with TypeConversion Annotation of class clazz and
-     * its superclasses to allFields
-     */
-    private void addConversionFields(ClassDeclaration clazz, List<ConversionDescription> allApplicationFields, List<ConversionDescription> allClassFields) {
-        if (clazz == null) {
-            return;
-        }
-
-        processConversionFields(clazz, allApplicationFields, allClassFields);
-
-        ClassType superClazz = clazz.getSuperclass();
-        if (superClazz != null) {
-            addConversionFields(superClazz.getDeclaration(), allApplicationFields, allClassFields);
-        }
-    }
-
-    /**
-     * Adds all fields with TypeConversion Annotation of class clazz and
-     * its superclasses to allFields
-     */
-    private void addConversionFields(InterfaceDeclaration clazz, List<ConversionDescription> allApplicationFields, List<ConversionDescription> allClassFields) {
-        if (clazz == null) {
-            return;
-        }
-
-        processConversionFields(clazz, allApplicationFields, allClassFields);
-        Collection<InterfaceType> ifaces = clazz.getSuperinterfaces();
-
-        if ( ifaces != null ) {
-            for ( InterfaceType it : ifaces) {
-                addConversionFields(it.getDeclaration(), allApplicationFields, allClassFields);
-            }
-        }
-    }
-
-    private void processConversionFields(TypeDeclaration clazz, List<ConversionDescription> allApplicationFields, List<ConversionDescription> allClassFields) {
-        Collection<? extends MethodDeclaration> methods = clazz.getMethods();
-
-        for (MethodDeclaration method : methods) {
-
-            Collection<AnnotationMirror> annos = method.getAnnotationMirrors();
-            for (AnnotationMirror am : annos) {
-
-                Map<AnnotationTypeElementDeclaration, AnnotationValue> values = am.getElementValues();
-                for ( AnnotationTypeElementDeclaration element : typeConversionAnnotation.getMethods()) {
-                    AnnotationValue value = values.get(element);
-                    if (value == null) {
-                        value = element.getDefaultValue();
-                    }
-                    if ( "type".equals(element.getSimpleName()) ) {
-                        ConversionDescription desc = createConversionDescription(method, am);
-                        if ( desc != null ) {
-                            if ( value.getValue().toString().equals(ConversionType.APPLICATION.toString())) {
-                                allApplicationFields.add(desc);
-                            } else {
-                                allClassFields.add(desc);
-                            }
-                            break;
-                        }
-                    }
-                }
-            }
-        }
-    }
-}

File src/java/com/opensymphony/xwork2/apt/Generator.java

-/*
- * Copyright (c) 2002-2006 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.xwork2.apt;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.Filer;
-
-/**
- * <code>Generator</code>
- *
- * @author Rainer Hermanns
- * @version $Id$
- */
-public abstract class Generator {
-
-
-    protected AnnotationProcessorEnvironment env;
-
-
-    /**
-     * Sets the AnnotationProcessorEnvironment.
-     *
-     * @param env the AnnotationProcessorEnvironment.
-     */
-    public void setEnv(AnnotationProcessorEnvironment env) {
-        this.env = env;
-    }
-
-    /**
-     * Generate the configuration file.
-     * Concrete implementations must override this method.
-     */
-    public abstract void generate(Filer filer);
-
-}

File src/java/com/opensymphony/xwork2/apt/XWorkProcessorFactory.java

-/*
- * Copyright (c) 2002-2006 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.xwork2.apt;
-
-import com.opensymphony.xwork2.conversion.annotations.Conversion;
-import com.opensymphony.xwork2.validator.annotations.Validation;
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-import com.sun.mirror.apt.AnnotationProcessors;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-import java.util.*;
-import java.util.prefs.Preferences;
-
-/**
- * <code>XWorkProcessorFactory</code>
- *
- * @author Rainer Hermanns
- * @version $Id$
- */
-public class XWorkProcessorFactory implements AnnotationProcessorFactory {
-
-    private static Preferences preferences = Preferences.userNodeForPackage(XWorkProcessorFactory.class);
-
-
-    /**
-     * Returns the options recognized by this factory or by any of the processors it may create.
-     *
-     * @return the options recognized by this factory or by any of the processors it may create,
-     *         or an empty collection if none.
-     */
-    public Collection<String> supportedOptions() {
-        return Collections.emptySet();
-    }
-
-    /**
-     * Returns the names of the annotations types supported by this factory.
-     *
-     * @return the names of the annotations types supported by this factory.
-     */
-    public Collection<String> supportedAnnotationTypes() {
-        return createCollection(
-                "com.opensymphony.xwork2.conversion.annotations.*" //,
-                //"com.opensymphony.xwork2.validator.annotations.*"
-        );
-    }
-
-
-    /**
-     * Returns an annotations processor for a set of annotations types.
-     *
-     * @param declarations The type declarations for the annotations types to be processed.
-     * @param env          The environment to use during processing.
-     * @return an annotations processor for the given annotations types, or <tt>null</tt>
-     *         if the types are not supported or the processor cannot be created.
-     */
-    public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> declarations, AnnotationProcessorEnvironment env) {
-        List<AnnotationProcessor> processors = new LinkedList<AnnotationProcessor>();
-
-        AnnotationTypeDeclaration conversionType = (AnnotationTypeDeclaration) env.getTypeDeclaration(Conversion.class.getName());
-        //AnnotationTypeDeclaration validationType = (AnnotationTypeDeclaration) env.getTypeDeclaration(Validation.class.getName());
-
-        if (declarations.contains(conversionType)) {
-            ConversionProcessor conversion = new ConversionProcessor();
-
-            conversion.setEnv(env);
-            conversion.init();
-            processors.add(conversion);
-        }
-
-        // TODO: Temporary disabled...
-        /*
-        if (declarations.contains(validationType)) {
-            ValidationProcessor validation = new ValidationProcessor();
-            validation.setEnv(env);
-            validation.init();
-            processors.add(validation);
-        }
-        */
-
-        if (processors.isEmpty()) {
-            return AnnotationProcessors.NO_OP;
-        }
-
-        if (processors.size() == 1) {
-            return processors.get(0);
-        }
-
-        return AnnotationProcessors.getCompositeAnnotationProcessor(processors);
-    }
-
-    public static <T> Collection<T> createCollection(T... args) {
-        return Arrays.asList(args);
-    }
-}

File src/test/com/opensymphony/xwork2/apt/AbstractAptTestCase.java

-/*
- * Copyright (c) 2002-2006 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.xwork2.apt;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.util.Properties;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.dom4j.Document;
-import org.dom4j.io.SAXReader;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Base class for tests that deal with the apt tool
- * 
- * @author Nils Hartmann <nils@nilshartmann.net>
- * @author Rainer Hermanns
- */
-public class AbstractAptTestCase extends TestCase {
-
-    protected static final Log log = LogFactory.getLog(AbstractAptTestCase.class);
-
-    public final static String SOURCE_DIR="src/test";
-    public final static String DEST_DIR="target/test-generate";
-    public final static String BUILD_DIR="target/classes";
-
-    public AbstractAptTestCase(String name) {
-        super(name);
-    }
-
-    /**
-     * Runs the apt-processor on all java-Sourcefiles in the
-     * defaultSourceDir.
-     *
-     * <p><b>Attention:</b> The destdir will be removed before
-     * running apt
-     */
-    protected AptRunnerResult runApt() throws Exception {
-        return runApt(getDefaultSourceDir());
-    }
-
-    /**
-     * Runs the apt-processor on all java-files in sourceDir
-     *
-     * <b>Attention:</b> The destdir will be removed before
-     * running apt
-     */
-    protected AptRunnerResult runApt(File sourceDir) throws Exception {
-
-        final File destDir = getDefaultDestDir();
-        assertNotNull(destDir);
-
-        if (getDefaultDestDir().exists()) {
-            removeDirectoryTree(getDefaultDestDir().getAbsolutePath());
-        }
-
-        if (!destDir.exists()) {
-            destDir.mkdirs();
-        }
-        assertTrue(destDir.exists());
-        assertTrue(destDir.isDirectory());
-
-        Properties p = System.getProperties();
-        for ( Map.Entry e : p.entrySet() ) {
-            System.out.println(e.getKey() + " : " + e.getValue());
-        }
-        AptRunner aptRunner = new AptRunner();
-        aptRunner.setDestDir(destDir);
-        aptRunner.addSourceDir(sourceDir);
-        aptRunner.setAdditionalClasspath( new File(getDefaultBaseDir(), BUILD_DIR).getAbsolutePath() + System.getProperty("path.separator") + System.getProperty("maven.dependency.classpath"));
-        aptRunner.setExecutable(getDefaultExcecutable().getAbsolutePath());
-        aptRunner.setFactoryName(getDefaultFactoryName());
-        return aptRunner.run();
-    }
-
-    protected File getDefaultBaseDir() {
-        return new File(System.getProperty("user.dir"));
-    }
-
-    protected File getDefaultSourceDir() {
-        return new File(getDefaultBaseDir(), SOURCE_DIR);
-    }
-
-    /**
-     * Returns the destination directory for the apt process
-     * <p><b>Warning:</b> This directory will be removed before
-     * starting apt !
-     * @return
-     */
-    protected File getDefaultDestDir() {
-        return new File(getDefaultBaseDir(), DEST_DIR);
-    }
-
-    protected File getDefaultExcecutable() {
-        String javaHome  = System.getProperty("java.home");
-        if (javaHome.endsWith("jre")) {
-            // javaHome points "only" to jre, which doesn't contain
-            // the apt tool
-            // check if it's a jre installation inside a complete jdk
-            javaHome = javaHome.substring(0, javaHome.length()-4);
-        }
-        File apt = new File(javaHome, File.separator + "bin" + File.separator + "apt");
-        assertTrue("apt executable not found. Plase set java.home to a jdk5 installation directory", apt.isFile());
-        return apt;
-    }
-
-    protected String getDefaultFactoryName() {
-        return "com.opensymphony.xwork2.apt.XWorkProcessorFactory";
-    }
-
-    protected String getPackageDirectoryName() {
-        final String className = getClass().getName();
-        String packageName = className.substring(0,className.lastIndexOf('.'));
-        return packageName.replace('.', '/');
-    }
-
-    protected InputStream readFromFolder(File file) throws Exception {
-        assertNotNull(file);
-        assertTrue(file.isFile());
-        FileInputStream fis = new FileInputStream(file);
-        return fis;
-    }
-
-    protected InputStream readFromSourceFolder(String relativeFileName) throws Exception {
-        return readFromFolder(new File(getDefaultSourceDir(), relativeFileName));
-    }
-
-    protected InputStream readFromDestFolder(String relativeFileName) throws Exception {
-        return readFromFolder(new File(getDefaultDestDir(), relativeFileName));
-    }
-
-    protected Document readDocumentFromSourceFolder(String relativeFileName) throws Exception {
-        SAXReader reader = new SAXReader();
-        Document document = reader.read(readFromSourceFolder(relativeFileName));
-        return document;
-    }
-
-    protected Document readDocumentFromDestFolder(String relativeFileName) throws Exception {
-        SAXReader reader = new SAXReader();
-        Document document = reader.read(readFromDestFolder(relativeFileName));
-        return document;
-    }
-
-    /**
-     * Delete a directory, his subdirectory and all files.
-     *
-     * @param directoryName
-     *          the name of the directory to remove.
-     * @throws Exception
-     *           if an error occurs.
-     */
-    public static void removeDirectoryTree(String directoryName) throws Exception {
-
-        File directory = new File(directoryName);
-
-        if (!directory.exists()) {
-            return;
-        }
-
-        if (!directory.isDirectory()) {
-            throw new Exception("'" + directory + "' is not a directory");
-        }
-
-        String[] fileList = directory.list();
-        int numFile = fileList.length;
-        boolean fileDeleted = false;
-        File f = null;
-        for (int i = 0; i < numFile; i++) {
-            f = new File(directoryName + File.separator + fileList[i]);
-            if (f.isDirectory()) {
-                removeDirectoryTree(f.getPath());
-            } else {
-                fileDeleted = f.delete();
-            }
-        }
-        fileDeleted = directory.delete();
-    }
-}

File src/test/com/opensymphony/xwork2/apt/AptRunner.java

-/*
- * Copyright (c) 2002-2006 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.xwork2.apt;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.LinkedList;
-import java.util.List;
-
-import junit.framework.Assert;
-
-/**
- * AptRunner -- Wraps a call to the Annotation Processing Tool
- * 
- * @author Nils Hartmann <nils@nilshartmann.net>
- * @author Rainer Hermanns
- * @version $Id$
- */
-public class AptRunner {
-
-	public final static String NEW_LINE = System.getProperty("line.separator");
-
-	private String executable;
-	private File destDir;
-	private String classpath;
-	private String additionalClasspath;
-	private String factoryName;
-	private List<String> sourceFiles;
-
-	public AptRunner() {
-
-	}
-
-	public List<String> getSourceFiles() {
-		if (sourceFiles == null) {
-			sourceFiles = new LinkedList<String>();
-		}
-		return sourceFiles;
-	}
-
-	public void addSourceDir(File sourceDir) {
-		Assert.assertNotNull(sourceDir);
-		Assert.assertTrue("sourceDir: " + sourceDir, sourceDir.exists());
-		Assert.assertTrue(sourceDir.isDirectory());
-
-		List<String> sourceFiles = getSourceFiles(sourceDir);
-		getSourceFiles().addAll(sourceFiles);
-
-	}
-
-	public void addSourceFiles(List<String> sourceFiles) {
-		Assert.assertNotNull(sourceFiles);
-		getSourceFiles().addAll(sourceFiles);
-	}
-
-	public void addSourceFile(String sourceFile) {
-		getSourceFiles().add(sourceFile);
-	}
-
-	public String getClasspath() {
-		return (classpath == null ? System.getProperty("java.class.path")
-				: classpath);
-	}
-
-	/**
-	 * Sets the classpath for the apt-call. If no classpath is specified, the
-	 * classpath of the current vm will be used (as specified in
-	 * <code>java.class.path</code> system property
-	 */
-	public void setClasspath(String classpath) {
-		this.classpath = classpath;
-	}
-
-
-    public String getAdditionalClasspath() {
-        return additionalClasspath;
-    }
-
-    public void setAdditionalClasspath(String additionalClasspath) {
-        this.additionalClasspath = additionalClasspath;
-    }
-
-    public File getDestDir() {
-		return destDir;
-	}
-
-	public void setDestDir(File destDir) {
-		this.destDir = destDir;
-	}
-
-	public String getExecutable() {
-		return (executable == null ? "apt" : executable);
-	}
-
-	public void setExecutable(String executable) {
-		this.executable = executable;
-	}
-
-	public String getFactoryName() {
-		return factoryName;
-	}
-
-	public void setFactoryName(String factoryName) {
-		this.factoryName = factoryName;
-	}
-
-	public AptRunnerResult run() throws Exception {
-		Assert.assertNotNull("Dest directory must be set", getDestDir());
-		Assert.assertNotNull("A factory name must be set", getFactoryName());
-		Assert.assertTrue("At least one source file must be specified",
-				getSourceFiles().size() > 0);
-
-		List<String> args = new LinkedList<String>();
-		args.add(getExecutable());
-		args.add("-s");
-		args.add(getDestDir().getAbsolutePath());
-		args.add("-classpath");
-        if ( additionalClasspath != null) {
-            args.add(getClasspath() + System.getProperty("path.separator") + additionalClasspath);
-        } else {
-            args.add(getClasspath());
-        }
-        args.add("-nocompile");
-		args.add("-factory");
-		args.add(getFactoryName());
-		args.addAll(getSourceFiles());
-
-		StringBuffer command =new StringBuffer();
-		for (String s : args) {
-			command.append(s);
-			command.append(' ');
-		}
-
-		//System.out.println("Running apt with '" + command + "'");
-		ProcessBuilder processBuilder = new ProcessBuilder(args);
-	
-		Process aptProcess = processBuilder.start(); 
-		StreamReader inputReader = new StreamReader("output", aptProcess.getInputStream());
-		StreamReader errorReader = new StreamReader("error", aptProcess.getErrorStream());
-		inputReader.start();
-		errorReader.start();
-		int result = aptProcess.waitFor();
-		
-		AptRunnerResult runnerResult = new AptRunnerResult(result, command.toString(), inputReader.getBuffer(), errorReader.getBuffer());
-		return runnerResult;
-	}
-
-	class StreamReader extends Thread {
-
-		private final BufferedReader reader;
-
-		private final StringBuffer output;
-
-		private boolean shouldStop = false;
-
-		public StreamReader(String name, InputStream is) {
-			super(name);
-			Assert.assertNotNull(is);
-			this.reader = new BufferedReader(new InputStreamReader(is));
-			this.output = new StringBuffer();
-		}
-
-		public void run() {
-			String line;
-			try {
-				while ((line = reader.readLine()) != null && !shouldStop) {
-					output.append(line);
-					output.append(NEW_LINE);
-				}
-			} catch (IOException ioe) {
-				ioe.printStackTrace();
-				output.append(ioe.toString());
-			}
-			//System.out.println(" ---> " + getName() + "-reader quit. buffer: " + output);
-		}
-
-		//
-		// public void stopReader() {
-		// this.shouldStop = false;
-		// }
-
-		public String getBuffer() {
-			return this.output.toString();
-		}
-	}
-
-	/**
-	 * Gets a list with all ".java"-files in sourceDir
-	 */
-	protected List<String> getSourceFiles(File sourceDir) {
-
-		final List<String> sourceFiles = new LinkedList<String>();
-
-		final File[] files = sourceDir.listFiles();
-		for (File file : files) {
-			if (file.isDirectory()) {
-				if (!file.getName().equals(".svn")
-						&& !file.getName().equals("CVS")) {
-					sourceFiles.addAll(getSourceFiles(file));
-				}
-			} else {
-				if (file.getName().endsWith(".java")) {
-					sourceFiles.add(file.getAbsolutePath());
-				}
-			}
-		}
-
-		return sourceFiles;
-	}
-
-}

File src/test/com/opensymphony/xwork2/apt/AptRunnerResult.java

-/*
- * Copyright (c) 2002-2006 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.xwork2.apt;
-
-/**
- * @author Rainer Hermanns
- * @author Nils Hartmann
- */
-public class AptRunnerResult {
-	
-	private final String _command;
-	private final int _result;
-	private final String _output;
-	private final String _error;
-	
-	public String getCommand() {
-		return _command;
-	}
-	public String getError() {
-		return _error;
-	}
-	
-	public boolean containsErrors() {
-        return (_error != null) && (_error.length()>0);
-	}
-	
-	public String getOutput() {
-		return _output;
-	}
-	public int getResult() {
-		return _result;
-	}
-	
-	public boolean succeeded() {
-		return (_result == 0);
-	}
-	
-	public AptRunnerResult(int result, String command, String output, String error) {
-		super();
-		this._result = result;
-		_command = command;
-		_output = output;
-		_error = error;
-	}
-	
-	public String toString() {
-			StringBuffer buffer = new StringBuffer();
-			buffer.append("[AptRunnerResult:");
-			buffer.append(" _command: ");
-			buffer.append(_command);
-			buffer.append(" _result: ");
-			buffer.append(_result);
-			buffer.append(" _output: ");
-			buffer.append(_output);
-			buffer.append(" _error: ");
-			buffer.append(_error);
-			buffer.append("]");
-			return buffer.toString();
-		}
-
-}

File src/test/com/opensymphony/xwork2/apt/ConversionProcessorTest.java

-/*
- * Copyright (c) 2002-2006 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.xwork2.apt;
-
-import java.io.File;
-import java.util.Properties;
-
-/**
- * @author Rainer Hermanns
- */
-public class ConversionProcessorTest extends AbstractAptTestCase {
-	
-	public ConversionProcessorTest(String name) {
-		super(name);
-	}
-
-	public void test_generate() throws Exception {
-		AptRunnerResult result = runApt(new File(getDefaultSourceDir(), "com/opensymphony/xwork2/conversion"));
-		assertTrue("ERRORS: " + result, result.succeeded());
-		assertFalse("ERRORS: " + result, result.containsErrors());
-		
-		Properties generatedProperties = new Properties();
-		generatedProperties.load(readFromDestFolder("xwork-conversion.properties"));
-		Properties expectedProperties = new Properties();
-		expectedProperties.load(readFromSourceFolder("com/opensymphony/xwork2/apt/expected/" + "xwork-conversion.properties"));
-		assertEquals(expectedProperties, generatedProperties);
-		
-		Properties generatedActionProperties = new Properties();
-		generatedActionProperties.load(
-				readFromDestFolder("com/opensymphony/xwork2/conversion/ConversionTestAction-conversion.properties"));
-		
-		Properties expectedActionProperties = new Properties();
-		expectedActionProperties.load(readFromSourceFolder(
-				getPackageDirectoryName() + File.separator + "expected" + File.separator  + "ConversionTestAction-conversion.properties"));
-		assertEquals(expectedActionProperties, generatedActionProperties);
-		
-	}
-	
-}

File src/test/com/opensymphony/xwork2/apt/expected/ConversionTestAction-conversion.properties

-# Generated automatically. Do not edit!
-convertDouble=com.opensymphony.xwork2.util.XWorkBasicConverter
-Collection_users=java.lang.String
-Map_keyValues=java.math.BigInteger

File src/test/com/opensymphony/xwork2/apt/expected/SimpleValidationAction-validation.xml

-<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
-<validators>
-
-	<!-- Generated automatically. Do not edit! -->
-
-	<!-- ALL FIELD VALIDATORS -->
-	<field name="baz">
-		<field-validator type="int" short-circuit="true">
-			<param name="min">0</param>
-			<message key="baz.range">Could not find baz.range!</message>
-		</field-validator>
-	</field>
-
-	<field name="bar">
-		<field-validator type="required" short-circuit="true">
-			<message>You must enter a value for bar.</message>
-		</field-validator>
-		<field-validator type="int" short-circuit="true">
-			<param name="min">6</param>
-			<param name="max">10</param>
-			<message>bar must be between ${min} and ${max}, current value is ${bar}.</message>
-		</field-validator>
-	</field>
-
-	<field name="needstringlength">
-		<field-validator type="stringlength" short-circuit="true">
-			<param name="minLength">10</param>
-			<param name="maxLength">12</param>
-			<message>You must enter a stringlength.</message>
-	</field-validator>
-	</field>
-
-	<field name="date">
-		<field-validator type="date" short-circuit="true">
-			<param name="min">12/22/2002</param>
-			<param name="max">12/25/2002</param>
-			<message>The date must be between 12-22-2002 and 12-25-2002.</message>
-		</field-validator>
-	</field>
-
-
-	<!-- ALL OTHER VALIDATORS -->
-	<validator type="expression" short-circuit="true">
-		<param name="expression">foo &gt; 1</param>
-		<message>Foo must be greater than Bar 1. Foo = ${foo}, Bar = ${bar}.</message>
-	</validator>
-
-	<validator type="expression" short-circuit="true">
-		<param name="expression">foo &gt; 2</param>
-		<message>Foo must be greater than Bar 2. Foo = ${foo}, Bar = ${bar}.</message>
-	</validator>
-
-	<validator type="expression" short-circuit="true">
-		<param name="expression">foo &gt; 3</param>
-		<message>Foo must be greater than Bar 3. Foo = ${foo}, Bar = ${bar}.</message>
-	</validator>
-
-	<validator type="expression" short-circuit="true">
-		<param name="expression">foo &gt; 4</param>
-		<message>Foo must be greater than Bar 4. Foo = ${foo}, Bar = ${bar}.</message>
-	</validator>
-
-	<validator type="expression" short-circuit="true">
-		<param name="expression">foo &gt; 5</param>
-		<message>Foo must be greater than Bar 5. Foo = ${foo}, Bar = ${bar}.</message>
-	</validator>
-
-
-	<validator type="required" short-circuit="true">
-		<param name="fieldName">customfield</param>
-		<message>You must enter a value for field.</message>
-	</validator>
-
-	<validator type="requiredstring" short-circuit="true">
-		<param name="fieldName">stringisrequired</param>
-		<message>You must enter a value for string.</message>
-	</validator>
-
-	<validator type="email" short-circuit="true">
-		<param name="fieldName">emailaddress</param>
-		<message>You must enter a value for email.</message>
-	</validator>
-
-	<validator type="url" short-circuit="true">
-		<param name="fieldName">hreflocation</param>
-		<message>You must enter a value for email.</message>
-	</validator>
-
-	<validator type="int" short-circuit="true">
-		<param name="fieldName">intfield</param>
-		<param name="min">6</param>
-		<param name="max">10</param>
-		<message>bar must be between ${min} and ${max}, current value is ${bar}.</message>
-	</validator>
-
-	<validator type="date" short-circuit="true">
-		<param name="fieldName">datefield</param>
-		<param name="min">-1</param>
-		<param name="max">99</param>
-		<message>bar must be between ${min} and ${max}, current value is ${bar}.</message>
-	</validator>
-
-</validators>

File src/test/com/opensymphony/xwork2/apt/expected/xwork-conversion.properties

-# Generated automatically. Do not edit!
-convertInt=com.opensymphony.xwork2.util.XWorkBasicConverter
-java.util.Date=com.opensymphony.xwork2.util.XWorkBasicConverter

File src/test/com/opensymphony/xwork2/conversion/ConversionTestAction.java

View file
 package com.opensymphony.xwork2.conversion;
 
 import com.opensymphony.xwork2.Action;
-import com.opensymphony.xwork2.util.XWorkBasicConverter;
 import com.opensymphony.xwork2.conversion.annotations.*;
 
 import java.util.List;
 import java.util.HashMap;
-import java.math.BigInteger;
 
 /**
  * <code>ConversionTestAction</code>

File src/test/com/opensymphony/xwork2/util/XWorkConverterTest.java

View file
 import com.opensymphony.xwork2.config.ConfigurationManager;
 import com.opensymphony.xwork2.test.ModelDrivenAction2;
 import com.opensymphony.xwork2.test.User;
-import junit.framework.TestCase;
 import ognl.OgnlException;
 import ognl.OgnlRuntime;