Java Code Examples for org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil#addJarToClasspath()
The following examples show how to use
org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil#addJarToClasspath() .
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: Storage2UriMapperJavaImplTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testOnCloseOpenRemoveProject() { try { Assert.assertEquals(0, this.getCachedPackageFragmentRootData().size()); final IJavaProject project = JavaProjectSetupUtil.createJavaProject("testProject"); final IJavaProject project2 = JavaProjectSetupUtil.createJavaProject("testProject2"); final int sizeBefore = this.getCachedPackageFragmentRootData().size(); final IFile file = this.createJar(project); JavaProjectSetupUtil.addJarToClasspath(project, file); JavaProjectSetupUtil.addJarToClasspath(project2, file); this.assertBothProjects(sizeBefore); project2.getProject().close(IResourcesSetupUtil.monitor()); this.assertFirstProject(sizeBefore); project.getProject().close(IResourcesSetupUtil.monitor()); this.assertNonProjects(); project.getProject().open(IResourcesSetupUtil.monitor()); this.assertFirstProject(sizeBefore); project2.getProject().open(IResourcesSetupUtil.monitor()); this.assertBothProjects(sizeBefore); project.getProject().delete(true, IResourcesSetupUtil.monitor()); project2.getProject().delete(true, IResourcesSetupUtil.monitor()); this.assertNonProjects(); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example 2
Source File: Storage2UriMapperJavaImplTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testOnRemoveTwoProjects() { try { Assert.assertEquals(0, this.getCachedPackageFragmentRootData().size()); final IJavaProject project = JavaProjectSetupUtil.createJavaProject("testProject"); final IJavaProject project2 = JavaProjectSetupUtil.createJavaProject("testProject2"); final int sizeBefore = this.getCachedPackageFragmentRootData().size(); final IFile file = this.createJar(project); JavaProjectSetupUtil.addJarToClasspath(project, file); JavaProjectSetupUtil.addJarToClasspath(project2, file); this.assertBothProjects(sizeBefore); final WorkspaceModifyOperation op = new WorkspaceModifyOperation() { @Override protected void execute(final IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { project.getProject().delete(true, monitor); project2.getProject().delete(true, monitor); } }; op.run(IResourcesSetupUtil.monitor()); this.assertNonProjects(); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example 3
Source File: ActiveAnnotationsInSameProjectTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testActiveAnnotationInSameProjectInJar() { try { final IJavaProject project = JavaCore.create( WorkbenchTestHelper.createPluginProject(WorkbenchTestHelper.TESTPROJECT_NAME, "com.google.inject", "org.eclipse.xtend.lib", "org.eclipse.xtext.xbase.lib")); final IFile jarFile = this.copyFile(project, "Bug414992.jar", "Bug414992.jar"); JavaProjectSetupUtil.addJarToClasspath(project, jarFile); StringConcatenation _builder = new StringConcatenation(); _builder.append("package mypack"); _builder.newLine(); _builder.newLine(); _builder.append("import myannotation.Bug414992"); _builder.newLine(); _builder.newLine(); _builder.append("@Bug414992 class Client {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this.workbenchTestHelper.createFile("mypack/Client.xtend", _builder.toString()); IResourcesSetupUtil.waitForBuild(); this.assertNoErrorsInWorkspace(); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example 4
Source File: WorkspaceClasspathUriResolverTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void testClasspathUriForFileInJarInWorkspace() throws Exception { _javaProject = JavaProjectSetupUtil.createJavaProject(TEST_PROJECT_NAME); _project = _javaProject.getProject(); IFile jarFile = PluginUtil.copyFileToWorkspace(TestsActivator.getInstance(), "/testfiles/" + JAR_FILE, _project, "/" + JAR_FILE); JavaProjectSetupUtil.addJarToClasspath(_javaProject, jarFile); URI classpathUri = URI.createURI("classpath:/model/" + MODEL_FILE); String expectedUri = "archive:platform:/resource/" + TEST_PROJECT_NAME + "/" + JAR_FILE + "!/model/" + MODEL_FILE; URI normalizedUri = _resolver.resolve(_project, classpathUri); assertResourceLoadable(classpathUri, normalizedUri, expectedUri); }
Example 5
Source File: WorkspaceClasspathUriResolverTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void testClasspathUriForFileInJarInWorkspaceWithFragment() throws Exception { _javaProject = JavaProjectSetupUtil.createJavaProject(TEST_PROJECT_NAME); _project = _javaProject.getProject(); IFile jarFile = PluginUtil.copyFileToWorkspace(TestsActivator.getInstance(), "/testfiles/" + JAR_FILE, _project, "/" + JAR_FILE); JavaProjectSetupUtil.addJarToClasspath(_javaProject, jarFile); URI classpathUri = URI.createURI("classpath:/model/" + MODEL_FILE + "#/"); String expectedUri = "archive:platform:/resource/" + TEST_PROJECT_NAME + "/" + JAR_FILE + "!/model/" + MODEL_FILE + "#/"; URI normalizedUri = _resolver.resolve(_project, classpathUri); assertResourceLoadable(classpathUri, normalizedUri, expectedUri); }
Example 6
Source File: JdtClasspathUriResolverTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void testClasspathUriForFileInJarInWorkspace() throws Exception { _javaProject = JavaProjectSetupUtil.createJavaProject(TEST_PROJECT_NAME); _project = _javaProject.getProject(); IFile jarFile = PluginUtil.copyFileToWorkspace(TestsActivator.getInstance(), "/testfiles/" + JAR_FILE, _project, "/" + JAR_FILE); JavaProjectSetupUtil.addJarToClasspath(_javaProject, jarFile); URI classpathUri = URI.createURI("classpath:/model/" + MODEL_FILE); String expectedUri = "archive:platform:/resource/" + TEST_PROJECT_NAME + "/" + JAR_FILE + "!/model/" + MODEL_FILE; URI normalizedUri = _resolver.resolve(_javaProject, classpathUri); assertResourceLoadable(classpathUri, normalizedUri, expectedUri); }
Example 7
Source File: JdtClasspathUriResolverTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void testClasspathUriForFileInJarInWorkspaceWithFragment() throws Exception { _javaProject = JavaProjectSetupUtil.createJavaProject(TEST_PROJECT_NAME); _project = _javaProject.getProject(); IFile jarFile = PluginUtil.copyFileToWorkspace(TestsActivator.getInstance(), "/testfiles/" + JAR_FILE, _project, "/" + JAR_FILE); JavaProjectSetupUtil.addJarToClasspath(_javaProject, jarFile); URI classpathUri = URI.createURI("classpath:/model/" + MODEL_FILE + "#/"); String expectedUri = "archive:platform:/resource/" + TEST_PROJECT_NAME + "/" + JAR_FILE + "!/model/" + MODEL_FILE + "#/"; URI normalizedUri = _resolver.resolve(_javaProject, classpathUri); assertResourceLoadable(classpathUri, normalizedUri, expectedUri); }
Example 8
Source File: JdtClasspathUriResolverTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void testClasspathUriForFileInRootInJarInWorkspaceWithFragment() throws Exception { _javaProject = JavaProjectSetupUtil.createJavaProject(TEST_PROJECT_NAME); _project = _javaProject.getProject(); IFile jarFile = PluginUtil.copyFileToWorkspace(TestsActivator.getInstance(), "/testfiles/" + JAR_FILE2, _project, "/" + JAR_FILE2); JavaProjectSetupUtil.addJarToClasspath(_javaProject, jarFile); URI classpathUri = URI.createURI("classpath:/" + MODEL_FILE + "#/"); String expectedUri = "archive:platform:/resource/" + TEST_PROJECT_NAME + "/" + JAR_FILE2 + "!/" + MODEL_FILE + "#/"; URI normalizedUri = _resolver.resolve(_javaProject, classpathUri); assertResourceLoadable(classpathUri, normalizedUri, expectedUri); }
Example 9
Source File: MockJavaProjectProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public static void setUp() throws Exception { if(javaProject != null) return; TargetPlatformUtil.setTargetPlatform(MockJavaProjectProvider.class); javaProject = createJavaProject("projectWithoutSources", new String[] { JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature" } ); String path = "/org/eclipse/xtext/common/types/testSetups"; String jarFileName = "/testData.jar"; IFile jarFile = PluginUtil.copyFileToWorkspace(TestsActivator.getInstance(), path + jarFileName, javaProject.getProject(), jarFileName); JavaProjectSetupUtil.addJarToClasspath(javaProject, jarFile); javaProjectWithSources = createJavaProject("projectWithSources", new String[] { JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature" } ); IFolder sourceFolder = JavaProjectSetupUtil.addSourceFolder(javaProjectWithSources, "src"); List<String> filesToCopy = readResource(path + "/files.list"); IFolder srcFolder = sourceFolder.getFolder(new Path(path)); createFolderRecursively(srcFolder); for(String fileToCopy: filesToCopy) { List<String> content = readResource(path + "/" + fileToCopy); String contentAsString = Strings.concat("\n", content); createFile(fileToCopy.substring(0, fileToCopy.length() - ".txt".length()), srcFolder, contentAsString); } createFile("ClassWithDefaultPackage.java", sourceFolder, "public class ClassWithDefaultPackage {}"); PreferenceConstants.getPreferenceStore().putValue(PreferenceConstants.TYPEFILTER_ENABLED, "*.javafx.*;"); IResourcesSetupUtil.waitForBuild(); }
Example 10
Source File: WorkspaceScenariosTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected IClasspathEntry addJarToProject(final IProject project, final byte[] jarData) { try { IClasspathEntry _xblockexpression = null; { final IFile jarFile = project.getFile("mydependency.jar"); ByteArrayInputStream _byteArrayInputStream = new ByteArrayInputStream(jarData); jarFile.create(_byteArrayInputStream, true, null); _xblockexpression = JavaProjectSetupUtil.addJarToClasspath(JavaCore.create(project), jarFile); } return _xblockexpression; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example 11
Source File: XbaseEditorOpenClassFileTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected IClasspathEntry addJarToProject(final IProject project, final byte[] jarData) { try { IClasspathEntry _xblockexpression = null; { final IFile jarFile = project.getFile("mydependency.jar"); ByteArrayInputStream _byteArrayInputStream = new ByteArrayInputStream(jarData); jarFile.create(_byteArrayInputStream, true, null); _xblockexpression = JavaProjectSetupUtil.addJarToClasspath(JavaCore.create(project), jarFile); } return _xblockexpression; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }