1 19 20 package org.netbeans.modules.apisupport.project.ui.customizer; 21 22 import java.io.File ; 23 import java.io.FileInputStream ; 24 import java.io.FileOutputStream ; 25 import java.io.IOException ; 26 import java.io.InputStream ; 27 import java.io.OutputStream ; 28 import java.util.ArrayList ; 29 import java.util.Arrays ; 30 import java.util.HashMap ; 31 import java.util.Iterator ; 32 import java.util.Map ; 33 import java.util.Set ; 34 import java.util.jar.Manifest ; 35 import org.netbeans.api.project.Project; 36 import org.netbeans.api.project.ProjectManager; 37 import org.netbeans.api.project.ProjectUtils; 38 import org.netbeans.modules.apisupport.project.EditableManifest; 39 import org.netbeans.modules.apisupport.project.ManifestManager; 40 import org.netbeans.modules.apisupport.project.NbModuleProject; 41 import org.netbeans.modules.apisupport.project.NbModuleProjectGenerator; 42 import org.netbeans.modules.apisupport.project.spi.NbModuleProvider; 43 import org.netbeans.modules.apisupport.project.ProjectXMLManager; 44 import org.netbeans.modules.apisupport.project.SuiteProvider; 45 import org.netbeans.modules.apisupport.project.TestBase; 46 import org.netbeans.modules.apisupport.project.Util; 47 import org.netbeans.modules.apisupport.project.suite.SuiteProject; 48 import org.netbeans.modules.apisupport.project.ui.customizer.CustomizerComponentFactory.PublicPackagesTableModel; 49 import org.netbeans.modules.apisupport.project.universe.LocalizedBundleInfo; 50 import org.netbeans.modules.apisupport.project.universe.ModuleEntry; 51 import org.netbeans.modules.apisupport.project.universe.ModuleList; 52 import org.netbeans.spi.project.support.ant.EditableProperties; 53 import org.openide.filesystems.FileLock; 54 import org.openide.filesystems.FileObject; 55 import org.openide.filesystems.FileUtil; 56 import org.openide.util.Mutex; 57 58 62 69 public class SingleModulePropertiesTest extends TestBase { 70 71 public SingleModulePropertiesTest(String name) { 72 super(name); 73 } 74 75 protected void setUp() throws Exception { 76 clearWorkDir(); 77 super.setUp(); 78 } 79 80 81 public void testThatBasicPropertiesAreLoaded() throws Exception { 82 NbModuleProject p = generateStandaloneModule("module1"); 83 SingleModuleProperties props = loadProperties(p); 84 assertNotNull(props.getActivePlatform()); 85 assertNotNull("loading bundle info", props.getBundleInfo()); 86 assertEquals("display name", "Testing Module", props.getBundleInfo().getDisplayName()); 87 assertEquals("cnb", "org.example.module1", props.getCodeNameBase()); 88 assertNull("no impl. version", props.getImplementationVersion()); 89 assertTrue("jar file", props.getJarFile().endsWith("org-example-module1.jar")); 90 assertEquals("major release version", null, props.getMajorReleaseVersion()); 91 assertEquals("spec. version", "1.0", props.getSpecificationVersion()); 92 } 93 94 public void testThatPropertiesAreRefreshed() throws Exception { 95 NbModuleProject p = generateStandaloneModule("module1"); 96 SingleModuleProperties props = loadProperties(p); 97 assertEquals("spec. version", "1.0", props.getSpecificationVersion()); 98 assertEquals("display name", "Testing Module", props.getBundleInfo().getDisplayName()); 99 assertEquals("number of dependencies", 0, props.getDependenciesListModel().getSize()); 100 101 InputStream is = new FileInputStream (props.getManifestFile()); 103 EditableManifest em = new EditableManifest(); 104 try { 105 em = new EditableManifest(is); 106 } finally { 107 is.close(); 108 } 109 em.setAttribute(ManifestManager.OPENIDE_MODULE_SPECIFICATION_VERSION, "1.1", null); 110 OutputStream os = new FileOutputStream (props.getManifestFile()); 111 try { 112 em.write(os); 113 } finally { 114 os.close(); 115 } 116 117 EditableProperties ep = new EditableProperties(); 119 is = new FileInputStream (props.getBundleInfo().getPaths()[0]); 120 try { 121 ep.load(is); 122 } finally { 123 is.close(); 124 } 125 ep.setProperty(LocalizedBundleInfo.NAME, "Miscellaneous"); 126 os = new FileOutputStream (props.getBundleInfo().getPaths()[0]); 127 try { 128 ep.store(os); 129 } finally { 130 os.close(); 131 } 132 133 Util.addDependency(p, "org.netbeans.modules.java.project", "1", null, false); 135 ProjectManager.getDefault().saveProject(p); 136 137 simulatePropertiesOpening(props, p); 138 139 assertEquals("spec. version", "1.1", props.getSpecificationVersion()); 141 assertEquals("display name should be changed", "Miscellaneous", props.getBundleInfo().getDisplayName()); 142 assertEquals("number of dependencies", 1, props.getDependenciesListModel().getSize()); 143 } 144 145 public void testThatPropertiesListen() throws Exception { 146 NbModuleProject p = generateStandaloneModule("module1"); 147 SingleModuleProperties props = loadProperties(p); 148 assertEquals("display name from ProjectInformation", "Testing Module", 149 ProjectUtils.getInformation(p).getDisplayName()); 150 assertEquals("display name from LocalizedBundleInfo", "Testing Module", 151 props.getBundleInfo().getDisplayName()); 152 153 FileObject bundleFO = FileUtil.toFileObject(props.getBundleInfo().getPaths()[0]); 154 EditableProperties bundleEP = Util.loadProperties(bundleFO); 155 bundleEP.setProperty(LocalizedBundleInfo.NAME, "Miscellaneous"); 156 Util.storeProperties(bundleFO, bundleEP); 158 159 assertEquals("display name was refreshed in ProjectInformation", "Miscellaneous", 161 ProjectUtils.getInformation(p).getDisplayName()); 162 assertEquals("display name was refreshed in LocalizedBundleInfo", "Miscellaneous", 163 props.getBundleInfo().getDisplayName()); 164 } 165 166 public void testGetPublicPackages() throws Exception { 167 final NbModuleProject p = generateStandaloneModule("module1"); 168 FileUtil.createData(p.getSourceDirectory(), "org/example/module1/One.java"); 169 FileUtil.createData(p.getSourceDirectory(), "org/example/module1/resources/Two.java"); 170 171 Boolean result = (Boolean ) ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction() { 173 public Object run() throws IOException { 174 ProjectXMLManager pxm = new ProjectXMLManager(p); 175 String [] newPP = new String [] { "org.example.module1" }; 176 pxm.replacePublicPackages(newPP); 177 return Boolean.TRUE; 178 } 179 }); 180 assertTrue("replace public packages", result.booleanValue()); 181 ProjectManager.getDefault().saveProject(p); 182 183 SingleModuleProperties props = loadProperties(p); 184 PublicPackagesTableModel pptm = props.getPublicPackagesModel(); 185 assertEquals("number of available public packages", 2, pptm.getRowCount()); 186 assertEquals("number of selected public packages", 1, pptm.getSelectedPackages().length); 187 188 NbModuleProject libP = (NbModuleProject) ProjectManager.getDefault().findProject(nbCVSRoot().getFileObject("libs/xerces")); 190 props = loadProperties(libP); 191 pptm = props.getPublicPackagesModel(); 192 assertEquals("number of available public packages", 39, pptm.getRowCount()); 193 assertEquals("number of selected public packages", 39, pptm.getSelectedPackages().length); 194 } 195 196 public void testThatProjectWithoutBundleDoesNotThrowNPE_61469() throws Exception { 197 FileObject pFO = TestBase.generateStandaloneModuleDirectory(getWorkDir(), "module1"); 198 FileObject propsFO = FileUtil.toFileObject(new File (getWorkDir(), 199 "module1/src/org/example/module1/resources/Bundle.properties")); 200 propsFO.delete(); 201 NbModuleProject p = (NbModuleProject) ProjectManager.getDefault().findProject(pFO); 202 SingleModuleProperties props = loadProperties(p); 203 simulatePropertiesOpening(props, p); 204 } 205 206 public void testThatManifestFormattingIsNotMessedUp_61248() throws Exception { 207 NbModuleProject p = generateStandaloneModule("module1"); 208 EditableManifest em = Util.loadManifest(p.getManifestFile()); 209 em.setAttribute(ManifestManager.OPENIDE_MODULE_REQUIRES, "\n" + 210 " org.openide.execution.ExecutionEngine,\n" + 211 " org.openide.windows.IOProvider", null); 212 Util.storeManifest(p.getManifestFile(), em); 213 String before = TestBase.slurp(p.getManifestFile()); 214 215 SingleModuleProperties props = loadProperties(p); 216 props.setImplementationVersion(""); 218 props.setProvidedTokens(""); 219 props.storeProperties(); 220 ProjectManager.getDefault().saveProject(p); 221 String after = TestBase.slurp(p.getManifestFile()); 222 223 assertEquals("the same content", before, after); 224 } 225 226 public void testNiceFormattingForRequiredTokensInManifest_63516() throws Exception { 227 NbModuleProject p = generateStandaloneModule("module1"); 228 EditableManifest em = Util.loadManifest(p.getManifestFile()); 229 em.setAttribute(ManifestManager.OPENIDE_MODULE_REQUIRES, "\n" + 230 " org.openide.execution.ExecutionEngine,\n" + 231 " org.openide.windows.IOProvider", null); 232 Util.storeManifest(p.getManifestFile(), em); 233 234 SingleModuleProperties props = loadProperties(p); 235 props.getRequiredTokenListModel().addToken("org.netbeans.api.javahelp.Help"); 236 props.setImplementationVersion(""); 238 props.setProvidedTokens(""); 239 props.storeProperties(); 240 ProjectManager.getDefault().saveProject(p); 241 String real = TestBase.slurp(p.getManifestFile()); 242 String expected = "Manifest-Version: 1.0\n" + 243 "OpenIDE-Module: org.example.module1\n" + 244 "OpenIDE-Module-Layer: org/example/module1/resources/layer.xml\n" + 245 "OpenIDE-Module-Localizing-Bundle: org/example/module1/resources/Bundle.properties\n" + 246 "OpenIDE-Module-Requires: \n" + 247 " org.netbeans.api.javahelp.Help,\n" + 248 " org.openide.execution.ExecutionEngine,\n" + 249 " org.openide.windows.IOProvider\n" + 250 "OpenIDE-Module-Specification-Version: 1.0\n\n"; 251 252 assertEquals("expected content", expected, real); 253 254 props.getRequiredTokenListModel().removeToken("org.openide.execution.ExecutionEngine"); 255 props.getRequiredTokenListModel().removeToken("org.netbeans.api.javahelp.Help"); 256 props.storeProperties(); 257 ProjectManager.getDefault().saveProject(p); 258 real = TestBase.slurp(p.getManifestFile()); 259 expected = "Manifest-Version: 1.0\n" + 260 "OpenIDE-Module: org.example.module1\n" + 261 "OpenIDE-Module-Layer: org/example/module1/resources/layer.xml\n" + 262 "OpenIDE-Module-Localizing-Bundle: org/example/module1/resources/Bundle.properties\n" + 263 "OpenIDE-Module-Requires: org.openide.windows.IOProvider\n" + 264 "OpenIDE-Module-Specification-Version: 1.0\n\n"; 265 266 assertEquals("expected content", expected, real); 267 } 268 269 public void testAvailablePublicPackages() throws Exception { 270 Map contents = new HashMap (); 271 contents.put("lib/pkg/Clazz3.class", ""); 272 contents.put("lib/pkg2/Clazz4.class", ""); 273 contents.put("1.0/oldlib/Clazz5.class", ""); File jar = new File (getWorkDir(), "some.jar"); 275 createJar(jar, contents, new Manifest ()); 276 SuiteProject sweet = generateSuite("sweet"); 277 File moduleDir = new File (getWorkDir(), "module"); 278 NbModuleProjectGenerator.createSuiteLibraryModule( 279 moduleDir, "module", "Module", "module/Bundle.properties", 280 sweet.getProjectDirectoryFile(), null, new File [] {jar}); 281 NbModuleProject p = (NbModuleProject) ProjectManager.getDefault().findProject(FileUtil.toFileObject(moduleDir)); 282 FileObject srcDir = p.getProjectDirectory().getFileObject("src"); 283 FileUtil.createData(srcDir, "pkg1/Clazz1.java"); 284 FileUtil.createData(srcDir, "pkg1/Clazz2.java"); 285 FileUtil.createData(srcDir, "pkg2/CVS/#1.20#Clazz1.java"); 286 FileUtil.createData(srcDir, "pkg2/Clazz1.java"); 287 FileUtil.createData(srcDir, "pkg2/deeper/Clazz1.java"); 288 FileUtil.createData(srcDir, "pkg2/deeper/and/deeper/Clazz1.java"); 289 FileUtil.createData(srcDir, ".broken/Clazz.java"); assertEquals(Arrays.asList(new String [] {"lib.pkg", "lib.pkg2", "pkg1", "pkg2", "pkg2.deeper", "pkg2.deeper.and.deeper"}), 291 new ArrayList (SingleModuleProperties.getInstance(p).getAvailablePublicPackages())); 292 } 293 294 public void testPublicPackagesAreUpToDate_63561() throws Exception { 295 SuiteProject suite1 = generateSuite("suite1"); 296 final NbModuleProject p = TestBase.generateSuiteComponent(suite1, "module1a"); 297 FileUtil.createData(p.getSourceDirectory(), "org/example/module1a/Dummy.java"); 298 SingleModuleProperties props = loadProperties(p); 299 PublicPackagesTableModel pptm = props.getPublicPackagesModel(); 300 assertEquals("number of available public packages", 1, pptm.getRowCount()); 301 assertEquals("number of selected public packages", 0, pptm.getSelectedPackages().length); 302 assertEquals("no public packages in the ModuleEntry", 0, props.getModuleList().getEntry("org.example.module1a").getPublicPackages().length); 303 304 Boolean result = (Boolean ) ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction() { 306 public Object run() throws IOException { 307 ProjectXMLManager pxm = new ProjectXMLManager(p); 308 String [] newPP = new String [] { "org.example.module1a" }; 309 pxm.replacePublicPackages(newPP); 310 return Boolean.TRUE; 311 } 312 }); 313 assertTrue("replace public packages", result.booleanValue()); 314 ProjectManager.getDefault().saveProject(p); 315 316 simulatePropertiesOpening(props, p); 317 318 pptm = props.getPublicPackagesModel(); 319 assertEquals("number of available public packages", 1, pptm.getRowCount()); 320 assertEquals("number of selected public packages", 1, pptm.getSelectedPackages().length); 321 assertEquals("one public packages in the ModuleEntry", 1, props.getModuleList().getEntry("org.example.module1a").getPublicPackages().length); 322 } 323 324 325 public void testThatTheModuleDoesNotOfferItself_61232() throws Exception { 326 NbModuleProject p = generateStandaloneModule("module1"); 327 SingleModuleProperties props = loadProperties(p); 328 Set set = props.getUniverseDependencies(true); 329 for (Iterator it = set.iterator() ; it.hasNext() ; ) { 330 ModuleDependency dependency = (ModuleDependency) it.next(); 331 ModuleEntry me = dependency.getModuleEntry(); 332 assertFalse("module doesn't offer itself in its dependency list: " + p.getCodeNameBase(), 333 p.getCodeNameBase().equals(me.getCodeNameBase())); 334 } 335 } 336 337 public void testGetAvailableFriends() throws Exception { 338 NbModuleProject standAlone = generateStandaloneModule("module1"); 340 SingleModuleProperties props = loadProperties(standAlone); 341 assertEquals("There are no friends for standalone module.", 0, props.getAvailableFriends().length); 342 343 SuiteProject suite1 = generateSuite("suite1"); 345 TestBase.generateSuiteComponent(suite1, "component1"); 346 NbModuleProject component2 = TestBase.generateSuiteComponent(suite1, "component2"); 347 TestBase.generateSuiteComponent(suite1, "component3"); 348 props = loadProperties(component2); 349 assertEquals("There are two available friends for component2.", 2, props.getAvailableFriends().length); 350 351 Project javaProject = ProjectManager.getDefault().findProject(nbCVSRoot().getFileObject("java/project")); 353 props = loadProperties((NbModuleProject) javaProject); 354 assertTrue("There are two available friends for component2.", props.getAvailableFriends().length > 50); 355 } 356 357 public void testSimulateLocalizedBundlePackageRefactoring() throws Exception { 358 NbModuleProject p = generateStandaloneModule("module1"); 359 SingleModuleProperties props = loadProperties(p); 360 assertEquals("display name from ProjectInformation", "Testing Module", 361 ProjectUtils.getInformation(p).getDisplayName()); 362 assertEquals("display name from LocalizedBundleInfo", "Testing Module", 363 props.getBundleInfo().getDisplayName()); 364 365 FileObject pDir = p.getProjectDirectory(); 367 FileObject pkg = pDir.getFileObject("src/org/example/module1"); 368 FileLock lock = pkg.lock(); 369 pkg.rename(lock, "module1Renamed", null); 370 lock.releaseLock(); 371 FileObject manifestFO = pDir.getFileObject("manifest.mf"); 372 373 EditableManifest mf = Util.loadManifest(manifestFO); 375 mf.setAttribute(ManifestManager.OPENIDE_MODULE_LOCALIZING_BUNDLE, "org/example/module1Renamed/resources/Bundle.properties", null); 376 Util.storeManifest(manifestFO, mf); 377 378 simulatePropertiesOpening(props, p); 379 380 assertEquals("display name was refreshed in ProjectInformation", "Testing Module", 382 ProjectUtils.getInformation(p).getDisplayName()); 383 assertEquals("display name was refreshed in LocalizedBundleInfo", "Testing Module", 384 props.getBundleInfo().getDisplayName()); 385 } 386 387 public void testSimulateIllLocalizedBundlePackageRefactoring_67961() throws Exception { 388 NbModuleProject p = generateStandaloneModule("module1"); 389 SingleModuleProperties props = loadProperties(p); 390 assertEquals("display name from ProjectInformation", "Testing Module", 391 ProjectUtils.getInformation(p).getDisplayName()); 392 assertEquals("display name from LocalizedBundleInfo", "Testing Module", 393 props.getBundleInfo().getDisplayName()); 394 395 FileObject pDir = p.getProjectDirectory(); 397 FileObject manifestFO = pDir.getFileObject("manifest.mf"); 398 EditableManifest mf = Util.loadManifest(manifestFO); 399 mf.setAttribute(ManifestManager.OPENIDE_MODULE_LOCALIZING_BUNDLE, "org/example/module1Renamed/resources/Bundle.properties", null); 400 Util.storeManifest(manifestFO, mf); 401 402 FileObject pkg = pDir.getFileObject("src/org/example/module1"); 404 FileLock lock = pkg.lock(); 405 pkg.rename(lock, "module1Renamed", null); 406 lock.releaseLock(); 407 408 simulatePropertiesOpening(props, p); 409 410 assertEquals("display name was refreshed in ProjectInformation", "Testing Module", 412 ProjectUtils.getInformation(p).getDisplayName()); 413 assertEquals("display name was refreshed in LocalizedBundleInfo", "Testing Module", 414 props.getBundleInfo().getDisplayName()); 415 } 416 417 public void testResolveFile() throws Exception { 418 NbModuleProject p = generateStandaloneModule("module1"); 419 SingleModuleProperties props = loadProperties(p); 420 assertTrue("manifest exist", props.evaluateFile("manifest.mf").exists()); 421 assertTrue("manifest exist", props.evaluateFile(props.getProjectDirectory() + "/manifest.mf").exists()); 422 assertTrue("manifest exist", props.evaluateFile("${basedir}/manifest.mf").exists()); 423 assertFalse("non-existing file", props.evaluateFile("non-existing").exists()); 424 assertFalse("invalid reference", props.evaluateFile("${invalid-reference}/manifest.mf").exists()); 425 } 426 427 public void testThatFilesAreNotTouched_67249() throws Exception { 428 NbModuleProject p = generateStandaloneModule("module1"); 429 FileUtil.createData(p.getSourceDirectory(), "org/example/module1/One.java"); 430 FileUtil.createData(p.getSourceDirectory(), "org/example/module1/resources/Two.java"); 431 SingleModuleProperties props = loadProperties(p); 432 433 FileObject bundle = FileUtil.toFileObject(props.getBundleInfo().getPaths()[0]); 435 FileObject mf = p.getManifestFile(); 436 long mfTime = mf.lastModified().getTime(); 437 long bundleTime = bundle.lastModified().getTime(); 438 439 Thread.sleep(2000); 441 442 props.getPublicPackagesModel().setValueAt(Boolean.TRUE, 0, 0); 444 props.storeProperties(); 445 446 assertEquals("time for manifest has not changed", mfTime, mf.lastModified().getTime()); 448 assertEquals("time for bundle has not changed", bundleTime, bundle.lastModified().getTime()); 449 } 450 451 public void testGetUniverseDependencies() throws Exception { 452 SuiteProject suite = generateSuite("suite"); 453 454 NbModuleProject testPrj = generateSuiteComponent(suite, "testPrj"); 455 456 NbModuleProject apiPrj = generateSuiteComponent(suite, "apiPrj"); 457 FileUtil.createData(apiPrj.getProjectDirectory(), "src/api/Util.java"); 458 SingleModuleProperties apiPrjProps = SingleModulePropertiesTest.loadProperties(apiPrj); 459 apiPrjProps.getPublicPackagesModel().setValueAt(Boolean.TRUE, 0, 0); 460 apiPrjProps.storeProperties(); 461 ProjectManager.getDefault().saveProject(apiPrj); 462 463 NbModuleProject friendPrj = generateSuiteComponent(suite, "friendPrj"); 464 FileUtil.createData(friendPrj.getProjectDirectory(), "src/friend/Karel.java"); 465 SingleModuleProperties friendPrjProps = SingleModulePropertiesTest.loadProperties(friendPrj); 466 friendPrjProps.getPublicPackagesModel().setValueAt(Boolean.TRUE, 0, 0); 467 friendPrjProps.getFriendListModel().addFriend("org.example.testPrj"); 468 friendPrjProps.storeProperties(); 469 ProjectManager.getDefault().saveProject(friendPrj); 470 471 generateSuiteComponent(suite, "nonApiPrj"); 472 ModuleEntry apiPrjME = ModuleList.getModuleList(testPrj.getProjectDirectoryFile()).getEntry("org.example.apiPrj"); 473 ModuleDependency apiPrjDep = new ModuleDependency(apiPrjME); 474 ModuleEntry friendPrjME = ModuleList.getModuleList(testPrj.getProjectDirectoryFile()).getEntry("org.example.friendPrj"); 475 ModuleDependency friendPrjDep = new ModuleDependency(friendPrjME); 476 ModuleEntry nonApiPrjME = ModuleList.getModuleList(testPrj.getProjectDirectoryFile()).getEntry("org.example.nonApiPrj"); 477 ModuleDependency nonApiPrjDep = new ModuleDependency(nonApiPrjME); 478 479 SingleModuleProperties testProps = SingleModulePropertiesTest.loadProperties(testPrj); 480 Set allDeps = testProps.getUniverseDependencies(false); 481 Set allDepsFilterExcluded = testProps.getUniverseDependencies(true); 482 Set apiDeps = testProps.getUniverseDependencies(false, true); 483 Set apiDepsFilterExcluded = testProps.getUniverseDependencies(true, true); 484 485 assertTrue(allDeps.contains(apiPrjDep)); 486 assertTrue(allDeps.contains(friendPrjDep)); 487 assertTrue(allDeps.contains(nonApiPrjDep)); 488 489 assertTrue(allDepsFilterExcluded.contains(apiPrjDep)); 490 assertTrue(allDepsFilterExcluded.contains(friendPrjDep)); 491 assertTrue(allDepsFilterExcluded.contains(nonApiPrjDep)); 492 493 assertTrue(apiDeps.contains(apiPrjDep)); 494 assertTrue(apiDeps.contains(friendPrjDep)); 495 assertFalse(apiDeps.contains(nonApiPrjDep)); 496 497 assertTrue(apiDepsFilterExcluded.contains(apiPrjDep)); 498 assertTrue(apiDepsFilterExcluded.contains(friendPrjDep)); 499 assertFalse(apiDepsFilterExcluded.contains(nonApiPrjDep)); 500 501 EditableProperties ep = suite.getHelper().getProperties("nbproject/platform.properties"); 503 ep.setProperty(SuiteProperties.ENABLED_CLUSTERS_PROPERTY, "crazy99"); suite.getHelper().putProperties("nbproject/platform.properties", ep); 505 ProjectManager.getDefault().saveProject(suite); 506 allDepsFilterExcluded = testProps.getUniverseDependencies(true); 507 assertTrue(allDepsFilterExcluded.contains(apiPrjDep)); 508 assertTrue(allDepsFilterExcluded.contains(friendPrjDep)); 509 assertTrue(allDepsFilterExcluded.contains(nonApiPrjDep)); 510 } 511 512 public void testDefaultPackageIsNotOffered_71532() throws Exception { 513 NbModuleProject p = generateStandaloneModule("module1"); 514 FileUtil.createData(p.getProjectDirectory(), "src/BadInDefault.java"); 515 FileUtil.createData(p.getProjectDirectory(), "src/org/example/module1/GoodOne.java"); 516 assertEquals("one non-default valid package", 1, loadProperties(p).getPublicPackagesModel().getRowCount()); 517 } 518 519 539 static SingleModuleProperties loadProperties(NbModuleProject project) throws IOException { 540 return new SingleModuleProperties(project.getHelper(), project.evaluator(), 541 getSuiteProvider(project), getModuleType(project), 542 (LocalizedBundleInfo.Provider) project.getLookup().lookup(LocalizedBundleInfo.Provider.class)); 543 } 544 545 private static NbModuleProvider.NbModuleType getModuleType(Project p) { 546 NbModuleProvider nmtp = (NbModuleProvider) p.getLookup().lookup(NbModuleProvider.class); 547 return nmtp.getModuleType(); 548 } 549 550 private static SuiteProvider getSuiteProvider(Project p) { 551 return (SuiteProvider) p.getLookup().lookup(SuiteProvider.class); 552 } 553 554 private static void simulatePropertiesOpening( 555 final SingleModuleProperties props, final NbModuleProject p) { 556 props.refresh(getModuleType(p), getSuiteProvider(p)); 557 } 558 559 } 560 | Popular Tags |