cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r903389 - in /cxf/branches/2.2.x-fixes: ./ common/common/src/main/java/org/apache/cxf/common/util/ tools/common/src/main/java/org/apache/cxf/tools/common/ tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/ tools/...
Date Tue, 26 Jan 2010 19:59:58 GMT
Author: dkulp
Date: Tue Jan 26 19:59:57 2010
New Revision: 903389

URL: http://svn.apache.org/viewvc?rev=903389&view=rev
Log:
Merged revisions 903346 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r903346 | dkulp | 2010-01-26 13:05:19 -0500 (Tue, 26 Jan 2010) | 3 lines
  
  Update to use the javax.tools.JavaCompiler thing if running on Java6
  Start using some junit 4.7 Rules things for temp dirs and setup stuff to
  start getting ready to enable some parallel test things.
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/Compiler.java
    cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java
    cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
    cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/BeanGenerator.java
    cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
    cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/DateTypeCustomGeneratorTest.java
    cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/FaultBeanGeneratorTest.java
    cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WrapperBeanGeneratorTest.java
    cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderNoAnnoTest.java
    cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderRPCTest.java
    cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
    cxf/branches/2.2.x-fixes/tools/wsdlto/core/src/test/java/org/apache/cxf/tools/wsdlto/core/AbstractGeneratorTest.java
    cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/test/java/org/apache/cxf/tools/misc/processor/WSDLToServiceProcessorTest.java
    cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/test/java/org/apache/cxf/tools/misc/processor/WSDLToSoapProcessorTest.java
    cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/test/java/org/apache/cxf/tools/misc/processor/WSDLToXMLProcessorTest.java
    cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/test/java/org/apache/cxf/tools/misc/processor/XSDToWSDLProcessorTest.java
    cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/AbstractCodeGenTest.java
    cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CatalogTest.java
    cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
    cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/JAXWSBindingTest.java
    cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/validator/ValidatorTest.java
    cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/xmlbeans/XmlbeansBindingTest.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/Compiler.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/Compiler.java?rev=903389&r1=903388&r2=903389&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/Compiler.java
