Added unit tests for jsfloader module mercurial1_4_beta2_base new_arch_exp_root
authorquynguyen@netbeans.org
Wed, 17 Oct 2007 22:33:27 +0000
changeset 1759c3952180eeda
parent 1758 cc78c6c2f2ad
child 1760 051a7dcfb2c7
Added unit tests for jsfloader module
visualweb.project.jsfloader/nbproject/project.xml
visualweb.project.jsfloader/test/build-qa-functional.xml
visualweb.project.jsfloader/test/build-unit.xml
visualweb.project.jsfloader/test/build.xml
visualweb.project.jsfloader/test/cfg-qa-functional.xml
visualweb.project.jsfloader/test/cfg-unit.xml
visualweb.project.jsfloader/test/unit/src/META-INF/services/org.netbeans.modules.project.uiapi.OpenProjectsTrampoline
visualweb.project.jsfloader/test/unit/src/META-INF/services/org.openide.filesystems.MIMEResolver
visualweb.project.jsfloader/test/unit/src/org/netbeans/modules/visualweb/project/jsfloader/JsfJspDataObjectTest.java
visualweb.project.jsfloader/test/unit/src/org/netbeans/modules/visualweb/project/jsfloader/test/JsfLoaderMimeResolver.java
visualweb.project.jsfloader/test/unit/src/org/netbeans/modules/visualweb/project/jsfloader/test/MockOpenProjectsTrampoline.java
visualweb.project.jsfloader/test/unit/src/org/netbeans/modules/visualweb/project/jsfloader/test/SetupUtils.java
     1.1 --- a/visualweb.project.jsfloader/nbproject/project.xml	Wed Oct 17 18:01:07 2007 +0000
     1.2 +++ b/visualweb.project.jsfloader/nbproject/project.xml	Wed Oct 17 22:33:27 2007 +0000
     1.3 @@ -259,6 +259,16 @@
     1.4                      </run-dependency>
     1.5                  </dependency>
     1.6              </module-dependencies>
     1.7 +            <test-dependencies>
     1.8 +                <test-type>
     1.9 +                    <name>unit</name>
    1.10 +                    <test-dependency>
    1.11 +                        <code-name-base>org.openide.util</code-name-base>
    1.12 +                        <compile-dependency/>
    1.13 +                        <test/>
    1.14 +                    </test-dependency>
    1.15 +                </test-type>
    1.16 +            </test-dependencies>
    1.17              <public-packages/>
    1.18          </data>
    1.19      </configuration>
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/visualweb.project.jsfloader/test/build-qa-functional.xml	Wed Oct 17 22:33:27 2007 +0000
     2.3 @@ -0,0 +1,75 @@
     2.4 +<?xml version="1.0"?>
     2.5 +<!--
     2.6 +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     2.7 +
     2.8 +Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
     2.9 +
    2.10 +
    2.11 +The contents of this file are subject to the terms of either the GNU
    2.12 +General Public License Version 2 only ("GPL") or the Common
    2.13 +Development and Distribution License("CDDL") (collectively, the
    2.14 +"License"). You may not use this file except in compliance with the
    2.15 +License. You can obtain a copy of the License at
    2.16 +http://www.netbeans.org/cddl-gplv2.html
    2.17 +or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    2.18 +specific language governing permissions and limitations under the
    2.19 +License.  When distributing the software, include this License Header
    2.20 +Notice in each file and include the License file at
    2.21 +nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    2.22 +particular file as subject to the "Classpath" exception as provided
    2.23 +by Sun in the GPL Version 2 section of the License file that
    2.24 +accompanied this code. If applicable, add the following below the
    2.25 +License Header, with the fields enclosed by brackets [] replaced by
    2.26 +your own identifying information:
    2.27 +"Portions Copyrighted [year] [name of copyright owner]"
    2.28 +
    2.29 +Contributor(s):
    2.30 +
    2.31 +The Original Software is NetBeans. The Initial Developer of the Original
    2.32 +Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
    2.33 +Microsystems, Inc. All Rights Reserved.
    2.34 +
    2.35 +If you wish your version of this file to be governed by only the CDDL
    2.36 +or only the GPL Version 2, indicate your decision by adding
    2.37 +"[Contributor] elects to include this software in this distribution
    2.38 +under the [CDDL or GPL Version 2] license." If you do not indicate a
    2.39 +single choice of license, a recipient has the option to distribute
    2.40 +your version of this file under either the CDDL, the GPL Version 2 or
    2.41 +to extend the choice of license to its licensees as provided above.
    2.42 +However, if you add GPL Version 2 code and therefore, elected the GPL
    2.43 +Version 2 license, then the option applies only if the new code is
    2.44 +made subject to such option by the copyright holder.
    2.45 +-->
    2.46 +<project name="org.netbeans.modules.visualweb.project.jsfloader/test-qa-functional" basedir="." default="all">
    2.47 +
    2.48 +    <!-- Imports default qa-functional-compiler and runidetest executor.
    2.49 +        jemmy and jellytools jars are on classpath for both. -->
    2.50 +    <import file="../../../../nbbuild/templates/xtest-qa-functional.xml"/>
    2.51 +
    2.52 +    <!-- ========= -->
    2.53 +    <!-- Compilers -->
    2.54 +    <!-- ========= -->
    2.55 +
    2.56 +    <!-- You can override default qa-functional-compiler if you need something special -->
    2.57 +         <!--
    2.58 +    <target name="qa-functional-compiler" depends="init-cp">
    2.59 +        <buildTests srcdir="qa-functional/src" compileexcludes="**/data/**">
    2.60 +            <classpath refid="test.qa-functional.compile.cp"/>
    2.61 +        </buildTests>
    2.62 +    </target>
    2.63 +    -->
    2.64 +    
    2.65 +    <!-- ========= -->
    2.66 +    <!-- Executors -->
    2.67 +    <!-- ========= -->
    2.68 +    
    2.69 +    <!-- This target executes tests inside IDE. It is defined in default-build-qa-functional.xml.
    2.70 +         If you need to customize it, you can uncomment the following and override it.
    2.71 +    <target name="runidetest" depends="init-cp">
    2.72 +        <executeTests pluginname="ide">
    2.73 +            <classpath refid="test.qa-functional.run.cp"/>
    2.74 +        </executeTests>
    2.75 +    </target>
    2.76 +    -->
    2.77 +</project>
    2.78 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/visualweb.project.jsfloader/test/build-unit.xml	Wed Oct 17 22:33:27 2007 +0000
     3.3 @@ -0,0 +1,48 @@
     3.4 +<?xml version="1.0"?>
     3.5 +<!--
     3.6 +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     3.7 +
     3.8 +Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
     3.9 +
    3.10 +
    3.11 +The contents of this file are subject to the terms of either the GNU
    3.12 +General Public License Version 2 only ("GPL") or the Common
    3.13 +Development and Distribution License("CDDL") (collectively, the
    3.14 +"License"). You may not use this file except in compliance with the
    3.15 +License. You can obtain a copy of the License at
    3.16 +http://www.netbeans.org/cddl-gplv2.html
    3.17 +or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    3.18 +specific language governing permissions and limitations under the
    3.19 +License.  When distributing the software, include this License Header
    3.20 +Notice in each file and include the License file at
    3.21 +nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    3.22 +particular file as subject to the "Classpath" exception as provided
    3.23 +by Sun in the GPL Version 2 section of the License file that
    3.24 +accompanied this code. If applicable, add the following below the
    3.25 +License Header, with the fields enclosed by brackets [] replaced by
    3.26 +your own identifying information:
    3.27 +"Portions Copyrighted [year] [name of copyright owner]"
    3.28 +
    3.29 +Contributor(s):
    3.30 +
    3.31 +The Original Software is NetBeans. The Initial Developer of the Original
    3.32 +Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
    3.33 +Microsystems, Inc. All Rights Reserved.
    3.34 +
    3.35 +If you wish your version of this file to be governed by only the CDDL
    3.36 +or only the GPL Version 2, indicate your decision by adding
    3.37 +"[Contributor] elects to include this software in this distribution
    3.38 +under the [CDDL or GPL Version 2] license." If you do not indicate a
    3.39 +single choice of license, a recipient has the option to distribute
    3.40 +your version of this file under either the CDDL, the GPL Version 2 or
    3.41 +to extend the choice of license to its licensees as provided above.
    3.42 +However, if you add GPL Version 2 code and therefore, elected the GPL
    3.43 +Version 2 license, then the option applies only if the new code is
    3.44 +made subject to such option by the copyright holder.
    3.45 +-->
    3.46 +<project name="org.netbeans.modules.visualweb.project.jsfloader/test-unit" basedir="." default="all">
    3.47 +
    3.48 +    <!-- Imports default-compiler, run-unit-test targets referenced from cfg-unit.xml. -->
    3.49 +    <import file="../../../../nbbuild/templates/xtest-unit.xml"/>
    3.50 +</project>
    3.51 +
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/visualweb.project.jsfloader/test/build.xml	Wed Oct 17 22:33:27 2007 +0000
     4.3 @@ -0,0 +1,62 @@
     4.4 +<?xml version="1.0"?>
     4.5 +<!--
     4.6 +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     4.7 +
     4.8 +Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
     4.9 +
    4.10 +
    4.11 +The contents of this file are subject to the terms of either the GNU
    4.12 +General Public License Version 2 only ("GPL") or the Common
    4.13 +Development and Distribution License("CDDL") (collectively, the
    4.14 +"License"). You may not use this file except in compliance with the
    4.15 +License. You can obtain a copy of the License at
    4.16 +http://www.netbeans.org/cddl-gplv2.html
    4.17 +or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    4.18 +specific language governing permissions and limitations under the
    4.19 +License.  When distributing the software, include this License Header
    4.20 +Notice in each file and include the License file at
    4.21 +nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    4.22 +particular file as subject to the "Classpath" exception as provided
    4.23 +by Sun in the GPL Version 2 section of the License file that
    4.24 +accompanied this code. If applicable, add the following below the
    4.25 +License Header, with the fields enclosed by brackets [] replaced by
    4.26 +your own identifying information:
    4.27 +"Portions Copyrighted [year] [name of copyright owner]"
    4.28 +
    4.29 +Contributor(s):
    4.30 +
    4.31 +The Original Software is NetBeans. The Initial Developer of the Original
    4.32 +Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
    4.33 +Microsystems, Inc. All Rights Reserved.
    4.34 +
    4.35 +If you wish your version of this file to be governed by only the CDDL
    4.36 +or only the GPL Version 2, indicate your decision by adding
    4.37 +"[Contributor] elects to include this software in this distribution
    4.38 +under the [CDDL or GPL Version 2] license." If you do not indicate a
    4.39 +single choice of license, a recipient has the option to distribute
    4.40 +your version of this file under either the CDDL, the GPL Version 2 or
    4.41 +to extend the choice of license to its licensees as provided above.
    4.42 +However, if you add GPL Version 2 code and therefore, elected the GPL
    4.43 +Version 2 license, then the option applies only if the new code is
    4.44 +made subject to such option by the copyright holder.
    4.45 +-->
    4.46 +<project name="org.netbeans.modules.visualweb.project.jsfloader/test" basedir="." default="all">
    4.47 +
    4.48 +    <!-- Name of tested module -->
    4.49 +    <property name="xtest.module" value="org.netbeans.modules.visualweb.project.jsfloader"/>
    4.50 +
    4.51 +    <!-- Home of XTest -->
    4.52 +    <property name="xtest.home" location="C:\Sun\rave\src\nbbuild\netbeans\testtools\xtest-distribution"/>
    4.53 +
    4.54 +    <!-- Imports buildtests, cleantests, runtest, cleanresults, realclean, printconfig targets. -->
    4.55 +    <import file="../../../../nbbuild/templates/xtest.xml"/>
    4.56 +
    4.57 +    <!-- default testtypes, attributes used when no value is supplied from command line -->
    4.58 +    <property name="xtest.testtype" value="unit"/>
    4.59 +    <property name="xtest.attribs" value="stable"/>
    4.60 +    <!--
    4.61 +    <property name="xtest.testtype" value="qa-functional"/>
    4.62 +    <property name="xtest.attribs" value="stable,validation"/>
    4.63 +    -->
    4.64 +</project>
    4.65 +
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/visualweb.project.jsfloader/test/cfg-qa-functional.xml	Wed Oct 17 22:33:27 2007 +0000
     5.3 @@ -0,0 +1,59 @@
     5.4 +<?xml version="1.0" encoding="UTF-8"?>
     5.5 +<!--
     5.6 +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     5.7 +
     5.8 +Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
     5.9 +
    5.10 +
    5.11 +The contents of this file are subject to the terms of either the GNU
    5.12 +General Public License Version 2 only ("GPL") or the Common
    5.13 +Development and Distribution License("CDDL") (collectively, the
    5.14 +"License"). You may not use this file except in compliance with the
    5.15 +License. You can obtain a copy of the License at
    5.16 +http://www.netbeans.org/cddl-gplv2.html
    5.17 +or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    5.18 +specific language governing permissions and limitations under the
    5.19 +License.  When distributing the software, include this License Header
    5.20 +Notice in each file and include the License file at
    5.21 +nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    5.22 +particular file as subject to the "Classpath" exception as provided
    5.23 +by Sun in the GPL Version 2 section of the License file that
    5.24 +accompanied this code. If applicable, add the following below the
    5.25 +License Header, with the fields enclosed by brackets [] replaced by
    5.26 +your own identifying information:
    5.27 +"Portions Copyrighted [year] [name of copyright owner]"
    5.28 +
    5.29 +Contributor(s):
    5.30 +
    5.31 +The Original Software is NetBeans. The Initial Developer of the Original
    5.32 +Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
    5.33 +Microsystems, Inc. All Rights Reserved.
    5.34 +
    5.35 +If you wish your version of this file to be governed by only the CDDL
    5.36 +or only the GPL Version 2, indicate your decision by adding
    5.37 +"[Contributor] elects to include this software in this distribution
    5.38 +under the [CDDL or GPL Version 2] license." If you do not indicate a
    5.39 +single choice of license, a recipient has the option to distribute
    5.40 +your version of this file under either the CDDL, the GPL Version 2 or
    5.41 +to extend the choice of license to its licensees as provided above.
    5.42 +However, if you add GPL Version 2 code and therefore, elected the GPL
    5.43 +Version 2 license, then the option applies only if the new code is
    5.44 +made subject to such option by the copyright holder.
    5.45 +-->
    5.46 +<!-- Configation file to group tests into testbags. For details see
    5.47 +     http://xtest.netbeans.org/xtest_config.html.
    5.48 +-->
    5.49 +<mconfig name="qa-functional config">
    5.50 +
    5.51 +    <testbag testattribs="validation,stable" executor="ide" name="qa-functional tests">
    5.52 +        <testset dir="qa-functional/src">
    5.53 +            <patternset>
    5.54 +                <include name="**/*Test.class"/>
    5.55 +            </patternset>
    5.56 +        </testset>
    5.57 +    </testbag>
    5.58 +
    5.59 +    <compiler name="qa-functional-compiler" antfile="build-qa-functional.xml"
    5.60 +              target="qa-functional-compiler" default="true"/>
    5.61 +    <executor name="ide" antfile="build-qa-functional.xml" target="runidetest" default="true"/>
    5.62 +</mconfig>
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/visualweb.project.jsfloader/test/cfg-unit.xml	Wed Oct 17 22:33:27 2007 +0000
     6.3 @@ -0,0 +1,58 @@
     6.4 +<?xml version="1.0" encoding="UTF-8"?>
     6.5 +<!--
     6.6 +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     6.7 +
     6.8 +Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
     6.9 +
    6.10 +
    6.11 +The contents of this file are subject to the terms of either the GNU
    6.12 +General Public License Version 2 only ("GPL") or the Common
    6.13 +Development and Distribution License("CDDL") (collectively, the
    6.14 +"License"). You may not use this file except in compliance with the
    6.15 +License. You can obtain a copy of the License at
    6.16 +http://www.netbeans.org/cddl-gplv2.html
    6.17 +or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    6.18 +specific language governing permissions and limitations under the
    6.19 +License.  When distributing the software, include this License Header
    6.20 +Notice in each file and include the License file at
    6.21 +nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    6.22 +particular file as subject to the "Classpath" exception as provided
    6.23 +by Sun in the GPL Version 2 section of the License file that
    6.24 +accompanied this code. If applicable, add the following below the
    6.25 +License Header, with the fields enclosed by brackets [] replaced by
    6.26 +your own identifying information:
    6.27 +"Portions Copyrighted [year] [name of copyright owner]"
    6.28 +
    6.29 +Contributor(s):
    6.30 +
    6.31 +The Original Software is NetBeans. The Initial Developer of the Original
    6.32 +Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
    6.33 +Microsystems, Inc. All Rights Reserved.
    6.34 +
    6.35 +If you wish your version of this file to be governed by only the CDDL
    6.36 +or only the GPL Version 2, indicate your decision by adding
    6.37 +"[Contributor] elects to include this software in this distribution
    6.38 +under the [CDDL or GPL Version 2] license." If you do not indicate a
    6.39 +single choice of license, a recipient has the option to distribute
    6.40 +your version of this file under either the CDDL, the GPL Version 2 or
    6.41 +to extend the choice of license to its licensees as provided above.
    6.42 +However, if you add GPL Version 2 code and therefore, elected the GPL
    6.43 +Version 2 license, then the option applies only if the new code is
    6.44 +made subject to such option by the copyright holder.
    6.45 +-->
    6.46 +<!-- Configation file to group tests into testbags. For details see
    6.47 +     http://xtest.netbeans.org/xtest_config.html
    6.48 +-->
    6.49 +<mconfig name="Unit config">
    6.50 +
    6.51 +    <testbag testattribs="stable" executor="unit-executor" name="unit tests">
    6.52 +        <testset dir="unit/src">
    6.53 +            <patternset>
    6.54 +                <include name="**/*Test.class"/>
    6.55 +            </patternset>
    6.56 +        </testset>
    6.57 +    </testbag>
    6.58 +
    6.59 +    <compiler name="default-compiler" antfile="build-unit.xml" target="default-compiler" default="true"/>
    6.60 +    <executor name="unit-executor" antfile="build-unit.xml" target="run-unit-test" default="true"/>
    6.61 +</mconfig>
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/visualweb.project.jsfloader/test/unit/src/META-INF/services/org.netbeans.modules.project.uiapi.OpenProjectsTrampoline	Wed Oct 17 22:33:27 2007 +0000
     7.3 @@ -0,0 +1,1 @@
     7.4 +org.netbeans.modules.visualweb.project.jsfloader.test.MockOpenProjectsTrampoline
     7.5 \ No newline at end of file
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/visualweb.project.jsfloader/test/unit/src/META-INF/services/org.openide.filesystems.MIMEResolver	Wed Oct 17 22:33:27 2007 +0000
     8.3 @@ -0,0 +1,1 @@
     8.4 +org.netbeans.modules.visualweb.project.jsfloader.test.JsfLoaderMimeResolver
     8.5 \ No newline at end of file
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/visualweb.project.jsfloader/test/unit/src/org/netbeans/modules/visualweb/project/jsfloader/JsfJspDataObjectTest.java	Wed Oct 17 22:33:27 2007 +0000
     9.3 @@ -0,0 +1,291 @@
     9.4 +/*
     9.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     9.6 + * 
     9.7 + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
     9.8 + * 
     9.9 + * The contents of this file are subject to the terms of either the GNU
    9.10 + * General Public License Version 2 only ("GPL") or the Common
    9.11 + * Development and Distribution License("CDDL") (collectively, the
    9.12 + * "License"). You may not use this file except in compliance with the
    9.13 + * License. You can obtain a copy of the License at
    9.14 + * http://www.netbeans.org/cddl-gplv2.html
    9.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    9.16 + * specific language governing permissions and limitations under the
    9.17 + * License.  When distributing the software, include this License Header
    9.18 + * Notice in each file and include the License file at
    9.19 + * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    9.20 + * particular file as subject to the "Classpath" exception as provided
    9.21 + * by Sun in the GPL Version 2 section of the License file that
    9.22 + * accompanied this code. If applicable, add the following below the
    9.23 + * License Header, with the fields enclosed by brackets [] replaced by
    9.24 + * your own identifying information:
    9.25 + * "Portions Copyrighted [year] [name of copyright owner]"
    9.26 + * 
    9.27 + * If you wish your version of this file to be governed by only the CDDL
    9.28 + * or only the GPL Version 2, indicate your decision by adding
    9.29 + * "[Contributor] elects to include this software in this distribution
    9.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
    9.31 + * single choice of license, a recipient has the option to distribute
    9.32 + * your version of this file under either the CDDL, the GPL Version 2 or
    9.33 + * to extend the choice of license to its licensees as provided above.
    9.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
    9.35 + * Version 2 license, then the option applies only if the new code is
    9.36 + * made subject to such option by the copyright holder.
    9.37 + * 
    9.38 + * Contributor(s):
    9.39 + * 
    9.40 + * Portions Copyrighted 2007 Sun Microsystems, Inc.
    9.41 + */
    9.42 +
    9.43 +package org.netbeans.modules.visualweb.project.jsfloader;
    9.44 +
    9.45 +import org.netbeans.api.project.Project;
    9.46 +import org.netbeans.junit.NbTestCase;
    9.47 +import org.netbeans.modules.visualweb.project.jsfloader.test.SetupUtils;
    9.48 +import org.netbeans.modules.web.core.jsploader.api.TagLibParseCookie;
    9.49 +import org.openide.cookies.EditCookie;
    9.50 +import org.openide.cookies.EditorCookie;
    9.51 +import org.openide.cookies.OpenCookie;
    9.52 +import org.openide.filesystems.FileObject;
    9.53 +import org.openide.filesystems.FileUtil;
    9.54 +import org.openide.loaders.DataObject;
    9.55 +import org.openide.util.Lookup;
    9.56 +import org.openide.util.test.MockLookup;
    9.57 +
    9.58 +/**
    9.59 + *
    9.60 + * @author quynguyen
    9.61 + */
    9.62 +public class JsfJspDataObjectTest extends NbTestCase {
    9.63 +    private Project project;
    9.64 +    private FileObject projectRoot;
    9.65 +    
    9.66 +    public JsfJspDataObjectTest(String testName) {
    9.67 +        super(testName);
    9.68 +    }            
    9.69 +
    9.70 +    @Override
    9.71 +    protected void setUp() throws Exception {
    9.72 +        super.setUp();
    9.73 +
    9.74 +        project = SetupUtils.setup(getWorkDir());
    9.75 +        projectRoot = FileUtil.toFileObject(getWorkDir()).getFileObject("VWJavaEE5");
    9.76 +        
    9.77 +        assertNotNull("Project should not be null", project);
    9.78 +        assertNotNull("Project root folder should not be null", projectRoot);
    9.79 +    }
    9.80 +
    9.81 +    @Override
    9.82 +    protected void tearDown() throws Exception {
    9.83 +        super.tearDown();
    9.84 +        project = null;
    9.85 +        projectRoot = null;
    9.86 +        
    9.87 +        MockLookup.setInstances();
    9.88 +    }
    9.89 +
    9.90 +    /**
    9.91 +     * Test of getLookup method, of class JsfJspDataObject.
    9.92 +     */
    9.93 +    public void testGetLookup() throws Exception {
    9.94 +        System.out.println("getLookup");
    9.95 +        FileObject jspPage = projectRoot.getFileObject("web/Page1.jsp");
    9.96 +        JsfJspDataObject instance = (JsfJspDataObject)DataObject.find(jspPage);
    9.97 +        
    9.98 +        // test validity of lookup results
    9.99 +        Lookup result = instance.getLookup();
   9.100 +        JsfJspEditorSupport support = result.lookup(JsfJspEditorSupport.class);
   9.101 +        OpenCookie openCookie = result.lookup(OpenCookie.class);
   9.102 +        EditCookie editCookie = result.lookup(EditCookie.class);
   9.103 +        EditorCookie editorCookie = result.lookup(EditorCookie.class);
   9.104 +        TagLibParseCookie tagLibParseCookie = result.lookup(TagLibParseCookie.class);
   9.105 +        
   9.106 +        assertNotNull("OpenCookie is null", openCookie);
   9.107 +        assertNotNull("EditCookie is null", editCookie);
   9.108 +        assertNotNull("EditorCookie is null", editorCookie);
   9.109 +        assertNotNull("TagLibParseCookie is null", tagLibParseCookie);
   9.110 +        assertNotNull("JsfJspEditorSupport is null", support);
   9.111 +        
   9.112 +        assertEquals("getLookup and getCookie should return the same OpenCookie", 
   9.113 +                openCookie, instance.getCookie(OpenCookie.class));
   9.114 +        assertEquals("getLookup and getCookie should return the same EditCookie", 
   9.115 +                editCookie, instance.getCookie(EditCookie.class));
   9.116 +        assertEquals("getLookup and getCookie should return the same EditorCookie", 
   9.117 +                editorCookie, instance.getCookie(EditorCookie.class));
   9.118 +        assertEquals("getLookup and getCookie should return the same TagLibParseCookie", 
   9.119 +                tagLibParseCookie, instance.getCookie(TagLibParseCookie.class));
   9.120 +        assertEquals("getLookup and getCookie should return the same JsfJspEditorSupport", 
   9.121 +                support, instance.getCookie(JsfJspEditorSupport.class));
   9.122 +    }
   9.123 +    
   9.124 +    public void testCorrespondingJsfJava() throws Exception {
   9.125 +        System.out.println("correspondingJsfJavaFile");
   9.126 +        FileObject jspPage = projectRoot.getFileObject("web/Page1.jsp");
   9.127 +        JsfJspDataObject instance = (JsfJspDataObject)DataObject.find(jspPage);
   9.128 +        FileObject javaSrc = Utils.findJavaForJsp(instance.getPrimaryFile());
   9.129 +        DataObject dobj = DataObject.find(javaSrc);
   9.130 +        assertTrue("Corresponding java file needs to be JSF", dobj instanceof JsfJavaDataObject);
   9.131 +    }
   9.132 +    
   9.133 +//    /**
   9.134 +//     * Test of createNodeDelegate method, of class JsfJspDataObject.
   9.135 +//     */
   9.136 +//    public void testCreateNodeDelegate() {
   9.137 +//        System.out.println("createNodeDelegate");
   9.138 +//        JsfJspDataObject instance = null;
   9.139 +//        Node expResult = null;
   9.140 +//        Node result = instance.createNodeDelegate();
   9.141 +//        assertEquals(expResult, result);
   9.142 +//        // TODO review the generated test code and remove the default call to fail.
   9.143 +//        fail("The test case is a prototype.");
   9.144 +//    }
   9.145 +//
   9.146 +//    /**
   9.147 +//     * Test of getHelpCtx method, of class JsfJspDataObject.
   9.148 +//     */
   9.149 +//    public void testGetHelpCtx() {
   9.150 +//        System.out.println("getHelpCtx");
   9.151 +//        JsfJspDataObject instance = null;
   9.152 +//        HelpCtx expResult = null;
   9.153 +//        HelpCtx result = instance.getHelpCtx();
   9.154 +//        assertEquals(expResult, result);
   9.155 +//        // TODO review the generated test code and remove the default call to fail.
   9.156 +//        fail("The test case is a prototype.");
   9.157 +//    }
   9.158 +//
   9.159 +//    /**
   9.160 +//     * Test of createCookie method, of class JsfJspDataObject.
   9.161 +//     */
   9.162 +//    public void testCreateCookie() {
   9.163 +//        System.out.println("createCookie");
   9.164 +//        Class klass = null;
   9.165 +//        JsfJspDataObject instance = null;
   9.166 +//        Cookie expResult = null;
   9.167 +//        Cookie result = instance.createCookie(klass);
   9.168 +//        assertEquals(expResult, result);
   9.169 +//        // TODO review the generated test code and remove the default call to fail.
   9.170 +//        fail("The test case is a prototype.");
   9.171 +//    }
   9.172 +//
   9.173 +//    /**
   9.174 +//     * Test of getCookieSet0 method, of class JsfJspDataObject.
   9.175 +//     */
   9.176 +//    public void testGetCookieSet0() {
   9.177 +//        System.out.println("getCookieSet0");
   9.178 +//        JsfJspDataObject instance = null;
   9.179 +//        CookieSet expResult = null;
   9.180 +//        CookieSet result = instance.getCookieSet0();
   9.181 +//        assertEquals(expResult, result);
   9.182 +//        // TODO review the generated test code and remove the default call to fail.
   9.183 +//        fail("The test case is a prototype.");
   9.184 +//    }
   9.185 +//
   9.186 +//
   9.187 +//    /**
   9.188 +//     * Test of getPureCookie method, of class JsfJspDataObject.
   9.189 +//     */
   9.190 +//    public void testGetPureCookie() {
   9.191 +//        System.out.println("getPureCookie");
   9.192 +//        Class clazz = null;
   9.193 +//        JsfJspDataObject instance = null;
   9.194 +//        Cookie expResult = null;
   9.195 +//        Cookie result = instance.getPureCookie(clazz);
   9.196 +//        assertEquals(expResult, result);
   9.197 +//        // TODO review the generated test code and remove the default call to fail.
   9.198 +//        fail("The test case is a prototype.");
   9.199 +//    }
   9.200 +//
   9.201 +//    /**
   9.202 +//     * Test of getCookie method, of class JsfJspDataObject.
   9.203 +//     */
   9.204 +//    public void testGetCookie() {
   9.205 +//        System.out.println("getCookie");
   9.206 +//        Class clazz = null;
   9.207 +//        JsfJspDataObject instance = null;
   9.208 +//        Cookie expResult = null;
   9.209 +//        Cookie result = instance.getCookie(clazz);
   9.210 +//        assertEquals(expResult, result);
   9.211 +//        // TODO review the generated test code and remove the default call to fail.
   9.212 +//        fail("The test case is a prototype.");
   9.213 +//    }
   9.214 +//
   9.215 +//    /**
   9.216 +//     * Test of getFileEncoding method, of class JsfJspDataObject.
   9.217 +//     */
   9.218 +//    public void testGetFileEncoding() {
   9.219 +//        System.out.println("getFileEncoding");
   9.220 +//        JsfJspDataObject instance = null;
   9.221 +//        String expResult = "";
   9.222 +//        String result = instance.getFileEncoding();
   9.223 +//        assertEquals(expResult, result);
   9.224 +//        // TODO review the generated test code and remove the default call to fail.
   9.225 +//        fail("The test case is a prototype.");
   9.226 +//    }
   9.227 +//
   9.228 +//    /**
   9.229 +//     * Test of updateFileEncoding method, of class JsfJspDataObject.
   9.230 +//     */
   9.231 +//    public void testUpdateFileEncoding() {
   9.232 +//        System.out.println("updateFileEncoding");
   9.233 +//        boolean fromEditor = false;
   9.234 +//        JsfJspDataObject instance = null;
   9.235 +//        instance.updateFileEncoding(fromEditor);
   9.236 +//        // TODO review the generated test code and remove the default call to fail.
   9.237 +//        fail("The test case is a prototype.");
   9.238 +//    }
   9.239 +//
   9.240 +//    /**
   9.241 +//     * Test of pureCopy method, of class JsfJspDataObject.
   9.242 +//     */
   9.243 +//    public void testPureCopy() throws Exception {
   9.244 +//        System.out.println("pureCopy");
   9.245 +//        DataFolder folder = null;
   9.246 +//        JsfJspDataObject instance = null;
   9.247 +//        instance.pureCopy(folder);
   9.248 +//        // TODO review the generated test code and remove the default call to fail.
   9.249 +//        fail("The test case is a prototype.");
   9.250 +//    }
   9.251 +//
   9.252 +//
   9.253 +//    /**
   9.254 +//     * Test of handleDelete method, of class JsfJspDataObject.
   9.255 +//     */
   9.256 +//    public void testHandleDelete() throws Exception {
   9.257 +//        System.out.println("handleDelete");
   9.258 +//        JsfJspDataObject instance = null;
   9.259 +//        instance.handleDelete();
   9.260 +//        // TODO review the generated test code and remove the default call to fail.
   9.261 +//        fail("The test case is a prototype.");
   9.262 +//    }
   9.263 +//
   9.264 +//    /**
   9.265 +//     * Test of handleCreateFromTemplate method, of class JsfJspDataObject.
   9.266 +//     */
   9.267 +//    public void testHandleCreateFromTemplate() throws Exception {
   9.268 +//        System.out.println("handleCreateFromTemplate");
   9.269 +//        DataFolder df = null;
   9.270 +//        String name = "";
   9.271 +//        JsfJspDataObject instance = null;
   9.272 +//        DataObject expResult = null;
   9.273 +//        DataObject result = instance.handleCreateFromTemplate(df, name);
   9.274 +//        assertEquals(expResult, result);
   9.275 +//        // TODO review the generated test code and remove the default call to fail.
   9.276 +//        fail("The test case is a prototype.");
   9.277 +//    }
   9.278 +//
   9.279 +//    /**
   9.280 +//     * Test of handleRename method, of class JsfJspDataObject.
   9.281 +//     */
   9.282 +//    public void testHandleRename() throws Exception {
   9.283 +//        System.out.println("handleRename");
   9.284 +//        String name = "";
   9.285 +//        JsfJspDataObject instance = null;
   9.286 +//        FileObject expResult = null;
   9.287 +//        FileObject result = instance.handleRename(name);
   9.288 +//        assertEquals(expResult, result);
   9.289 +//        // TODO review the generated test code and remove the default call to fail.
   9.290 +//        fail("The test case is a prototype.");
   9.291 +//    }
   9.292 +
   9.293 +
   9.294 +}
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/visualweb.project.jsfloader/test/unit/src/org/netbeans/modules/visualweb/project/jsfloader/test/JsfLoaderMimeResolver.java	Wed Oct 17 22:33:27 2007 +0000
    10.3 @@ -0,0 +1,53 @@
    10.4 +/*
    10.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    10.6 + *
    10.7 + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
    10.8 + *
    10.9 + * The contents of this file are subject to the terms of either the GNU
   10.10 + * General Public License Version 2 only ("GPL") or the Common
   10.11 + * Development and Distribution License("CDDL") (collectively, the
   10.12 + * "License"). You may not use this file except in compliance with the
   10.13 + * License. You can obtain a copy of the License at
   10.14 + * http://www.netbeans.org/cddl-gplv2.html
   10.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   10.16 + * specific language governing permissions and limitations under the
   10.17 + * License.  When distributing the software, include this License Header
   10.18 + * Notice in each file and include the License file at
   10.19 + * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   10.20 + * particular file as subject to the "Classpath" exception as provided
   10.21 + * by Sun in the GPL Version 2 section of the License file that
   10.22 + * accompanied this code. If applicable, add the following below the
   10.23 + * License Header, with the fields enclosed by brackets [] replaced by
   10.24 + * your own identifying information:
   10.25 + * "Portions Copyrighted [year] [name of copyright owner]"
   10.26 + *
   10.27 + * Contributor(s):
   10.28 + *
   10.29 + * Portions Copyrighted 2007 Sun Microsystems, Inc.
   10.30 + */
   10.31 +package org.netbeans.modules.visualweb.project.jsfloader.test;
   10.32 +
   10.33 +import org.openide.filesystems.FileObject;
   10.34 +import org.openide.filesystems.MIMEResolver;
   10.35 +
   10.36 +/**
   10.37 + *
   10.38 + * @author sandipchitale
   10.39 + */
   10.40 +public class JsfLoaderMimeResolver extends MIMEResolver {
   10.41 +
   10.42 +    public JsfLoaderMimeResolver() {
   10.43 +        super();
   10.44 +    }
   10.45 +
   10.46 +    public String findMIMEType(FileObject fo) {
   10.47 +        //System.out.println("Trying to find FileObject MIME Type." + fo);
   10.48 +
   10.49 +        if (fo.getExt().equals("jsp") || fo.getExt().equals("jspf")) {
   10.50 +            return "text/x-jsp";
   10.51 +        } else if (fo.getExt().equals("java")) {
   10.52 +            return "text/x-java";
   10.53 +        }
   10.54 +        return null;
   10.55 +    }
   10.56 +}
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/visualweb.project.jsfloader/test/unit/src/org/netbeans/modules/visualweb/project/jsfloader/test/MockOpenProjectsTrampoline.java	Wed Oct 17 22:33:27 2007 +0000
    11.3 @@ -0,0 +1,108 @@
    11.4 +/*
    11.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    11.6 + *
    11.7 + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
    11.8 + *
    11.9 + * The contents of this file are subject to the terms of either the GNU
   11.10 + * General Public License Version 2 only ("GPL") or the Common
   11.11 + * Development and Distribution License("CDDL") (collectively, the
   11.12 + * "License"). You may not use this file except in compliance with the
   11.13 + * License. You can obtain a copy of the License at
   11.14 + * http://www.netbeans.org/cddl-gplv2.html
   11.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   11.16 + * specific language governing permissions and limitations under the
   11.17 + * License.  When distributing the software, include this License Header
   11.18 + * Notice in each file and include the License file at
   11.19 + * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   11.20 + * particular file as subject to the "Classpath" exception as provided
   11.21 + * by Sun in the GPL Version 2 section of the License file that
   11.22 + * accompanied this code. If applicable, add the following below the
   11.23 + * License Header, with the fields enclosed by brackets [] replaced by
   11.24 + * your own identifying information:
   11.25 + * "Portions Copyrighted [year] [name of copyright owner]"
   11.26 + *
   11.27 + * Contributor(s):
   11.28 + *
   11.29 + * Portions Copyrighted 2007 Sun Microsystems, Inc.
   11.30 + */
   11.31 +package org.netbeans.modules.visualweb.project.jsfloader.test;
   11.32 +
   11.33 +import java.beans.PropertyChangeListener;
   11.34 +import java.beans.PropertyChangeSupport;
   11.35 +import java.util.ArrayList;
   11.36 +import java.util.Collection;
   11.37 +import org.netbeans.api.project.Project;
   11.38 +import org.netbeans.api.project.ProjectUtils;
   11.39 +import org.netbeans.api.project.ui.OpenProjects;
   11.40 +import org.netbeans.modules.project.uiapi.OpenProjectsTrampoline;
   11.41 +
   11.42 +/**
   11.43 + *
   11.44 + * @author joelle
   11.45 + */
   11.46 +public class MockOpenProjectsTrampoline implements OpenProjectsTrampoline {
   11.47 +    /** Property change listeners registered through API */
   11.48 +    private PropertyChangeSupport pchSupport;
   11.49 +    
   11.50 +    private final Collection<Project> openProjects = new ArrayList<Project>();
   11.51 +
   11.52 +    public MockOpenProjectsTrampoline() {
   11.53 +        
   11.54 +    }
   11.55 +
   11.56 +    public Project[] getOpenProjectsAPI() {
   11.57 +        Project[] projects = new Project[openProjects.size()];
   11.58 +        openProjects.toArray(projects);
   11.59 +        return projects;
   11.60 +    }
   11.61 +
   11.62 +    public void openAPI(Project[] projects, boolean openRequiredProjects) {
   11.63 +        Project[] oldProjects = getOpenProjectsAPI();
   11.64 +        for (Project project : projects) {
   11.65 +            openProjects.add(project);
   11.66 +            mainProject = project;
   11.67 +        }
   11.68 +        Project[] newProjects = getOpenProjectsAPI();
   11.69 +        if (pchSupport != null) {
   11.70 +            pchSupport.firePropertyChange(OpenProjects.PROPERTY_OPEN_PROJECTS, oldProjects, newProjects);
   11.71 +        }
   11.72 +    }
   11.73 +
   11.74 +    public void closeAPI(Project[] projects) {
   11.75 +        Project[] oldProjects = getOpenProjectsAPI();
   11.76 +        for (Project project : projects) {
   11.77 +            openProjects.remove(project);
   11.78 +        }
   11.79 +        Project[] newProjects = getOpenProjectsAPI();
   11.80 +        if (pchSupport != null) {
   11.81 +            pchSupport.firePropertyChange(OpenProjects.PROPERTY_OPEN_PROJECTS, oldProjects, newProjects);
   11.82 +        }
   11.83 +    }
   11.84 +
   11.85 +    public void addPropertyChangeListenerAPI(PropertyChangeListener listener, Object source) {
   11.86 +        if (pchSupport == null) {
   11.87 +            pchSupport = new PropertyChangeSupport(this);
   11.88 +        }
   11.89 +        pchSupport.addPropertyChangeListener(listener);
   11.90 +    }
   11.91 +
   11.92 +    public void removePropertyChangeListenerAPI(PropertyChangeListener listener) {
   11.93 +        if (pchSupport == null) {
   11.94 +            pchSupport = new PropertyChangeSupport(this);
   11.95 +        }
   11.96 +        pchSupport.removePropertyChangeListener(listener);
   11.97 +    }
   11.98 +    
   11.99 +    private Project mainProject;
  11.100 +
  11.101 +    public Project getMainProject() {
  11.102 +        return mainProject;
  11.103 +    }
  11.104 +
  11.105 +    public void setMainProject(Project project) {
  11.106 +        if (project != null && !openProjects.contains(project)) {
  11.107 +            throw new IllegalArgumentException("Project " + ProjectUtils.getInformation(project).getDisplayName() + " is not open and cannot be set as main.");
  11.108 +        }
  11.109 +        this.mainProject = project;
  11.110 +    }
  11.111 +}
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/visualweb.project.jsfloader/test/unit/src/org/netbeans/modules/visualweb/project/jsfloader/test/SetupUtils.java	Wed Oct 17 22:33:27 2007 +0000
    12.3 @@ -0,0 +1,167 @@
    12.4 +/*
    12.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    12.6 + * 
    12.7 + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
    12.8 + * 
    12.9 + * The contents of this file are subject to the terms of either the GNU
   12.10 + * General Public License Version 2 only ("GPL") or the Common
   12.11 + * Development and Distribution License("CDDL") (collectively, the
   12.12 + * "License"). You may not use this file except in compliance with the
   12.13 + * License. You can obtain a copy of the License at
   12.14 + * http://www.netbeans.org/cddl-gplv2.html
   12.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   12.16 + * specific language governing permissions and limitations under the
   12.17 + * License.  When distributing the software, include this License Header
   12.18 + * Notice in each file and include the License file at
   12.19 + * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
   12.20 + * particular file as subject to the "Classpath" exception as provided
   12.21 + * by Sun in the GPL Version 2 section of the License file that
   12.22 + * accompanied this code. If applicable, add the following below the
   12.23 + * License Header, with the fields enclosed by brackets [] replaced by
   12.24 + * your own identifying information:
   12.25 + * "Portions Copyrighted [year] [name of copyright owner]"
   12.26 + * 
   12.27 + * If you wish your version of this file to be governed by only the CDDL
   12.28 + * or only the GPL Version 2, indicate your decision by adding
   12.29 + * "[Contributor] elects to include this software in this distribution
   12.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   12.31 + * single choice of license, a recipient has the option to distribute
   12.32 + * your version of this file under either the CDDL, the GPL Version 2 or
   12.33 + * to extend the choice of license to its licensees as provided above.
   12.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   12.35 + * Version 2 license, then the option applies only if the new code is
   12.36 + * made subject to such option by the copyright holder.
   12.37 + * 
   12.38 + * Contributor(s):
   12.39 + * 
   12.40 + * Portions Copyrighted 2007 Sun Microsystems, Inc.
   12.41 + */
   12.42 +
   12.43 +package org.netbeans.modules.visualweb.project.jsfloader.test;
   12.44 +
   12.45 +import java.io.File;
   12.46 +import java.io.FileInputStream;
   12.47 +import java.io.IOException;
   12.48 +import java.io.OutputStream;
   12.49 +import java.util.Arrays;
   12.50 +import java.util.Collections;
   12.51 +import java.util.Enumeration;
   12.52 +import java.util.zip.ZipEntry;
   12.53 +import java.util.zip.ZipInputStream;
   12.54 +import javax.swing.event.ChangeEvent;
   12.55 +import org.netbeans.api.project.Project;
   12.56 +import org.netbeans.api.project.ProjectManager;
   12.57 +import org.netbeans.api.project.ui.OpenProjects;
   12.58 +import org.netbeans.modules.visualweb.project.jsfloader.JsfJavaDataLoader;
   12.59 +import org.netbeans.modules.visualweb.project.jsfloader.JsfJspDataLoader;
   12.60 +import org.openide.filesystems.FileLock;
   12.61 +import org.openide.filesystems.FileObject;
   12.62 +import org.openide.filesystems.FileUtil;
   12.63 +import org.openide.loaders.DataLoader;
   12.64 +import org.openide.loaders.DataLoaderPool;
   12.65 +import org.openide.util.Lookup;
   12.66 +import org.openide.util.LookupEvent;
   12.67 +import org.openide.util.LookupListener;
   12.68 +import org.openide.util.test.MockLookup;
   12.69 +
   12.70 +/**
   12.71 + *
   12.72 + * @author quynguyen
   12.73 + */
   12.74 +public class SetupUtils {
   12.75 +    
   12.76 +    public static Project setup(File workDir) throws IOException {
   12.77 +        File userDir = new File(workDir, "userdir");
   12.78 +        userDir.mkdir();
   12.79 +        System.getProperties().put("netbeans.user", userDir.getAbsolutePath());
   12.80 +        
   12.81 +        MockLookup.init();
   12.82 +        DataLoaderPool pool = new SetupUtils.DefaultPool();
   12.83 +        MockLookup.setInstances(pool);
   12.84 +        
   12.85 +        DataLoader loader = new JsfJspDataLoader();
   12.86 +        DataLoader javaLoader = new JsfJavaDataLoader();
   12.87 +        MockLookup.setInstances(pool, loader, javaLoader);
   12.88 +        
   12.89 +        String zipResource = "VWJavaEE5.zip";
   12.90 +        String zipPath = SetupUtils.class.getResource(zipResource).getPath();
   12.91 +        if (zipPath == null) {
   12.92 +            throw new IOException("Could not load zip resource: " + zipResource);
   12.93 +        }
   12.94 +        
   12.95 +        File archiveFile = new File(zipPath);
   12.96 +
   12.97 +        FileObject destFileObj = FileUtil.toFileObject(workDir);
   12.98 +        unZipFile(archiveFile, destFileObj);
   12.99 +        
  12.100 +        if (!destFileObj.isValid()) {
  12.101 +            throw new IOException("FileObject for project directory not valid");
  12.102 +        }
  12.103 +        
  12.104 +        FileObject testApp = destFileObj.getFileObject("VWJavaEE5");
  12.105 +        System.out.println("Children of VWJavaEE5:" + Arrays.toString(testApp.getChildren()));
  12.106 +
  12.107 +        Project project = ProjectManager.getDefault().findProject(testApp);
  12.108 +        
  12.109 +        if (project == null) {
  12.110 +            throw new IOException("Could not load project");
  12.111 +        }
  12.112 +        
  12.113 +        OpenProjects.getDefault().open(new Project[]{project}, false);
  12.114 +        return project;
  12.115 +    }
  12.116 +
  12.117 +    private static void unZipFile(File archiveFile, FileObject destDir) throws IOException {
  12.118 +        FileInputStream fis = new FileInputStream(archiveFile);
  12.119 +        try {
  12.120 +            ZipInputStream str = new ZipInputStream(fis);
  12.121 +            ZipEntry entry;
  12.122 +            while ((entry = str.getNextEntry()) != null) {
  12.123 +                if (entry.isDirectory()) {
  12.124 +                    FileUtil.createFolder(destDir, entry.getName());
  12.125 +                } else {
  12.126 +                    FileObject fo = FileUtil.createData(destDir, entry.getName());
  12.127 +                    FileLock lock = fo.lock();
  12.128 +                    try {
  12.129 +                        OutputStream out = fo.getOutputStream(lock);
  12.130 +                        try {
  12.131 +                            FileUtil.copy(str, out);
  12.132 +                        } finally {
  12.133 +                            out.close();
  12.134 +                        }
  12.135 +                    } finally {
  12.136 +                        lock.releaseLock();
  12.137 +                    }
  12.138 +                }
  12.139 +            }
  12.140 +        } finally {
  12.141 +            fis.close();
  12.142 +        }
  12.143 +    }
  12.144 +    
  12.145 +    /**
  12.146 +     * Taken from DataLoaderPool.DefaultPool to override NbLoaderPool
  12.147 +     * 
  12.148 +     * Special pool for unit testing etc.
  12.149 +     * Finds all relevant data loaders in default lookup.
  12.150 +     * 
  12.151 +     */
  12.152 +    public static final class DefaultPool extends DataLoaderPool implements LookupListener {
  12.153 +        
  12.154 +        private final Lookup.Result<DataLoader> result;
  12.155 +        
  12.156 +        public DefaultPool() {
  12.157 +            result = Lookup.getDefault().lookupResult(DataLoader.class);
  12.158 +            result.addLookupListener(this);
  12.159 +        }
  12.160 +        
  12.161 +        protected Enumeration<? extends DataLoader> loaders() {
  12.162 +            return Collections.enumeration(result.allInstances());
  12.163 +        }
  12.164 +        
  12.165 +        public void resultChanged(LookupEvent e) {
  12.166 +            fireChangeEvent(new ChangeEvent(this));
  12.167 +        }
  12.168 +        
  12.169 +    }
  12.170 +}