Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristof Marti2004-11-26 17:14:37 +0000
committerChristof Marti2004-11-26 17:14:37 +0000
commitd1f7b2f5034efcd5033f8998fe0c4200629494f7 (patch)
tree8558e575513e9b28cee220a4f4036188f2cafbda
parentf278b5ee132a16f753a95bf715a641f12dcee038 (diff)
downloadeclipse.platform.text-d1f7b2f5034efcd5033f8998fe0c4200629494f7.tar.gz
eclipse.platform.text-d1f7b2f5034efcd5033f8998fe0c4200629494f7.tar.xz
eclipse.platform.text-d1f7b2f5034efcd5033f8998fe0c4200629494f7.zip
update
-rw-r--r--org.eclipse.core.filebuffers.tests/build.properties8
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/ContainerGenerator.java140
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileTool.java5
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FilebuffersTestPlugin.java70
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/ResourceHelper.java3
-rw-r--r--org.eclipse.jface.text.tests/build.properties6
-rw-r--r--org.eclipse.jface.text.tests/test.xml19
-rw-r--r--org.eclipse.text.tests/.classpath2
-rw-r--r--org.eclipse.text.tests/build.properties4
-rw-r--r--org.eclipse.text.tests/plugin.xml2
-rw-r--r--org.eclipse.text.tests/src/org/eclipse/text/tests/Accessor.java31
11 files changed, 260 insertions, 30 deletions
diff --git a/org.eclipse.core.filebuffers.tests/build.properties b/org.eclipse.core.filebuffers.tests/build.properties
index 065209c8a..336cbc08f 100644
--- a/org.eclipse.core.filebuffers.tests/build.properties
+++ b/org.eclipse.core.filebuffers.tests/build.properties
@@ -9,7 +9,11 @@
# IBM Corporation - initial API and implementation
###############################################################################
bin.includes = plugin.xml,\
+ plugin.properties,\
test.xml,\
about.html,\
- *.jar,\
-source.javauitests.jar = src/
+ *.jar
+
+src.includes = about.html
+
+source.filebufferstests.jar = src/
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/ContainerGenerator.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/ContainerGenerator.java
new file mode 100644
index 000000000..1f5ac589b
--- /dev/null
+++ b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/ContainerGenerator.java
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.core.filebuffers.tests;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+
+public class ContainerGenerator {
+
+ private IPath fContainerFullPath;
+ private IContainer fContainer;
+ private IWorkspace fWorkspace;
+
+ public ContainerGenerator(IWorkspace workspace, IPath containerPath) {
+ fWorkspace= workspace;
+ fContainerFullPath = containerPath;
+ }
+
+ private IFolder createFolder(IFolder folderHandle, IProgressMonitor monitor) throws CoreException {
+ folderHandle.create(false, true, monitor);
+ if (monitor.isCanceled())
+ throw new OperationCanceledException();
+ return folderHandle;
+ }
+
+ private IFolder createFolderHandle(IContainer container, String folderName) {
+ return container.getFolder(new Path(folderName));
+ }
+
+ private IProject createProject(IProject projectHandle, IProgressMonitor monitor) throws CoreException {
+ monitor.beginTask("", 100);//$NON-NLS-1$
+ try {
+
+ IProgressMonitor subMonitor= new SubProgressMonitor(monitor, 50);
+ projectHandle.create(subMonitor);
+ subMonitor.done();
+
+ if (monitor.isCanceled())
+ throw new OperationCanceledException();
+
+ subMonitor= new SubProgressMonitor(monitor, 50);
+ projectHandle.open(subMonitor);
+ subMonitor.done();
+
+ if (monitor.isCanceled())
+ throw new OperationCanceledException();
+
+ } finally {
+ monitor.done();
+ }
+
+ return projectHandle;
+ }
+
+ private IProject createProjectHandle(IWorkspaceRoot root, String projectName) {
+ return root.getProject(projectName);
+ }
+
+ public IContainer generateContainer(IProgressMonitor progressMonitor) throws CoreException {
+ IWorkspaceRunnable runnable= new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ monitor.beginTask("ContainerGenerator.task.creatingContainer", fContainerFullPath.segmentCount()); //$NON-NLS-1$
+ if (fContainer != null)
+ return;
+
+ // Does the container exist already?
+ IWorkspaceRoot root= fWorkspace.getRoot();
+ IResource found= root.findMember(fContainerFullPath);
+ if (found instanceof IContainer) {
+ fContainer= (IContainer) found;
+ return;
+ } else if (found != null) {
+ // fContainerFullPath specifies a file as directory
+ throw new CoreException(new Status(IStatus.ERROR, FilebuffersTestPlugin.PLUGIN_ID, IStatus.OK, "ContainerGenerator.destinationMustBeAContainer", null)); //$NON-NLS-1$
+ }
+
+ // Create the container for the given path
+ fContainer= root;
+ for (int i = 0; i < fContainerFullPath.segmentCount(); i++) {
+ String currentSegment = fContainerFullPath.segment(i);
+ IResource resource = fContainer.findMember(currentSegment);
+ if (resource != null) {
+ if (resource instanceof IContainer) {
+ fContainer= (IContainer) resource;
+ monitor.worked(1);
+ } else {
+ // fContainerFullPath specifies a file as directory
+ throw new CoreException(new Status(IStatus.ERROR, FilebuffersTestPlugin.PLUGIN_ID, IStatus.OK, "ContainerGenerator.destinationMustBeAContainer", null)); //$NON-NLS-1$
+ }
+ }
+ else {
+ if (i == 0) {
+ IProject projectHandle= createProjectHandle(root, currentSegment);
+ IProgressMonitor subMonitor= new SubProgressMonitor(monitor, 1);
+ fContainer= createProject(projectHandle, subMonitor);
+ subMonitor.done();
+ }
+ else {
+ IFolder folderHandle= createFolderHandle(fContainer, currentSegment);
+ IProgressMonitor subMonitor= new SubProgressMonitor(monitor, 1);
+ fContainer= createFolder(folderHandle, subMonitor);
+ subMonitor.done();
+ }
+ }
+ }
+ }
+ };
+
+ // Get scheduling rule
+ IWorkspaceRoot root= fWorkspace.getRoot();
+ IPath existingParentPath= fContainerFullPath;
+ while (!root.exists(existingParentPath))
+ existingParentPath= existingParentPath.removeLastSegments(1);
+
+ IResource schedulingRule= root.findMember(existingParentPath);
+ fWorkspace.run(runnable, progressMonitor);
+ return fContainer;
+ }
+}
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileTool.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileTool.java
index cad283faf..3def11627 100644
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileTool.java
+++ b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileTool.java
@@ -184,7 +184,10 @@ public class FileTool {
public static File getFileInPlugin(Plugin plugin, IPath path) {
try {
- URL installURL= plugin.getBundle().getEntry(path.toString());
+ String sPath= path.toString();
+ if (sPath.startsWith("/"))
+ sPath= sPath.substring(1);
+ URL installURL= new URL(plugin.getDescriptor().getInstallURL(), sPath);
URL localURL= Platform.asLocalURL(installURL);
return new File(localURL.getFile());
} catch (IOException e) {
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FilebuffersTestPlugin.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FilebuffersTestPlugin.java
new file mode 100644
index 000000000..4d0e7cd6c
--- /dev/null
+++ b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FilebuffersTestPlugin.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.core.filebuffers.tests;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IPluginDescriptor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+
+/**
+ * The main plug-in class to be used in the desktop.
+ *
+ * @since 3.0
+ */
+public class FilebuffersTestPlugin extends Plugin {
+
+ public final static String PLUGIN_ID= "org.eclipse.core.filebuffers.tests"; //$NON-NLS-1$
+
+ //The shared instance.
+ private static FilebuffersTestPlugin fPlugin;
+
+ /**
+ * The constructor.
+ */
+ public FilebuffersTestPlugin(IPluginDescriptor descriptor) {
+ super(descriptor);
+ fPlugin = this;
+ }
+
+ /**
+ * Returns the shared instance.
+ */
+ public static FilebuffersTestPlugin getDefault() {
+ return fPlugin;
+ }
+
+ /**
+ * Returns the workspace instance.
+ */
+ public static IWorkspace getWorkspace() {
+ return ResourcesPlugin.getWorkspace();
+ }
+
+ public static File getFileInPlugin(Plugin plugin, IPath path) {
+ try {
+ String sPath= path.toString();
+ if (sPath.startsWith("/"))
+ sPath= sPath.substring(1);
+ URL installURL= new URL(plugin.getDescriptor().getInstallURL(), sPath);
+ URL localURL= Platform.asLocalURL(installURL);
+ return new File(localURL.getFile());
+ } catch (IOException e) {
+ return null;
+ }
+ }
+}
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/ResourceHelper.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/ResourceHelper.java
index 1b76b5833..f16537078 100644
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/ResourceHelper.java
+++ b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/ResourceHelper.java
@@ -14,7 +14,6 @@ import java.io.File;
import java.io.InputStream;
import java.io.StringBufferInputStream;
-import org.eclipse.core.internal.filebuffers.ContainerGenerator;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
@@ -73,7 +72,7 @@ public class ResourceHelper {
i= MAX_RETRY;
} catch (CoreException x) {
if (i == MAX_RETRY - 1) {
- FileBuffersTestPlugin.getDefault().getLog().log(x.getStatus());
+ FilebuffersTestPlugin.getDefault().getLog().log(x.getStatus());
// throw x;
}
try {
diff --git a/org.eclipse.jface.text.tests/build.properties b/org.eclipse.jface.text.tests/build.properties
index 1e3de6203..045afe6d0 100644
--- a/org.eclipse.jface.text.tests/build.properties
+++ b/org.eclipse.jface.text.tests/build.properties
@@ -9,7 +9,11 @@
# IBM Corporation - initial API and implementation
###############################################################################
bin.includes = plugin.xml,\
+ plugin.properties,\
test.xml,\
about.html,\
- *.jar,\
+ *.jar
+
+src.includes = about.html
+
source.jfacetexttests.jar = src/
diff --git a/org.eclipse.jface.text.tests/test.xml b/org.eclipse.jface.text.tests/test.xml
index b318da2fc..97bf3ba0a 100644
--- a/org.eclipse.jface.text.tests/test.xml
+++ b/org.eclipse.jface.text.tests/test.xml
@@ -20,19 +20,6 @@
</delete>
</target>
- <!-- This target defines the tests that need to be run. -->
- <target name="suite">
- <property name="jface-text-folder"
- value="${eclipse-home}/jface_text_folder"/>
- <delete dir="${jface-text-folder}" quiet="true"/>
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${jface-text-folder}"/>
- <property name="plugin-name" value="${plugin-name}"/>
- <property name="classname"
- value="org.eclipse.jface.text.tests.JFaceTextTestSuite"/>
- </ant>
- </target>
-
<!-- This target holds code to cleanup the testing environment after -->
<!-- after all of the tests have been run. You can use this target to -->
<!-- delete temporary files that have been created. -->
@@ -41,11 +28,7 @@
<!-- This target runs the test suite. Any actions that need to happen -->
<!-- after all the tests have been run should go here. -->
- <target name="run" depends="init,suite,cleanup">
- <ant target="collect" antfile="${library-file}" dir="${eclipse-home}">
- <property name="includes" value="org*.xml"/>
- <property name="output-file" value="${plugin-name}.xml"/>
- </ant>
+ <target name="run">
</target>
<!-- This target runs the performance test suites. -->
diff --git a/org.eclipse.text.tests/.classpath b/org.eclipse.text.tests/.classpath
index 21d37ba83..065ac06e1 100644
--- a/org.eclipse.text.tests/.classpath
+++ b/org.eclipse.text.tests/.classpath
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="src" path="/org.junit"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/org.eclipse.text.tests/build.properties b/org.eclipse.text.tests/build.properties
index 7cef8ebf6..f255a764b 100644
--- a/org.eclipse.text.tests/build.properties
+++ b/org.eclipse.text.tests/build.properties
@@ -9,7 +9,11 @@
# IBM Corporation - initial API and implementation
###############################################################################
bin.includes = plugin.xml,\
+ plugin.properties,\
test.xml,\
about.html,\
*.jar
+
+src.includes = about.html
+
source.texttests.jar = src/
diff --git a/org.eclipse.text.tests/plugin.xml b/org.eclipse.text.tests/plugin.xml
index 45f9c78a6..8a241d95f 100644
--- a/org.eclipse.text.tests/plugin.xml
+++ b/org.eclipse.text.tests/plugin.xml
@@ -15,5 +15,5 @@
<requires>
<import plugin="org.junit"/>
</requires>
-
+
</plugin>
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/Accessor.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/Accessor.java
index 3ed77877a..784b8c209 100644
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/Accessor.java
+++ b/org.eclipse.text.tests/src/org/eclipse/text/tests/Accessor.java
@@ -47,16 +47,39 @@ public class Accessor extends Assert {
}
/**
+ * Creates an accessor for the given <code>instance</code> and
+ * <code>class</code>. Only non-inherited members that particular
+ * <code>class</code> can be accessed.
+ *
+ * @param instance the instance
+ * @param className the name of the class
+ * @param classLoader the class loader to use i.e. <code>getClass().getClassLoader()</code>
+ */
+ public Accessor(Object instance, String className, ClassLoader classLoader) {
+ assertNotNull(instance);
+ assertNotNull(className);
+ assertNotNull(classLoader);
+ fInstance= instance;
+ try {
+ fClass= Class.forName(className, true, classLoader);
+ } catch (ClassNotFoundException e) {
+ fail();
+ } catch (ExceptionInInitializerError e) {
+ fail();
+ }
+ }
+
+ /**
* Creates an accessor for the given class.
* <p>
* In order to get the type information from the given
- * arguments they must all be instanceof Object. Use
+ * arguments they must all be instanc eof Object. Use
* {@link #Accessor(String, ClassLoader, Class[], Object[])} if this
* is not the case.</p>
*
* @param className the name of the class
* @param classLoader the class loader to use i.e. <code>getClass().getClassLoader()</code>
- * @param constructorArgs the constructor arguments which must all be instanceof Object
+ * @param constructorArgs the constructor arguments which must all be instance of Object
*/
public Accessor(String className, ClassLoader classLoader, Object[] constructorArgs) {
this(className, classLoader, getTypes(constructorArgs), constructorArgs);
@@ -105,12 +128,12 @@ public class Accessor extends Assert {
* Invokes the method with the given method name and arguments.
* <p>
* In order to get the type information from the given
- * arguments all those arguments must be instanceof Object. Use
+ * arguments all those arguments must be instance of Object. Use
* {@link #invoke(String, Class[], Object[])} if this
* is not the case.</p>
*
* @param methodName the method name
- * @param arguments the method arguments which must all be instanceof Object
+ * @param arguments the method arguments which must all be instance of Object
* @return the method return value
*/
public Object invoke(String methodName, Object[] arguments) {

Back to the top