Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 85761 Details for
Bug 213786
[JUnit] Add context menu action to import junit test results from package explorer
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch to org.eclipse.jdt.junit
213786.patch (text/plain), 6.57 KB, created by
Brock Janiczak
on 2007-12-23 00:52:39 EST
(
hide
)
Description:
Patch to org.eclipse.jdt.junit
Filename:
MIME Type:
Creator:
Brock Janiczak
Created:
2007-12-23 00:52:39 EST
Size:
6.57 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.junit >Index: src/org/eclipse/jdt/internal/junit/model/JUnitModel.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/model/JUnitModel.java,v >retrieving revision 1.12 >diff -u -r1.12 JUnitModel.java >--- src/org/eclipse/jdt/internal/junit/model/JUnitModel.java 29 May 2007 18:36:53 -0000 1.12 >+++ src/org/eclipse/jdt/internal/junit/model/JUnitModel.java 23 Dec 2007 05:51:37 -0000 >@@ -14,6 +14,7 @@ > import java.io.File; > import java.io.FileOutputStream; > import java.io.IOException; >+import java.io.InputStream; > import java.io.OutputStream; > import java.util.ArrayList; > import java.util.HashSet; >@@ -389,6 +390,34 @@ > } > > /** >+ * Imports a test run session from the given input stream. >+ * >+ * @param contents an input stream containing a test run session transcript >+ * @param absoluteFileName absolute location of the file being imported >+ * @return the imported test run session >+ * @throws CoreException if the import failed >+ */ >+ public static TestRunSession importTestRunSession(InputStream contents, String absoluteFileName) throws CoreException { >+ try { >+ SAXParserFactory parserFactory= SAXParserFactory.newInstance(); >+// parserFactory.setValidating(true); // TODO: add DTD and debug flag >+ SAXParser parser= parserFactory.newSAXParser(); >+ TestRunHandler handler= new TestRunHandler(); >+ parser.parse(contents, handler); >+ TestRunSession session= handler.getTestRunSession(); >+ JUnitPlugin.getModel().addTestRunSession(session); >+ return session; >+ } catch (ParserConfigurationException e) { >+ throwImportError(absoluteFileName, e); >+ } catch (SAXException e) { >+ throwImportError(absoluteFileName, e); >+ } catch (IOException e) { >+ throwImportError(absoluteFileName, e); >+ } >+ return null; // does not happen >+ } >+ >+ /** > * Imports a test run session from the given file. > * > * @param file a file containing a test run session transcript >@@ -493,9 +522,13 @@ > } > > private static void throwImportError(File file, Exception e) throws CoreException { >+ throwImportError(file.getAbsolutePath(), e); >+ } >+ >+ private static void throwImportError(String absoluteFileName, Exception e) throws CoreException { > throw new CoreException(new org.eclipse.core.runtime.Status(IStatus.ERROR, > JUnitPlugin.getPluginId(), >- Messages.format(ModelMessages.JUnitModel_could_not_read, file.getAbsolutePath()), >+ Messages.format(ModelMessages.JUnitModel_could_not_read, absoluteFileName), > e)); > } > >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.junit/plugin.xml,v >retrieving revision 1.125 >diff -u -r1.125 plugin.xml >--- plugin.xml 12 Sep 2007 14:10:54 -0000 1.125 >+++ plugin.xml 23 Dec 2007 05:51:36 -0000 >@@ -160,6 +160,22 @@ > id="updateTestSuite"> > </action> > </objectContribution> >+ <objectContribution >+ adaptable="false" >+ id="org.eclipse.jdt.junit.TestRunFile" >+ objectClass="org.eclipse.core.resources.IFile"> >+ <action >+ class="org.eclipse.jdt.internal.junit.ui.ImportTestRunAction" >+ enablesFor="1" >+ id="org.eclipse.jdt.junit.action1" >+ label="Import Test Run"> >+ </action> >+ <visibility> >+ <objectState >+ name="contentTypeId" >+ value="org.eclipse.jdt.junit.testRun"> >+ </objectState></visibility> >+ </objectContribution> > </extension> > <extension > point="org.eclipse.ui.actionSets"> >@@ -487,5 +503,16 @@ > <!-- END : do we need these? --> > </kind> > </extension> >+ <extension >+ point="org.eclipse.core.runtime.contentTypes"> >+ <content-type >+ base-type="org.eclipse.core.runtime.xml" >+ describer="org.eclipse.core.runtime.content.XMLRootElementContentDescriber:testrun" >+ file-extensions="xml" >+ id="org.eclipse.jdt.junit.testRun" >+ name="JUnit Test Run File" >+ priority="normal"> >+ </content-type> >+ </extension> > > </plugin> >Index: src/org/eclipse/jdt/internal/junit/ui/ImportTestRunAction.java >=================================================================== >RCS file: src/org/eclipse/jdt/internal/junit/ui/ImportTestRunAction.java >diff -N src/org/eclipse/jdt/internal/junit/ui/ImportTestRunAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jdt/internal/junit/ui/ImportTestRunAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,66 @@ >+package org.eclipse.jdt.internal.junit.ui; >+ >+import java.io.IOException; >+import java.io.InputStream; >+ >+import org.eclipse.core.runtime.CoreException; >+ >+import org.eclipse.core.resources.IFile; >+ >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.dialogs.ErrorDialog; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.IStructuredSelection; >+ >+import org.eclipse.ui.IObjectActionDelegate; >+import org.eclipse.ui.IWorkbenchPart; >+ >+import org.eclipse.jdt.internal.junit.model.JUnitModel; >+ >+public final class ImportTestRunAction implements IObjectActionDelegate { >+ >+ private IWorkbenchPart fTargetPart; >+ private IFile fSelectedFile; >+ >+ public void setActivePart(IAction action, IWorkbenchPart targetPart) { >+ this.fTargetPart= targetPart; >+ } >+ >+ public void run(IAction action) { >+ if (fSelectedFile == null) { >+ return; >+ } >+ >+ InputStream fileContents = null; >+ try { >+ fileContents = fSelectedFile.getContents(); >+ JUnitModel.importTestRunSession(fileContents, fSelectedFile.getFullPath().toOSString()); >+ } catch (CoreException e) { >+ JUnitPlugin.log(e); >+ ErrorDialog.openError(fTargetPart.getSite().getShell(), JUnitMessages.TestRunnerViewPart_ImportTestRunSessionAction_error_title, e.getStatus().getMessage(), e.getStatus()); >+ } finally { >+ if (fileContents != null) { >+ try { >+ fileContents.close(); >+ } catch (IOException e) { >+ } >+ } >+ } >+ >+ } >+ >+ public void selectionChanged(IAction action, ISelection selection) { >+ fSelectedFile = null; >+ >+ if (selection != null) { >+ if (selection instanceof IStructuredSelection) { >+ Object selectedObject = ((IStructuredSelection)selection).getFirstElement(); >+ >+ if (selectedObject instanceof IFile) { >+ fSelectedFile = (IFile) selectedObject; >+ } >+ } >+ } >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 213786
:
85761
|
109722