You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by po...@apache.org on 2017/09/03 17:33:22 UTC

[29/51] [partial] incubator-netbeans-jackpot30 git commit: INFRA-15006 Import for http://bits.netbeans.org/download/apache-donation

http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/remoting/common/borrowedtests/src/org/netbeans/api/java/source/SourceUtilsTestUtil.java
----------------------------------------------------------------------
diff --git a/remoting/common/borrowedtests/src/org/netbeans/api/java/source/SourceUtilsTestUtil.java b/remoting/common/borrowedtests/src/org/netbeans/api/java/source/SourceUtilsTestUtil.java
new file mode 100644
index 0000000..4aaae65
--- /dev/null
+++ b/remoting/common/borrowedtests/src/org/netbeans/api/java/source/SourceUtilsTestUtil.java
@@ -0,0 +1,441 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ */
+package org.netbeans.api.java.source;
+
+import com.sun.source.util.JavacTask;
+import java.beans.PropertyVetoException;
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.WeakHashMap;
+import java.util.logging.Logger;
+import java.util.logging.Level;
+import java.util.regex.Pattern;
+import javax.swing.event.ChangeListener;
+import junit.framework.Assert;
+import org.netbeans.api.editor.mimelookup.MimePath;
+import org.netbeans.api.java.classpath.ClassPath;
+import org.netbeans.api.java.queries.SourceForBinaryQuery;
+import org.netbeans.api.java.source.JavaSource.Phase;
+import org.netbeans.junit.NbTestCase;
+import org.netbeans.modules.java.JavaDataLoader;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer;
+import org.netbeans.modules.java.source.parsing.JavacParser;
+import org.netbeans.modules.java.source.parsing.JavacParserFactory;
+import org.netbeans.modules.java.source.usages.IndexUtil;
+import org.netbeans.modules.parsing.api.indexing.IndexingManager;
+import org.netbeans.modules.parsing.impl.indexing.MimeTypes;
+import org.netbeans.spi.editor.mimelookup.MimeDataProvider;
+import org.netbeans.spi.java.classpath.ClassPathProvider;
+import org.netbeans.spi.java.classpath.support.ClassPathSupport;
+import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
+import org.netbeans.spi.java.queries.SourceLevelQueryImplementation;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileStateInvalidException;
+import org.openide.filesystems.FileSystem;
+import org.openide.filesystems.FileUtil;
+import org.openide.filesystems.LocalFileSystem;
+import org.openide.filesystems.MIMEResolver;
+import org.openide.filesystems.MultiFileSystem;
+import org.openide.filesystems.Repository;
+import org.openide.filesystems.URLMapper;
+import org.openide.filesystems.XMLFileSystem;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.Lookups;
+import org.openide.util.lookup.ProxyLookup;
+import org.openide.util.lookup.ServiceProvider;
+import org.xml.sax.SAXException;
+
+/**
+ *
+ * @author Jan Lahoda
+ */
+public final class SourceUtilsTestUtil extends ProxyLookup {
+    
+    private static SourceUtilsTestUtil DEFAULT_LOOKUP = null;
+    
+    public SourceUtilsTestUtil() {
+//        Assert.assertNull(DEFAULT_LOOKUP);
+        DEFAULT_LOOKUP = this;
+    }
+    
+    /**
+     * Set the global default lookup with some fixed instances including META-INF/services/*.
+     */
+    /**
+     * Set the global default lookup with some fixed instances including META-INF/services/*.
+     */
+    public static void setLookup(Object[] instances, ClassLoader cl) {
+        DEFAULT_LOOKUP.setLookups(new Lookup[] {
+            Lookups.fixed(instances),
+            Lookups.metaInfServices(cl),
+            Lookups.singleton(cl),
+        });
+    }
+    
+    private static Object[] extraLookupContent = null;
+    
+    public static void prepareTest(String[] additionalLayers, Object[] additionalLookupContent) throws IOException, SAXException, PropertyVetoException {
+        List<URL> layers = new LinkedList<URL>();
+        
+        for (int cntr = 0; cntr < additionalLayers.length; cntr++) {
+            boolean found = false;
+
+            for (Enumeration<URL> en = Thread.currentThread().getContextClassLoader().getResources(additionalLayers[cntr]); en.hasMoreElements(); ) {
+                found = true;
+                layers.add(en.nextElement());
+            }
+
+            Assert.assertTrue(additionalLayers[cntr], found);
+        }
+        
+        XMLFileSystem xmlFS = new XMLFileSystem();
+        xmlFS.setXmlUrls(layers.toArray(new URL[0]));
+        
+        FileSystem system = new MultiFileSystem(new FileSystem[] {FileUtil.createMemoryFileSystem(), xmlFS});
+        
+        Repository repository = new Repository(system);
+        extraLookupContent = new Object[additionalLookupContent.length + 1];
+        
+        System.arraycopy(additionalLookupContent, 0, extraLookupContent, 1, additionalLookupContent.length);
+        
+        extraLookupContent[0] = repository;
+        
+        SourceUtilsTestUtil.setLookup(extraLookupContent, SourceUtilsTestUtil.class.getClassLoader());
+        
+        SourceUtilsTestUtil2.disableLocks();
+
+        Set<String> mimeTypes = MimeTypes.getAllMimeTypes();
+
+        if (mimeTypes == null) {
+            mimeTypes = new HashSet<String>();
+        } else {
+            mimeTypes = new HashSet<String>(mimeTypes);
+        }
+
+        mimeTypes.add("text/x-java");
+
+        MimeTypes.setAllMimeTypes(mimeTypes);
+        org.netbeans.api.project.ui.OpenProjects.getDefault().getOpenProjects();
+    }
+    
+    static {
+        SourceUtilsTestUtil.class.getClassLoader().setDefaultAssertionStatus(true);
+        System.setProperty("org.openide.util.Lookup", SourceUtilsTestUtil.class.getName());
+        Assert.assertEquals(SourceUtilsTestUtil.class, Lookup.getDefault().getClass());
+    }
+    
+    public static void prepareTest(FileObject sourceRoot, FileObject buildRoot, FileObject cache) throws Exception {
+        prepareTest(sourceRoot, buildRoot, cache, new FileObject[0]);
+    }
+    
+    public static void prepareTest(FileObject sourceRoot, FileObject buildRoot, FileObject cache, FileObject[] classPathElements) throws Exception {
+        if (extraLookupContent == null)
+            prepareTest(new String[0], new Object[0]);
+        
+        Object[] lookupContent = new Object[extraLookupContent.length + 4];
+        
+        System.arraycopy(extraLookupContent, 0, lookupContent, 4, extraLookupContent.length);
+        
+        lookupContent[0] = new TestProxyClassPathProvider(sourceRoot, buildRoot, classPathElements);
+        lookupContent[1] = new TestSourceForBinaryQuery(sourceRoot, buildRoot);
+        lookupContent[2] = new TestSourceLevelQueryImplementation();
+        lookupContent[3] = JavaDataLoader.getLoader(JavaDataLoader.class);
+        
+        setLookup(lookupContent, SourceUtilsTestUtil.class.getClassLoader());
+
+        IndexUtil.setCacheFolder(FileUtil.toFile(cache));
+    }
+
+    private static Map<FileObject,  String> file2SourceLevel = new WeakHashMap<FileObject, String>();
+    
+    public static void setSourceLevel(FileObject file, String level) {
+        file2SourceLevel.put(file, level);
+    }
+
+    /**This method assures that all java classes under sourceRoot are compiled,
+     * and the caches are created for them.
+     */
+    public static void compileRecursively(FileObject sourceRoot) throws Exception {
+        IndexingManager.getDefault().refreshIndexAndWait(sourceRoot.getURL(), null);
+    }
+
+    private static List<URL> bootClassPath;
+
+    private static Logger log = Logger.getLogger(SourceUtilsTestUtil.class.getName());
+    
+    public static synchronized List<URL> getBootClassPath() {
+        if (bootClassPath == null) {
+            try {
+                String cp = System.getProperty("sun.boot.class.path");
+                List<URL> urls = new ArrayList<URL>();
+                String[] paths = cp.split(Pattern.quote(System.getProperty("path.separator")));
+                
+                for (String path : paths) {
+                    File f = new File(path);
+                    
+                    if (!f.canRead())
+                        continue;
+                    
+                    FileObject fo = FileUtil.toFileObject(f);
+                    
+                    if (FileUtil.isArchiveFile(fo)) {
+                        fo = FileUtil.getArchiveRoot(fo);
+                    }
+                    
+                    if (fo != null) {
+                        urls.add(fo.getURL());
+                    }
+                }
+                
+                bootClassPath = urls;
+            } catch (FileStateInvalidException e) {
+                if (log.isLoggable(Level.SEVERE))
+                    log.log(Level.SEVERE, e.getMessage(), e);
+            }
+        }
+
+        return bootClassPath;
+    }
+
+    private static class TestSourceForBinaryQuery implements SourceForBinaryQueryImplementation {
+        
+        private final FileObject sourceRoot;
+        private final FileObject buildRoot;
+        
+        public TestSourceForBinaryQuery(FileObject sourceRoot, FileObject buildRoot) {
+            this.sourceRoot = sourceRoot;
+            this.buildRoot = buildRoot;
+        }
+        
+        public SourceForBinaryQuery.Result findSourceRoots(URL binaryRoot) {
+            FileObject f = URLMapper.findFileObject(binaryRoot);
+
+            if (buildRoot.equals(f)) {
+                return new SourceForBinaryQuery.Result() {
+                    public FileObject[] getRoots() {
+                        return new FileObject[] {
+                            sourceRoot,
+                        };
+                    }
+
+                    public void addChangeListener(ChangeListener l) {
+                    }
+
+                    public void removeChangeListener(ChangeListener l) {
+                    }
+                };
+            }
+
+            return null;
+        }
+        
+    }
+    
+    private static class TestProxyClassPathProvider implements ClassPathProvider {
+        
+        private FileObject sourceRoot;
+        private FileObject buildRoot;
+        private FileObject[] classPathElements;
+        
+        public TestProxyClassPathProvider(FileObject sourceRoot, FileObject buildRoot, FileObject[] classPathElements) {
+            this.sourceRoot = sourceRoot;
+            this.buildRoot = buildRoot;
+            this.classPathElements = classPathElements;
+        }
+        
+        public ClassPath findClassPath(FileObject file, String type) {
+            try {
+            if (ClassPath.BOOT == type) {
+                return ClassPathSupport.createClassPath(getBootClassPath().toArray(new URL[0]));
+            }
+            
+            if (ClassPath.SOURCE == type) {
+                return ClassPathSupport.createClassPath(new FileObject[] {
+                    sourceRoot
+                });
+            }
+            
+            if (ClassPath.COMPILE == type) {
+                return ClassPathSupport.createClassPath(classPathElements);
+            }
+            
+            if (ClassPath.EXECUTE == type) {
+                return ClassPathSupport.createClassPath(new FileObject[] {
+                    buildRoot
+                });
+            }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            return null;
+        }
+        
+    }
+
+    public static class TestSourceLevelQueryImplementation implements SourceLevelQueryImplementation {
+        
+        public String getSourceLevel(FileObject javaFile) {
+            String level = file2SourceLevel.get(javaFile);
+            
+            if (level == null) {
+                if (javaFile.isFolder()) {
+                    for (FileObject data : file2SourceLevel.keySet()) {
+                        if (FileUtil.isParentOf(javaFile, data)) {
+                            return file2SourceLevel.get(data);
+                        }
+                    }
+                }
+                return "1.5";
+            } else
+                return level;
+        }
+        
+    }
+
+    /**Copied from org.netbeans.api.project.
+     * Create a scratch directory for tests.
+     * Will be in /tmp or whatever, and will be empty.
+     * If you just need a java.io.File use clearWorkDir + getWorkDir.
+     */
+    public static FileObject makeScratchDir(NbTestCase test) throws IOException {
+        test.clearWorkDir();
+        File root = test.getWorkDir();
+        assert root.isDirectory() && root.list().length == 0;
+        FileObject fo = FileUtil.toFileObject(root);
+        if (fo != null) {
+            // Presumably using masterfs.
+            return fo;
+        } else {
+            // For the benefit of those not using masterfs.
+            LocalFileSystem lfs = new LocalFileSystem();
+            try {
+                lfs.setRootDirectory(root);
+            } catch (PropertyVetoException e) {
+                assert false : e;
+            }
+            Repository.getDefault().addFileSystem(lfs);
+            return lfs.getRoot();
+        }
+    }
+    
+    public static JavacTask getJavacTaskFor(CompilationInfo info) {
+        return info.impl.getJavacTask();
+    }
+    
+    /** Blocking call for CompilationInfo after given phase is reached.
+     *  @param phase to be reached
+     *  @return CompilationInfo or null
+     *  XXX: REMOVE ME!!!!!!!
+     */
+    public static CompilationInfo getCompilationInfo(JavaSource js, Phase phase ) throws IOException {        
+        if (phase == null || phase == Phase.MODIFIED) { 
+            throw new IllegalArgumentException (String.format("The %s is not a legal value of phase",phase));   //NOI18N
+        }
+        final DeadlockTask bt = new DeadlockTask(phase);
+        js.runUserActionTask(bt,true);
+        return bt.info;
+    }
+    
+    
+    private static class DeadlockTask implements Task<CompilationController> {
+        
+        private final Phase phase;
+        private CompilationInfo info;
+        
+        public DeadlockTask(Phase phase) {
+            assert phase != null;
+            this.phase = phase;
+        }
+        
+        public void run( CompilationController info ) {
+            try {
+                info.toPhase(this.phase);
+                this.info = info;
+            } catch (IOException ioe) {
+                if (log.isLoggable(Level.SEVERE))
+                    log.log(Level.SEVERE, ioe.getMessage(), ioe);
+            }
+        }                
+        
+    }
+
+    @ServiceProvider(service=MimeDataProvider.class)
+    public static final class JavacParserProvider implements MimeDataProvider {
+
+        private Lookup javaLookup = Lookups.fixed(new JavacParserFactory(), new JavaCustomIndexer.Factory());
+
+        public Lookup getLookup(MimePath mimePath) {
+            if (mimePath.getPath().endsWith(JavacParser.MIME_TYPE)) {
+                return javaLookup;
+            }
+
+            return Lookup.EMPTY;
+        }
+        
+    }
+
+    @ServiceProvider(service=MIMEResolver.class)
+    public static final class JavaMimeResolver extends MIMEResolver {
+
+        public JavaMimeResolver() {
+            super(JavacParser.MIME_TYPE);
+        }
+
+        @Override
+        public String findMIMEType(FileObject fo) {
+            if ("java".equals(fo.getExt())) {
+                return JavacParser.MIME_TYPE;
+            }
+
+            return null;
+        }
+
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/remoting/common/borrowedtests/src/org/netbeans/api/java/source/SourceUtilsTestUtil2.java
----------------------------------------------------------------------
diff --git a/remoting/common/borrowedtests/src/org/netbeans/api/java/source/SourceUtilsTestUtil2.java b/remoting/common/borrowedtests/src/org/netbeans/api/java/source/SourceUtilsTestUtil2.java
new file mode 100644
index 0000000..b2920c3
--- /dev/null
+++ b/remoting/common/borrowedtests/src/org/netbeans/api/java/source/SourceUtilsTestUtil2.java
@@ -0,0 +1,80 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ */
+package org.netbeans.api.java.source;
+
+import com.sun.source.tree.Tree;
+import org.apache.lucene.store.FSDirectory;
+import org.netbeans.modules.java.source.transform.Transformer;
+
+/**
+ *
+ * @author Jan Lahoda
+ */
+public final class SourceUtilsTestUtil2 {
+
+    private SourceUtilsTestUtil2() {
+    }
+
+    public static <R, P> void run(WorkingCopy wc, Transformer<R, P> t) {
+//        if (afterCommit)
+//            throw new IllegalStateException ("The run method can't be called on a WorkingCopy instance after the commit");   //NOI18N
+        t.init();
+        t.attach(wc.impl.getJavacTask().getContext(), wc);
+        t.apply(wc.getCompilationUnit());
+        t.release();
+        t.destroy();
+    }
+    
+    public static <R, P> void run(WorkingCopy wc, Transformer<R, P> t, Tree tree) {
+//        if (afterCommit)
+//            throw new IllegalStateException ("The run method can't be called on a WorkingCopy instance after the commit");   //NOI18N
+        t.init();
+        t.attach(wc.impl.getJavacTask().getContext(), wc);
+        t.apply(tree);
+        t.release();
+        t.destroy();
+    }
+    
+    public static void disableLocks() {
+//        FSDirectory.setDisableLocks(true);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/remoting/common/borrowedtests/src/org/netbeans/api/java/source/TestUtilities.java
----------------------------------------------------------------------
diff --git a/remoting/common/borrowedtests/src/org/netbeans/api/java/source/TestUtilities.java b/remoting/common/borrowedtests/src/org/netbeans/api/java/source/TestUtilities.java
new file mode 100644
index 0000000..62332a6
--- /dev/null
+++ b/remoting/common/borrowedtests/src/org/netbeans/api/java/source/TestUtilities.java
@@ -0,0 +1,263 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ */
+
+package org.netbeans.api.java.source;
+
+import java.io.ByteArrayInputStream;
+import java.io.EOFException;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.zip.GZIPInputStream;
+
+import org.netbeans.api.java.classpath.ClassPath;
+import org.netbeans.modules.java.source.usages.BinaryAnalyser;
+import org.netbeans.modules.java.source.usages.ClassIndexImpl;
+import org.netbeans.modules.java.source.usages.ClassIndexManager;
+import org.netbeans.modules.java.source.usages.IndexUtil;
+//import org.netbeans.modules.parsing.lucene.support.IndexManager.Action;
+import org.netbeans.spi.java.classpath.support.ClassPathSupport;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+
+/**
+ * Utilities to aid unit testing java.source module.
+ *
+ * @author Jaroslav Tulach
+ * @author Tom Ball
+ * @author Tomas Zezula
+ */
+public final class TestUtilities {
+    
+    // do not instantiate
+    private TestUtilities() {}
+    
+    /**
+     * Waits for the end of the background scan, this helper method 
+     * is designed for tests which require to wait for the end of initial scan.
+     * The method can be used as a barrier but it is not guaranteed that the
+     * background scan will not start again after return from this method, the
+     * test is responsible for it itself. In general it's safer to use {@link JavaSource#runWhenScanFinished}
+     * method and do the critical action inside the run method.
+     * @param timeout the maximum time to wait
+     * @param unit the time unit of the timeout argument
+     * @return true if the scan finished, false when the timeout elapsed before the end of the scan.
+     * @throws InterruptedException is thrown when the waiting thread is interrupted.
+     */
+    public static boolean waitScanFinished (final long timeout, final TimeUnit unit) throws InterruptedException {
+        assert unit != null;
+        final ClasspathInfo cpInfo = ClasspathInfo.create(ClassPathSupport.createClassPath(new URL[0]),
+                ClassPathSupport.createClassPath(new URL[0]), null);
+        assert cpInfo != null;
+        final JavaSource js = JavaSource.create(cpInfo);
+        assert js != null;
+        try {
+            Future<Void> future = js.runWhenScanFinished(new Task<CompilationController>() {
+                public void run(CompilationController parameter) throws Exception {
+                }
+            }, true);
+            future.get(timeout,unit);
+            return true;
+        } catch (IOException ioe) {
+            //Actually never thrown
+        }
+        catch (ExecutionException ee) {
+            //Actually never thrown
+        }
+        catch (TimeoutException timeoutEx) {
+        }
+        return false;
+    }
+    
+//    /**
+//     * Disables use of {@link LibraryManager} in the {@link GlobalSourcePath}. The tests
+//     * which don't register {@link LibraryProvider} or {@link LibraryTypeProvider} may
+//     * use this method to disable use of {@link LibraryManager} in the {@link GlobalSourcePath}.
+//     * @param use false value disables use of {@link LibraryManager}
+//     */
+//    public static void setUseLibraries (final boolean use) {
+//        //GlobalSourcePathTestUtil.setUseLibraries(use);
+//        // IMO this in fact did nothing... If your tests are failing due to this
+//        // please file a defect on editor/parsing & indexing and we will try to help.
+//    }
+    
+    /**
+     * Sets a root folder of the java source caches. This method may be used by tests
+     * which need to do an initial compilation, they require either {@link ClassIndex} or
+     * need to work with a group of related java files.
+     * @param cacheFolder the folder used by java infrastructure as a cache,
+     * has to exist and must be a folder.
+     */
+    public static void setCacheFolder (final File cacheFolder) {
+        IndexUtil.setCacheFolder(cacheFolder);
+    }
+    
+    /**
+     * Creates boot {@link ClassPath} for platform the test is running on,
+     * it uses the sun.boot.class.path property to find out the boot path roots.
+     * @return ClassPath
+     * @throws java.io.IOException when boot path property contains non valid path
+     */
+    public static ClassPath createBootClassPath () throws IOException {
+        String bootPath = System.getProperty ("sun.boot.class.path");
+        String[] paths = bootPath.split(File.pathSeparator);
+        List<URL>roots = new ArrayList<URL> (paths.length);
+        for (String path : paths) {
+            File f = new File (path);            
+            if (!f.exists()) {
+                continue;
+            }
+            URL url = f.toURI().toURL();
+            if (FileUtil.isArchiveFile(url)) {
+                url = FileUtil.getArchiveRoot(url);
+            }
+            roots.add (url);
+        }
+        return ClassPathSupport.createClassPath(roots.toArray(new URL[roots.size()]));
+    }
+    /**
+     * Returns a string which contains the contents of a file.
+     *
+     * @param f the file to be read
+     * @return the contents of the file(s).
+     */
+    public final static String copyFileToString (java.io.File f) throws java.io.IOException {
+        int s = (int)f.length ();
+        byte[] data = new byte[s];
+        int len = new FileInputStream (f).read (data);
+        if (len != s)
+            throw new EOFException("truncated file");
+        return new String (data);
+    }
+    
+    /**
+     * Returns a string which contains the contents of a GZIP compressed file.
+     *
+     * @param f the file to be read
+     * @return the contents of the file(s).
+     */
+    public final static String copyGZipFileToString (java.io.File f) throws java.io.IOException {
+        GZIPInputStream is = new GZIPInputStream(new FileInputStream(f));
+        byte[] arr = new byte[256 * 256];
+        int first = 0;
+        for(;;) {
+            int len = is.read(arr, first, arr.length - first);
+            if (first + len < arr.length) {
+                return new String(arr, 0, first + len);
+            }
+        }
+    }
+    
+    /**
+     * Copies a string to a specified file.
+     *
+     * @param f the file to use.
+     * @param content the contents of the returned file.
+     * @return the created file
+     */
+    public final static File copyStringToFile (File f, String content) throws Exception {
+        FileOutputStream os = new FileOutputStream(f);
+        InputStream is = new ByteArrayInputStream(content.getBytes("UTF-8"));
+        FileUtil.copy(is, os);
+        os.close ();
+        is.close();
+            
+        return f;
+    }
+    
+    /**
+     * Copies a string to a specified file.
+     *
+     * @param f the {@link FilObject} to use.
+     * @param content the contents of the returned file.
+     * @return the created file
+     */
+    public final static FileObject copyStringToFile (FileObject f, String content) throws Exception {
+        OutputStream os = f.getOutputStream();
+        InputStream is = new ByteArrayInputStream(content.getBytes("UTF-8"));
+        FileUtil.copy(is, os);
+        os.close ();
+        is.close();
+            
+        return f;
+    }   
+
+    private static final ClassPath EMPTY = ClassPathSupport.createClassPath(new URL[0]);
+    
+//    /**
+//     * Prepare Java caches for given binary roots.
+//     *
+//     * @param urls to analyze
+//     */
+//    public final static void analyzeBinaries(final Collection<URL> urls) throws IOException {
+//        final ClasspathInfo cpInfo = ClasspathInfo.create(EMPTY, EMPTY, EMPTY);
+//        final ClassIndexManager mgr  = ClassIndexManager.getDefault();
+//        final JavaSource js = JavaSource.create(cpInfo);
+//        js.runUserActionTask(new Task<CompilationController>() {
+//            public void run(CompilationController parameter) throws Exception {
+//                for (final URL url : urls) {
+//                    final ClassIndexImpl cii = mgr.createUsagesQuery(url, false);
+//                    ClassIndexManager.getDefault().writeLock(new Action<Void>() {
+//                        public Void run() throws IOException, InterruptedException {
+//                            BinaryAnalyser ba = cii.getBinaryAnalyser();
+//                            ba.start(url, new AtomicBoolean(false), new AtomicBoolean(false));
+//                            ba.finish();
+//                            return null;
+//                        }
+//                    });
+//                }
+//            }
+//        }, true);
+//    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/remoting/common/borrowedtests/src/org/netbeans/api/java/source/matching/MatchingTestAccessor.java
----------------------------------------------------------------------
diff --git a/remoting/common/borrowedtests/src/org/netbeans/api/java/source/matching/MatchingTestAccessor.java b/remoting/common/borrowedtests/src/org/netbeans/api/java/source/matching/MatchingTestAccessor.java
new file mode 100644
index 0000000..c3b754b
--- /dev/null
+++ b/remoting/common/borrowedtests/src/org/netbeans/api/java/source/matching/MatchingTestAccessor.java
@@ -0,0 +1,62 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2012 Sun Microsystems, Inc.
+ */
+package org.netbeans.api.java.source.matching;
+
+import com.sun.source.util.TreePath;
+import java.util.Collection;
+import java.util.Map;
+import javax.lang.model.type.TypeMirror;
+
+/**
+ *
+ * @author lahvac
+ */
+public class MatchingTestAccessor {
+
+    public static Collection<? extends TreePath> getPattern(Pattern p) {
+        return p.pattern;
+    }
+
+    public static Map<String, TypeMirror> getVariable2Type(Pattern p) {
+        return p.variable2Type;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/remoting/common/borrowedtests/src/org/netbeans/modules/jackpot30/impl/TestUtils.java
----------------------------------------------------------------------
diff --git a/remoting/common/borrowedtests/src/org/netbeans/modules/jackpot30/impl/TestUtils.java b/remoting/common/borrowedtests/src/org/netbeans/modules/jackpot30/impl/TestUtils.java
new file mode 100644
index 0000000..e14a04c
--- /dev/null
+++ b/remoting/common/borrowedtests/src/org/netbeans/modules/jackpot30/impl/TestUtils.java
@@ -0,0 +1,116 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2011 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.jackpot30.impl;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+import java.net.URLStreamHandlerFactory;
+import java.util.HashMap;
+import java.util.Map;
+import junit.framework.Assert;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ * @author lahvac
+ */
+public class TestUtils {
+
+    public static void clearRemoteContent() {
+        content.clear();
+    }
+
+    public static void addRemoteContent(URL url, String content) {
+        TestUtils.content.put(url, content);
+    }
+
+    private static final Map<URL, String> content = new HashMap<URL, String>();
+
+    @ServiceProvider(service=URLStreamHandlerFactory.class)
+    public static final class URLStreamHandlerFactoryImpl implements URLStreamHandlerFactory {
+
+        public URLStreamHandler createURLStreamHandler(String protocol) {
+            if ("test".equals(protocol)) {
+                return new URLStreamHandlerImpl();
+            }
+
+            return null;
+        }
+
+    }
+
+    private static final class URLStreamHandlerImpl extends URLStreamHandler {
+
+        @Override
+        protected URLConnection openConnection(URL u) throws IOException {
+            String str = content.get(u);
+
+            Assert.assertNotNull(u.toExternalForm(), str);
+
+            return new TestURLConnection(u, str);
+        }
+
+    }
+
+    private static final class TestURLConnection extends URLConnection {
+
+        private final String content;
+
+        public TestURLConnection(URL url, String content) {
+            super(url);
+            this.content = content;
+        }
+
+        @Override
+        public void connect() throws IOException {
+        }
+
+        @Override
+        public Object getContent() throws IOException {
+            return new ByteArrayInputStream(content.getBytes("ASCII")); //XXX
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/remoting/common/borrowedtests/src/org/netbeans/modules/jackpot30/test/borrowed/Bundle.properties
----------------------------------------------------------------------
diff --git a/remoting/common/borrowedtests/src/org/netbeans/modules/jackpot30/test/borrowed/Bundle.properties b/remoting/common/borrowedtests/src/org/netbeans/modules/jackpot30/test/borrowed/Bundle.properties
new file mode 100644
index 0000000..3e728a3
--- /dev/null
+++ b/remoting/common/borrowedtests/src/org/netbeans/modules/jackpot30/test/borrowed/Bundle.properties
@@ -0,0 +1,38 @@
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+#
+# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+#
+# The contents of this file are subject to the terms of either the GNU
+# General Public License Version 2 only ("GPL") or the Common
+# Development and Distribution License("CDDL") (collectively, the
+# "License"). You may not use this file except in compliance with the
+# License. You can obtain a copy of the License at
+# http://www.netbeans.org/cddl-gplv2.html
+# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+# specific language governing permissions and limitations under the
+# License.  When distributing the software, include this License Header
+# Notice in each file and include the License file at
+# nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Sun in the GPL Version 2 section of the License file that
+# accompanied this code. If applicable, add the following below the
+# License Header, with the fields enclosed by brackets [] replaced by
+# your own identifying information:
+# "Portions Copyrighted [year] [name of copyright owner]"
+#
+# If you wish your version of this file to be governed by only the CDDL
+# or only the GPL Version 2, indicate your decision by adding
+# "[Contributor] elects to include this software in this distribution
+# under the [CDDL or GPL Version 2] license." If you do not indicate a
+# single choice of license, a recipient has the option to distribute
+# your version of this file under either the CDDL, the GPL Version 2 or
+# to extend the choice of license to its licensees as provided above.
+# However, if you add GPL Version 2 code and therefore, elected the GPL
+# Version 2 license, then the option applies only if the new code is
+# made subject to such option by the copyright holder.
+#
+# Contributor(s):
+#
+# Portions Copyrighted 2009 Sun Microsystems, Inc.
+
+OpenIDE-Module-Name=Borrowed Test Infra

http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/remoting/common/borrowedtests/src/org/netbeans/modules/java/hints/TestUtilities.java
----------------------------------------------------------------------
diff --git a/remoting/common/borrowedtests/src/org/netbeans/modules/java/hints/TestUtilities.java b/remoting/common/borrowedtests/src/org/netbeans/modules/java/hints/TestUtilities.java
new file mode 100644
index 0000000..f936ed7
--- /dev/null
+++ b/remoting/common/borrowedtests/src/org/netbeans/modules/java/hints/TestUtilities.java
@@ -0,0 +1,60 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2007 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.java.hints;
+
+import junit.framework.Assert;
+
+/**
+ *
+ * @author Jan Lahoda
+ */
+public class TestUtilities {
+
+    private TestUtilities() {
+    }
+
+    public static String detectOffsets(String source, int[] positionOrSpan) {
+        //for now, the position/span delimiter is '|', without possibility of escaping:
+        String[] split = source.split("\\|");
+        
+        Assert.assertTrue("incorrect number of position markers (|)", positionOrSpan.length == split.length - 1);
+        
+        StringBuilder sb = new StringBuilder();
+        int index = 0;
+        int offset = 0;
+        
+        for (String s : split) {
+            sb.append(s);
+            if (index < positionOrSpan.length)
+                positionOrSpan[index++] = (offset += s.length());
+        }
+        
+        return sb.toString();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/remoting/common/borrowedtests/src/org/netbeans/modules/java/hints/infrastructure/TreeRuleTestBase.java
----------------------------------------------------------------------
diff --git a/remoting/common/borrowedtests/src/org/netbeans/modules/java/hints/infrastructure/TreeRuleTestBase.java b/remoting/common/borrowedtests/src/org/netbeans/modules/java/hints/infrastructure/TreeRuleTestBase.java
new file mode 100644
index 0000000..e4f37a9
--- /dev/null
+++ b/remoting/common/borrowedtests/src/org/netbeans/modules/java/hints/infrastructure/TreeRuleTestBase.java
@@ -0,0 +1,303 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ */
+package org.netbeans.modules.java.hints.infrastructure;
+
+import com.sun.source.util.TreePath;
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.text.Document;
+import org.netbeans.api.java.lexer.JavaTokenId;
+import org.netbeans.api.java.source.CompilationInfo;
+import org.netbeans.api.java.source.JavaSource;
+import org.netbeans.api.java.source.JavaSource.Phase;
+import org.netbeans.api.java.source.SourceUtilsTestUtil;
+import org.netbeans.api.java.source.TestUtilities;
+import org.netbeans.api.lexer.Language;
+import org.netbeans.junit.NbTestCase;
+import org.netbeans.modules.java.source.TreeLoader;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.Fix;
+import org.openide.LifecycleManager;
+import org.openide.cookies.EditorCookie;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.loaders.DataObject;
+
+/**
+ * @author Jan Lahoda
+ */
+public abstract class TreeRuleTestBase extends NbTestCase {
+    protected final Logger LOG;
+    
+    public TreeRuleTestBase(String name) {
+        super(name);
+        LOG = Logger.getLogger("test." + name);
+    }
+    
+    @Override
+    protected Level logLevel() {
+        return Level.INFO;
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        SourceUtilsTestUtil.prepareTest(new String[] {"org/netbeans/modules/java/editor/resources/layer.xml"}, new Object[0]);
+        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
+    }
+
+    private void prepareTest(String fileName, String code) throws Exception {
+        clearWorkDir();
+        File wdFile = getWorkDir();
+        FileUtil.refreshFor(wdFile);
+
+        FileObject wd = FileUtil.toFileObject(wdFile);
+        assertNotNull(wd);
+        sourceRoot = FileUtil.createFolder(wd, "src");
+        FileObject buildRoot = FileUtil.createFolder(wd, "build");
+        FileObject cache = FileUtil.createFolder(wd, "cache");
+
+        FileObject data = FileUtil.createData(sourceRoot, fileName);
+        File dataFile = FileUtil.toFile(data);
+        
+        assertNotNull(dataFile);
+        
+        TestUtilities.copyStringToFile(dataFile, code);
+        
+        SourceUtilsTestUtil.prepareTest(sourceRoot, buildRoot, cache, extraClassPath());
+        
+        DataObject od = DataObject.find(data);
+        EditorCookie ec = od.getCookie(EditorCookie.class);
+        
+        assertNotNull(ec);
+        
+        doc = ec.openDocument();
+        doc.putProperty(Language.class, JavaTokenId.language());
+        doc.putProperty("mimeType", "text/x-java");
+        
+        JavaSource js = JavaSource.forFileObject(data);
+        
+        assertNotNull(js);
+        
+        info = SourceUtilsTestUtil.getCompilationInfo(js, Phase.RESOLVED);
+        
+        assertNotNull(info);
+    }
+    
+    private FileObject sourceRoot;
+    private CompilationInfo info;
+    private Document doc;
+    
+    protected abstract List<ErrorDescription> computeErrors(CompilationInfo info, TreePath path);
+    
+    protected List<ErrorDescription> computeErrors(CompilationInfo info, TreePath path, int offset) {
+        return computeErrors(info, path);
+    }
+    
+    protected String toDebugString(CompilationInfo info, Fix f) {
+        return f.toString();
+    }
+    
+    protected void performAnalysisTest(String fileName, String code, String... golden) throws Exception {
+        int[] offset = new int[1];
+        
+        code = org.netbeans.modules.java.hints.TestUtilities.detectOffsets(code, offset);
+        
+        performAnalysisTest(fileName, code, offset[0], golden);
+    }
+    
+    protected void performAnalysisTest(String fileName, String code, int pos, String... golden) throws Exception {
+        prepareTest(fileName, code);
+        
+        TreePath path = info.getTreeUtilities().pathFor(pos);
+        
+        List<ErrorDescription> errors = computeErrors(info, path, pos);
+        List<String> errorsNames = new LinkedList<String>();
+        
+        errors = errors != null ? errors : Collections.<ErrorDescription>emptyList();
+        
+        for (ErrorDescription e : errors) {
+            errorsNames.add(e.toString());
+        }
+        
+        assertTrue("The warnings provided by the hint do not match expected warnings. Provided warnings: " + errorsNames.toString(), Arrays.equals(golden, errorsNames.toArray(new String[0])));
+    }
+    
+    protected String performFixTest(String fileName, String code, String errorDescriptionToString, String fixDebugString, String golden) throws Exception {
+        int[] offset = new int[1];
+
+        code = org.netbeans.modules.java.hints.TestUtilities.detectOffsets(code, offset);
+        
+        return performFixTest(fileName, code, offset[0], errorDescriptionToString, fixDebugString, golden);
+    }
+    
+    protected String performFixTest(String fileName, String code, int pos, String errorDescriptionToString, String fixDebugString, String golden) throws Exception {
+        return performFixTest(fileName, code, pos, errorDescriptionToString, fixDebugString, fileName, golden);
+    }
+    
+    protected String performFixTest(String fileName, String code, String errorDescriptionToString, String fixDebugString, String goldenFileName, String golden) throws Exception {
+        int[] offset = new int[1];
+
+        code = org.netbeans.modules.java.hints.TestUtilities.detectOffsets(code, offset);
+
+        return performFixTest(fileName, code, offset[0], errorDescriptionToString, fixDebugString, goldenFileName, golden);
+    }
+    
+    protected String performFixTest(String fileName, String code, int pos, String errorDescriptionToString, String fixDebugString, String goldenFileName, String golden) throws Exception {
+        prepareTest(fileName, code);
+        
+        TreePath path = info.getTreeUtilities().pathFor(pos);
+        
+        List<ErrorDescription> errors = computeErrors(info, path, pos);
+        
+        ErrorDescription toFix = null;
+        
+        for (ErrorDescription d : errors) {
+            if (errorDescriptionToString.equals(d.toString())) {
+                toFix = d;
+                break;
+            }
+        }
+        
+        assertNotNull("Error: \"" + errorDescriptionToString + "\" not found. All ErrorDescriptions: " + errors.toString(), toFix);
+        
+        assertTrue("Must be computed", toFix.getFixes().isComputed());
+        
+        List<Fix> fixes = toFix.getFixes().getFixes();
+        List<String> fixNames = new LinkedList<String>();
+        Fix toApply = null;
+        
+        for (Fix f : fixes) {
+            if (fixDebugString.equals(toDebugString(info, f))) {
+                toApply = f;
+            }
+            
+            fixNames.add(toDebugString(info, f));
+        }
+        
+        assertNotNull("Cannot find fix to invoke: " + fixNames.toString(), toApply);
+        
+        toApply.implement();
+        
+        FileObject toCheck = sourceRoot.getFileObject(goldenFileName);
+        
+        assertNotNull(toCheck);
+        
+        DataObject toCheckDO = DataObject.find(toCheck);
+        EditorCookie ec = toCheckDO.getLookup().lookup(EditorCookie.class);
+        Document toCheckDocument = ec.openDocument();
+        
+        String realCode = toCheckDocument.getText(0, toCheckDocument.getLength());
+        
+        //ignore whitespaces:
+        realCode = realCode.replaceAll("[ \t\n]+", " ");
+
+        if (golden != null) {
+            assertEquals("The output code does not match the expected code.", golden, realCode);
+        }
+        
+        LifecycleManager.getDefault().saveAll();
+
+        return realCode;
+    }
+    
+    protected FileObject[] extraClassPath() {
+        return new FileObject[0];
+    }
+
+    // common tests to check nothing is reported
+    public void testIssue105979() throws Exception {
+        String before = "package test; class Test {" +
+                "  return b;" +
+                "}\n";
+
+        for (int i = 0; i < before.length(); i++) {
+            LOG.info("testing position " + i + " at " + before.charAt(i));
+            clearWorkDir();
+            performAnalysisTest("test/Test.java", before, i);
+}
+    }
+    public void testIssue108246() throws Exception {
+
+        String before = "package test; class Test {" +
+            "  Integer ii = new Integer(0);" +
+            "  String s = ii.toString();" +
+            "\n}\n";
+
+        for (int i = 0; i < before.length(); i++) {
+            LOG.info("testing position " + i + " at " + before.charAt(i));
+            clearWorkDir();
+            performAnalysisTest("test/Test.java", before, i);
+        }
+    }
+
+    public void testNoHintsForSimpleInitialize() throws Exception {
+
+        String before = "package test; class Test {" +
+            " { java.lang.System.out.println(); } " +
+            "}\n";
+
+        for (int i = 0; i < before.length(); i++) {
+            LOG.info("testing position " + i + " at " + before.charAt(i));
+            clearWorkDir();
+            performAnalysisTest("test/Test.java", before, i);
+        }
+    }
+
+    public void testIssue113933() throws Exception {
+
+        String before = "package test; class Test {" +
+            "  public void test() {" +
+            "  super.A();" +
+            "\n}\n}\n";
+
+        for (int i = 0; i < before.length(); i++) {
+            LOG.info("testing position " + i + " at " + before.charAt(i));
+            clearWorkDir();
+            performAnalysisTest("test/Test.java", before, i);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/remoting/common/borrowedtests/src/org/netbeans/modules/java/hints/jackpot/code/spi/TestBase.java
----------------------------------------------------------------------
diff --git a/remoting/common/borrowedtests/src/org/netbeans/modules/java/hints/jackpot/code/spi/TestBase.java b/remoting/common/borrowedtests/src/org/netbeans/modules/java/hints/jackpot/code/spi/TestBase.java
new file mode 100644
index 0000000..a332df8
--- /dev/null
+++ b/remoting/common/borrowedtests/src/org/netbeans/modules/java/hints/jackpot/code/spi/TestBase.java
@@ -0,0 +1,341 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2009-2010 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
+ */
+
+package org.netbeans.modules.java.hints.jackpot.code.spi;
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.text.Document;
+import org.netbeans.api.java.lexer.JavaTokenId;
+import org.netbeans.api.java.source.CompilationInfo;
+import org.netbeans.api.java.source.JavaSource;
+import org.netbeans.api.java.source.JavaSource.Phase;
+import org.netbeans.api.java.source.SourceUtilsTestUtil;
+import org.netbeans.api.java.source.TestUtilities;
+import org.netbeans.api.java.source.support.CaretAwareJavaSourceTaskFactory;
+import org.netbeans.api.lexer.Language;
+import org.netbeans.junit.NbTestCase;
+import org.netbeans.modules.java.hints.jackpot.spi.HintsRunner;
+import org.netbeans.modules.java.hints.providers.code.CodeHintProviderImpl;
+import org.netbeans.modules.java.hints.providers.code.FSWrapper;
+import org.netbeans.modules.java.hints.providers.code.FSWrapper.ClassWrapper;
+import org.netbeans.modules.java.hints.providers.spi.HintDescription;
+import org.netbeans.modules.java.hints.providers.spi.HintMetadata;
+import org.netbeans.modules.java.source.TreeLoader;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.Fix;
+import org.openide.LifecycleManager;
+import org.openide.cookies.EditorCookie;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.loaders.DataObject;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author lahvac
+ */
+public abstract class TestBase extends NbTestCase {
+    private final Class<?> hintClass;
+    protected final Logger LOG;
+
+    public TestBase(String name, Class<?> hintClass) {
+        super(name);
+        this.hintClass = hintClass;
+        LOG = Logger.getLogger("test." + name);
+    }
+
+    @Override
+    protected Level logLevel() {
+        return Level.INFO;
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        SourceUtilsTestUtil.prepareTest(new String[] {"org/netbeans/modules/java/editor/resources/layer.xml", "META-INF/generated-layer.xml"}, new Object[0]);
+        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
+    }
+
+    private String sourceLevel = "1.5";
+
+    protected void setSourceLevel(String sourceLevel) {
+        this.sourceLevel = sourceLevel;
+    }
+    
+    protected void prepareTest(String fileName, String code) throws Exception {
+        clearWorkDir();
+        File wdFile = getWorkDir();
+        FileUtil.refreshFor(wdFile);
+
+        FileObject wd = FileUtil.toFileObject(wdFile);
+        assertNotNull(wd);
+        sourceRoot = FileUtil.createFolder(wd, "src");
+        FileObject buildRoot = FileUtil.createFolder(wd, "build");
+        FileObject cache = FileUtil.createFolder(wd, "cache");
+
+        FileObject data = FileUtil.createData(sourceRoot, fileName);
+        File dataFile = FileUtil.toFile(data);
+
+        assertNotNull(dataFile);
+
+        TestUtilities.copyStringToFile(dataFile, code);
+
+        SourceUtilsTestUtil.prepareTest(sourceRoot, buildRoot, cache, extraClassPath());
+
+        SourceUtilsTestUtil.setSourceLevel(data, sourceLevel);
+
+        DataObject od = DataObject.find(data);
+        EditorCookie ec = od.getCookie(EditorCookie.class);
+
+        assertNotNull(ec);
+
+        doc = ec.openDocument();
+        doc.putProperty(Language.class, JavaTokenId.language());
+        doc.putProperty("mimeType", "text/x-java");
+
+        JavaSource js = JavaSource.forFileObject(data);
+
+        assertNotNull(js);
+
+        info = SourceUtilsTestUtil.getCompilationInfo(js, Phase.RESOLVED);
+
+        assertNotNull(info);
+    }
+
+    private FileObject sourceRoot;
+    private CompilationInfo info;
+    private Document doc;
+
+    protected final void setTestFileCaretLocation(int pos) throws Exception {
+        Method m = CaretAwareJavaSourceTaskFactory.class.getDeclaredMethod("setLastPosition", FileObject.class, int.class);
+
+        m.setAccessible(true);
+        m.invoke(null, info.getFileObject(), pos);
+    }
+
+    private List<ErrorDescription> computeErrors(CompilationInfo info) {
+        Map<HintMetadata, Collection<HintDescription>> hints = new HashMap<HintMetadata, Collection<HintDescription>>();
+
+        ClassWrapper found = null;
+
+        for (ClassWrapper w : FSWrapper.listClasses()) {
+            if (w.getName().equals(hintClass.getName())) {
+                found = w;
+                break;
+            }
+        }
+
+        assertNotNull(found);
+        
+        CodeHintProviderImpl.processClass(found, hints);
+
+        List<HintDescription> total = new LinkedList<HintDescription>();
+
+        for (Collection<? extends HintDescription> l : hints.values()) {
+            total.addAll(l);
+        }
+
+        List<ErrorDescription> result = new ArrayList<ErrorDescription>();
+        
+        for (Entry<HintDescription, List<ErrorDescription>> e : HintsRunner.computeErrors(info, total, new AtomicBoolean()).entrySet()) {
+            result.addAll(e.getValue());
+        }
+
+        return result;
+    }
+
+    protected String toDebugString(CompilationInfo info, Fix f) {
+        return "FixImpl";
+    }
+
+    protected void performAnalysisTest(String fileName, String code, String... golden) throws Exception {
+        prepareTest(fileName, code);
+
+        List<ErrorDescription> errors = computeErrors(info);
+        Collections.sort (errors, ERRORS_COMPARATOR);
+        List<String> errorsNames = new LinkedList<String>();
+
+        errors = errors != null ? errors : Collections.<ErrorDescription>emptyList();
+
+        for (ErrorDescription e : errors) {
+            errorsNames.add(e.toString());
+        }
+
+        assertTrue("The warnings provided by the hint do not match expected warnings. Provided warnings: " + errorsNames.toString(), Arrays.equals(golden, errorsNames.toArray(new String[0])));
+    }
+
+    protected void performAnalysisContainsTest(String fileName, String code, String... golden) throws Exception {
+        prepareTest(fileName, code);
+
+        Set<String> goldenSet = new HashSet<String>();
+        for (String s : golden) {
+            goldenSet.add(s);
+        }
+
+        List<ErrorDescription> errors = computeErrors(info);
+        Collections.sort (errors, ERRORS_COMPARATOR);
+        List<String> errorsNames = new LinkedList<String>();
+
+        errors = errors != null ? errors : Collections.<ErrorDescription>emptyList();
+
+        for (ErrorDescription d : errors) {
+            goldenSet.remove(d.toString());
+            errorsNames.add(d.toString());
+        }
+        assertTrue("The warnings provided by the hint do not contain expected warnings. Provided warnings: " + errorsNames.toString(), goldenSet.isEmpty());
+    }
+
+    protected void performAnalysisExcludesTest(String fileName, String code, String... golden) throws Exception {
+        prepareTest(fileName, code);
+
+        Set<String> goldenSet = new HashSet<String>();
+        for (String s : golden) {
+            goldenSet.add(s);
+        }
+
+        List<ErrorDescription> errors = computeErrors(info);
+        Collections.sort (errors, ERRORS_COMPARATOR);
+        List<String> errorsNames = new LinkedList<String>();
+
+        errors = errors != null ? errors : Collections.<ErrorDescription>emptyList();
+
+        boolean fail = false;
+        for (ErrorDescription d : errors) {
+            if (goldenSet.remove(d.getDescription()))
+                fail = true;
+            errorsNames.add(d.toString());
+        }
+        assertFalse("The warnings provided by the hint do not exclude expected warnings. Provided warnings: " + errorsNames.toString(), fail);
+    }
+
+    protected String performFixTest(String fileName, String code, String errorDescriptionToString, String fixDebugString, String golden) throws Exception {
+        return performFixTest(fileName, code, errorDescriptionToString, fixDebugString, fileName, golden);
+    }
+
+    protected String performFixTest(String fileName, String code, String errorDescriptionToString, String fixDebugString, String goldenFileName, String golden) throws Exception {
+        prepareTest(fileName, code);
+
+        List<ErrorDescription> errors = computeErrors(info);
+        Collections.sort (errors, ERRORS_COMPARATOR);
+
+        ErrorDescription toFix = null;
+
+        for (ErrorDescription d : errors) {
+            if (errorDescriptionToString.equals(d.toString())) {
+                toFix = d;
+                break;
+            }
+        }
+
+        assertNotNull("Error: \"" + errorDescriptionToString + "\" not found. All ErrorDescriptions: " + errors.toString(), toFix);
+
+        assertTrue("Must be computed", toFix.getFixes().isComputed());
+
+        List<Fix> fixes = toFix.getFixes().getFixes();
+        List<String> fixNames = new LinkedList<String>();
+        Fix toApply = null;
+
+        for (Fix f : fixes) {
+            if (fixDebugString.equals(toDebugString(info, f))) {
+                toApply = f;
+            }
+
+            fixNames.add(toDebugString(info, f));
+        }
+
+        assertNotNull("Cannot find fix to invoke: " + fixNames.toString(), toApply);
+
+        toApply.implement();
+
+        FileObject toCheck = sourceRoot.getFileObject(goldenFileName);
+
+        assertNotNull(toCheck);
+
+        DataObject toCheckDO = DataObject.find(toCheck);
+        EditorCookie ec = toCheckDO.getLookup().lookup(EditorCookie.class);
+        Document toCheckDocument = ec.openDocument();
+
+        String realCode = toCheckDocument.getText(0, toCheckDocument.getLength());
+
+        //ignore whitespaces:
+        realCode = realCode.replaceAll("[ \t\n]+", " ");
+
+        if (golden != null) {
+            assertEquals("The output code does not match the expected code.", golden, realCode);
+        }
+
+        LifecycleManager.getDefault().saveAll();
+
+        return realCode;
+    }
+
+    protected FileObject[] extraClassPath() {
+        return new FileObject[0];
+    }
+
+    static {
+        NbBundle.setBranding("test");
+    }
+
+    private static final Comparator<ErrorDescription> ERRORS_COMPARATOR = new Comparator<ErrorDescription> () {
+
+        public int compare (ErrorDescription e1, ErrorDescription e2) {
+            return e1.getRange ().getBegin ().getOffset () - e2.getRange ().getBegin ().getOffset ();
+        }
+    };
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/remoting/common/borrowedtests/src/org/netbeans/modules/java/source/transform/Transformer.java
----------------------------------------------------------------------
diff --git a/remoting/common/borrowedtests/src/org/netbeans/modules/java/source/transform/Transformer.java b/remoting/common/borrowedtests/src/org/netbeans/modules/java/source/transform/Transformer.java
new file mode 100644
index 0000000..98a063f
--- /dev/null
+++ b/remoting/common/borrowedtests/src/org/netbeans/modules/java/source/transform/Transformer.java
@@ -0,0 +1,133 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ */
+
+package org.netbeans.modules.java.source.transform;
+
+import org.netbeans.modules.java.source.query.CommentHandler;
+import org.openide.util.NbBundle;
+import com.sun.source.tree.*;
+import com.sun.source.util.TreeScanner;
+import com.sun.tools.javac.model.JavacTypes;
+import com.sun.tools.javac.util.Context;
+import java.util.List;
+import java.util.logging.*;
+import javax.lang.model.util.Types;
+import org.netbeans.api.java.source.WorkingCopy;
+import org.netbeans.modules.java.source.builder.ASTService;
+import org.netbeans.modules.java.source.builder.CommentHandlerService;
+import org.netbeans.modules.java.source.builder.TreeFactory;
+
+/**
+ * A Transformer is an Query that modifies the model.  Model transformation
+ * is done by a supplied ImmutableTreeTranslator implementation.  A new context
+ * is set upon successful completion of this Transformer.
+ */
+public abstract class Transformer<R, P> extends TreeScanner<R,P> {
+
+    CommentHandler commentHandler;
+    public TreeFactory make;
+    protected WorkingCopy copy;
+    protected String refactoringDescription;
+    protected Types types; // used by tests
+    private String failureMessage;
+    protected ASTService model;
+
+    static final Logger logger = Logger.getLogger("org.netbeans.modules.java.source");
+
+    public void init() {
+    }
+
+    /**
+     * Initialize and associate this Query instance with the
+     * specified QueryEnvironment.
+     */
+    public void attach(Context context, WorkingCopy copy) {
+        make = TreeFactory.instance(context);
+        types = JavacTypes.instance(context);
+        commentHandler = CommentHandlerService.instance(context);
+        model = ASTService.instance(context);
+        this.copy = copy;
+    }
+
+    /**
+     * Release any instance data created during attach() invocation.  This
+     * is necessary because the Java reflection support may cache created
+     * instances, preventing the session data from being garbage-collected.
+     */
+    public void release() {
+        //changes.release();  // enable when async results are supported
+        //result.release()
+        make = null;
+        types = null;
+        this.copy = null;
+    }
+
+    public void destroy() {}
+    
+    public String getRefactoringDescription() {
+        return refactoringDescription != null ? refactoringDescription : "Unnamed Refactoring";
+    }
+
+    public void setRefactoringDescription(String description) {
+        refactoringDescription = description;
+    }
+
+    public void apply(Tree t) {
+        t.accept(this, null);
+    }
+
+    String getString(String key) {
+        return NbBundle.getBundle(Transformer.class).getString(key); //NOI18N
+    }
+
+    /**
+     * True if no translation failures occurred.
+     */
+    protected boolean translationSuccessful() {
+        return failureMessage == null;
+    }
+
+    public final void copyCommentTo(Tree from, Tree to) {
+        if (from != null && to != null) {
+            commentHandler.copyComments(from, to);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/remoting/common/borrowedtests/src/org/netbeans/modules/java/source/usages/IndexUtil.java
----------------------------------------------------------------------
diff --git a/remoting/common/borrowedtests/src/org/netbeans/modules/java/source/usages/IndexUtil.java b/remoting/common/borrowedtests/src/org/netbeans/modules/java/source/usages/IndexUtil.java
new file mode 100644
index 0000000..b56f1c9
--- /dev/null
+++ b/remoting/common/borrowedtests/src/org/netbeans/modules/java/source/usages/IndexUtil.java
@@ -0,0 +1,58 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ */
+
+package org.netbeans.modules.java.source.usages;
+
+import java.io.File;
+import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
+import org.openide.filesystems.FileUtil;
+
+/**
+ *
+ * @author Tomas Zezula
+ */
+public class IndexUtil {
+
+    public static void setCacheFolder (final File cacheFolder) {
+        CacheFolder.setCacheFolder(FileUtil.toFileObject(cacheFolder));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans-jackpot30/blob/9ed0a377/remoting/common/borrowedtests/src/org/netbeans/modules/parsing/impl/indexing/MimeTypes.java
----------------------------------------------------------------------
diff --git a/remoting/common/borrowedtests/src/org/netbeans/modules/parsing/impl/indexing/MimeTypes.java b/remoting/common/borrowedtests/src/org/netbeans/modules/parsing/impl/indexing/MimeTypes.java
new file mode 100644
index 0000000..ce7bd86
--- /dev/null
+++ b/remoting/common/borrowedtests/src/org/netbeans/modules/parsing/impl/indexing/MimeTypes.java
@@ -0,0 +1,66 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2011 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.parsing.impl.indexing;
+
+import java.util.Set;
+import org.netbeans.api.annotations.common.CheckForNull;
+import org.netbeans.api.annotations.common.NonNull;
+import org.openide.util.Parameters;
+
+/**
+ *
+ * @author Tomas Zezula
+ */
+public class MimeTypes {
+
+    private MimeTypes() {}
+
+    public static void setAllMimeTypes(@NonNull final Set<String> allMimeTypes) {
+        Parameters.notNull("allMimeTypes", allMimeTypes);   //NOI18N
+        Util.allMimeTypes = allMimeTypes;
+    }
+
+    @CheckForNull
+    public static Set<String> getAllMimeTypes() {
+        return Util.allMimeTypes;
+    }
+}