Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
View | Details | Raw Unified | Return to bug 121855
Collapse All | Expand All

(-)ide/manifest.mf (+3 lines)
Line 0    Link Here 
1
Manifest-Version: 1.0
2
OpenIDE-Module: IDE
3
(-)ide/nbproject/project.properties (+2 lines)
 Lines 37-42    Link Here 
37
# Version 2 license, then the option applies only if the new code is
37
# Version 2 license, then the option applies only if the new code is
38
# made subject to such option by the copyright holder.
38
# made subject to such option by the copyright holder.
39
39
40
javac.compilerargs=-Xlint -Xlint:-serial
41
javac.source=1.5
40
#test.unit.cp.extra=
42
#test.unit.cp.extra=
41
#test.unit.run.cp.extra=
43
#test.unit.run.cp.extra=
42
test.qa-functional.cp.extra=${openide/windows.dir}/modules/org-openide-windows.jar:\
44
test.qa-functional.cp.extra=${openide/windows.dir}/modules/org-openide-windows.jar:\
(-)ide/test/qa-functional/src/org/netbeans/test/ide/IDECommitValidation.java (+2 lines)
 Lines 60-65    Link Here 
60
    
60
    
61
    public static NbTestSuite suite() {
61
    public static NbTestSuite suite() {
62
        NbTestSuite suite = new NbTestSuite();
62
        NbTestSuite suite = new NbTestSuite();
63
        suite.addTest(new IDEValidation("testInitGCProjects"));
63
        suite.addTest(new IDEValidation("testMainMenu"));
64
        suite.addTest(new IDEValidation("testMainMenu"));
64
        suite.addTest(new IDEValidation("testHelp"));
65
        suite.addTest(new IDEValidation("testHelp"));
65
        suite.addTest(new IDEValidation("testOptions"));
66
        suite.addTest(new IDEValidation("testOptions"));
 Lines 84-89    Link Here 
84
        suite.addTest(new IDEValidation("testWindowSystem"));
85
        suite.addTest(new IDEValidation("testWindowSystem"));
85
        // temporary removed because new code has replaced Update Center Wizard and Module Manager
86
        // temporary removed because new code has replaced Update Center Wizard and Module Manager
86
        //suite.addTest(new IDEValidation("testModuleInstallation"));
87
        //suite.addTest(new IDEValidation("testModuleInstallation"));
88
        suite.addTest(new IDEValidation("testGCProjects"));
87
        return suite;
89
        return suite;
88
    }
90
    }
89
    
91
    
(-)ide/test/qa-functional/src/org/netbeans/test/ide/IDEValidation.java (+12 lines)
 Lines 49-54    Link Here 
49
import java.awt.event.KeyEvent;
49
import java.awt.event.KeyEvent;
50
import java.io.File;
50
import java.io.File;
51
import java.io.IOException;
51
import java.io.IOException;
52
import java.util.logging.Level;
52
import javax.swing.JTextField;
53
import javax.swing.JTextField;
53
import javax.swing.KeyStroke;
54
import javax.swing.KeyStroke;
54
import javax.swing.UIManager;
55
import javax.swing.UIManager;
 Lines 115-120    Link Here 
115
116
116
import org.netbeans.junit.NbTestSuite;
117
import org.netbeans.junit.NbTestSuite;
117
import org.netbeans.junit.ide.ProjectSupport;
118
import org.netbeans.junit.ide.ProjectSupport;
119
import org.openide.util.Lookup;
118
import org.openide.windows.Mode;
120
import org.openide.windows.Mode;
119
import org.openide.windows.TopComponent;
121
import org.openide.windows.TopComponent;
120
import org.openide.windows.WindowManager;
122
import org.openide.windows.WindowManager;
 Lines 133-138    Link Here 
133
135
134
    public static NbTestSuite suite() {
136
    public static NbTestSuite suite() {
135
        NbTestSuite suite = new NbTestSuite();
137
        NbTestSuite suite = new NbTestSuite();
138
        suite.addTest(new IDEValidation("testInitGCProjects"));
136
        suite.addTest(new IDEValidation("testMainMenu"));
139
        suite.addTest(new IDEValidation("testMainMenu"));
137
        suite.addTest(new IDEValidation("testHelp"));
140
        suite.addTest(new IDEValidation("testHelp"));
138
        suite.addTest(new IDEValidation("testOptions"));
141
        suite.addTest(new IDEValidation("testOptions"));
 Lines 1420-1425    Link Here 
1420
        pluginManagerOper.close();
1423
        pluginManagerOper.close();
1421
    }
1424
    }
1422
1425
1426
    public void testInitGCProjects() throws Exception {
1427
        WatchProjects.initialize();
1428
    }
