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 46929 Details for
Bug 143567
support automatic duplicate detection before submitting reports
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]
Improves stack trace identification, adds test case
duplicate-detection-fix-stack-identify.txt (text/plain), 7.55 KB, created by
Jeff Pound
on 2006-07-28 00:10:37 EDT
(
hide
)
Description:
Improves stack trace identification, adds test case
Filename:
MIME Type:
Creator:
Jeff Pound
Created:
2006-07-28 00:10:37 EDT
Size:
7.55 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylar.bugzilla.tests >Index: src/org/eclipse/mylar/bugzilla/tests/AllBugzillaTests.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.tests/src/org/eclipse/mylar/bugzilla/tests/AllBugzillaTests.java,v >retrieving revision 1.22 >diff -u -r1.22 AllBugzillaTests.java >--- src/org/eclipse/mylar/bugzilla/tests/AllBugzillaTests.java 25 Jul 2006 02:04:03 -0000 1.22 >+++ src/org/eclipse/mylar/bugzilla/tests/AllBugzillaTests.java 28 Jul 2006 04:09:24 -0000 >@@ -51,6 +51,7 @@ > // TODO: enable > // suite.addTest(new TestSuite(BugzillaParserTest.class)); > suite.addTestSuite(BugzillaSearchDialogTest.class); >+ suite.addTestSuite(DuplicateDetetionTest.class); > // $JUnit-END$ > return suite; > } >Index: src/org/eclipse/mylar/bugzilla/tests/DuplicateDetetionTest.java >=================================================================== >RCS file: src/org/eclipse/mylar/bugzilla/tests/DuplicateDetetionTest.java >diff -N src/org/eclipse/mylar/bugzilla/tests/DuplicateDetetionTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/bugzilla/tests/DuplicateDetetionTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,74 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.bugzilla.tests; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin; >+import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; >+import org.eclipse.mylar.internal.bugzilla.core.NewBugzillaReport; >+import org.eclipse.mylar.internal.bugzilla.ui.BugzillaUiPlugin; >+import org.eclipse.mylar.internal.bugzilla.ui.editor.NewBugEditor; >+import org.eclipse.mylar.internal.bugzilla.ui.editor.NewBugEditorInput; >+import org.eclipse.mylar.internal.tasks.ui.TaskUiUtil; >+import org.eclipse.mylar.tasks.core.TaskRepository; >+import org.eclipse.mylar.tasks.ui.TasksUiPlugin; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.PlatformUI; >+ >+public class DuplicateDetetionTest extends TestCase { >+ >+ private TaskRepository repository; >+ >+ @Override >+ protected void setUp() throws Exception { >+ super.setUp(); >+ repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL); >+ >+ } >+ >+ public void testDuplicateDetection() throws Exception { >+ >+ String stackTrace = "java.lang.NullPointerException\nat jeff.testing.stack.trace.functionality(jeff.java:481)"; >+ >+ NewBugzillaReport model = new NewBugzillaReport(repository.getUrl(), TasksUiPlugin.getDefault() >+ .getOfflineReportsFile().getNextOfflineBugId()); >+ model.setNewComment(stackTrace); >+ model.setHasLocalChanges(true); >+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); >+ NewBugEditorInput input = new NewBugEditorInput(repository, model); >+ TaskUiUtil.openEditor(input, BugzillaUiPlugin.NEW_BUG_EDITOR_ID, page); >+ >+ NewBugEditor editor = (NewBugEditor) page.getActiveEditor(); >+ assertTrue(editor.searchForDuplicates()); >+ >+ editor.changeDirtyStatus(false); >+ editor.close(); >+ } >+ >+ public void testNoStackTrace() throws Exception { >+ String fakeStackTrace = "this is not really a stacktrace"; >+ NewBugzillaReport model = new NewBugzillaReport(repository.getUrl(), TasksUiPlugin.getDefault() >+ .getOfflineReportsFile().getNextOfflineBugId()); >+ model.setNewComment(fakeStackTrace); >+ model.setHasLocalChanges(true); >+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); >+ NewBugEditorInput input = new NewBugEditorInput(repository, model); >+ TaskUiUtil.openEditor(input, BugzillaUiPlugin.NEW_BUG_EDITOR_ID, page); >+ >+ NewBugEditor editor = (NewBugEditor) page.getActiveEditor(); >+ assertNull(editor.getStackTraceFromDescription()); >+ >+ editor.changeDirtyStatus(false); >+ editor.close(); >+ } >+} >#P org.eclipse.mylar.bugzilla.ui >Index: src/org/eclipse/mylar/internal/bugzilla/ui/editor/NewBugEditor.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.ui/src/org/eclipse/mylar/internal/bugzilla/ui/editor/NewBugEditor.java,v >retrieving revision 1.38 >diff -u -r1.38 NewBugEditor.java >--- src/org/eclipse/mylar/internal/bugzilla/ui/editor/NewBugEditor.java 27 Jul 2006 21:39:52 -0000 1.38 >+++ src/org/eclipse/mylar/internal/bugzilla/ui/editor/NewBugEditor.java 28 Jul 2006 04:09:26 -0000 >@@ -15,6 +15,7 @@ > import java.net.URLEncoder; > import java.util.Calendar; > import java.util.GregorianCalendar; >+import java.util.StringTokenizer; > > import org.eclipse.core.runtime.Status; > import org.eclipse.core.runtime.jobs.IJobChangeEvent; >@@ -186,18 +187,18 @@ > return taskData.getLabel(); > } > >- protected void searchForDuplicates() { >+ public boolean searchForDuplicates() { > > String stackTrace = getStackTraceFromDescription(); > if (stackTrace == null) { > MessageDialog.openWarning(null, "No Stack Trace Found", NO_STACK_MESSAGE); >- return; >+ return false; > } > > String queryUrl = ""; > try { > queryUrl = repository.getUrl() + "/buglist.cgi?long_desc_type=allwordssubstr&long_desc=" >- + URLEncoder.encode("Stack Trace:\n" + stackTrace, BugzillaPlugin.ENCODING_UTF_8); >+ + URLEncoder.encode(stackTrace, BugzillaPlugin.ENCODING_UTF_8); > } catch (UnsupportedEncodingException e) { > // This should never happen > } >@@ -210,19 +211,47 @@ > BugzillaSearchQuery query = new BugzillaSearchQuery(operation); > > NewSearchUI.runQueryInBackground(query); >+ return true; > } > >- private String getStackTraceFromDescription() { >+ public String getStackTraceFromDescription() { > String description = newDescriptionTextViewer.getTextWidget().getText().trim(); >- // TODO: improve stack trace detection >- int index; >- String stackIdentifier = "Stack Trace:\n"; >- if (description == null || (index = description.indexOf(stackIdentifier)) < 0) { >+ String stackTrace = null; >+ >+ if (description == null) { > return null; > } > >- description = description.substring(index + stackIdentifier.length()); >- return description; >+ // Temporary stack trace identifying until a better regex based method >+ // can be implemented >+ // Find a sequence of lines containing "at " and ".java" as well as the >+ // line that precedes the sequence >+ StringTokenizer tok = new StringTokenizer(description, "\n"); >+ StringBuffer stackBuffer = new StringBuffer(); >+ String prevLine = ""; >+ boolean hit = false; >+ while (tok.hasMoreTokens() && stackBuffer.length() == 0) { >+ String line = tok.nextToken().trim(); >+ while (line.indexOf("at ") < 0 && line.indexOf(".java:") < 0 && tok.hasMoreTokens()) { >+ prevLine = line; >+ line = tok.nextToken(); >+ hit = true; >+ } >+ >+ if (!hit) { >+ return null; >+ } >+ stackBuffer.append(prevLine + "\n" + line + "\n"); >+ while (line.indexOf(".java:") > 0 && line.indexOf("at ") == 0 && tok.hasMoreTokens()) { >+ line = tok.nextToken(); >+ stackBuffer.append(line + "\n"); >+ } >+ } >+ if (stackBuffer.length() > 0) { >+ stackTrace = stackBuffer.toString(); >+ } >+ >+ return stackTrace; > } > > @Override
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 143567
:
46617
|
46618
|
46620
|
46621
|
46646
|
46850
|
46851
|
46907
| 46929 |
47016
|
47017
|
47021
|
47025