You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "lahodaj (via GitHub)" <gi...@apache.org> on 2026/09/07 09:56:51 UTC

Re: [PR] Running `ide/projectui` tests in the CI checks [netbeans]

lahodaj commented on code in PR #9603:
URL: https://github.com/apache/netbeans/pull/9603#discussion_r3948531114


##########
ide/projectui/test/unit/src/org/netbeans/modules/project/ui/ProjectsRootNodeTest.java:
##########
@@ -403,7 +403,7 @@ public void testReplaceProjectSingleNonRootNode() throws Exception { // #197864
             }
         };
         ProjectsRootNode.checkNoLazyNode(ch);
-        Node[] ns = ch.getNodes(true);
+        Node[] ns = ch.getNodes(false);

Review Comment:
   Hmm, this feels weird. What is the motivation? I am really surprised stability of the test is improved for you when `optimalResult == false`, compared to `optimalResult == true`. I tried to run the test, and it passes for me without this change.



##########
ide/projectui/test/unit/src/org/netbeans/modules/project/ui/ProjectsRootNodeInitializedSoonerTest.java:
##########
@@ -1,200 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.netbeans.modules.project.ui;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.logging.Handler;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-import org.netbeans.api.project.Project;
-import org.netbeans.api.project.ProjectManager;
-import org.netbeans.api.project.ui.OpenProjects;
-import org.netbeans.junit.NbTestCase;
-import org.netbeans.modules.project.ui.actions.TestSupport;
-import org.netbeans.spi.project.ui.LogicalViewProvider;
-import org.netbeans.spi.project.ui.ProjectOpenedHook;
-import org.openide.filesystems.FileObject;
-import org.openide.filesystems.FileUtil;
-import org.openide.filesystems.URLMapper;
-import org.openide.nodes.AbstractNode;
-import org.openide.nodes.Children;
-import org.openide.nodes.Node;
-import org.openide.util.Exceptions;
-import org.openide.util.Lookup;
-import org.openide.util.RequestProcessor;
-import org.openide.util.lookup.Lookups;
-import org.openide.util.test.MockLookup;
-
-public class ProjectsRootNodeInitializedSoonerTest extends NbTestCase {
-    
-    public ProjectsRootNodeInitializedSoonerTest(String testName) {
-        super(testName);
-    }
-
-    @Override
-    protected Level logLevel() {
-        return Level.OFF;
-    }
-
-    public void testWrongOrderOfInitialization() throws Exception {
-        MockLookup.setInstances(new TestSupport.TestProjectFactory());
-        List<URL> list = new ArrayList<URL>();
-        List<ExtIcon> icons = new ArrayList<ExtIcon>();
-        List<String> names = new ArrayList<String>();
-        clearWorkDir();
-        FileObject workDir = FileUtil.toFileObject(getWorkDir());
-        assertNotNull(workDir);
-        for (int i = 0; i < 30; i++) {
-            FileObject prj = TestSupport.createTestProject(workDir, "prj" + i);
-            URL url = URLMapper.findURL(prj, URLMapper.EXTERNAL);
-            list.add(url);
-            names.add(url.toExternalForm());
-            icons.add(new ExtIcon());
-            TestSupport.TestProject tmp = (TestSupport.TestProject) ProjectManager.getDefault().findProject(prj);
-            assertNotNull("Project found", tmp);
-            final TestProjectOpenedHookImpl hook = new TestProjectOpenedHookImpl();
-            tmp.setLookup(Lookups.fixed(tmp, hook));
-            hook.lkp = tmp.getLookup();
-        }
-
-        OpenProjectListSettings.getInstance().setOpenProjectsURLs(list);
-        OpenProjectListSettings.getInstance().setOpenProjectsDisplayNames(names);
-        OpenProjectListSettings.getInstance().setOpenProjectsIcons(icons);
-
-        Node logicalView = new ProjectsRootNode(ProjectsRootNode.LOGICAL_VIEW);
-        
-
-        class H extends Handler {
-            boolean ok;
-
-            @Override
-            public void publish(LogRecord record) {

Review Comment:
   The only problem here appears to be that the `ide/projectui/src/org/netbeans/modules/project/ui/ProjectsRootNode.java/.../BadgingNode` is sending the event to a different Logger than the one on which the test is listening. Fixing that appears to be easy enough:
   ```
   diff --git a/ide/projectui/test/unit/src/org/netbeans/modules/project/ui/ProjectsRootNodeInitializedSoonerTest.java b/ide/projectui/test/unit/src/org/netbeans/modules/project/ui/ProjectsRootNodeInitializedSoonerTest.java
   index fa6ec62ab4..855760cfa6 100644
   --- a/ide/projectui/test/unit/src/org/netbeans/modules/project/ui/ProjectsRootNodeInitializedSoonerTest.java
   +++ b/ide/projectui/test/unit/src/org/netbeans/modules/project/ui/ProjectsRootNodeInitializedSoonerTest.java
   @@ -29,6 +29,7 @@ import java.util.concurrent.TimeoutException;
    import java.util.logging.Handler;
    import java.util.logging.Level;
    import java.util.logging.LogRecord;
   +import java.util.logging.Logger;
    import org.netbeans.api.project.Project;
    import org.netbeans.api.project.ProjectManager;
    import org.netbeans.api.project.ui.OpenProjects;
   @@ -126,9 +127,10 @@ public class ProjectsRootNodeInitializedSoonerTest extends NbTestCase {
            }
            H h = new H();
            h.setLevel(Level.ALL);
   -        OpenProjectList.LOGGER.addHandler(h);
   -        OpenProjectList.LOGGER.setUseParentHandlers(false);
   -        OpenProjectList.LOGGER.setLevel(Level.ALL);
   +        Logger projectsRootNodeLOG = Logger.getLogger("org.netbeans.modules.project.ui.ProjectsRootNode");
   +        projectsRootNodeLOG.addHandler(h);
   +        projectsRootNodeLOG.setUseParentHandlers(false);
   +        projectsRootNodeLOG.setLevel(Level.ALL);
    
            assertEquals("30 children", 30, logicalView.getChildren().getNodesCount());
    
   ```
   
   Is there a particular reason to not fix the test and rather delete it?
   



##########
ide/projectui/test/unit/src/org/netbeans/modules/project/ui/ProjectUtilitiesTest.java:
##########
@@ -144,7 +144,6 @@ protected void setUp () throws Exception {
                 "org.openide.util.lookup.MetaInfServicesLookup.beforeLookup",
                 "org.netbeans.modules.project.ui.OpenProjectList.close",
                 "org.netbeans.modules.project.ui.OpenProjectList.doOpenProject");
-        RestrictThreadCreation.forbidNewThreads(false);

Review Comment:
   Hm, I see two possible directions:
   - try to change `RestrictThreadCreation` to use JFR. Might need a bit more help from the test, but should be doable.
   - delete not only `RestrictThreadCreation.forbidNewThreads(false);` but also the rest of the `RestrictThreadCreation` setup above, which seems completely irrelevant when `forbidNewThreads` is not called.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists