Tests at least should compile now.
authorJesse Glick <jglick@netbeans.org>
Wed, 23 Mar 2011 16:50:27 -0400
changeset 3213c85dcf71e424
parent 3212 bbc8dd036333
child 3214 cf80c1d5c3ea
Tests at least should compile now.
visualweb.insync/nbproject/genfiles.properties
visualweb.insync/nbproject/project.xml
visualweb.insync/test/unit/src/org/netbeans/modules/visualweb/insync/InsyncTestBase.java
visualweb.jsfsupport/nbproject/genfiles.properties
visualweb.jsfsupport/nbproject/project.xml
visualweb.propertyeditors/nbproject/genfiles.properties
visualweb.propertyeditors/nbproject/project.xml
visualweb.websvcmgr/nbproject/genfiles.properties
visualweb.websvcmgr/nbproject/project.properties
visualweb.websvcmgr/nbproject/project.xml
visualweb.websvcmgr/test/qa-functional/src/org/netbeans/test/websvcmgr/WebServiceAcceptanceTest.java
visualweb.websvcmgr/test/unit/src/org/netbeans/modules/websvc/manager/test/DialogDisplayerNotifier.java
visualweb.websvcmgr/test/unit/src/org/netbeans/modules/websvc/manager/test/InstalledFileLocatorImpl.java
visualweb.websvcmgr/test/unit/src/org/netbeans/modules/websvc/manager/test/SetupData.java
visualweb.websvcmgr/test/unit/src/org/netbeans/modules/websvc/manager/test/SetupUtil.java
visualweb.websvcmgr/test/unit/src/org/netbeans/modules/websvc/manager/test/WebServiceManagerEvent.java
visualweb.websvcmgr/test/unit/src/org/netbeans/modules/websvc/manager/test/WebServiceManagerListener.java
visualweb.websvcmgr/test/unit/src/org/netbeans/modules/websvc/saas/model/SaasServicesModelTest.java
visualweb.websvcmgr/test/unit/src/org/netbeans/modules/websvc/saas/util/DialogDisplayerNotifier.java
visualweb.websvcmgr/test/unit/src/org/netbeans/modules/websvc/saas/util/InstalledFileLocatorImpl.java
visualweb.websvcmgr/test/unit/src/org/netbeans/modules/websvc/saas/util/SetupUtil.java
visualweb.webui.designtime/nbproject/genfiles.properties
visualweb.webui.designtime/nbproject/project.xml
     1.1 --- a/visualweb.insync/nbproject/genfiles.properties	Wed Mar 23 16:49:42 2011 -0400
     1.2 +++ b/visualweb.insync/nbproject/genfiles.properties	Wed Mar 23 16:50:27 2011 -0400
     1.3 @@ -1,5 +1,5 @@
     1.4  # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
     1.5  # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
     1.6 -nbproject/build-impl.xml.data.CRC32=4767b086
     1.7 +nbproject/build-impl.xml.data.CRC32=2f4d3ee1
     1.8  nbproject/build-impl.xml.script.CRC32=578bda41
     1.9  nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.45
     2.1 --- a/visualweb.insync/nbproject/project.xml	Wed Mar 23 16:49:42 2011 -0400
     2.2 +++ b/visualweb.insync/nbproject/project.xml	Wed Mar 23 16:50:27 2011 -0400
     2.3 @@ -489,6 +489,10 @@
     2.4                  <test-type>
     2.5                      <name>unit</name>
     2.6                      <test-dependency>
     2.7 +                        <code-name-base>org.netbeans.libs.junit4</code-name-base>
     2.8 +                        <compile-dependency/>
     2.9 +                    </test-dependency>
    2.10 +                    <test-dependency>
    2.11                          <code-name-base>org.netbeans.modules.editor.mimelookup.impl</code-name-base>
    2.12                          <recursive/>
    2.13                          <compile-dependency/>
    2.14 @@ -503,6 +507,11 @@
    2.15                          <recursive/>
    2.16                      </test-dependency>
    2.17                      <test-dependency>
    2.18 +                        <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
    2.19 +                        <recursive/>
    2.20 +                        <compile-dependency/>
    2.21 +                    </test-dependency>
    2.22 +                    <test-dependency>
    2.23                          <code-name-base>org.netbeans.modules.projectapi</code-name-base>
    2.24                          <recursive/>
    2.25                          <compile-dependency/>
     3.1 --- a/visualweb.insync/test/unit/src/org/netbeans/modules/visualweb/insync/InsyncTestBase.java	Wed Mar 23 16:49:42 2011 -0400
     3.2 +++ b/visualweb.insync/test/unit/src/org/netbeans/modules/visualweb/insync/InsyncTestBase.java	Wed Mar 23 16:50:27 2011 -0400
     3.3 @@ -40,10 +40,9 @@
     3.4  import java.util.ArrayList;
     3.5  import java.util.List;
     3.6  import java.util.regex.Pattern;
     3.7 -import junit.framework.*;
     3.8  import org.netbeans.api.project.Project;
     3.9  import org.netbeans.api.project.libraries.LibraryManager;
    3.10 -import org.netbeans.core.startup.layers.NbinstURLStreamHandlerFactory;
    3.11 +import org.netbeans.junit.MockServices;
    3.12  import org.netbeans.junit.NbTestCase;
    3.13  import org.netbeans.modules.visualweb.insync.beans.Bean;
    3.14  import org.netbeans.modules.visualweb.insync.beans.BeansUnit;
    3.15 @@ -52,7 +51,7 @@
    3.16  import org.netbeans.modules.web.project.WebProject;
    3.17  import org.openide.filesystems.FileObject;
    3.18  import org.openide.util.Exceptions;
    3.19 -import org.openide.util.test.MockLookup;
    3.20 +import org.openide.util.Lookup;
    3.21  
    3.22  /**
    3.23   *
    3.24 @@ -283,12 +282,7 @@
    3.25      }
    3.26      
    3.27      private static void setupServices() {
    3.28 -        URLStreamHandlerFactory urlStreamHandlerFactory = new NbinstURLStreamHandlerFactory();
    3.29 -        URL.setURLStreamHandlerFactory(urlStreamHandlerFactory);        
    3.30 -        MockLookup.setInstances(
    3.31 -            new RepositoryImpl(),
    3.32 -            new InsyncMimeResolver(),
    3.33 -            urlStreamHandlerFactory
    3.34 -        );
    3.35 +        URL.setURLStreamHandlerFactory(Lookup.getDefault().lookup(URLStreamHandlerFactory.class));
    3.36 +        MockServices.setServices(RepositoryImpl.class, InsyncMimeResolver.class);
    3.37      }    
    3.38  }
     4.1 --- a/visualweb.jsfsupport/nbproject/genfiles.properties	Wed Mar 23 16:49:42 2011 -0400
     4.2 +++ b/visualweb.jsfsupport/nbproject/genfiles.properties	Wed Mar 23 16:50:27 2011 -0400
     4.3 @@ -1,5 +1,5 @@
     4.4  # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
     4.5  # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
     4.6 -nbproject/build-impl.xml.data.CRC32=eabbf6c6
     4.7 +nbproject/build-impl.xml.data.CRC32=269417f7
     4.8  nbproject/build-impl.xml.script.CRC32=c51984ed
     4.9  nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.45
     5.1 --- a/visualweb.jsfsupport/nbproject/project.xml	Wed Mar 23 16:49:42 2011 -0400
     5.2 +++ b/visualweb.jsfsupport/nbproject/project.xml	Wed Mar 23 16:50:27 2011 -0400
     5.3 @@ -158,11 +158,6 @@
     5.4                          <recursive/>
     5.5                          <compile-dependency/>
     5.6                      </test-dependency>
     5.7 -                    <test-dependency>
     5.8 -                        <code-name-base>org.openide.util</code-name-base>
     5.9 -                        <compile-dependency/>
    5.10 -                        <test/>
    5.11 -                    </test-dependency>
    5.12                  </test-type>
    5.13              </test-dependencies>
    5.14              <friend-packages>
     6.1 --- a/visualweb.propertyeditors/nbproject/genfiles.properties	Wed Mar 23 16:49:42 2011 -0400
     6.2 +++ b/visualweb.propertyeditors/nbproject/genfiles.properties	Wed Mar 23 16:50:27 2011 -0400
     6.3 @@ -1,5 +1,5 @@
     6.4  # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
     6.5  # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
     6.6 -nbproject/build-impl.xml.data.CRC32=21855a35
     6.7 +nbproject/build-impl.xml.data.CRC32=2a3c6743
     6.8  nbproject/build-impl.xml.script.CRC32=2101cfd6
     6.9  nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.45
     7.1 --- a/visualweb.propertyeditors/nbproject/project.xml	Wed Mar 23 16:49:42 2011 -0400
     7.2 +++ b/visualweb.propertyeditors/nbproject/project.xml	Wed Mar 23 16:50:27 2011 -0400
     7.3 @@ -210,6 +210,20 @@
     7.4                      </run-dependency>
     7.5                  </dependency>
     7.6              </module-dependencies>
     7.7 +            <test-dependencies>
     7.8 +                <test-type>
     7.9 +                    <name>unit</name>
    7.10 +                    <test-dependency>
    7.11 +                        <code-name-base>org.netbeans.libs.junit4</code-name-base>
    7.12 +                        <compile-dependency/>
    7.13 +                    </test-dependency>
    7.14 +                    <test-dependency>
    7.15 +                        <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
    7.16 +                        <recursive/>
    7.17 +                        <compile-dependency/>
    7.18 +                    </test-dependency>
    7.19 +                </test-type>
    7.20 +            </test-dependencies>
    7.21              <friend-packages>
    7.22                  <friend>org.netbeans.modules.visualweb.designer.jsf</friend>
    7.23                  <friend>org.netbeans.modules.visualweb.insync</friend>
     8.1 --- a/visualweb.websvcmgr/nbproject/genfiles.properties	Wed Mar 23 16:49:42 2011 -0400
     8.2 +++ b/visualweb.websvcmgr/nbproject/genfiles.properties	Wed Mar 23 16:50:27 2011 -0400
     8.3 @@ -1,5 +1,5 @@
     8.4  # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
     8.5  # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
     8.6 -nbproject/build-impl.xml.data.CRC32=1aa34677
     8.7 +nbproject/build-impl.xml.data.CRC32=87240cfe
     8.8  nbproject/build-impl.xml.script.CRC32=c13b62a3
     8.9  nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.45
     9.1 --- a/visualweb.websvcmgr/nbproject/project.properties	Wed Mar 23 16:49:42 2011 -0400
     9.2 +++ b/visualweb.websvcmgr/nbproject/project.properties	Wed Mar 23 16:50:27 2011 -0400
     9.3 @@ -41,7 +41,3 @@
     9.4  # made subject to such option by the copyright holder.
     9.5  
     9.6  javac.source=1.6
     9.7 -test-unit-sys-prop.java.endorsed.dirs=${websvc.jaxws21.dir}/modules/ext/jaxws21/api
     9.8 -test.qa-functional.cp.extra=${nb_all}/visualweb.kit/gravy/builds/gravy.jar:\
     9.9 -${visualweb.websvcmgr.dir}/modules/ext/tidy-mod.jar:\
    9.10 -${nb_all}/testtools/external/httpunit.jar
    10.1 --- a/visualweb.websvcmgr/nbproject/project.xml	Wed Mar 23 16:49:42 2011 -0400
    10.2 +++ b/visualweb.websvcmgr/nbproject/project.xml	Wed Mar 23 16:50:27 2011 -0400
    10.3 @@ -354,20 +354,7 @@
    10.4                  <test-type>
    10.5                      <name>unit</name>
    10.6                      <test-dependency>
    10.7 -                        <code-name-base>org.netbeans.modules.websvc.manager</code-name-base>
    10.8 -                        <compile-dependency/>
    10.9 -                        <test/>
   10.10 -                    </test-dependency>
   10.11 -                    <test-dependency>
   10.12 -                        <code-name-base>org.netbeans.modules.websvc.saas.api</code-name-base>
   10.13 -                        <compile-dependency/>
   10.14 -                        <test/>
   10.15 -                    </test-dependency>
   10.16 -                </test-type>
   10.17 -                <test-type>
   10.18 -                    <name>qa-functional</name>
   10.19 -                    <test-dependency>
   10.20 -                        <code-name-base>org.netbeans.modules.visualweb.insync</code-name-base>
   10.21 +                        <code-name-base>org.netbeans.libs.junit4</code-name-base>
   10.22                          <compile-dependency/>
   10.23                      </test-dependency>
   10.24                      <test-dependency>
   10.25 @@ -375,12 +362,20 @@
   10.26                          <recursive/>
   10.27                          <compile-dependency/>
   10.28                      </test-dependency>
   10.29 +                </test-type>
   10.30 +                <test-type>
   10.31 +                    <name>qa-functional</name>
   10.32                      <test-dependency>
   10.33 -                        <code-name-base>org.netbeans.modules.visualweb.gravy</code-name-base>
   10.34 +                        <code-name-base>org.netbeans.libs.junit4</code-name-base>
   10.35                          <compile-dependency/>
   10.36                      </test-dependency>
   10.37                      <test-dependency>
   10.38 -                        <code-name-base>org.netbeans.modules.jellytools.platform</code-name-base>
   10.39 +                        <code-name-base>org.netbeans.modules.visualweb.gravy</code-name-base>
   10.40 +                        <recursive/>
   10.41 +                        <compile-dependency/>
   10.42 +                    </test-dependency>
   10.43 +                    <test-dependency>
   10.44 +                        <code-name-base>org.netbeans.modules.visualweb.insync</code-name-base>
   10.45                          <compile-dependency/>
   10.46                      </test-dependency>
   10.47                  </test-type>
    11.1 --- a/visualweb.websvcmgr/test/qa-functional/src/org/netbeans/test/websvcmgr/WebServiceAcceptanceTest.java	Wed Mar 23 16:49:42 2011 -0400
    11.2 +++ b/visualweb.websvcmgr/test/qa-functional/src/org/netbeans/test/websvcmgr/WebServiceAcceptanceTest.java	Wed Mar 23 16:50:27 2011 -0400
    11.3 @@ -51,13 +51,9 @@
    11.4  import org.netbeans.modules.visualweb.gravy.dataconnectivity.ServerNavigatorOperator;
    11.5  import org.netbeans.modules.visualweb.gravy.dataconnectivity.ServerExplorerOperator;
    11.6  import org.netbeans.modules.visualweb.gravy.designer.DesignerPaneOperator;
    11.7 -import org.netbeans.modules.visualweb.gravy.DocumentOutlineOperator;
    11.8  import org.netbeans.modules.visualweb.gravy.plugins.PluginsOperator;
    11.9  import org.netbeans.modules.visualweb.gravy.actions.FindAction;
   11.10  import org.netbeans.modules.visualweb.gravy.websvc.*;
   11.11 -import org.netbeans.modules.visualweb.gravy.RaveWindowOperator;
   11.12 -import org.netbeans.modules.visualweb.gravy.TestUtils;
   11.13 -import org.netbeans.modules.visualweb.gravy.Util;
   11.14  import org.netbeans.modules.visualweb.gravy.model.project.components.*;
   11.15  import org.netbeans.modules.visualweb.gravy.model.project.*;
   11.16  import org.netbeans.modules.visualweb.gravy.model.components.*;
   11.17 @@ -65,7 +61,6 @@
   11.18  import org.netbeans.modules.visualweb.gravy.model.*;
   11.19  import org.netbeans.modules.visualweb.gravy.*;
   11.20  
   11.21 -import com.meterware.httpunit.*;
   11.22  import java.util.Properties;
   11.23  import java.awt.event.KeyEvent;
   11.24  import java.awt.Point;
   11.25 @@ -304,6 +299,7 @@
   11.26      }
   11.27  
   11.28      private void verifyHTTP(Project prj, String verificationString) {
   11.29 +        /* XXX httpunit not available anywhere
   11.30          try {
   11.31              WebConversation conversation = new WebConversation();
   11.32              WebResponse response = null;
   11.33 @@ -315,6 +311,7 @@
   11.34              e.printStackTrace();
   11.35              fail("Excetion in HTTP check : " + e);
   11.36          }
   11.37 +         */
   11.38      }
   11.39  
   11.40      private void projectUndeployAndClose(Project prj) {
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/visualweb.websvcmgr/test/unit/src/org/netbeans/modules/websvc/manager/test/DialogDisplayerNotifier.java	Wed Mar 23 16:50:27 2011 -0400
    12.3 @@ -0,0 +1,72 @@
    12.4 +/*
    12.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    12.6 + *
    12.7 + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
    12.8 + *
    12.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   12.10 + * Other names may be trademarks of their respective owners.
   12.11 + *
   12.12 + * The contents of this file are subject to the terms of either the GNU
   12.13 + * General Public License Version 2 only ("GPL") or the Common
   12.14 + * Development and Distribution License("CDDL") (collectively, the
   12.15 + * "License"). You may not use this file except in compliance with the
   12.16 + * License. You can obtain a copy of the License at
   12.17 + * http://www.netbeans.org/cddl-gplv2.html
   12.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   12.19 + * specific language governing permissions and limitations under the
   12.20 + * License.  When distributing the software, include this License Header
   12.21 + * Notice in each file and include the License file at
   12.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   12.23 + * particular file as subject to the "Classpath" exception as provided
   12.24 + * by Oracle in the GPL Version 2 section of the License file that
   12.25 + * accompanied this code. If applicable, add the following below the
   12.26 + * License Header, with the fields enclosed by brackets [] replaced by
   12.27 + * your own identifying information:
   12.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   12.29 + * 
   12.30 + * Contributor(s):
   12.31 + * 
   12.32 + * Portions Copyrighted 2007 Sun Microsystems, Inc.
   12.33 + */
   12.34 +
   12.35 +package org.netbeans.modules.websvc.manager.test;
   12.36 +
   12.37 +import java.awt.Dialog;
   12.38 +import java.util.LinkedList;
   12.39 +import org.openide.DialogDescriptor;
   12.40 +import org.openide.DialogDisplayer;
   12.41 +import org.openide.NotifyDescriptor;
   12.42 +
   12.43 +/**
   12.44 + *
   12.45 + * @author quynguyen
   12.46 + */
   12.47 +public class DialogDisplayerNotifier extends DialogDisplayer {
   12.48 +    private LinkedList<WebServiceManagerListener> listeners = new LinkedList<WebServiceManagerListener>();
   12.49 +    
   12.50 +    public void addListener(WebServiceManagerListener listener) {
   12.51 +        listeners.add(listener);
   12.52 +    }
   12.53 +    
   12.54 +    public void removeListener(WebServiceManagerListener listener) {
   12.55 +        listeners.remove(listener);
   12.56 +    }
   12.57 +    
   12.58 +    public void removeAllListeners() {
   12.59 +        listeners.clear();
   12.60 +    }
   12.61 +    
   12.62 +    @Override
   12.63 +    public Object notify(NotifyDescriptor descriptor) {
   12.64 +        for (WebServiceManagerListener listener : listeners) {
   12.65 +            listener.eventFired(new WebServiceManagerEvent((String)descriptor.getMessage()));
   12.66 +        }
   12.67 +        return NotifyDescriptor.OK_OPTION;
   12.68 +    }
   12.69 +
   12.70 +    @Override
   12.71 +    public Dialog createDialog(DialogDescriptor descriptor) {
   12.72 +        return null;
   12.73 +    }
   12.74 +
   12.75 +}
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/visualweb.websvcmgr/test/unit/src/org/netbeans/modules/websvc/manager/test/InstalledFileLocatorImpl.java	Wed Mar 23 16:50:27 2011 -0400
    13.3 @@ -0,0 +1,89 @@
    13.4 +/*
    13.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    13.6 + *
    13.7 + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
    13.8 + *
    13.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   13.10 + * Other names may be trademarks of their respective owners.
   13.11 + *
   13.12 + * The contents of this file are subject to the terms of either the GNU
   13.13 + * General Public License Version 2 only ("GPL") or the Common
   13.14 + * Development and Distribution License("CDDL") (collectively, the
   13.15 + * "License"). You may not use this file except in compliance with the
   13.16 + * License. You can obtain a copy of the License at
   13.17 + * http://www.netbeans.org/cddl-gplv2.html
   13.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   13.19 + * specific language governing permissions and limitations under the
   13.20 + * License.  When distributing the software, include this License Header
   13.21 + * Notice in each file and include the License file at
   13.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   13.23 + * particular file as subject to the "Classpath" exception as provided
   13.24 + * by Oracle in the GPL Version 2 section of the License file that
   13.25 + * accompanied this code. If applicable, add the following below the
   13.26 + * License Header, with the fields enclosed by brackets [] replaced by
   13.27 + * your own identifying information:
   13.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   13.29 + *
   13.30 + * Contributor(s):
   13.31 + *
   13.32 + * Portions Copyrighted 2007 Sun Microsystems, Inc.
   13.33 + */
   13.34 +
   13.35 +package org.netbeans.modules.websvc.manager.test;
   13.36 +
   13.37 +import java.io.File;
   13.38 +import java.util.ArrayList;
   13.39 +import org.openide.modules.InstalledFileLocator;
   13.40 +
   13.41 +/**
   13.42 + *  InstalledFileLocator implementation that searches the NB install directory
   13.43 + * (uses java.endorsed.dirs value from nbproject/project.properties)
   13.44 + * @author quynguyen
   13.45 + */
   13.46 +public class InstalledFileLocatorImpl extends InstalledFileLocator {
   13.47 +
   13.48 +    private ArrayList<File> baseDirs;
   13.49 +    private File userDirConfigRoot;
   13.50 +    
   13.51 +    public InstalledFileLocatorImpl() {
   13.52 +        super();
   13.53 +        File endorsedDir = new File(System.getProperty("java.endorsed.dirs"));
   13.54 +        for (int i = 0; i < 5; i++) {
   13.55 +            endorsedDir = endorsedDir.getParentFile();
   13.56 +        }
   13.57 +
   13.58 +        File installRoot = endorsedDir;
   13.59 +        File[] subdirs = installRoot.listFiles();
   13.60 +        baseDirs = new ArrayList<File>();
   13.61 +
   13.62 +        for (int i = 0; subdirs != null && i < subdirs.length; i++) {
   13.63 +            if (subdirs[i].isDirectory()) {
   13.64 +                baseDirs.add(subdirs[i]);
   13.65 +            }
   13.66 +        }
   13.67 +    }
   13.68 +
   13.69 +    @Override
   13.70 +    public File locate(String relativePath, String codeNameBase, boolean localized) {
   13.71 +        for (File baseDir : baseDirs) {
   13.72 +            File f = new File(baseDir, relativePath);
   13.73 +            if (f.exists()) {
   13.74 +                return f;
   13.75 +            }
   13.76 +        }
   13.77 +
   13.78 +        return null;
   13.79 +    }
   13.80 +    
   13.81 +    public void setUserConfigRoot(File baseDir) {
   13.82 +        if (userDirConfigRoot != null) {
   13.83 +            baseDirs.remove(userDirConfigRoot);
   13.84 +            userDirConfigRoot = null;
   13.85 +        }
   13.86 +        
   13.87 +        if (baseDir != null) {
   13.88 +            baseDirs.add(baseDir);
   13.89 +            userDirConfigRoot = baseDir;
   13.90 +        }
   13.91 +    }
   13.92 +}
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/visualweb.websvcmgr/test/unit/src/org/netbeans/modules/websvc/manager/test/SetupData.java	Wed Mar 23 16:50:27 2011 -0400
    14.3 @@ -0,0 +1,83 @@
    14.4 +/*
    14.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    14.6 + *
    14.7 + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
    14.8 + *
    14.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   14.10 + * Other names may be trademarks of their respective owners.
   14.11 + *
   14.12 + * The contents of this file are subject to the terms of either the GNU
   14.13 + * General Public License Version 2 only ("GPL") or the Common
   14.14 + * Development and Distribution License("CDDL") (collectively, the
   14.15 + * "License"). You may not use this file except in compliance with the
   14.16 + * License. You can obtain a copy of the License at
   14.17 + * http://www.netbeans.org/cddl-gplv2.html
   14.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   14.19 + * specific language governing permissions and limitations under the
   14.20 + * License.  When distributing the software, include this License Header
   14.21 + * Notice in each file and include the License file at
   14.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   14.23 + * particular file as subject to the "Classpath" exception as provided
   14.24 + * by Oracle in the GPL Version 2 section of the License file that
   14.25 + * accompanied this code. If applicable, add the following below the
   14.26 + * License Header, with the fields enclosed by brackets [] replaced by
   14.27 + * your own identifying information:
   14.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   14.29 + * 
   14.30 + * Contributor(s):
   14.31 + * 
   14.32 + * Portions Copyrighted 2007 Sun Microsystems, Inc.
   14.33 + */
   14.34 +
   14.35 +package org.netbeans.modules.websvc.manager.test;
   14.36 +
   14.37 +import java.io.File;
   14.38 +
   14.39 +/**
   14.40 + *
   14.41 + * @author quynguyen
   14.42 + */
   14.43 +public class SetupData {
   14.44 +    private File localWsdlFile = null;
   14.45 +    private File localCatalogFile = null;
   14.46 +    private File localOriginalWsdl = null;
   14.47 +    
   14.48 +    private File websvcHome = null;
   14.49 +    
   14.50 +    public SetupData() {
   14.51 +    }
   14.52 +
   14.53 +    public File getLocalCatalogFile() {
   14.54 +        return localCatalogFile;
   14.55 +    }
   14.56 +
   14.57 +    public void setLocalCatalogFile(File localCatalogFile) {
   14.58 +        this.localCatalogFile = localCatalogFile;
   14.59 +    }
   14.60 +
   14.61 +    public File getLocalOriginalWsdl() {
   14.62 +        return localOriginalWsdl;
   14.63 +    }
   14.64 +
   14.65 +    public void setLocalOriginalWsdl(File localOriginalWsdl) {
   14.66 +        this.localOriginalWsdl = localOriginalWsdl;
   14.67 +    }
   14.68 +
   14.69 +    public File getLocalWsdlFile() {
   14.70 +        return localWsdlFile;
   14.71 +    }
   14.72 +
   14.73 +    public void setLocalWsdlFile(File localWsdlFile) {
   14.74 +        this.localWsdlFile = localWsdlFile;
   14.75 +    }
   14.76 +
   14.77 +    public File getWebsvcHome() {
   14.78 +        return websvcHome;
   14.79 +    }
   14.80 +
   14.81 +    public void setWebsvcHome(File websvcHome) {
   14.82 +        this.websvcHome = websvcHome;
   14.83 +    }
   14.84 +    
   14.85 +    
   14.86 +}
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/visualweb.websvcmgr/test/unit/src/org/netbeans/modules/websvc/manager/test/SetupUtil.java	Wed Mar 23 16:50:27 2011 -0400
    15.3 @@ -0,0 +1,265 @@
    15.4 +/*
    15.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    15.6 + *
    15.7 + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
    15.8 + *
    15.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   15.10 + * Other names may be trademarks of their respective owners.
   15.11 + *
   15.12 + * The contents of this file are subject to the terms of either the GNU
   15.13 + * General Public License Version 2 only ("GPL") or the Common
   15.14 + * Development and Distribution License("CDDL") (collectively, the
   15.15 + * "License"). You may not use this file except in compliance with the
   15.16 + * License. You can obtain a copy of the License at
   15.17 + * http://www.netbeans.org/cddl-gplv2.html
   15.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   15.19 + * specific language governing permissions and limitations under the
   15.20 + * License.  When distributing the software, include this License Header
   15.21 + * Notice in each file and include the License file at
   15.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   15.23 + * particular file as subject to the "Classpath" exception as provided
   15.24 + * by Oracle in the GPL Version 2 section of the License file that
   15.25 + * accompanied this code. If applicable, add the following below the
   15.26 + * License Header, with the fields enclosed by brackets [] replaced by
   15.27 + * your own identifying information:
   15.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   15.29 + * 
   15.30 + * Contributor(s):
   15.31 + * 
   15.32 + * Portions Copyrighted 2007 Sun Microsystems, Inc.
   15.33 + */
   15.34 +
   15.35 +package org.netbeans.modules.websvc.manager.test;
   15.36 +
   15.37 +import java.io.File;
   15.38 +import java.io.FileFilter;
   15.39 +import java.io.FileInputStream;
   15.40 +import java.io.FileOutputStream;
   15.41 +import java.io.IOException;
   15.42 +import java.io.InputStream;
   15.43 +import java.net.URL;
   15.44 +import java.nio.channels.FileChannel;
   15.45 +import java.util.ArrayList;
   15.46 +import java.util.List;
   15.47 +import java.util.Properties;
   15.48 +import java.util.jar.Manifest;
   15.49 +import org.netbeans.junit.MockServices;
   15.50 +import org.netbeans.modules.websvc.manager.WebServiceManager;
   15.51 +import org.openide.DialogDisplayer;
   15.52 +import org.openide.filesystems.FileSystem;
   15.53 +import org.openide.filesystems.FileUtil;
   15.54 +import org.openide.filesystems.LocalFileSystem;
   15.55 +import org.openide.filesystems.MultiFileSystem;
   15.56 +import org.openide.filesystems.Repository;
   15.57 +import org.openide.filesystems.XMLFileSystem;
   15.58 +import org.openide.modules.InstalledFileLocator;
   15.59 +import org.openide.util.Lookup;
   15.60 +import org.openide.util.LookupEvent;
   15.61 +import org.openide.util.LookupListener;
   15.62 +import org.openide.util.NbCollections;
   15.63 +
   15.64 +/**
   15.65 + *
   15.66 + * @author quynguyen
   15.67 + */
   15.68 +public class SetupUtil {
   15.69 +    private static final String WORKDIR_SPACES = "user directory";
   15.70 +    private static final String WORKDIR = "userdirectory";
   15.71 +    private static final String TEST_WSDL = "/org/netbeans/modules/websvc/manager/resources/uszip-asmx-catalog/www.webservicemart.com/uszip.asmx.wsdl";
   15.72 +    private static final String TEST_CATALOG = "/org/netbeans/modules/websvc/manager/resources/uszip-asmx-catalog/catalog.xml";
   15.73 +    private static final String CATALOG_FILE = "uszip-asmx-catalog/catalog.xml";
   15.74 +    private static final String WSDL_FILE = "uszip-asmx-catalog/www.webservicemart.com/uszip.asmx.wsdl";
   15.75 +    
   15.76 +    private static final String ENDORSED_REF = "modules/ext/jaxws21/api/jaxws-api.jar";
   15.77 +    private static final String JAXWS_LIB_PROPERTY = "libs.jaxws21.classpath";
   15.78 +    
   15.79 +    public static SetupData commonSetUp(File workingDir) throws Exception {
   15.80 +        SetupData data = new SetupData();
   15.81 +        
   15.82 +        File userDir = new File(workingDir.getParentFile(),
   15.83 +                System.getProperty("os.name").startsWith("Windows") ? WORKDIR_SPACES : WORKDIR);
   15.84 +        System.getProperties().setProperty("netbeans.user", userDir.getAbsolutePath());
   15.85 +        
   15.86 +        File websvcHome = new File(WebServiceManager.WEBSVC_HOME);
   15.87 +        data.setWebsvcHome(websvcHome);
   15.88 +        
   15.89 +        File websvcUserDir = new File(WebServiceManager.WEBSVC_HOME);
   15.90 +        websvcUserDir.mkdirs();
   15.91 +        
   15.92 +        File wsdlFile = new File(websvcUserDir, WSDL_FILE);
   15.93 +        File catalogFile = new File(websvcUserDir, CATALOG_FILE);
   15.94 +
   15.95 +        retrieveURL(wsdlFile, SetupUtil.class.getResource(TEST_WSDL));
   15.96 +        retrieveURL(catalogFile, SetupUtil.class.getResource(TEST_CATALOG));
   15.97 +        
   15.98 +        copy(wsdlFile, workingDir);
   15.99 +        
  15.100 +        data.setLocalWsdlFile(wsdlFile);
  15.101 +        data.setLocalCatalogFile(catalogFile);
  15.102 +        data.setLocalOriginalWsdl(new File(workingDir, wsdlFile.getName()));
  15.103 +        
  15.104 +        MainFS fs = new MainFS();
  15.105 +        fs.setConfigRootDir(websvcHome.getParentFile());
  15.106 +        TestRepository.defaultFileSystem = fs;
  15.107 +        
  15.108 +        MockServices.setServices(DialogDisplayerNotifier.class, InstalledFileLocatorImpl.class, TestRepository.class);
  15.109 +        
  15.110 +        InstalledFileLocatorImpl locator = (InstalledFileLocatorImpl)Lookup.getDefault().lookup(InstalledFileLocator.class);
  15.111 +        locator.setUserConfigRoot(websvcHome.getParentFile());
  15.112 +        
  15.113 +        File targetBuildProperties = new File(websvcUserDir.getParentFile().getParentFile(), "build.properties");
  15.114 +        generatePropertiesFile(targetBuildProperties);
  15.115 +        
  15.116 +        return data;
  15.117 +    }
  15.118 +
  15.119 +    public static void commonTearDown() throws Exception {
  15.120 +        DialogDisplayer dd = DialogDisplayer.getDefault();
  15.121 +        if (dd instanceof DialogDisplayerNotifier) {
  15.122 +            ((DialogDisplayerNotifier)dd).removeAllListeners();
  15.123 +        }
  15.124 +        
  15.125 +        MockServices.setServices();
  15.126 +    }
  15.127 +    
  15.128 +    public static void copy(File src, File target) throws Exception {        
  15.129 +        if (src.isFile()) {
  15.130 +            File targetFile = new File(target, src.getName());
  15.131 +            
  15.132 +            FileInputStream is = new FileInputStream(src);
  15.133 +            FileOutputStream os = new FileOutputStream(targetFile);
  15.134 +            
  15.135 +            FileChannel inputChannel = is.getChannel();
  15.136 +            FileChannel outputChannel = os.getChannel();
  15.137 +            
  15.138 +            inputChannel.transferTo(0, inputChannel.size(), outputChannel);
  15.139 +            inputChannel.close();
  15.140 +            outputChannel.close();
  15.141 +        }else {
  15.142 +            File newDir = new File(target, src.getName());
  15.143 +            newDir.mkdirs();
  15.144 +            
  15.145 +            File[] dirFiles = src.listFiles();
  15.146 +            if (dirFiles != null) {
  15.147 +                for (int i = 0; i < dirFiles.length; i++) {
  15.148 +                    copy(dirFiles[i], newDir);
  15.149 +                }
  15.150 +            }
  15.151 +        }
  15.152 +    }
  15.153 +    
  15.154 +    public static void retrieveURL(File targetFile, URL url) throws IOException {
  15.155 +        targetFile.getParentFile().mkdirs();
  15.156 +        FileOutputStream fos = new FileOutputStream(targetFile);
  15.157 +        byte[] readBuffer = new byte[1024];
  15.158 +        
  15.159 +        InputStream is = url.openStream();
  15.160 +        int bytesRead = 0;
  15.161 +        while ( (bytesRead = is.read(readBuffer, 0, 1024)) > 0) {
  15.162 +            fos.write(readBuffer, 0, bytesRead);
  15.163 +        }
  15.164 +        fos.flush();
  15.165 +        fos.close();
  15.166 +        is.close();
  15.167 +    }
  15.168 +    
  15.169 +    private static void generatePropertiesFile(File target) throws IOException {
  15.170 +        String separator = System.getProperty("path.separator");
  15.171 +        File apiBase = InstalledFileLocator.getDefault().locate(ENDORSED_REF, null, true).getParentFile();
  15.172 +        File jaxWsBase = apiBase.getParentFile();
  15.173 +        
  15.174 +        FileFilter jarFilter = new FileFilter() {
  15.175 +            public boolean accept(File pathname) {
  15.176 +                return pathname.isFile() && pathname.getName().endsWith(".jar");
  15.177 +            }
  15.178 +        };
  15.179 +        
  15.180 +        File[] apiJars = apiBase.listFiles(jarFilter);
  15.181 +        File[] implJars = jaxWsBase.listFiles(jarFilter);
  15.182 +        
  15.183 +        Properties result = new Properties();
  15.184 +        StringBuffer classpath = new StringBuffer();
  15.185 +        
  15.186 +        for (int i = 0; i < apiJars.length; i++) {
  15.187 +            String pathElement = apiJars[i].getAbsolutePath() + separator;
  15.188 +            classpath.append(pathElement);
  15.189 +        }
  15.190 +        
  15.191 +        for (int i = 0; i < implJars.length; i++) {
  15.192 +            classpath.append(implJars[i].getAbsolutePath());
  15.193 +            if (i != implJars.length - 1) {
  15.194 +                classpath.append(separator);
  15.195 +            }
  15.196 +        }
  15.197 +        
  15.198 +        result.setProperty(JAXWS_LIB_PROPERTY, classpath.toString());
  15.199 +        
  15.200 +        FileOutputStream fos = new FileOutputStream(target);
  15.201 +        result.store(fos, "build.properties file");
  15.202 +    }
  15.203 +    
  15.204 +    public static final class TestRepository extends Repository {
  15.205 +        static FileSystem defaultFileSystem = null;
  15.206 +        
  15.207 +        public TestRepository() {
  15.208 +            super(defaultFileSystem);
  15.209 +        }
  15.210 +    }
  15.211 +    
  15.212 +    // Taken from org.openide.filesystems.ExternalUtil to allow layer files to be
  15.213 +    // loaded into the default filesystem (since core/startup is in the classpath
  15.214 +    // and registers a default Repository that we do not want)
  15.215 +    public static final class MainFS extends MultiFileSystem implements LookupListener {
  15.216 +        private final Lookup.Result<FileSystem> ALL = Lookup.getDefault().lookupResult(FileSystem.class);
  15.217 +        private final FileSystem MEMORY = FileUtil.createMemoryFileSystem();
  15.218 +        private final XMLFileSystem layers = new XMLFileSystem();
  15.219 +        
  15.220 +        private final LocalFileSystem configRoot = new LocalFileSystem();
  15.221 +        
  15.222 +        public void setConfigRootDir(File root) throws Exception {
  15.223 +            configRoot.setRootDirectory(root);
  15.224 +        }
  15.225 +        
  15.226 +        public MainFS() {
  15.227 +            ALL.addLookupListener(this);
  15.228 +            
  15.229 +            List<URL> layerUrls = new ArrayList<URL>();
  15.230 +            ClassLoader l = Thread.currentThread().getContextClassLoader();
  15.231 +            try {
  15.232 +                for (URL manifest : NbCollections.iterable(l.getResources("META-INF/MANIFEST.MF"))) { // NOI18N
  15.233 +                    InputStream is = manifest.openStream();
  15.234 +                    try {
  15.235 +                        Manifest mani = new Manifest(is);
  15.236 +                        String layerLoc = mani.getMainAttributes().getValue("OpenIDE-Module-Layer"); // NOI18N
  15.237 +                        if (layerLoc != null) {
  15.238 +                            URL layer = l.getResource(layerLoc);
  15.239 +                            if (layer != null) {
  15.240 +                                layerUrls.add(layer);
  15.241 +                            }
  15.242 +                        }
  15.243 +                    } finally {
  15.244 +                        is.close();
  15.245 +                    }
  15.246 +                }
  15.247 +                layers.setXmlUrls(layerUrls.toArray(new URL[layerUrls.size()]));
  15.248 +            } catch (Exception x) {
  15.249 +            }
  15.250 +            resultChanged(null); // run after add listener - see PN1 in #26338
  15.251 +        }
  15.252 +        
  15.253 +        private FileSystem[] computeDelegates() {
  15.254 +            List<FileSystem> arr = new ArrayList<FileSystem>();
  15.255 +            arr.add(MEMORY);
  15.256 +            arr.add(layers);
  15.257 +            arr.add(configRoot);
  15.258 +            arr.addAll(ALL.allInstances());
  15.259 +            return arr.toArray(new FileSystem[0]);
  15.260 +        }
  15.261 +    
  15.262 +        public void resultChanged(LookupEvent ev) {
  15.263 +            setDelegates(computeDelegates());
  15.264 +        }
  15.265 +    }
  15.266 +    
  15.267 +    
  15.268 +}
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/visualweb.websvcmgr/test/unit/src/org/netbeans/modules/websvc/manager/test/WebServiceManagerEvent.java	Wed Mar 23 16:50:27 2011 -0400
    16.3 @@ -0,0 +1,48 @@
    16.4 +/*
    16.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    16.6 + *
    16.7 + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
    16.8 + *
    16.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   16.10 + * Other names may be trademarks of their respective owners.
   16.11 + *
   16.12 + * The contents of this file are subject to the terms of either the GNU
   16.13 + * General Public License Version 2 only ("GPL") or the Common
   16.14 + * Development and Distribution License("CDDL") (collectively, the
   16.15 + * "License"). You may not use this file except in compliance with the
   16.16 + * License. You can obtain a copy of the License at
   16.17 + * http://www.netbeans.org/cddl-gplv2.html
   16.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   16.19 + * specific language governing permissions and limitations under the
   16.20 + * License.  When distributing the software, include this License Header
   16.21 + * Notice in each file and include the License file at
   16.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   16.23 + * particular file as subject to the "Classpath" exception as provided
   16.24 + * by Oracle in the GPL Version 2 section of the License file that
   16.25 + * accompanied this code. If applicable, add the following below the
   16.26 + * License Header, with the fields enclosed by brackets [] replaced by
   16.27 + * your own identifying information:
   16.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   16.29 + * 
   16.30 + * Contributor(s):
   16.31 + * 
   16.32 + * Portions Copyrighted 2007 Sun Microsystems, Inc.
   16.33 + */
   16.34 +
   16.35 +package org.netbeans.modules.websvc.manager.test;
   16.36 +
   16.37 +/**
   16.38 + *
   16.39 + * @author quynguyen
   16.40 + */
   16.41 +public class WebServiceManagerEvent {
   16.42 +    private final String data;
   16.43 +    
   16.44 +    public WebServiceManagerEvent(String data) {
   16.45 +        this.data = data;
   16.46 +    }
   16.47 +    
   16.48 +    public String getData() {
   16.49 +        return data;
   16.50 +    }
   16.51 +}
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/visualweb.websvcmgr/test/unit/src/org/netbeans/modules/websvc/manager/test/WebServiceManagerListener.java	Wed Mar 23 16:50:27 2011 -0400
    17.3 @@ -0,0 +1,41 @@
    17.4 +/*
    17.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    17.6 + *
    17.7 + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
    17.8 + *
    17.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   17.10 + * Other names may be trademarks of their respective owners.
   17.11 + *
   17.12 + * The contents of this file are subject to the terms of either the GNU
   17.13 + * General Public License Version 2 only ("GPL") or the Common
   17.14 + * Development and Distribution License("CDDL") (collectively, the
   17.15 + * "License"). You may not use this file except in compliance with the
   17.16 + * License. You can obtain a copy of the License at
   17.17 + * http://www.netbeans.org/cddl-gplv2.html
   17.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   17.19 + * specific language governing permissions and limitations under the
   17.20 + * License.  When distributing the software, include this License Header
   17.21 + * Notice in each file and include the License file at
   17.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   17.23 + * particular file as subject to the "Classpath" exception as provided
   17.24 + * by Oracle in the GPL Version 2 section of the License file that
   17.25 + * accompanied this code. If applicable, add the following below the
   17.26 + * License Header, with the fields enclosed by brackets [] replaced by
   17.27 + * your own identifying information:
   17.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   17.29 + * 
   17.30 + * Contributor(s):
   17.31 + * 
   17.32 + * Portions Copyrighted 2007 Sun Microsystems, Inc.
   17.33 + */
   17.34 +
   17.35 +package org.netbeans.modules.websvc.manager.test;
   17.36 +
   17.37 +/**
   17.38 + * Generic listener for test classes
   17.39 + * 
   17.40 + * @author quynguyen
   17.41 + */
   17.42 +public interface WebServiceManagerListener {
   17.43 +    public void eventFired(WebServiceManagerEvent event);
   17.44 +}
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/visualweb.websvcmgr/test/unit/src/org/netbeans/modules/websvc/saas/model/SaasServicesModelTest.java	Wed Mar 23 16:50:27 2011 -0400
    18.3 @@ -0,0 +1,186 @@
    18.4 +/*
    18.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    18.6 + *
    18.7 + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
    18.8 + *
    18.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   18.10 + * Other names may be trademarks of their respective owners.
   18.11 + *
   18.12 + * The contents of this file are subject to the terms of either the GNU
   18.13 + * General Public License Version 2 only ("GPL") or the Common
   18.14 + * Development and Distribution License("CDDL") (collectively, the
   18.15 + * "License"). You may not use this file except in compliance with the
   18.16 + * License. You can obtain a copy of the License at
   18.17 + * http://www.netbeans.org/cddl-gplv2.html
   18.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   18.19 + * specific language governing permissions and limitations under the
   18.20 + * License.  When distributing the software, include this License Header
   18.21 + * Notice in each file and include the License file at
   18.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   18.23 + * particular file as subject to the "Classpath" exception as provided
   18.24 + * by Oracle in the GPL Version 2 section of the License file that
   18.25 + * accompanied this code. If applicable, add the following below the
   18.26 + * License Header, with the fields enclosed by brackets [] replaced by
   18.27 + * your own identifying information:
   18.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   18.29 + * 
   18.30 + * If you wish your version of this file to be governed by only the CDDL
   18.31 + * or only the GPL Version 2, indicate your decision by adding
   18.32 + * "[Contributor] elects to include this software in this distribution
   18.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   18.34 + * single choice of license, a recipient has the option to distribute
   18.35 + * your version of this file under either the CDDL, the GPL Version 2 or
   18.36 + * to extend the choice of license to its licensees as provided above.
   18.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   18.38 + * Version 2 license, then the option applies only if the new code is
   18.39 + * made subject to such option by the copyright holder.
   18.40 + * 
   18.41 + * Contributor(s):
   18.42 + * 
   18.43 + * Portions Copyrighted 2008 Sun Microsystems, Inc.
   18.44 + */
   18.45 +
   18.46 +package org.netbeans.modules.websvc.saas.model;
   18.47 +
   18.48 +import org.netbeans.junit.NbTestCase;
   18.49 +import org.netbeans.modules.websvc.saas.spi.websvcmgr.WsdlData;
   18.50 +import org.netbeans.modules.websvc.saas.util.SetupUtil;
   18.51 +import org.openide.filesystems.FileObject;
   18.52 +import org.openide.filesystems.FileUtil;
   18.53 +import java.io.OutputStream;
   18.54 +import org.netbeans.modules.websvc.saas.util.SaasUtil;
   18.55 +
   18.56 +/**
   18.57 + *
   18.58 + * @author nam
   18.59 + */
   18.60 +public class SaasServicesModelTest extends NbTestCase {
   18.61 +    
   18.62 +    public static void resetSaasServicesModel() {
   18.63 +        SaasServicesModel.getInstance().reset();
   18.64 +    }
   18.65 +    
   18.66 +    public static void setWsdlData(WsdlSaas saas, WsdlData data) {
   18.67 +        saas.setWsdlData(data);
   18.68 +    }
   18.69 +    
   18.70 +    public SaasServicesModelTest(String testName) {
   18.71 +        super(testName);
   18.72 +    }            
   18.73 +
   18.74 +    @Override
   18.75 +    protected void setUp() throws Exception {
   18.76 +        SetupUtil.commonSetUp(super.getWorkDir());
   18.77 +    }
   18.78 +
   18.79 +    @Override
   18.80 +    protected void tearDown() throws Exception {
   18.81 +        SetupUtil.commonTearDown();
   18.82 +    }
   18.83 +
   18.84 +    public void testLoading() throws Exception {
   18.85 +
   18.86 +        SaasServicesModel instance = SaasServicesModel.getInstance();
   18.87 +        assertEquals("Zillow", instance.getGroups().get(1).getName());
   18.88 +        //No Sub-group for now
   18.89 +        //SaasGroup group = instance.getGroups().get(0).getChildGroup("Videos");
   18.90 +        //assertNotNull(group);
   18.91 +        SaasGroup group = instance.getGroups().get(1);
   18.92 +        WadlSaas service = (WadlSaas) group.getServices().get(0);
   18.93 +        assertEquals("Real Estate Service", service.getDisplayName());
   18.94 +        assertNotNull(service.getWadlModel());
   18.95 +
   18.96 +        SetupUtil.commonTearDown();
   18.97 +    }
   18.98 +    
   18.99 +    public void testAddGroup() throws Exception {
  18.100 +
  18.101 +        SaasServicesModel instance = SaasServicesModel.getInstance();
  18.102 +        instance.createGroup(instance.getRootGroup(), "groupA");
  18.103 +        SaasGroup added = instance.getRootGroup().getChildGroup("groupA");
  18.104 +        assertEquals("groupA", added.getName());
  18.105 +        instance.createGroup(added, "child1");
  18.106 +        SaasGroup child2 = instance.createGroup(added, "child2");
  18.107 +        instance.createGroup(child2, "grandChild");
  18.108 +        
  18.109 +        instance.reset();
  18.110 +        instance.initRootGroup();
  18.111 +        
  18.112 +        SaasGroup reloaded = instance.getRootGroup().getChildGroup("groupA");
  18.113 +        assertEquals("groupA", reloaded.getName());
  18.114 +        assertEquals(2, reloaded.getChildrenGroups().size());
  18.115 +        assertEquals("child1", reloaded.getChildGroup("child1").getName());
  18.116 +        assertEquals("grandChild", reloaded.getChildGroup("child2").getChildGroup("grandChild").getName());
  18.117 +
  18.118 +        SetupUtil.commonTearDown();
  18.119 +    }
  18.120 +
  18.121 +    public void testAddToPrePackagedGroup() throws Exception {
  18.122 +
  18.123 +        System.out.println(getWorkDirPath());
  18.124 +        SaasServicesModel instance = SaasServicesModel.getInstance();
  18.125 +        SaasGroup delicious = instance.getTopGroup("Delicious");
  18.126 +        assertFalse(delicious.isUserDefined());
  18.127 +        assertNotNull(delicious.getChildService("Bookmarking Service"));
  18.128 +        instance.createGroup(delicious, "myDelicious");
  18.129 +        assertTrue(delicious.getChildGroup("myDelicious").isUserDefined());
  18.130 +        assertNotNull(delicious.getChildService("Bookmarking Service"));
  18.131 +        
  18.132 +        instance.reset();
  18.133 +        instance.initRootGroup();
  18.134 +        
  18.135 +        delicious = instance.getTopGroup("Delicious");
  18.136 +        assertFalse(delicious.isUserDefined());
  18.137 +        assertNotNull(delicious.getChildGroup("myDelicious"));
  18.138 +        assertTrue(delicious.getChildGroup("myDelicious").isUserDefined());
  18.139 +        assertNotNull(delicious.getChildService("Bookmarking Service"));
  18.140 +
  18.141 +    }
  18.142 +
  18.143 +    private FileObject setupLocalWadl() throws Exception {
  18.144 +        FileObject workDir = FileUtil.toFileObject(getWorkDir());
  18.145 +        FileObject wadl = workDir.getFileObject("application.wadl.xml");
  18.146 +        if (wadl == null) {
  18.147 +            wadl = workDir.createData("application.wadl.xml");
  18.148 +        }
  18.149 +        OutputStream out = wadl.getOutputStream();
  18.150 +        try {
  18.151 +            FileUtil.copy(getClass().getResourceAsStream("application.wadl"), out);
  18.152 +        } finally {
  18.153 +            out.close();
  18.154 +        }
  18.155 +        return wadl;
  18.156 +    }
  18.157 +
  18.158 +    public void testAddWadlService() throws Exception {
  18.159 +        FileObject wadl = setupLocalWadl();
  18.160 +        
  18.161 +        String url = wadl.getURL().toExternalForm();
  18.162 +        SaasServicesModel instance = SaasServicesModel.getInstance();
  18.163 +        SaasGroup delicious = instance.getTopGroup("Delicious");
  18.164 +        SaasGroup myDelicious = instance.createGroup(delicious, "myDelicious");
  18.165 +        WadlSaas saas = (WadlSaas) instance.createSaasService(myDelicious, url, null);
  18.166 +        assertEquals(1, saas.getResources().size());
  18.167 +    }
  18.168 +
  18.169 +    public void testRemoveGroupWithWadlService() throws Exception {
  18.170 +        FileObject wadl = setupLocalWadl();
  18.171 +        
  18.172 +        String url = wadl.getURL().toExternalForm();
  18.173 +        SaasServicesModel instance = SaasServicesModel.getInstance();
  18.174 +        SaasGroup delicious = instance.getTopGroup("Delicious");
  18.175 +        SaasGroup myDelicious = instance.createGroup(delicious, "myDelicious");
  18.176 +        instance.createSaasService(myDelicious, url, null);
  18.177 +        
  18.178 +        instance.reset();
  18.179 +        
  18.180 +        SaasGroup g = instance.getTopGroup("Delicious").getChildGroup("myDelicious");
  18.181 +        WadlSaas saas = (WadlSaas)g.getServices().get(0);
  18.182 +        assertEquals(1, saas.getResources().get(0).getMethods().size());
  18.183 +        assertNotNull(instance.getWebServiceHome().getFileObject(SaasUtil.toValidJavaName(saas.getDisplayName())));
  18.184 +        
  18.185 +        instance.removeGroup(g);
  18.186 +        assertNull(instance.getWebServiceHome().getFileObject(SaasUtil.toValidJavaName(saas.getDisplayName())));
  18.187 +        assertNull(instance.getTopGroup("Delicious").getChildGroup("myDelicious"));
  18.188 +    }
  18.189 +}
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/visualweb.websvcmgr/test/unit/src/org/netbeans/modules/websvc/saas/util/DialogDisplayerNotifier.java	Wed Mar 23 16:50:27 2011 -0400
    19.3 @@ -0,0 +1,56 @@
    19.4 +/*
    19.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    19.6 + *
    19.7 + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
    19.8 + *
    19.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   19.10 + * Other names may be trademarks of their respective owners.
   19.11 + *
   19.12 + * The contents of this file are subject to the terms of either the GNU
   19.13 + * General Public License Version 2 only ("GPL") or the Common
   19.14 + * Development and Distribution License("CDDL") (collectively, the
   19.15 + * "License"). You may not use this file except in compliance with the
   19.16 + * License. You can obtain a copy of the License at
   19.17 + * http://www.netbeans.org/cddl-gplv2.html
   19.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   19.19 + * specific language governing permissions and limitations under the
   19.20 + * License.  When distributing the software, include this License Header
   19.21 + * Notice in each file and include the License file at
   19.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   19.23 + * particular file as subject to the "Classpath" exception as provided
   19.24 + * by Oracle in the GPL Version 2 section of the License file that
   19.25 + * accompanied this code. If applicable, add the following below the
   19.26 + * License Header, with the fields enclosed by brackets [] replaced by
   19.27 + * your own identifying information:
   19.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   19.29 + * 
   19.30 + * Contributor(s):
   19.31 + * 
   19.32 + * Portions Copyrighted 2007 Sun Microsystems, Inc.
   19.33 + */
   19.34 +
   19.35 +package org.netbeans.modules.websvc.saas.util;
   19.36 +
   19.37 +import java.awt.Dialog;
   19.38 +import java.util.LinkedList;
   19.39 +import org.openide.DialogDescriptor;
   19.40 +import org.openide.DialogDisplayer;
   19.41 +import org.openide.NotifyDescriptor;
   19.42 +
   19.43 +/**
   19.44 + *
   19.45 + * @author quynguyen
   19.46 + */
   19.47 +public class DialogDisplayerNotifier extends DialogDisplayer {
   19.48 +    
   19.49 +    @Override
   19.50 +    public Object notify(NotifyDescriptor descriptor) {
   19.51 +        return NotifyDescriptor.OK_OPTION;
   19.52 +    }
   19.53 +
   19.54 +    @Override
   19.55 +    public Dialog createDialog(DialogDescriptor descriptor) {
   19.56 +        return null;
   19.57 +    }
   19.58 +
   19.59 +}
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/visualweb.websvcmgr/test/unit/src/org/netbeans/modules/websvc/saas/util/InstalledFileLocatorImpl.java	Wed Mar 23 16:50:27 2011 -0400
    20.3 @@ -0,0 +1,89 @@
    20.4 +/*
    20.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    20.6 + *
    20.7 + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
    20.8 + *
    20.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   20.10 + * Other names may be trademarks of their respective owners.
   20.11 + *
   20.12 + * The contents of this file are subject to the terms of either the GNU
   20.13 + * General Public License Version 2 only ("GPL") or the Common
   20.14 + * Development and Distribution License("CDDL") (collectively, the
   20.15 + * "License"). You may not use this file except in compliance with the
   20.16 + * License. You can obtain a copy of the License at
   20.17 + * http://www.netbeans.org/cddl-gplv2.html
   20.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   20.19 + * specific language governing permissions and limitations under the
   20.20 + * License.  When distributing the software, include this License Header
   20.21 + * Notice in each file and include the License file at
   20.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   20.23 + * particular file as subject to the "Classpath" exception as provided
   20.24 + * by Oracle in the GPL Version 2 section of the License file that
   20.25 + * accompanied this code. If applicable, add the following below the
   20.26 + * License Header, with the fields enclosed by brackets [] replaced by
   20.27 + * your own identifying information:
   20.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   20.29 + *
   20.30 + * Contributor(s):
   20.31 + *
   20.32 + * Portions Copyrighted 2007 Sun Microsystems, Inc.
   20.33 + */
   20.34 +
   20.35 +package org.netbeans.modules.websvc.saas.util;
   20.36 +
   20.37 +import java.io.File;
   20.38 +import java.util.ArrayList;
   20.39 +import org.openide.modules.InstalledFileLocator;
   20.40 +
   20.41 +/**
   20.42 + *  InstalledFileLocator implementation that searches the NB install directory
   20.43 + * (uses java.endorsed.dirs value from nbproject/project.properties)
   20.44 + * @author quynguyen
   20.45 + */
   20.46 +public class InstalledFileLocatorImpl extends InstalledFileLocator {
   20.47 +
   20.48 +    private ArrayList<File> baseDirs;
   20.49 +    private File userDirConfigRoot;
   20.50 +    
   20.51 +    public InstalledFileLocatorImpl() {
   20.52 +        super();
   20.53 +        File endorsedDir = new File(System.getProperty("java.endorsed.dirs"));
   20.54 +        for (int i = 0; i < 5; i++) {
   20.55 +            endorsedDir = endorsedDir.getParentFile();
   20.56 +        }
   20.57 +
   20.58 +        File installRoot = endorsedDir;
   20.59 +        File[] subdirs = installRoot.listFiles();
   20.60 +        baseDirs = new ArrayList<File>();
   20.61 +
   20.62 +        for (int i = 0; subdirs != null && i < subdirs.length; i++) {
   20.63 +            if (subdirs[i].isDirectory()) {
   20.64 +                baseDirs.add(subdirs[i]);
   20.65 +            }
   20.66 +        }
   20.67 +    }
   20.68 +
   20.69 +    @Override
   20.70 +    public File locate(String relativePath, String codeNameBase, boolean localized) {
   20.71 +        for (File baseDir : baseDirs) {
   20.72 +            File f = new File(baseDir, relativePath);
   20.73 +            if (f.exists()) {
   20.74 +                return f;
   20.75 +            }
   20.76 +        }
   20.77 +
   20.78 +        return null;
   20.79 +    }
   20.80 +    
   20.81 +    public void setUserConfigRoot(File baseDir) {
   20.82 +        if (userDirConfigRoot != null) {
   20.83 +            baseDirs.remove(userDirConfigRoot);
   20.84 +            userDirConfigRoot = null;
   20.85 +        }
   20.86 +        
   20.87 +        if (baseDir != null) {
   20.88 +            baseDirs.add(baseDir);
   20.89 +            userDirConfigRoot = baseDir;
   20.90 +        }
   20.91 +    }
   20.92 +}
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/visualweb.websvcmgr/test/unit/src/org/netbeans/modules/websvc/saas/util/SetupUtil.java	Wed Mar 23 16:50:27 2011 -0400
    21.3 @@ -0,0 +1,193 @@
    21.4 +/*
    21.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    21.6 + *
    21.7 + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
    21.8 + *
    21.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   21.10 + * Other names may be trademarks of their respective owners.
   21.11 + *
   21.12 + * The contents of this file are subject to the terms of either the GNU
   21.13 + * General Public License Version 2 only ("GPL") or the Common
   21.14 + * Development and Distribution License("CDDL") (collectively, the
   21.15 + * "License"). You may not use this file except in compliance with the
   21.16 + * License. You can obtain a copy of the License at
   21.17 + * http://www.netbeans.org/cddl-gplv2.html
   21.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   21.19 + * specific language governing permissions and limitations under the
   21.20 + * License.  When distributing the software, include this License Header
   21.21 + * Notice in each file and include the License file at
   21.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   21.23 + * particular file as subject to the "Classpath" exception as provided
   21.24 + * by Oracle in the GPL Version 2 section of the License file that
   21.25 + * accompanied this code. If applicable, add the following below the
   21.26 + * License Header, with the fields enclosed by brackets [] replaced by
   21.27 + * your own identifying information:
   21.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   21.29 + * 
   21.30 + * Contributor(s):
   21.31 + * 
   21.32 + * Portions Copyrighted 2007 Sun Microsystems, Inc.
   21.33 + */
   21.34 +
   21.35 +package org.netbeans.modules.websvc.saas.util;
   21.36 +
   21.37 +import java.io.File;
   21.38 +import java.io.FileFilter;
   21.39 +import java.io.FileOutputStream;
   21.40 +import java.io.IOException;
   21.41 +import java.io.InputStream;
   21.42 +import java.net.URL;
   21.43 +import java.util.ArrayList;
   21.44 +import java.util.List;
   21.45 +import java.util.Properties;
   21.46 +import java.util.jar.Manifest;
   21.47 +import org.netbeans.junit.MockServices;
   21.48 +import org.netbeans.modules.websvc.saas.model.SaasServicesModel;
   21.49 +import org.netbeans.modules.websvc.saas.model.SaasServicesModelTest;
   21.50 +import org.openide.filesystems.FileObject;
   21.51 +import org.openide.filesystems.FileSystem;
   21.52 +import org.openide.filesystems.FileUtil;
   21.53 +import org.openide.filesystems.LocalFileSystem;
   21.54 +import org.openide.filesystems.MultiFileSystem;
   21.55 +import org.openide.filesystems.Repository;
   21.56 +import org.openide.filesystems.XMLFileSystem;
   21.57 +import org.openide.modules.InstalledFileLocator;
   21.58 +import org.openide.util.Lookup;
   21.59 +import org.openide.util.LookupEvent;
   21.60 +import org.openide.util.LookupListener;
   21.61 +import org.openide.util.NbCollections;
   21.62 +
   21.63 +/**
   21.64 + *
   21.65 + * @author quynguyen
   21.66 + */
   21.67 +public class SetupUtil {
   21.68 +    
   21.69 +    private static final String ENDORSED_REF = "modules/ext/jaxws21/api/jaxws-api.jar";
   21.70 +    private static final String JAXWS_LIB_PROPERTY = "libs.jaxws21.classpath";
   21.71 +    
   21.72 +    public static void commonSetUp(File workingDir) throws Exception {
   21.73 +        File testuserdir = new File(workingDir.getParentFile(), "testuser");
   21.74 +        System.getProperties().setProperty("netbeans.user", testuserdir.getAbsolutePath());
   21.75 +        SaasServicesModelTest.resetSaasServicesModel();
   21.76 +        FileObject websvcHome = SaasServicesModel.getWebServiceHome();
   21.77 +        File userconfig = FileUtil.toFile(websvcHome.getParent());
   21.78 +        MainFS fs = new MainFS();
   21.79 +        fs.setConfigRootDir(userconfig);
   21.80 +        TestRepository.defaultFileSystem = fs;
   21.81 +        
   21.82 +        MockServices.setServices(DialogDisplayerNotifier.class, InstalledFileLocatorImpl.class, TestRepository.class);
   21.83 +        
   21.84 +        InstalledFileLocatorImpl locator = (InstalledFileLocatorImpl)Lookup.getDefault().lookup(InstalledFileLocator.class);
   21.85 +        locator.setUserConfigRoot(userconfig);
   21.86 +        
   21.87 +        File targetBuildProperties = new File(testuserdir, "build.properties");
   21.88 +        generatePropertiesFile(targetBuildProperties);
   21.89 +        
   21.90 +    }
   21.91 +
   21.92 +    public static void commonTearDown() throws Exception {
   21.93 +        SaasServicesModel.getWebServiceHome().delete();
   21.94 +        MockServices.setServices();
   21.95 +    }
   21.96 +    
   21.97 +    private static void generatePropertiesFile(File target) throws IOException {
   21.98 +        String separator = System.getProperty("path.separator");
   21.99 +        File apiBase = InstalledFileLocator.getDefault().locate(ENDORSED_REF, null, true).getParentFile();
  21.100 +        File jaxWsBase = apiBase.getParentFile();
  21.101 +        
  21.102 +        FileFilter jarFilter = new FileFilter() {
  21.103 +            public boolean accept(File pathname) {
  21.104 +                return pathname.isFile() && pathname.getName().endsWith(".jar");
  21.105 +            }
  21.106 +        };
  21.107 +        
  21.108 +        File[] apiJars = apiBase.listFiles(jarFilter);
  21.109 +        File[] implJars = jaxWsBase.listFiles(jarFilter);
  21.110 +        
  21.111 +        Properties result = new Properties();
  21.112 +        StringBuffer classpath = new StringBuffer();
  21.113 +        
  21.114 +        for (int i = 0; i < apiJars.length; i++) {
  21.115 +            String pathElement = apiJars[i].getAbsolutePath() + separator;
  21.116 +            classpath.append(pathElement);
  21.117 +        }
  21.118 +        
  21.119 +        for (int i = 0; i < implJars.length; i++) {
  21.120 +            classpath.append(implJars[i].getAbsolutePath());
  21.121 +            if (i != implJars.length - 1) {
  21.122 +                classpath.append(separator);
  21.123 +            }
  21.124 +        }
  21.125 +        
  21.126 +        result.setProperty(JAXWS_LIB_PROPERTY, classpath.toString());
  21.127 +        
  21.128 +        FileOutputStream fos = new FileOutputStream(target);
  21.129 +        result.store(fos, "build.properties file");
  21.130 +    }
  21.131 +    
  21.132 +    public static final class TestRepository extends Repository {
  21.133 +        static FileSystem defaultFileSystem = null;
  21.134 +        
  21.135 +        public TestRepository() {
  21.136 +            super(defaultFileSystem);
  21.137 +        }
  21.138 +    }
  21.139 +    
  21.140 +    // Taken from org.openide.filesystems.ExternalUtil to allow layer files to be
  21.141 +    // loaded into the default filesystem (since core/startup is in the classpath
  21.142 +    // and registers a default Repository that we do not want)
  21.143 +    public static final class MainFS extends MultiFileSystem implements LookupListener {
  21.144 +        private final Lookup.Result<FileSystem> ALL = Lookup.getDefault().lookupResult(FileSystem.class);
  21.145 +        private final FileSystem MEMORY = FileUtil.createMemoryFileSystem();
  21.146 +        private final XMLFileSystem layers = new XMLFileSystem();
  21.147 +        
  21.148 +        private final LocalFileSystem configRoot = new LocalFileSystem();
  21.149 +        
  21.150 +        public void setConfigRootDir(File root) throws Exception {
  21.151 +            configRoot.setRootDirectory(root);
  21.152 +        }
  21.153 +        
  21.154 +        public MainFS() {
  21.155 +            ALL.addLookupListener(this);
  21.156 +            
  21.157 +            List<URL> layerUrls = new ArrayList<URL>();
  21.158 +            ClassLoader l = Thread.currentThread().getContextClassLoader();
  21.159 +            try {
  21.160 +                for (URL manifest : NbCollections.iterable(l.getResources("META-INF/MANIFEST.MF"))) { // NOI18N
  21.161 +                    InputStream is = manifest.openStream();
  21.162 +                    try {
  21.163 +                        Manifest mani = new Manifest(is);
  21.164 +                        String layerLoc = mani.getMainAttributes().getValue("OpenIDE-Module-Layer"); // NOI18N
  21.165 +                        if (layerLoc != null) {
  21.166 +                            URL layer = l.getResource(layerLoc);
  21.167 +                            if (layer != null) {
  21.168 +                                layerUrls.add(layer);
  21.169 +                            }
  21.170 +                        }
  21.171 +                    } finally {
  21.172 +                        is.close();
  21.173 +                    }
  21.174 +                }
  21.175 +                layers.setXmlUrls(layerUrls.toArray(new URL[layerUrls.size()]));
  21.176 +            } catch (Exception x) {
  21.177 +            }
  21.178 +            resultChanged(null); // run after add listener - see PN1 in #26338
  21.179 +        }
  21.180 +        
  21.181 +        private FileSystem[] computeDelegates() {
  21.182 +            List<FileSystem> arr = new ArrayList<FileSystem>();
  21.183 +            arr.add(MEMORY);
  21.184 +            arr.add(layers);
  21.185 +            arr.add(configRoot);
  21.186 +            arr.addAll(ALL.allInstances());
  21.187 +            return arr.toArray(new FileSystem[0]);
  21.188 +        }
  21.189 +    
  21.190 +        public void resultChanged(LookupEvent ev) {
  21.191 +            setDelegates(computeDelegates());
  21.192 +        }
  21.193 +    }
  21.194 +    
  21.195 +    
  21.196 +}
    22.1 --- a/visualweb.webui.designtime/nbproject/genfiles.properties	Wed Mar 23 16:49:42 2011 -0400
    22.2 +++ b/visualweb.webui.designtime/nbproject/genfiles.properties	Wed Mar 23 16:50:27 2011 -0400
    22.3 @@ -1,5 +1,5 @@
    22.4  # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
    22.5  # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
    22.6 -nbproject/build-impl.xml.data.CRC32=ebfbf351
    22.7 +nbproject/build-impl.xml.data.CRC32=4a78b76c
    22.8  nbproject/build-impl.xml.script.CRC32=b7644caf
    22.9  nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.45
    23.1 --- a/visualweb.webui.designtime/nbproject/project.xml	Wed Mar 23 16:49:42 2011 -0400
    23.2 +++ b/visualweb.webui.designtime/nbproject/project.xml	Wed Mar 23 16:50:27 2011 -0400
    23.3 @@ -187,6 +187,20 @@
    23.4                      </run-dependency>
    23.5                  </dependency>
    23.6              </module-dependencies>
    23.7 +            <test-dependencies>
    23.8 +                <test-type>
    23.9 +                    <name>unit</name>
   23.10 +                    <test-dependency>
   23.11 +                        <code-name-base>org.netbeans.libs.junit4</code-name-base>
   23.12 +                        <compile-dependency/>
   23.13 +                    </test-dependency>
   23.14 +                    <test-dependency>
   23.15 +                        <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
   23.16 +                        <recursive/>
   23.17 +                        <compile-dependency/>
   23.18 +                    </test-dependency>
   23.19 +                </test-type>
   23.20 +            </test-dependencies>
   23.21              <friend-packages>
   23.22                  <friend>org.netbeans.modules.visualweb.complib</friend>
   23.23                  <friend>org.netbeans.modules.visualweb.designer.jsf</friend>