From bd3abb833dfaf5fe9da4b6cc204aad4a05770989 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Sun, 25 Feb 2024 06:02:40 +0100 Subject: [PATCH] Include FileObject (and its lookup) even when working with whole Project --- .../debugging/launch/NbLaunchDelegateTest.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/debugging/launch/NbLaunchDelegateTest.java b/java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/debugging/launch/NbLaunchDelegateTest.java index f654b8fdf9b9..2035554950f8 100644 --- a/java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/debugging/launch/NbLaunchDelegateTest.java +++ b/java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/debugging/launch/NbLaunchDelegateTest.java @@ -101,6 +101,22 @@ public void testFindsWithFileObjectAndDataObject() throws Exception { assertEquals(prj, lkp.lookup(Project.class)); } + @Test + public void testFindsWithFileObjectAndDataObjectNoMethod() throws Exception { + FileObject dir = FileUtil.createMemoryFileSystem().getRoot().createFolder("testprj"); + FileObject xml = dir.createData("build.xml"); + Project prj = ProjectManager.getDefault().findProject(dir); + assertNotNull("Project dir recognized", prj); + + Lookup lkp = NbLaunchDelegate.createTargetLookup(prj, null, xml); + assertEquals("File object is available", xml, lkp.lookup(FileObject.class)); + DataObject obj = lkp.lookup(DataObject.class); + assertNotNull("DataObject is available", obj); + assertEquals("DataObject's FileObject is correct", xml, obj.getPrimaryFile()); + assertNull("No Single method is present", lkp.lookup(SingleMethod.class)); + assertEquals(prj, lkp.lookup(Project.class)); + } + @Test public void testAvoidNPEWithoutActionsProviderInLookup() throws Exception { MockProjectFactory.MockProject prj = new MockProjectFactory.MockProject(FileUtil.getConfigRoot());