(original)
+++ cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/Compiler.java
Tue Jan 26 19:59:57 2010
@@ -23,14 +23,90 @@
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.io.Writer;
+import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Locale;
 
 import org.apache.cxf.helpers.FileUtils;
 
 public class Compiler {
-    public boolean compileFiles(String[] files, File outputDir) {
+    private long maxMemory = Runtime.getRuntime().maxMemory();
+    private boolean verbose;
+    private String target;
+    private String outputDir;
+    private String classPath;
+    private boolean forceFork = Boolean.getBoolean(Compiler.class.getName() + "-fork");
+    
+    public Compiler() {
+    }
+    
+    public void setMaxMemory(long l) {
+        maxMemory = l;
+    }
+    public void setVerbose(boolean b) {
+        verbose = b;
+    }
+    public void setTarget(String s) {
+        target = s;
+    }
+    public void setOutputDir(File s) {
+        if (s != null) {
+            outputDir = s.getAbsolutePath().replace(File.pathSeparatorChar, '/');
+        } else {
+            outputDir = null;
+        }
+    }
+    public void setOutputDir(String s) {
+        outputDir = s.replace(File.pathSeparatorChar, '/');
+    }
+    public void setClassPath(String s) {
+        classPath = s;
+    }
+    
+    private void addArgs(List<String> list) {
+        if (verbose) {
+            list.add("-verbose");
+        }
+        if (!StringUtils.isEmpty(target)) {
+            list.add("-target");
+            list.add(target);
+        }
+
+        if (outputDir != null) {
+            list.add("-d");
+            list.add(outputDir);
+        }
+        
+        if (classPath == null) {
+            String javaClasspath = System.getProperty("java.class.path");
+            boolean classpathSetted = javaClasspath != null ? true : false;
+            if (!classpathSetted) {
+                list.add("-extdirs");
+                list.add(getClass().getClassLoader().getResource(".").getFile() + "../lib/");
+            } else {
+                list.add("-classpath");
+                list.add(javaClasspath);
+            }
+        } else {
+            list.add("-classpath");
+            list.add(classPath);
+        }
+
+    }
+    
+    public boolean compileFiles(String[] files) {
+        if (!forceFork) {
+            try { 
+                Class.forName("javax.tools.JavaCompiler");
+                return useJava6Compiler(files);
+            } catch (Exception ex) {
+                //ignore - fork javac
+            }
+        }
+        
         List<String> list = new ArrayList<String>();
 
         // Start of honoring java.home for used javac
@@ -55,33 +131,47 @@
         list.add(javacstr);
         // End of honoring java.home for used javac
 
-        // This code doesn't honor java.home
-        // list.add("javac");
 
         //fix for CXF-2081, set maximum heap of this VM to javac.
-        list.add("-J-Xmx" + Runtime.getRuntime().maxMemory());
-
-        if (outputDir != null) {
-            list.add("-d");
-            list.add(outputDir.getAbsolutePath().replace(File.pathSeparatorChar, '/'));
-        }
-
-        String javaClasspath = System.getProperty("java.class.path");
-        boolean classpathSetted = javaClasspath != null ? true : false;
-        if (!classpathSetted) {
-            list.add("-extdirs");
-            list.add(getClass().getClassLoader().getResource(".").getFile() + "../lib/");
-        } else {
-            list.add("-classpath");
-            list.add(javaClasspath);
-        }
+        list.add("-J-Xmx" + maxMemory);
 
+        addArgs(list);
+        
         int idx = list.size();
         list.addAll(Arrays.asList(files));
 
         return internalCompile(list.toArray(new String[list.size()]), idx);
     }
 
+    private boolean useJava6Compiler(String[] files) 
+        throws Exception {
+        
+        Object compiler = Class.forName("javax.tools.ToolProvider")
+            .getMethod("getSystemJavaCompiler").invoke(null);
+        Object fileManager = compiler.getClass().getMethod("getStandardFileManager", 
+                                                           Class.forName("javax.tools.DiagnosticListener"),
+                                                           Locale.class,
+                                                           Charset.class).invoke(compiler,
null, null, null);
+        Object fileList = fileManager.getClass().getMethod("getJavaFileObjectsFromStrings",
Iterable.class)
+            .invoke(fileManager, Arrays.asList(files));
+        
+        
+        List<String> args = new ArrayList<String>();
+        addArgs(args);
+        Object task = compiler.getClass().getMethod("getTask", 
+                                                    Writer.class,
+                                                    Class.forName("javax.tools.JavaFileManager"),
+                                                    Class.forName("javax.tools.DiagnosticListener"),
+                                                    Iterable.class,
+                                                    Iterable.class,
+                                                    Iterable.class)
+                                                    .invoke(compiler, null, fileManager,
null, 
+                                                            args, null, fileList);
+        Boolean ret = (Boolean)task.getClass().getMethod("call").invoke(task);
+        fileManager.getClass().getMethod("close").invoke(fileManager);
+        return ret;
+    }
+
     public boolean internalCompile(String[] args, int sourceFileIndex) {
         Process p = null;
         String cmdArray[] = null;
@@ -166,4 +256,6 @@
         }
         return strBuffer.toString().length() > 4096 ? true : false;
     }
+
+    
 }

Modified: cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java?rev=903389&r1=903388&r2=903389&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java
Tue Jan 26 19:59:57 2010
@@ -39,41 +39,27 @@
     
     protected static final Logger LOG = LogUtils.getL7dLogger(ClassUtils.class);
     