1429
    
1430
    
1431
    public void testGCProjects() throws Exception {
1432
        WatchProjects.assertProjects();
1433
    }
1434
1423
    /** Closes help window if any. It should not stay open between test cases.
1435
    /** Closes help window if any. It should not stay open between test cases.
1424
     *  Otherwise it can break next tests.
1436
     *  Otherwise it can break next tests.
1425
     */
1437
     */
(-)ide/test/qa-functional/src/org/netbeans/test/ide/WatchProjects.java (+144 lines)
Line 0    Link Here 
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
 * 
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 * 
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 * 
35
 * Contributor(s):
36
 * 
37
 * Portions Copyrighted 2007 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.test.ide;
41
42
import java.beans.PropertyChangeEvent;
43
import java.beans.PropertyChangeListener;
44
import java.lang.ref.WeakReference;
45
import java.lang.reflect.InvocationTargetException;
46
import java.lang.reflect.Method;
47
import java.util.Arrays;
48
import java.util.HashSet;
49
import java.util.Set;
50
import java.util.logging.Logger;
51
import junit.framework.Assert;
52
import org.netbeans.junit.NbTestCase;
53
import org.openide.util.Exceptions;
54
import org.openide.util.Lookup;
55
import org.openide.util.WeakSet;
56
57
/**
58
 *
59
 * @author Jaroslav Tulach <jtulach@netbeans.org>
60
 */
61
final class WatchProjects implements PropertyChangeListener {
62
    private static Logger LOG = Logger.getLogger(WatchProjects.class.getName());
63
    
64
    
65
    private Method getProjects;
66
    private Method closeProjects;
67
    private Object projectManager;
68
    
69
    private static int maxCount;
70
    private static Set<Object> projects = new WeakSet<Object>();
71
    private static Exception failure;
72
    private static WatchProjects INST;
73
    
74
    private WatchProjects() throws Exception {
75
        final ClassLoader loader = Lookup.getDefault().lookup(ClassLoader.class);
76
        Assert.assertNotNull("Classloader must exists", loader);
77
        LOG.fine("Classloader: " + loader);
78
        Class pmClass = Class.forName(
79
            "org.netbeans.api.project.ui.OpenProjects", false, loader); //NOI18N
80
        LOG.fine("class: " + pmClass);
81
        Method add = pmClass.getMethod("addPropertyChangeListener", PropertyChangeListener.class);
82
        LOG.fine("  add: " + add);
83
        Method getDefault = pmClass.getMethod("getDefault");
84
        LOG.fine("  getDefault: " + getDefault);
85
        projectManager = getDefault.invoke(null);
86
        add.invoke(projectManager, this);
87
        LOG.info("listening on " + projectManager);
88
             
89
        getProjects = pmClass.getMethod("getOpenProjects");
90
        LOG.fine("getOpenProjects: " + getProjects);
91
        
92
        Class projectArray = Class.forName("[Lorg.netbeans.api.project.Project;");
93
        
94
        closeProjects = pmClass.getMethod("close", projectArray);
95
        LOG.fine("getOpenProjects: " + getProjects);
96
    }
97
    
98
    public static void initialize() throws Exception {
99
        INST = new WatchProjects();
100
    }
101
    
102
    public static void assertProjects() throws Exception {
103
        INST.closeProjects.invoke(
104
            INST.projectManager,
105
            INST.getProjects.invoke(INST.projectManager)
106
        );
107
        
108
        Set<WeakReference<?>> refs = new HashSet<WeakReference<?>>();
109
        for (Object project : projects) {
110
            refs.add(new WeakReference<Object>(project));
111
        }
112
        projects.clear();
113
        
114
        for (WeakReference<?> weakReference : refs) {
115
            NbTestCase.assertGC("Can project be GCed?", weakReference);
116
        }
117
118
        
119
        if (maxCount == 0) {
120
            Assert.fail("No projects were opened or closed and that is strange");
121
        }
122
        
123
        if (failure != null) {
124
            throw failure;
125
        }
126
    }
127
128
    public void propertyChange(PropertyChangeEvent evt) {
129
        try {
130
            LOG.fine("event: " + evt.getPropertyName());
131
            Object[] arr = (Object[]) getProjects.invoke(projectManager);
132
            projects.addAll(Arrays.asList(arr));
133
            LOG.finest("existing projects: " + projects);
134
            
135
            int p = projects.size();
136
            if (p > maxCount) {
137
                maxCount = p;
138
            }
139
        } catch (Exception ex) {
140
            failure = ex;
141
        }
142
    }
143
144
}

Return to bug 121855
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo