com.intellij.testFramework.PsiTestUtil Java Examples
The following examples show how to use
com.intellij.testFramework.PsiTestUtil.
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: CamelLightCodeInsightFixtureTestCaseIT.java From camel-idea-plugin with Apache License 2.0 | 6 votes |
@Override protected void setUp() throws Exception { super.setUp(); if (!ignoreCamelCoreLib) { PsiTestUtil.addLibrary(myFixture.getProjectDisposable(), myFixture.getModule(), "Maven: " + CAMEL_CORE_MAVEN_ARTIFACT, mavenArtifacts[0].getParent(), mavenArtifacts[0].getName()); } ApplicationManager .getApplication() .executeOnPooledThread(() -> ApplicationManager.getApplication().runReadAction(() -> { disposeOnTearDown(ServiceManager.getService(getModule().getProject(), CamelCatalogService.class)); disposeOnTearDown(ServiceManager.getService(getModule().getProject(), CamelService.class)); disposeOnTearDown(ServiceManager.getService(CamelPreferenceService.class)); disposeOnTearDown(ServiceManager.getService(CamelIdeaUtils.class)); disposeOnTearDown(ServiceManager.getService(IdeaUtils.class)); disposeOnTearDown(ServiceManager.getService(JavaMethodUtils.class)); })); ServiceManager.getService(getModule().getProject(), CamelService.class).setCamelPresent(true); }
Example #2
Source File: PantsProjectCacheTest.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
public void testLastOne() { final PantsProjectCache cache = PantsProjectCache.getInstance(myFixture.getProject()); final VirtualFile root = getMainContentRoot(); ApplicationManager.getApplication().runWriteAction(() -> { try { PsiTestUtil.addSourceRoot(getModule(), VfsUtil.createDirectoryIfMissing(root, "bar")); PsiTestUtil.addSourceRoot(getModule(), VfsUtil.createDirectoryIfMissing(root, "baz")); assertTrue(cache.folderContainsSourceRoot(VfsUtil.createDirectoryIfMissing(root, "baz"))); assertFalse(cache.folderContainsSourceRoot(VfsUtil.createDirectoryIfMissing(root, "ba"))); assertFalse(cache.folderContainsSourceRoot(VfsUtil.createDirectoryIfMissing(root, "bat"))); } catch (IOException e) { fail(e.getMessage()); } }); }
Example #3
Source File: PantsProjectCacheTest.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
public void testFirstOne() { final PantsProjectCache cache = PantsProjectCache.getInstance(myFixture.getProject()); final VirtualFile root = getMainContentRoot(); ApplicationManager.getApplication().runWriteAction(() -> { try { PsiTestUtil.addSourceRoot(getModule(), VfsUtil.createDirectoryIfMissing(root, "abc")); PsiTestUtil.addSourceRoot(getModule(), VfsUtil.createDirectoryIfMissing(root, "foo/bar")); PsiTestUtil.addSourceRoot(getModule(), VfsUtil.createDirectoryIfMissing(root, "foo/baz")); assertTrue(cache.folderContainsSourceRoot(VfsUtil.createDirectoryIfMissing(root, "abc"))); assertTrue(cache.folderContainsSourceRoot(VfsUtil.createDirectoryIfMissing(root, "foo"))); } catch (IOException e) { fail(e.getMessage()); } }); }
Example #4
Source File: MavenTestCase.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
protected Module createModule(final String name, final ModuleType type) { try { return WriteCommandAction.writeCommandAction(myProject).compute(() -> { VirtualFile f = createProjectSubFile(name + "/" + name + ".iml"); Module module = ModuleManager.getInstance(myProject).newModule(f.getPath(), type.getId()); PsiTestUtil.addContentRoot(module, f.getParent()); return module; }); } catch (IOException e) { throw new RuntimeException(e); } }
Example #5
Source File: CamelServiceTestIT.java From camel-idea-plugin with Apache License 2.0 | 5 votes |
public void testScanForCamelProjectShouldSupportDependenciesWithoutVersion() throws Throwable { CamelService service = ServiceManager.getService(getModule().getProject(), CamelService.class); assertNoException(ArrayIndexOutOfBoundsExceptionCase.check( () -> PsiTestUtil.addProjectLibrary(getModule(), "gradle::mylib:")) ); assertTrue(service.isCamelPresent()); assertNoException(ArrayIndexOutOfBoundsExceptionCase.check( () -> PsiTestUtil.addProjectLibrary(getModule(), "gradle:mygroup:myartifactId:")) ); assertNoException(ArrayIndexOutOfBoundsExceptionCase.check( () -> PsiTestUtil.addProjectLibrary(getModule(), "mygroup:myartifactId:")) ); }
Example #6
Source File: IdeaUtilsSkipEndpointValidationTestIT.java From camel-idea-plugin with Apache License 2.0 | 5 votes |
@Override protected void setUp() throws Exception { super.setUp(); ServiceManager.getService(myFixture.getProject(), CamelService.class).setCamelPresent(true); Stream.of( Maven.resolver().resolve(ACTIVEMQ_ARTIFACT, QPID_ARTIFACT) .withTransitivity().asFile() ).forEach(f -> PsiTestUtil.addLibrary(myFixture.getProjectDisposable(), myFixture.getModule(), f.getName(), f.getParentFile().getAbsolutePath(), f.getName())); }
Example #7
Source File: RPiJavaModuleBuilder.java From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 | 5 votes |
private void addJarFiles(Module module) { if (jarsToAdd == null) { return; } for (final File fileEntry : jarsToAdd) { if (!fileEntry.isDirectory() && Files.getFileExtension(fileEntry.getName()).contains("jar")) { PsiTestUtil.addLibrary(module, fileEntry.getName(), fileEntry.getParentFile().getPath(), fileEntry.getName()); } } }
Example #8
Source File: ArtifactsTestCase.java From consulo with Apache License 2.0 | 5 votes |
protected Module addModule(final String moduleName, final @Nullable VirtualFile sourceRoot) { return WriteAction.compute(() -> { final Module module = createModule(moduleName); if (sourceRoot != null) { PsiTestUtil.addSourceContentToRoots(module, sourceRoot); } // ModuleRootModificationUtil.setModuleSdk(module, getTestProjectJdk()); return module; }); }
Example #9
Source File: JavaCamelBeanReferenceSmartCompletionTestIT.java From camel-idea-plugin with Apache License 2.0 | 4 votes |
@Override protected void setUp() throws Exception { super.setUp(); PsiTestUtil.addLibrary(myFixture.getProjectDisposable(), getModule(), "Maven: " + SPRING_CONTEXT_MAVEN_ARTIFACT, springMavenArtifacts[0].getParent(), springMavenArtifacts[0].getName()); }
Example #10
Source File: CamelInspectJavaSimpleTestIT.java From camel-idea-plugin with Apache License 2.0 | 4 votes |
@Override protected void setUp() throws Exception { super.setUp(); File[] mavenArtifacts = Maven.resolver().resolve(CAMEL_CORE_MAVEN_ARTIFACT).withoutTransitivity().asFile(); PsiTestUtil.addLibrary(myFixture.getProjectDisposable(), myFixture.getModule(), "Maven: " + CAMEL_CORE_MAVEN_ARTIFACT, mavenArtifacts[0].getParent(), mavenArtifacts[0].getName()); }
Example #11
Source File: CamelInspectXmlSimpleTestIT.java From camel-idea-plugin with Apache License 2.0 | 4 votes |
@Override protected void setUp() throws Exception { super.setUp(); File[] mavenArtifacts = Maven.resolver().resolve(CAMEL_CORE_MAVEN_ARTIFACT).withoutTransitivity().asFile(); PsiTestUtil.addLibrary(myFixture.getProjectDisposable(), myFixture.getModule(), "Maven: " + CAMEL_CORE_MAVEN_ARTIFACT, mavenArtifacts[0].getParent(), mavenArtifacts[0].getName()); }
Example #12
Source File: CamelInspectJavaJSonPathTestIT.java From camel-idea-plugin with Apache License 2.0 | 4 votes |
@Override protected void setUp() throws Exception { super.setUp(); File[] mavenArtifacts = Maven.resolver().resolve(CAMEL_JSONPATH_MAVEN_ARTIFACT).withTransitivity().asFile(); PsiTestUtil.addLibrary(myFixture.getProjectDisposable(), myFixture.getModule(), "Maven: " + CAMEL_JSONPATH_MAVEN_ARTIFACT, mavenArtifacts[0].getParent(), mavenArtifacts[0].getName()); }
Example #13
Source File: CamelBeanMethodReferenceTest.java From camel-idea-plugin with Apache License 2.0 | 4 votes |
@Override protected void setUp() throws Exception { super.setUp(); PsiTestUtil.addLibrary(myFixture.getProjectDisposable(), myFixture.getModule(), "Maven: " + SPRING_CONTEXT_MAVEN_ARTIFACT, springMavenArtifacts[0].getParent(), springMavenArtifacts[0].getName()); }
Example #14
Source File: LombokTestUtil.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 4 votes |
private static void loadLibrary(@NotNull Disposable projectDisposable, @NotNull Module module, String libraryName, String libraryJarName) { final String lombokLibPath = PathUtil.toSystemIndependentName(new File(THIRD_PARTY_LIB_DIRECTORY).getAbsolutePath()); VfsRootAccess.allowRootAccess(projectDisposable, lombokLibPath); PsiTestUtil.addLibrary(projectDisposable, module, libraryName, lombokLibPath, libraryJarName); }
Example #15
Source File: IntegrationTestCase.java From consulo with Apache License 2.0 | 4 votes |
protected void setUpInWriteAction() throws Exception { myRoot = LocalFileSystem.getInstance().findFileByIoFile(createTempDirectory()); PsiTestUtil.addContentRoot(myModule, myRoot); }