-    public void compile(ToolContext context) throws ToolException {        
-        List<String> argList = new ArrayList<String>();
+    public void compile(ToolContext context) throws ToolException {
+        Compiler compiler = new Compiler();
         
-        //fix for CXF-2081, set maximum heap of current VM to javac.
-        argList.add("-J-Xmx" + Runtime.getRuntime().maxMemory());
-
-        String javaClasspath = System.getProperty("java.class.path");
-        // hard code cxf.jar
-        boolean classpathSetted = javaClasspath != null ? true : false;
-        // && (javaClasspath.indexOf("cxf.jar") >= 0);
         if (context.isVerbose()) {
-            argList.add("-verbose");
+            compiler.setVerbose(true);
         }
-
+        
         if ("1.5".equals(System.getProperty("java.specification.version"))) {
-            argList.add("-target");
-            argList.add("1.5");
+            compiler.setTarget("1.5");
         }
-        
         if (context.get(ToolConstants.CFG_CLASSDIR) != null) {
-            argList.add("-d");
-            String classDir = (String)context.get(ToolConstants.CFG_CLASSDIR);
-            argList.add(classDir.replace(File.pathSeparatorChar, '/'));
+            compiler.setOutputDir((String)context.get(ToolConstants.CFG_CLASSDIR));
         }
-
-        if (!classpathSetted) {
-            argList.add("-extdirs");
-            argList.add(getClass().getClassLoader().getResource(".").getFile() + "../lib/");
-        } else {
-            argList.add("-classpath");
+        
+        String javaClasspath = System.getProperty("java.class.path");
+        if (javaClasspath != null) {
             if (context.get(ToolConstants.CFG_OUTPUTDIR) != null) { 
-                argList.add(javaClasspath + File.pathSeparatorChar 
+                compiler.setClassPath(javaClasspath + File.pathSeparatorChar 
                             + context.get(ToolConstants.CFG_OUTPUTDIR));
             } else {
-                argList.add(javaClasspath);
+                compiler.setClassPath(javaClasspath);
             }
         }
 
@@ -123,30 +109,8 @@
             }
 
         }
-        //Jaxb's bug . Jaxb ClassNameCollecotr may not be invoked when generated class is
an enum.
-        //So we need recheck whether we add all generated source files to  fileList
-        
-        String[] arguments = new String[argList.size() + fileList.size() + 1];
-        arguments[0] = "javac";
-        
-        int i = 1;
-        
-        for (Object obj : argList.toArray()) {
-            String arg = (String)obj;
-            arguments[i] = arg;
-            i++;
-        }
-        
-        int srcFileIndex = i; 
-        for (Object o : fileList.toArray()) {
-            String file = (String)o;
-            arguments[i] = file;
-            i++;
-        }
-
-        Compiler compiler = new Compiler();
 
-        if (!compiler.internalCompile(arguments, srcFileIndex)) {
+        if (!compiler.compileFiles(fileList.toArray(new String[fileList.size()]))) {
             Message msg = new Message("FAIL_TO_COMPILE_GENERATE_CODES", LOG);
             throw new ToolException(msg);
         }        

Modified: cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java?rev=903389&r1=903388&r2=903389&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
Tue Jan 26 19:59:57 2010
@@ -45,8 +45,9 @@
 import org.apache.cxf.tools.util.ToolsStaxUtils;
 import org.junit.After;
 import org.junit.Assert;
-import org.junit.Before;
 import org.junit.ComparisonFailure;
+import org.junit.Rule;
+import org.junit.rules.TemporaryFolder;
 
 public class ProcessorTestBase extends Assert {
 
@@ -56,21 +57,23 @@
                                                                                       "version"});
     public static final List<String> DEFAULT_IGNORE_TAG = Arrays.asList(new String[]{"sequence"});
 
-    protected ToolContext env = new ToolContext();
+    //CHECKSTYLE:OFF
+    @Rule
+    public TemporaryFolder tmpDir = new TemporaryFolder() {
+        protected void before() throws Throwable {
+            super.before();
+            output = tmpDir.getRoot();
+            env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
+        }
+    };
+    //CHECKSTYLE:ON
+    
     protected File output;
+    protected ToolContext env = new ToolContext();
 
-    @Before
-    public void setUp() throws Exception {
-        URL url = getClass().getResource(".");
-        output = new File(url.toURI());
-        output = new File(output, "/generated");
-        FileUtils.mkDir(output);
-    }
 
     @After
     public void tearDown() {
-        FileUtils.removeDir(output);
-        output = null;
         env = null;
     }
 

Modified: cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/BeanGenerator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/BeanGenerator.java?rev=903389&r1=903388&r2=903389&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/BeanGenerator.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/BeanGenerator.java
Tue Jan 26 19:59:57 2010
@@ -81,12 +81,12 @@
         
                 //compile the classes
             Compiler compiler = new Compiler();
-
+            compiler.setOutputDir(compileToDir);
             List<String> files = new ArrayList<String>(generatedFiles.size());
             for (File file : generatedFiles) {
                 files.add(file.getAbsolutePath());
             }
-            if (!compiler.compileFiles(files.toArray(new String[files.size()]), compileToDir))
{
+            if (!compiler.compileFiles(files.toArray(new String[files.size()]))) {
                 // TODO - compile issue
             }
 

Modified: cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java?rev=903389&r1=903388&r2=903389&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
Tue Jan 26 19:59:57 2010
@@ -116,7 +116,8 @@
         String[] files = new String[]{client.getAbsoluteFile().toString(),
                                      server.getAbsoluteFile().toString(),
                                      impl.getAbsoluteFile().toString()};
-        compiler.compileFiles(files, this.classDir);
+        compiler.setOutputDir(this.classDir);
+        compiler.compileFiles(files);
     }
 
     @Test
@@ -150,7 +151,8 @@
         String[] files = new String[]{client.getAbsoluteFile().toString(),
                                      server.getAbsoluteFile().toString(),
                                      impl.getAbsoluteFile().toString()};
-        compiler.compileFiles(files, this.classDir);
+        compiler.setOutputDir(this.classDir);
+        compiler.compileFiles(files);
 
 
     }

Modified: cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/DateTypeCustomGeneratorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/DateTypeCustomGeneratorTest.java?rev=903389&r1=903388&r2=903389&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/DateTypeCustomGeneratorTest.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/DateTypeCustomGeneratorTest.java
Tue Jan 26 19:59:57 2010
@@ -41,7 +41,6 @@
 
     @Before
     public void setUp() throws Exception {
-        super.setUp();
         processor.setEnvironment(env);
     }
 

Modified: cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/FaultBeanGeneratorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/FaultBeanGeneratorTest.java?rev=903389&r1=903388&r2=903389&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/FaultBeanGeneratorTest.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/FaultBeanGeneratorTest.java
Tue Jan 26 19:59:57 2010
@@ -39,7 +39,6 @@
     String classPath = "";
     @Before
     public void setUp() throws Exception {
-        super.setUp();
         classPath = System.getProperty("java.class.path");
         System.setProperty("java.class.path", getClassPath());
         processor.setEnvironment(env);

Modified: cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WrapperBeanGeneratorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WrapperBeanGeneratorTest.java?rev=903389&r1=903388&r2=903389&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WrapperBeanGeneratorTest.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WrapperBeanGeneratorTest.java
Tue Jan 26 19:59:57 2010
@@ -22,6 +22,8 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.lang.reflect.Field;
+import java.net.URL;
+import java.net.URLClassLoader;
 
 import javax.xml.bind.annotation.XmlList;
 
@@ -30,33 +32,33 @@
 import org.apache.cxf.tools.common.ProcessorTestBase;
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.java2wsdl.processor.JavaToWSDLProcessor;
-import org.apache.cxf.tools.util.AnnotationUtil;
-import org.junit.After;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExternalResource;
 
 public class WrapperBeanGeneratorTest extends ProcessorTestBase {
     JavaToWSDLProcessor processor = new JavaToWSDLProcessor();
-    String classPath = "";
     ClassLoader classLoader;
 
+    //CHECKSTYLE:OFF
+    @Rule 
+    public ExternalResource envRule = new ExternalResource() {
+        protected void before() throws Throwable {
+            System.setProperty("java.class.path", getClassPath() + tmpDir.getRoot().getCanonicalPath()
+                                                  + File.separatorChar);
+            classLoader = new URLClassLoader(new URL[] {tmpDir.getRoot().toURI().toURL()},
+                                             Thread.currentThread().getContextClassLoader());
+        }
+    };
+    //CHECKSTYLE:ON
+    
+    
     @Before
     public void setUp() throws Exception {
-        super.setUp();        
-        classPath = System.getProperty("java.class.path");
-        String pathSeparator = System.getProperty("path.separator");
-        System.setProperty("java.class.path", getClassPath() + pathSeparator + output.getPath());
-        classLoader = AnnotationUtil.getClassLoader(Thread.currentThread().getContextClassLoader());
         processor.setEnvironment(env);
-        
     }
 
-    @After
-    public void tearDown() {
-        super.tearDown();
-        System.setProperty("java.class.path", classPath);
-    }
-    
     private ServiceInfo getServiceInfo() {
         return processor.getServiceBuilder().createService();
     }

Modified: cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderNoAnnoTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderNoAnnoTest.java?rev=903389&r1=903388&r2=903389&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderNoAnnoTest.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderNoAnnoTest.java
Tue Jan 26 19:59:57 2010
@@ -38,7 +38,6 @@
 
     @Before
     public void setUp() throws Exception {
-        super.setUp();
         JAXBDataBinding.clearCaches();
         builder.setBus(BusFactory.getDefaultBus());
         generator.setBus(builder.getBus());

Modified: cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderRPCTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderRPCTest.java?rev=903389&r1=903388&r2=903389&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderRPCTest.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderRPCTest.java
Tue Jan 26 19:59:57 2010
@@ -36,7 +36,6 @@
 
     @Before
     public void setUp() throws Exception {
-        super.setUp();
         JAXBDataBinding.clearCaches();
         builder.setBus(BusFactory.getDefaultBus());
         generator.setBus(builder.getBus());

Modified: cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java?rev=903389&r1=903388&r2=903389&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
Tue Jan 26 19:59:57 2010
@@ -49,7 +49,6 @@
 
     @Before
     public void setUp() throws Exception {
-        super.setUp();
         JAXBDataBinding.clearCaches();
         builder = new JaxwsServiceBuilder();
         builder.setBus(BusFactory.getDefaultBus());

Modified: cxf/branches/2.2.x-fixes/tools/wsdlto/core/src/test/java/org/apache/cxf/tools/wsdlto/core/AbstractGeneratorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/wsdlto/core/src/test/java/org/apache/cxf/tools/wsdlto/core/AbstractGeneratorTest.java?rev=903389&r1=903388&r2=903389&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/wsdlto/core/src/test/java/org/apache/cxf/tools/wsdlto/core/AbstractGeneratorTest.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/wsdlto/core/src/test/java/org/apache/cxf/tools/wsdlto/core/AbstractGeneratorTest.java
Tue Jan 26 19:59:57 2010
@@ -25,7 +25,6 @@
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.common.ToolContext;
 import org.apache.cxf.tools.util.FileWriterUtil;
-import org.junit.Before;
 import org.junit.Test;
 
 public class AbstractGeneratorTest extends ProcessorTestBase {
@@ -37,10 +36,8 @@
     String packageName = "org.apache";
     String className = "Hello";
 
-    @Before
-    public void setUp() throws Exception {
-        super.setUp();
-
+    @Test
+    public void testKeep() throws Exception {
         gen = new DummyGenerator();
         util = new FileWriterUtil(output.toString());
 
@@ -52,16 +49,26 @@
         writer.write("hello world");
         writer.flush();
         writer.close();
-    }
 
-    @Test
-    public void testKeep() throws Exception {
         context.put(ToolConstants.CFG_GEN_NEW_ONLY, "keep");
         assertNull(gen.parseOutputName(packageName, className));
     }
 
     @Test
     public void testOverwrite() throws Exception {
+        gen = new DummyGenerator();
+        util = new FileWriterUtil(output.toString());
+
+        context = new ToolContext();
+        context.put(ToolConstants.CFG_OUTPUTDIR, output.toString());
+
+        gen.setEnvironment(context);
+
+        Writer writer = util.getWriter(packageName, className + ".java");
+        writer.write("hello world");
+        writer.flush();
+        writer.close();
+
         assertNotNull(gen.parseOutputName(packageName, className));
     }
 }

Modified: cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/test/java/org/apache/cxf/tools/misc/processor/WSDLToServiceProcessorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/test/java/org/apache/cxf/tools/misc/processor/WSDLToServiceProcessorTest.java?rev=903389&r1=903388&r2=903389&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/test/java/org/apache/cxf/tools/misc/processor/WSDLToServiceProcessorTest.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/test/java/org/apache/cxf/tools/misc/processor/WSDLToServiceProcessorTest.java
Tue Jan 26 19:59:57 2010
@@ -42,8 +42,6 @@
 
     @Before
     public void setUp() throws Exception {
-        super.setUp();
-        env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
         env.put(Bus.class, BusFactory.getDefaultBus());
     }
 

Modified: cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/test/java/org/apache/cxf/tools/misc/processor/WSDLToSoapProcessorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/test/java/org/apache/cxf/tools/misc/processor/WSDLToSoapProcessorTest.java?rev=903389&r1=903388&r2=903389&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/test/java/org/apache/cxf/tools/misc/processor/WSDLToSoapProcessorTest.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/test/java/org/apache/cxf/tools/misc/processor/WSDLToSoapProcessorTest.java
Tue Jan 26 19:59:57 2010
@@ -54,8 +54,6 @@
 
     @Before
     public void setUp() throws Exception {
-        super.setUp();
-        env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
         env.put(Bus.class, BusFactory.getDefaultBus());
     }
 

Modified: cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/test/java/org/apache/cxf/tools/misc/processor/WSDLToXMLProcessorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/test/java/org/apache/cxf/tools/misc/processor/WSDLToXMLProcessorTest.java?rev=903389&r1=903388&r2=903389&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/test/java/org/apache/cxf/tools/misc/processor/WSDLToXMLProcessorTest.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/test/java/org/apache/cxf/tools/misc/processor/WSDLToXMLProcessorTest.java
Tue Jan 26 19:59:57 2010
@@ -33,7 +33,6 @@
 import org.apache.cxf.bindings.xformat.XMLBindingMessageFormat;
 import org.apache.cxf.bindings.xformat.XMLFormatBinding;
 import org.apache.cxf.tools.common.ProcessorTestBase;
-import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.misc.WSDLToXML;
 import org.junit.Before;
 import org.junit.Test;
@@ -43,8 +42,6 @@
 
     @Before
     public void setUp() throws Exception {
-        super.setUp();
-        env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
         env.put(Bus.class, BusFactory.getDefaultBus());
     }
 

Modified: cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/test/java/org/apache/cxf/tools/misc/processor/XSDToWSDLProcessorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/test/java/org/apache/cxf/tools/misc/processor/XSDToWSDLProcessorTest.java?rev=903389&r1=903388&r2=903389&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/test/java/org/apache/cxf/tools/misc/processor/XSDToWSDLProcessorTest.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/test/java/org/apache/cxf/tools/misc/processor/XSDToWSDLProcessorTest.java
Tue Jan 26 19:59:57 2010
@@ -24,20 +24,12 @@
 import java.net.URISyntaxException;
 
 import org.apache.cxf.tools.common.ProcessorTestBase;
-import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.misc.XSDToWSDL;
-import org.junit.Before;
 import org.junit.Test;
 
 public class XSDToWSDLProcessorTest
     extends ProcessorTestBase {
     
-    @Before
-    public void setUp() throws Exception {
-        super.setUp();
-        env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
-    }
-
     @Test
     public void testNewTypes() throws Exception {
         String[] args = new String[] {"-t", "http://org.apache/invoice", "-n", "Invoice",
"-d",

Modified: cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/AbstractCodeGenTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/AbstractCodeGenTest.java?rev=903389&r1=903388&r2=903389&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/AbstractCodeGenTest.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/AbstractCodeGenTest.java
Tue Jan 26 19:59:57 2010
@@ -19,47 +19,53 @@
 package org.apache.cxf.tools.wsdlto;
 
 import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
 
 import org.apache.cxf.tools.common.ProcessorTestBase;
 import org.apache.cxf.tools.common.ToolConstants;
-import org.apache.cxf.tools.util.AnnotationUtil;
 import org.apache.cxf.tools.wsdlto.core.DataBindingProfile;
 import org.apache.cxf.tools.wsdlto.core.FrontEndProfile;
 import org.apache.cxf.tools.wsdlto.core.PluginLoader;
 import org.apache.cxf.tools.wsdlto.frontend.jaxws.JAXWSContainer;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Rule;
+import org.junit.rules.ExternalResource;
 
 public abstract class AbstractCodeGenTest extends ProcessorTestBase {
 
+    //CHECKSTYLE:OFF
+    @Rule 
+    public ExternalResource envRule = new ExternalResource() {
+        protected void before() throws Throwable {
+            File classFile = tmpDir.newFolder("classes");
+            classFile.mkdir();
+            classLoader = new URLClassLoader(new URL[] {classFile.toURI().toURL()},
+                                             Thread.currentThread().getContextClassLoader());
+            env.put(ToolConstants.CFG_COMPILE, ToolConstants.CFG_COMPILE);
+            env.put(ToolConstants.CFG_CLASSDIR, classFile.toString());
+            env.put(FrontEndProfile.class, PluginLoader.getInstance().getFrontEndProfile("jaxws"));
+            env.put(DataBindingProfile.class, PluginLoader.getInstance().getDataBindingProfile("jaxb"));
+            env.put(ToolConstants.CFG_IMPL, "impl");
+            env.put(ToolConstants.CFG_OUTPUTDIR, tmpDir.getRoot().toString());
+            env.put(ToolConstants.CFG_SUPPRESS_WARNINGS, true);
+        }
+    };
+    //CHECKSTYLE:ON
+    
+    
     protected JAXWSContainer processor;
     protected ClassLoader classLoader;
-    protected String origCP;
 
     @Before
     public void setUp() throws Exception {
-        super.setUp();
-        File classFile = new java.io.File(output.getCanonicalPath() + "/classes");
-        classFile.mkdir();
-        origCP = System.getProperty("java.class.path");
-        System.setProperty("java.class.path", getClassPath() + classFile.getCanonicalPath()
-                                              + File.separatorChar);
-        classLoader = AnnotationUtil.getClassLoader(Thread.currentThread().getContextClassLoader());
-        env.put(ToolConstants.CFG_COMPILE, ToolConstants.CFG_COMPILE);
-        env.put(ToolConstants.CFG_CLASSDIR, output.getCanonicalPath() + "/classes");
-        env.put(FrontEndProfile.class, PluginLoader.getInstance().getFrontEndProfile("jaxws"));
-        env.put(DataBindingProfile.class, PluginLoader.getInstance().getDataBindingProfile("jaxb"));
-        env.put(ToolConstants.CFG_IMPL, "impl");
-        env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
-        env.put(ToolConstants.CFG_SUPPRESS_WARNINGS, true);
-    
         processor = new JAXWSContainer(null);
     
     }
 
     @After
     public void tearDown() {
-        System.setProperty("java.class.path", origCP);
         processor = null;
         env = null;
         super.tearDown();

Modified: cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CatalogTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CatalogTest.java?rev=903389&r1=903388&r2=903389&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CatalogTest.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CatalogTest.java
Tue Jan 26 19:59:57 2010
@@ -33,11 +33,9 @@
 
     @Before
     public void setUp() throws Exception {
-        super.setUp();
         env.put(FrontEndProfile.class, PluginLoader.getInstance().getFrontEndProfile("jaxws"));
         env.put(DataBindingProfile.class, PluginLoader.getInstance().getDataBindingProfile("jaxb"));
 
-        env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
         processor = new JAXWSContainer(null);
     }
 

Modified: cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java?rev=903389&r1=903388&r2=903389&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
Tue Jan 26 19:59:57 2010
@@ -44,9 +44,11 @@
 import org.apache.cxf.wsdl11.WSDLRuntimeException;
 
 import org.junit.Test;
+
 import org.mortbay.jetty.Server;
 import org.mortbay.jetty.handler.ResourceHandler;
 
+
 public class CodeGenBugTest extends AbstractCodeGenTest {
     
     

Modified: cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/JAXWSBindingTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/JAXWSBindingTest.java?rev=903389&r1=903388&r2=903389&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/JAXWSBindingTest.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/JAXWSBindingTest.java
Tue Jan 26 19:59:57 2010
@@ -37,11 +37,8 @@
 
     @Before
     public void setUp() throws Exception {
-
-        super.setUp();
         env.put(FrontEndProfile.class, PluginLoader.getInstance().getFrontEndProfile("jaxws"));
         env.put(DataBindingProfile.class, PluginLoader.getInstance().getDataBindingProfile("jaxb"));
-        env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
 
         processor = new JAXWSContainer(null);
     }

Modified: cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/validator/ValidatorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/validator/ValidatorTest.java?rev=903389&r1=903388&r2=903389&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/validator/ValidatorTest.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/validator/ValidatorTest.java
Tue Jan 26 19:59:57 2010
@@ -34,11 +34,9 @@
 
     @Before
     public void setUp() throws Exception {
-        super.setUp();
         env.put(ToolConstants.CFG_VERBOSE, ToolConstants.CFG_VERBOSE);
         env.put(FrontEndProfile.class, PluginLoader.getInstance().getFrontEndProfile("jaxws"));
         env.put(DataBindingProfile.class, PluginLoader.getInstance().getDataBindingProfile("jaxb"));
-        env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());        
     }
     
     @Test

Modified: cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/xmlbeans/XmlbeansBindingTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/xmlbeans/XmlbeansBindingTest.java?rev=903389&r1=903388&r2=903389&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/xmlbeans/XmlbeansBindingTest.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/xmlbeans/XmlbeansBindingTest.java
Tue Jan 26 19:59:57 2010
@@ -24,27 +24,10 @@
 import org.apache.cxf.helpers.FileUtils;
 import org.apache.cxf.tools.common.ProcessorTestBase;
 import org.apache.cxf.tools.wsdlto.WSDLToJava;
-import org.junit.After;
-import org.junit.Before;
 import org.junit.Test;
 
 public class XmlbeansBindingTest extends ProcessorTestBase {
     
-    @Before
-    public void setUp() throws Exception {
-        super.setUp();
-        File classFile = new java.io.File(output.getCanonicalPath() + "/classes");
-        classFile.mkdir();
-        System.setProperty("java.class.path", getClassPath() + classFile.getCanonicalPath()
-                                              + File.separatorChar);
-
-    }
-
-    @After
-    public void tearDown() {
-        //super.tearDown();
-    }
-    
     @Test
     public void testEmbeddedSchema() throws Exception {
         



Mime
View raw message