Java Code Examples for org.openide.filesystems.FileObject#createFolder()
The following examples show how to use
org.openide.filesystems.FileObject#createFolder() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MavenJAXWSSupportImpl.java From netbeans with Apache License 2.0 | 6 votes |
private Endpoint addSunJaxWsEntries(JaxWsService service) throws IOException { FileObject ddFolder = getDeploymentDescriptorFolder(); if (ddFolder == null) { File webAppFolder = FileUtilities.resolveFilePath( FileUtil.toFile(prj.getProjectDirectory()), "src/main/webapp"); //NOI18N if (webAppFolder.exists()) { FileObject webapp = FileUtil.toFileObject(webAppFolder); ddFolder = webapp.createFolder("WEB-INF"); //NOI18N } } if (ddFolder != null) { return WSUtils.addSunJaxWsEntry(ddFolder, service); } else { String mes = NbBundle.getMessage(MavenJAXWSSupportImpl.class, "MSG_CannotFindWEB-INF"); // NOI18N NotifyDescriptor desc = new NotifyDescriptor.Message(mes, NotifyDescriptor.Message.ERROR_MESSAGE); DialogDisplayer.getDefault().notify(desc); return null; } }
Example 2
Source File: SourceTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testDOMove154813() throws IOException { FileObject file = createFileObject("test1/empty.txt", "", "\n"); DataObject dfile = DataObject.find(file); Document doc = createDocument("text/x-testtesttest", ""); doc.putProperty(Document.StreamDescriptionProperty, dfile); Source source = Source.create(doc); assertNotNull("No Source for " + doc, source); FileObject wd = file.getParent().getParent(); FileObject nueParent = wd.getFileObject("test2"); if (nueParent == null) { nueParent = wd.createFolder("test2"); } dfile.move(DataFolder.findFolder(nueParent)); source = Source.create(doc); assertNotNull("No Source for " + doc, source); assertEquals("Correct FileObject", dfile.getPrimaryFile(), source.getFileObject()); }
Example 3
Source File: J2SEModularPersistenceProvider.java From netbeans with Apache License 2.0 | 6 votes |
@Override public FileObject createLocation(FileObject fo) throws IOException { List<FileObject> roots = findSourceRoots(fo); if (roots.isEmpty()) { throw new IOException("There is no target source root specified."); // NOI18N } FileObject root = roots.get(0); FileObject metaInf = root.getFileObject("META-INF"); // NOI18N if (metaInf != null) { if (!metaInf.isFolder()) { throw new IOException("The META-INF directory exists, but is not a folder."); // NOI18N } } else { metaInf = root.createFolder("META-INF"); // NOI18N } // // // FileUtil.addFileChangeListener(puChangeListener, new File(FileUtil.toFile(metaInf), "persistence.xml")); // return metaInf; }
Example 4
Source File: SpecialSearchGroupTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testFindCommonPathNegative() throws IOException { FileObject root1 = FileUtil.createMemoryFileSystem().getRoot(); FileObject root2 = FileUtil.createMemoryFileSystem().getRoot(); FileObject a1 = root1.createFolder("a"); FileObject b1 = a1.createData("b"); FileObject a2 = root2.createFolder("a"); FileObject b2 = a2.createData("b"); // List<FileObject> p1 = filePathAsList(b1); // List<FileObject> p2 = filePathAsList(b2); // // List<FileObject> common = findCommonPath(p1, p2); // // assertTrue(common.isEmpty()); }
Example 5
Source File: ProjectManagerTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testClearNonProjectCache() throws Exception { FileObject p1 = scratch.createFolder("p1"); p1.createFolder("testproject"); Project proj1 = pm.findProject(p1); assertNotNull("p1 immediately recognized as a project", proj1); FileObject p2 = scratch.createFolder("p2"); assertNull("p2 not yet recognized as a project", pm.findProject(p2)); FileObject p2a = scratch.createFolder("p2a"); assertNull("p2a not yet recognized as a project", pm.findProject(p2a)); FileObject p3 = scratch.createFolder("p3"); FileObject p3broken = p3.createFolder("testproject").createData("broken"); try { pm.findProject(p3); fail("p3 should throw an error"); } catch (IOException e) { // Correct. } p2.createFolder("testproject"); p2a.createFolder("testproject"); p3broken.delete(); pm.clearNonProjectCache(); assertNotNull("now p2 is recognized as a project", pm.findProject(p2)); assertNotNull("now p2a is recognized as a project", pm.findProject(p2a)); assertNotNull("now p3 is recognized as a non-broken project", pm.findProject(p3)); assertEquals("p1 still recognized as a project", proj1, pm.findProject(p1)); }
Example 6
Source File: SourceLevelQueryImplTest.java From netbeans with Apache License 2.0 | 5 votes |
private void prepareProject (String platformName) throws IOException { scratch = TestUtil.makeScratchDir(this); FileObject projdir = scratch.createFolder("proj"); AntProjectHelper helper = ProjectGenerator.createProject(projdir, "org.netbeans.modules.java.j2seproject"); EditableProperties props = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); props.setProperty("javac.source", "${def}"); props.setProperty ("platform.active",platformName); props.setProperty("def", "1.2"); helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, props); props = PropertyUtils.getGlobalProperties(); props.put("default.javac.source", "4.3"); PropertyUtils.putGlobalProperties(props); sources = projdir.createFolder("src"); projdir.createFolder("test"); }
Example 7
Source File: BinaryAnalyserTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testTransactionalFlush() throws Exception { requireFullIndex(true); FileObject workDir = FileUtil.toFileObject(getWorkDir()); FileObject indexDir = workDir.createFolder("index"); File binaryAnalyzerDataDir = annotationsJar(); final Index index = IndexManager.createIndex(FileUtil.toFile(indexDir), DocumentUtil.createAnalyzer()); BinaryAnalyser a = new BinaryAnalyser( new IndexWriter(index) { @Override public void deleteAndFlush(List<Pair<Pair<BinaryName, String>, Object[]>> refs, Set<Pair<String, String>> toDelete) throws IOException { super.deleteAndFlush(refs, toDelete); try { dataFlushed(index); } catch (InterruptedException ex) { Exceptions.printStackTrace(ex); } } }, getWorkDir() ); LowMemoryWatcherAccessor.setLowMemory(true); assertTrue(a.analyse(Utilities.toURI(binaryAnalyzerDataDir).toURL()).done); // at least one flush occured. assertFalse(flushCount == 0); assertReference(index, "annotations.NoArgAnnotation", "usages.ClassAnnotations", "usages.MethodAnnotations", "usages.FieldAnnotations"); assertReference(index, "annotations.ArrayOfStringArgAnnotation", "usages.ClassAnnotations", "usages.ClassArrayAnnotations", "usages.MethodAnnotations", "usages.MethodArrayAnnotations", "usages.FieldAnnotations", "usages.FieldArrayAnnotations"); assertReference(index, "annotations.TestEnum", "usages.ClassAnnotations", "usages.ClassArrayAnnotations", "usages.MethodAnnotations", "usages.MethodArrayAnnotations", "usages.FieldAnnotations", "usages.FieldArrayAnnotations"); assertReference(index, "java.util.List", "usages.ClassAnnotations", "usages.ClassArrayAnnotations", "usages.MethodAnnotations", "usages.MethodArrayAnnotations", "usages.FieldAnnotations", "usages.FieldArrayAnnotations"); }
Example 8
Source File: GeneratorTestBase.java From netbeans with Apache License 2.0 | 5 votes |
private void deepCopy(FileObject source, FileObject targetDirectory) throws IOException { for (FileObject child : source.getChildren()) { if (child.isFolder()) { FileObject target = targetDirectory.createFolder(child.getNameExt()); deepCopy(child, target); } else { FileUtil.copyFile(child, targetDirectory, child.getName()); } } }
Example 9
Source File: BaseFileObjectTestHid.java From netbeans with Apache License 2.0 | 5 votes |
public void testMoveOfAFolderDoesNotTouchSubhierarchy() throws Exception { FileObjectFactory fs = FileObjectFactory.getInstance(getWorkDir()); assertNotNull(fs); FileObject root1 = fs.getValidFileObject(getWorkDir(), FileObjectFactory.Caller.Others); FileObject where = root1.createFolder("else").createFolder("sub").createFolder("subsub"); FileObject fo = root1.createFolder("something"); FileObject kidTxt = fo.createData("kid.txt"); FileObject kid = fo.createFolder("kid"); File kidFile = FileUtil.toFile(kid); File kidTxtFile = FileUtil.toFile(kidTxt); accessMonitor = new StatFiles(); FileLock lock = fo.lock(); FileObject newFolder; try { newFolder = fo.move(lock, where, fo.getNameExt(), null); } finally { lock.releaseLock(); } assertEquals("Subfolder", where, newFolder.getParent()); assertNotNull("Folder found", newFolder.getFileObject("kid")); assertNotNull("File found", newFolder.getFileObject("kid.txt")); assertFalse("No longer valid file", kidTxt.isValid()); assertFalse("No longer valid dir", kid.isValid()); String msg = accessMonitor.getResults().statResultStack(kidFile, StatFiles.ALL) + "\n" + accessMonitor.getResults().statResultStack(kidTxtFile, StatFiles.ALL) + "\n"; final Set<File> files = accessMonitor.getResults().getFiles(); if (files.contains(kidFile) || files.contains(kidTxtFile)) { fail(msg); } }
Example 10
Source File: ClusteredIndexablesCacheTest.java From netbeans with Apache License 2.0 | 5 votes |
@Override protected void setUp() throws Exception { super.setUp(); clearWorkDir(); final File wd = getWorkDir(); final FileObject wdo = FileUtil.toFileObject(wd); assertNotNull("No masterfs",wdo); //NOI18N final FileObject cache = wdo.createFolder("cache"); //NOI18N CacheFolder.setCacheFolder(cache); src1 = wdo.createFolder("src1"); //NOI18N assertNotNull(src1); file1 = src1.createData("test", FOO_EXT); //NOI18N assertNotNull(file1); file2 = src1.createData("test2", FOO_EXT); //NOI18N assertNotNull(file2); file3 = src1.createData("test3", FOO_EXT); //NOI18N assertNotNull(file3); file4 = src1.createData("test4", FOO_EXT); //NOI18N assertNotNull(file4); FileUtil.setMIMEType(FOO_EXT, FOO_MIME); src2 = wdo.createFolder("src2"); //NOI18N assertNotNull(src2); file5 = src2.createData("test5", EMB_EXT); //NOI18N assertNotNull(file5); file6 = src2.createData("test6", EMB_EXT); //NOI18N assertNotNull(file6); file7 = src2.createData("test7", EMB_EXT); //NOI18N assertNotNull(file7); file8 = src2.createData("test8", EMB_EXT); //NOI18N assertNotNull(file8); FileUtil.setMIMEType(EMB_EXT, EMB_MIME); cp1 = ClassPathSupport.createClassPath(src1); cp2 = ClassPathSupport.createClassPath(src2); MockMimeLookup.setInstances(MimePath.get(FOO_MIME), new FooIndexerFactory()); MockMimeLookup.setInstances(MimePath.get(EMB_MIME), new EmbIndexerFactory(), new EmbParserFactory()); RepositoryUpdaterTest.setMimeTypes(FOO_MIME, EMB_MIME); RepositoryUpdaterTest.waitForRepositoryUpdaterInit(); }
Example 11
Source File: ProjectLibraryProviderTest.java From netbeans with Apache License 2.0 | 5 votes |
private static void registerTestLibraryTypeProvider () throws Exception { StringTokenizer tk = new StringTokenizer("org-netbeans-api-project-libraries/LibraryTypeProviders","/"); FileObject root = FileUtil.getConfigRoot(); while (tk.hasMoreElements()) { String pathElement = tk.nextToken(); FileObject tmp = root.getFileObject(pathElement); if (tmp == null) { tmp = root.createFolder(pathElement); } root = tmp; } if (root.getChildren().length == 0) { InstanceDataObject.create (DataFolder.findFolder(root),"TestLibraryTypeProvider",TestLibraryTypeProvider.class); } }
Example 12
Source File: J2SESourcesTest.java From netbeans with Apache License 2.0 | 5 votes |
private static FileObject getFileObject (FileObject parent, String name) throws IOException { FileObject result = parent.getFileObject(name); if (result == null) { result = parent.createFolder(name); } return result; }
Example 13
Source File: TestPerformer.java From netbeans with Apache License 2.0 | 4 votes |
private static Map<TestCase, Collection<String>> performTestImpl(FileObject ruleFile, FileObject test, TestCase[] tests, final AtomicBoolean cancel) throws Exception { final List<HintDescription> hints = new LinkedList<HintDescription>(); for (Collection<? extends HintDescription> descs : DeclarativeHintRegistry.parseHintFile(ruleFile).values()) { hints.addAll(descs); } FileObject scratchPad = FileUtil.toFileObject(createScratchpadDir()); Map<TestCase, Collection<String>> result = new HashMap<TestCase, Collection<String>>(); for (int cntr = 0; cntr < tests.length; cntr++) { FileObject srcRoot = scratchPad.createFolder("src" + cntr); FileObject src = FileUtil.createData(srcRoot, "test/Test.java"); setData(test, srcRoot, tests[cntr].getSourceLevel()); copyStringToFile(src, tests[cntr].getCode()); final List<ErrorDescription> errors = new LinkedList<ErrorDescription>(); JavaSource.forFileObject(src).runUserActionTask(new Task<CompilationController>() { public void run(CompilationController parameter) throws Exception { parameter.toPhase(Phase.RESOLVED); Map<HintDescription, List<ErrorDescription>> sortedByHintDescription = new TreeMap<HintDescription, List<ErrorDescription>>(new Comparator<HintDescription>() { public int compare(HintDescription o1, HintDescription o2) { return hints.indexOf(o1) - hints.indexOf(o2); } }); Map<HintDescription, List<ErrorDescription>> computedHints = new HintsInvoker(HintsSettings.getGlobalSettings(), cancel).computeHints(parameter, new TreePath(parameter.getCompilationUnit()), hints, new LinkedList<MessageImpl>()); if (computedHints == null || cancel.get()) return; sortedByHintDescription.putAll(computedHints); for (Entry<HintDescription, List<ErrorDescription>> e : sortedByHintDescription.entrySet()) { errors.addAll(e.getValue()); } } }, true); if (cancel.get()) return null; LinkedList<String> currentResults = new LinkedList<String>(); result.put(tests[cntr],currentResults); for (ErrorDescription ed : errors) { if (!ed.getFixes().isComputed()) { throw new UnsupportedOperationException(); } for (Fix f : ed.getFixes().getFixes()) { //XXX: this fix is automatically added to all hints that do not have any fixes, filtering it out. Should be done more reliably: if (f.getClass().getName().equals("org.netbeans.modules.java.hints.jackpot.spi.support.ErrorDescriptionFactory$TopLevelConfigureFix")) continue; if (f.getClass().getName().equals("org.netbeans.spi.java.hints.ErrorDescriptionFactory$TopLevelConfigureFix")) continue; currentResults.add(getFixResult(src, f)); } if (currentResults.isEmpty()) { currentResults.add(ed.getDescription() + ":" + ed.getRange().getText() + "\n"); } } } //intentionally keeping the directory in case an exception occurs, to //simplify error diagnostics scratchPad.delete(); return result; }
Example 14
Source File: SelectedTablesTest.java From netbeans with Apache License 2.0 | 4 votes |
public void testBasic() throws Exception { class CL implements ChangeListener { private int changeCount; public void stateChanged(ChangeEvent event) { changeCount++; } } clearWorkDir(); FileObject workDirFO = FileUtil.toFileObject(getWorkDir()); FileObject locationFO = workDirFO.createFolder("location"); String package1Name = "package1"; FileObject package1FO = locationFO.createFolder(package1Name); String package2Name = "package2"; FileObject package2FO = locationFO.createFolder(package2Name); package1FO.createData("Table3", "java"); SourceGroup location = new SourceGroupImpl(locationFO); Map<String, Set<String>> tablesAndRefs = new HashMap<String, Set<String>>(); tablesAndRefs.put("TABLE1", Collections.<String>emptySet()); tablesAndRefs.put("TABLE2", Collections.<String>emptySet()); TableProviderImpl provider = new TableProviderImpl(null, null, tablesAndRefs); TableClosure closure = new TableClosure(provider); PersistenceGenerator persistenceGen = new PersistenceGeneratorImpl(); SelectedTables selectedTables = new SelectedTables(persistenceGen, closure, location, package1Name); CL cl = new CL(); selectedTables.addChangeListener(cl); assertEquals(0, selectedTables.getTables().size()); assertNull(selectedTables.getFirstProblem()); assertEquals(0, cl.changeCount); closure.addTables(Collections.singleton(provider.getTableByName("TABLE1"))); assertEquals(1, selectedTables.getTables().size()); assertNull(selectedTables.getFirstProblem()); assertEquals(1, cl.changeCount); Table table = provider.getTableByName("TABLE2"); closure.addTables(Collections.singleton(table)); assertEquals(2, selectedTables.getTables().size()); assertNull(selectedTables.getFirstProblem()); assertEquals(2, cl.changeCount); selectedTables.setClassName(table,"Table@"); assertEquals(2, selectedTables.getTables().size()); assertEquals(SelectedTables.Problem.NO_JAVA_IDENTIFIER, selectedTables.getFirstProblem()); assertEquals(3, cl.changeCount); selectedTables.setClassName(table,"SELECT"); assertEquals(2, selectedTables.getTables().size()); assertEquals(SelectedTables.Problem.JPA_QL_IDENTIFIER, selectedTables.getFirstProblem()); assertEquals(4, cl.changeCount); selectedTables.setClassName(table,"Table3"); assertEquals(2, selectedTables.getTables().size()); // assertEquals(SelectedTables.Problem.ALREADY_EXISTS, selectedTables.getFirstProblem()); assertNull(selectedTables.getFirstProblem()); assertEquals(5, cl.changeCount); selectedTables.setTargetFolder(location, package2Name); assertEquals(2, selectedTables.getTables().size()); assertNull(selectedTables.getFirstProblem()); assertEquals(6, cl.changeCount); }
Example 15
Source File: MultiModuleBinaryForSourceQueryImplTest.java From netbeans with Apache License 2.0 | 4 votes |
public void testModuleSourcesChanges() throws IOException { final FileObject wd = FileUtil.toFileObject(FileUtil.normalizeFile(getWorkDir())); final FileObject modulesFolder = wd.createFolder("modules"); //NOI18N assertNotNull(modulesFolder); final FileObject classesFolder = modulesFolder.createFolder("module").createFolder("classes"); //NOI18N assertTrue(mtu.updateModuleRoots(false, "classes:resources", modulesFolder)); //NOI18N final SourceRoots modules = mtu.newModuleRoots(false); assertTrue(Arrays.equals(new FileObject[]{modulesFolder}, modules.getRoots())); final SourceRoots sources = mtu.newSourceRoots(false); final MultiModule model = MultiModule.getOrCreate(modules, sources); assertNotNull(model); final SourceRoots testModules = mtu.newModuleRoots(true); assertTrue(Arrays.equals(new FileObject[]{}, testModules.getRoots())); final SourceRoots testSources = mtu.newSourceRoots(true); final MultiModule testModel = MultiModule.getOrCreate(testModules, testSources); final MultiModuleBinaryForSourceQueryImpl q = new MultiModuleBinaryForSourceQueryImpl( tp.getUpdateHelper().getAntProjectHelper(), tp.getEvaluator(), model, testModel, new String[]{ String.format("${%s}/${module.name}",ProjectProperties.BUILD_CLASSES_DIR), //NOI18N String.format("${%s}/${module.name}.jar",ProjectProperties.DIST_DIR) //NOI18N }, new String[]{}); final BinaryForSourceQuery.Result r1 = q.findBinaryRoots(classesFolder.toURL()); assertNotNull(r1); assertEquals( Arrays.asList( mtu.buildFor(classesFolder.getParent().getNameExt()), mtu.distFor(classesFolder.getParent().getNameExt()) ), Arrays.asList(r1.getRoots())); final FileObject resourcesFolder = modulesFolder.getFileObject("module").createFolder("resources"); //NOI18N final BinaryForSourceQuery.Result r2 = q.findBinaryRoots(resourcesFolder.toURL()); assertNotNull(r2); assertEquals( Arrays.asList( mtu.buildFor(classesFolder.getParent().getNameExt()), mtu.distFor(classesFolder.getParent().getNameExt()) ), Arrays.asList(r2.getRoots())); assertTrue(mtu.updateModuleRoots(false, "resources", modulesFolder)); //NOI18N assertEquals( Collections.emptyList(), Arrays.asList(r1.getRoots())); final BinaryForSourceQuery.Result r3 = q.findBinaryRoots(classesFolder.toURL()); assertNull(r3); final BinaryForSourceQuery.Result r4 = q.findBinaryRoots(resourcesFolder.toURL()); assertNotNull(r4); assertEquals( Arrays.asList( mtu.buildFor(classesFolder.getParent().getNameExt()), mtu.distFor(classesFolder.getParent().getNameExt()) ), Arrays.asList(r4.getRoots())); }
Example 16
Source File: EjbJarProjectGenerator.java From netbeans with Apache License 2.0 | 4 votes |
private static AntProjectHelper createProjectImpl(final EjbJarProjectCreateData createData, final FileObject projectDir) throws IOException { String name = createData.getName(); String serverInstanceID = createData.getServerInstanceID(); FileObject srcRoot = projectDir.createFolder(DEFAULT_SRC_FOLDER); // NOI18N srcRoot.createFolder(DEFAULT_JAVA_FOLDER); //NOI18N if (!createData.skipTests()) { projectDir.createFolder(DEFAULT_TEST_FOLDER); } FileObject confRoot = srcRoot.createFolder(DEFAULT_DOC_BASE_FOLDER); // NOI18N //create a default manifest FileUtil.copyFile(FileUtil.getConfigFile("org-netbeans-modules-j2ee-ejbjarproject/MANIFEST.MF"), confRoot, "MANIFEST"); //NOI18N final AntProjectHelper h = setupProject(projectDir, name, "src", "test", null, null, null, createData.getJavaEEProfile(), serverInstanceID, createData.getLibrariesDefinition(), createData.skipTests()); EditableProperties ep = h.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); ep.put(EjbJarProjectProperties.SOURCE_ROOT, DEFAULT_SRC_FOLDER); //NOI18N ep.setProperty(EjbJarProjectProperties.META_INF, "${"+EjbJarProjectProperties.SOURCE_ROOT+"}/"+DEFAULT_DOC_BASE_FOLDER); //NOI18N ep.setProperty(EjbJarProjectProperties.SRC_DIR, "${"+EjbJarProjectProperties.SOURCE_ROOT+"}/"+DEFAULT_JAVA_FOLDER); //NOI18N ep.setProperty(EjbJarProjectProperties.META_INF_EXCLUDES, "sun-cmp-mappings.xml"); // NOI18N Charset enc = FileEncodingQuery.getDefaultEncoding(); ep.setProperty(EjbJarProjectProperties.SOURCE_ENCODING, enc.name()); h.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep); EjbJarProject p = (EjbJarProject) ProjectManager.getDefault().findProject(h.getProjectDirectory()); ProjectManager.getDefault().saveProject(p); final ReferenceHelper refHelper = p.getReferenceHelper(); try { ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() { public Void run() throws Exception { copyRequiredLibraries(h, refHelper, createData); return null; } }); } catch (MutexException ex) { Exceptions.printStackTrace(ex.getException()); } // create ejb-jar.xml Profile profile = createData.getJavaEEProfile(); if (!Profile.JAVA_EE_5.equals(profile) && !Profile.JAVA_EE_6_FULL.equals(profile) && !Profile.JAVA_EE_6_WEB.equals(profile) && !Profile.JAVA_EE_7_FULL.equals(profile) && !Profile.JAVA_EE_7_WEB.equals(profile)) { String resource = "org-netbeans-modules-j2ee-ejbjarproject/ejb-jar-2.1.xml"; FileObject ddFile = FileUtil.copyFile(FileUtil.getConfigFile(resource), confRoot, "ejb-jar"); //NOI18N EjbJar ejbJar = DDProvider.getDefault().getDDRoot(ddFile); ejbJar.setDisplayName(name); ejbJar.write(ddFile); } if (createData.isCDIEnabled()) { DDHelper.createBeansXml(profile, confRoot); } return h; }
Example 17
Source File: MultiModuleGroupQueryImplTest.java From netbeans with Apache License 2.0 | 4 votes |
@Override protected void setUp() throws Exception { super.setUp(); clearWorkDir(); MockLookup.setInstances(TestProject.createProjectType()); final FileObject wd = FileUtil.toFileObject(FileUtil.normalizeFile(getWorkDir())); final FileObject scratch = TestUtil.makeScratchDir(this); projDir = scratch.createFolder("proj"); //NOI18N final Project prj = TestProject.createProject(projDir, null, null); tp = prj.getLookup().lookup(TestProject.class); helper = tp.getUpdateHelper().getAntProjectHelper(); eval = helper.getStandardPropertyEvaluator(); project = FileOwnerQuery.getOwner(projDir); src1 = projDir.createFolder("src1"); //NOI18N assertNotNull(src1); src2 = projDir.createFolder("src2"); //NOI18N assertNotNull(src2); mod1a = src1.createFolder("lib.common").createFolder("classes"); //NOI18N assertNotNull(mod1a); mod1b = src1.createFolder("lib.util").createFolder("classes"); //NOI18N assertNotNull(mod1b); mod1d = src1.createFolder("lib.event").createFolder("classes"); //NOI18N assertNotNull(mod1d); mod1c = src1.getFileObject("lib.event").createFolder("i386"); //NOI18N assertNotNull(mod1c); mod1e = src1.getFileObject("lib.event").createFolder("xxx"); //NOI18N assertNotNull(mod1e); mod2c = src2.createFolder("lib.discovery").createFolder("classes"); //NOI18N assertNotNull(mod2c); mod2a = src2.getFileObject("lib.discovery").createFolder("amd64"); //NOI18N assertNotNull(mod2a); mod2d = src2.createFolder("lib.event").createFolder("amd64"); //NOI18N assertNotNull(mod2d); assertNotNull(tp); mtu = ModuleTestUtilities.newInstance(tp); assertNotNull(mtu); testRoots = mtu.newSourceRoots(false); src = QuerySupport.createSources(project, helper, eval, testRoots, Roots.nonSourceRoots("dist.dir")); //NOI18N }
Example 18
Source File: SourceUtilsTest.java From netbeans with Apache License 2.0 | 3 votes |
private void prepareTest() throws Exception { File work = getWorkDir(); FileObject workFO = FileUtil.toFileObject(work); assertNotNull(workFO); FileObject sourceRoot = workFO.getFileObject("src"); if (sourceRoot == null) { sourceRoot = workFO.createFolder("src"); } FileObject buildRoot = workFO.createFolder("build"); FileObject cache = workFO.createFolder("cache"); FileObject packageRoot = sourceRoot.getFileObject("sourceutils"); if (packageRoot == null) { packageRoot = sourceRoot.createFolder("sourceutils"); } SourceUtilsTestUtil.prepareTest(sourceRoot, buildRoot, cache); String capitalizedName = "T" + getName().substring(1); TestUtil.copyFiles(FileUtil.toFile(sourceRoot), "sourceutils/" + capitalizedName + ".java"); packageRoot.refresh(); FileObject testSource = packageRoot.getFileObject(capitalizedName + ".java"); assertNotNull(testSource); SourceUtilsTestUtil.compileRecursively(sourceRoot); js = JavaSource.forFileObject(testSource); assertNotNull(js); info = SourceUtilsTestUtil.getCompilationInfo(js, JavaSource.Phase.RESOLVED); assertNotNull(info); }
Example 19
Source File: ElementNodeTest.java From netbeans with Apache License 2.0 | 3 votes |
private void prepareTest(String filename, String code) throws Exception { clearWorkDir(); File work = getWorkDir(); FileObject workFO = FileUtil.toFileObject(work); assertNotNull(workFO); FileObject sourceRoot = workFO.createFolder("src"); FileObject buildRoot = workFO.createFolder("build"); FileObject cache = workFO.createFolder("cache"); FileObject packageRoot = sourceRoot.createFolder("test"); SourceUtilsTestUtil.prepareTest(sourceRoot, buildRoot, cache); FileObject testSource = FileUtil.createData(packageRoot, filename); assertNotNull(testSource); TestUtilities.copyStringToFile(FileUtil.toFile(testSource), code); JavaSource js = JavaSource.forFileObject(testSource); assertNotNull(js); info = SourceUtilsTestUtil.getCompilationInfo(js, JavaSource.Phase.RESOLVED); assertNotNull(info); }
Example 20
Source File: OpenProjectListTest.java From netbeans with Apache License 2.0 | 3 votes |
public void testNotifyDeleted() throws Exception { FileObject workDir = FileUtil.toFileObject (getWorkDir ()); FileObject p1 = workDir.createFolder("p1"); FileObject p1TestProject = p1.createFolder("testproject"); Project prj1 = ProjectManager.getDefault().findProject(p1); assertNotNull("project1 is recognized", prj1); OpenProjectList.getDefault().open(prj1); OpenProjectList.getDefault().close(new Project[] {prj1}, false); p1TestProject.delete(); TestSupport.notifyDeleted(prj1); assertNull("project1 is deleted", ProjectManager.getDefault().findProject(p1)); assertFalse("project1 is not in recent projects list", OpenProjectList.getDefault().getRecentProjects().contains(prj1)); FileObject p2 = workDir.createFolder("p2"); p2.createFolder("testproject"); Project prj2 = ProjectManager.getDefault().findProject(p2); assertNotNull("project2 is recognized", prj2); OpenProjectList.getDefault().open(prj2); OpenProjectList.getDefault().close(new Project[] {prj2}, false); TestSupport.notifyDeleted(prj2); assertFalse("project2 is not in recent projects list", OpenProjectList.getDefault().getRecentProjects().contains(prj2)); }