diff options
4 files changed, 99 insertions, 67 deletions
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java index 3ce3b3f0e..bdd9ad43e 100644 --- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java +++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java @@ -21,6 +21,7 @@ public class AllBugzillaTests { public static Test suite() { TestSuite suite = new TestSuite("Test for org.eclipse.mylar.bugzilla.tests"); // $JUnit-BEGIN$ + suite.addTestSuite(ReportAttachmentTest.class); suite.addTestSuite(BugzillaSearchEngineTest.class); suite.addTestSuite(Bugzilla220ParserTest.class); suite.addTestSuite(BugzillaRepositoryConnectorTest.class); diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/Bugzilla220ParserTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/Bugzilla220ParserTest.java index a06dd19c5..41ed3bd79 100644 --- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/Bugzilla220ParserTest.java +++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/Bugzilla220ParserTest.java @@ -14,21 +14,16 @@ package org.eclipse.mylar.bugzilla.tests; import java.io.File; import java.io.FileReader; import java.io.Reader; -import java.net.URL; import junit.framework.TestCase; -import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; import org.eclipse.mylar.bugzilla.core.BugReport; import org.eclipse.mylar.core.tests.support.FileTool; -import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin; -import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryUtil; import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; import org.eclipse.mylar.internal.bugzilla.core.NewBugModel; import org.eclipse.mylar.internal.bugzilla.core.internal.BugParser; import org.eclipse.mylar.internal.bugzilla.core.internal.NewBugParser; -import org.eclipse.mylar.provisional.tasklist.TaskRepository; /** * @author Mik Kersten @@ -36,10 +31,12 @@ import org.eclipse.mylar.provisional.tasklist.TaskRepository; */ public class Bugzilla220ParserTest extends TestCase { + public static final String TEST_SERVER = IBugzillaConstants.ECLIPSE_BUGZILLA_URL; + private static final String PRODUCT_MYLAR = "Mylar"; + private static final String PRODUCT_TEST = "TestProduct"; - private static final String TEST_SERVER = IBugzillaConstants.ECLIPSE_BUGZILLA_URL; - + public void testId220() throws Exception { File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path( @@ -47,92 +44,49 @@ public class Bugzilla220ParserTest extends TestCase { Reader in = new FileReader(f); BugReport bug = BugParser.parseBug(in, 7, TEST_SERVER, false, null, null, null); - + assertEquals(7, bug.getId()); assertEquals("summary", bug.getSummary()); assertEquals("7", bug.getAttribute("Bug#").getValue()); assertEquals("7", bug.getAttribute("id").getValue()); } - + public void testId2201() throws Exception { - + File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path( "testdata/pages/test-report-2201.html")); Reader in = new FileReader(f); BugReport bug = BugParser.parseBug(in, 125527, TEST_SERVER, false, null, null, null); - + assertEquals(125527, bug.getId()); assertEquals("bugzilla refresh incorrect for new reports and newly opened hits", bug.getSummary()); assertEquals("125527", bug.getAttribute("Bug#").getValue()); assertEquals("125527", bug.getAttribute("id").getValue()); } - - + public void testNewBugProduct220() throws Exception { - + NewBugModel nbm = new NewBugModel(); - - File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path( - "testdata/pages/enter-bug220.html")); + + File f = FileTool + .getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path("testdata/pages/enter-bug220.html")); Reader in = new FileReader(f); - + new NewBugParser(in).parseBugAttributes(nbm, true); assertEquals(PRODUCT_TEST, nbm.getAttribute("product").getValue()); } - + public void testNewBugProduct2201() throws Exception { - + NewBugModel nbm = new NewBugModel(); - - File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path( - "testdata/pages/enter-bug2201.html")); + + File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), + new Path("testdata/pages/enter-bug2201.html")); Reader in = new FileReader(f); - + new NewBugParser(in).parseBugAttributes(nbm, true); assertEquals(PRODUCT_MYLAR, nbm.getAttribute("product").getValue()); } - - public void testExistingBugWithAttachment() throws Exception { - File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path( - "testdata/pages/test-report-222attachment.html")); - Reader in = new FileReader(f); - BugReport bug = BugParser.parseBug(in, 4, TEST_SERVER, false, null, null, null); - - assertEquals(4, bug.getId()); - assertEquals("4", bug.getAttribute("Bug#").getValue()); - assertEquals("4", bug.getAttribute("id").getValue()); - - assertNotNull(bug.getComments()); - assertEquals(1, bug.getComments().size()); - assertTrue(bug.getComments().get(0).hasAttachment()); - assertEquals("Testing upload", bug.getComments().get(0).getAttachmentDescription()); -// System.err.println(bug.getComments().get(0).getText()); -// assertEquals(1, bug.getAttachements().size()); -// assertEquals("Testing upload", bug.getAttachements().get(1)); - } - - public void testAttachementDownload() throws Exception { - URL localURL = null; - - URL installURL = BugzillaTestPlugin.getDefault().getBundle().getEntry("testdata/contexts/"); - localURL = FileLocator.toFileURL(installURL); - - File destinationFile = new File(localURL.getPath()+"downloadedContext.xml"); - - TaskRepository repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL); - boolean result = BugzillaRepositoryUtil.downloadAttachment(repository, 2, destinationFile, true); - assertTrue(result); - } - -// public void testAttachementUpload() throws Exception { -// File sourceFile = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path( -// "testdata/contexts/downloadedContext.xml")); -// TaskRepository repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL); -// repository.setAuthenticationCredentials("relves@cs.ubc.ca", "***"); -// boolean result = BugzillaRepositoryUtil.uploadAttachment(repository, 4, "Upload Comment 2", "Upload Description 2", sourceFile, "application/xml", false); -// assertTrue(result); -// } - } diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ReportAttachmentTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ReportAttachmentTest.java new file mode 100644 index 000000000..b52b47221 --- /dev/null +++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ReportAttachmentTest.java @@ -0,0 +1,78 @@ +/******************************************************************************* + * 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 java.io.File; +import java.io.FileReader; +import java.io.Reader; +import java.net.URL; + +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.Path; +import org.eclipse.mylar.bugzilla.core.BugReport; +import org.eclipse.mylar.core.tests.support.FileTool; +import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin; +import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryUtil; +import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; +import org.eclipse.mylar.internal.bugzilla.core.internal.BugParser; +import org.eclipse.mylar.provisional.tasklist.TaskRepository; + +import junit.framework.TestCase; + +/** + * @author Rob Elves + */ +public class ReportAttachmentTest extends TestCase { + + public void testExistingBugWithAttachment() throws Exception { + File f = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path( + "testdata/pages/test-report-222attachment.html")); + Reader in = new FileReader(f); + + BugReport bug = BugParser.parseBug(in, 4, IBugzillaConstants.ECLIPSE_BUGZILLA_URL, false, null, null, null); + + assertEquals(4, bug.getId()); + assertEquals("4", bug.getAttribute("Bug#").getValue()); + assertEquals("4", bug.getAttribute("id").getValue()); + + assertNotNull(bug.getComments()); + assertEquals(1, bug.getComments().size()); + assertTrue(bug.getComments().get(0).hasAttachment()); + assertEquals("Testing upload", bug.getComments().get(0).getAttachmentDescription()); +// System.err.println(bug.getComments().get(0).getText()); +// assertEquals(1, bug.getAttachements().size()); +// assertEquals("Testing upload", bug.getAttachements().get(1)); + } + + public void testAttachementDownload() throws Exception { + URL localURL = null; + + URL installURL = BugzillaTestPlugin.getDefault().getBundle().getEntry("testdata/contexts/"); + localURL = FileLocator.toFileURL(installURL); + + File destinationFile = new File(localURL.getPath()+"downloadedContext.xml"); + + TaskRepository repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL); + boolean result = BugzillaRepositoryUtil.downloadAttachment(repository, 2, destinationFile, true); + assertTrue(result); + } + +// public void testAttachementUpload() throws Exception { +// File sourceFile = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path( +// "testdata/contexts/downloadedContext.xml")); +// TaskRepository repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL); +// repository.setAuthenticationCredentials("relves@cs.ubc.ca", "***"); +// boolean result = BugzillaRepositoryUtil.uploadAttachment(repository, 4, "Upload Comment 2", "Upload Description 2", sourceFile, "application/xml", false); +// assertTrue(result); +// } + +} diff --git a/org.eclipse.mylyn.bugzilla.tests/testdata/contexts/downloadedContext.xml b/org.eclipse.mylyn.bugzilla.tests/testdata/contexts/downloadedContext.xml deleted file mode 100644 index b85da0a78..000000000 --- a/org.eclipse.mylyn.bugzilla.tests/testdata/contexts/downloadedContext.xml +++ /dev/null @@ -1 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?><InteractionHistory Id="local-25" Version="1"><InteractionEvent Delta="null" EndDate="2006-02-01 12:43:55.253 PST" Interest="-0.25500003" Kind="manipulation" Navigation="null" OriginId="org.eclipse.mylar.core.model.interest.decay" StartDate="2006-02-01 12:43:55.253 PST" StructureHandle="=org.eclipse.mylar.bugzilla.ui/src&lt;org.eclipse.mylar.internal.bugzilla.ui.editor" StructureKind="java"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:05:08.898 PST" Interest="-0.0" Kind="manipulation" Navigation="null" OriginId="org.eclipse.mylar.core.model.interest.decay" StartDate="2006-02-01 12:05:08.898 PST" StructureHandle="=org.eclipse.mylar.bugzilla.ui/src&lt;org.eclipse.mylar.internal.bugzilla.ui.editor" StructureKind="java"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:12:59.174 PST" Interest="8.749001" Kind="propagation" Navigation="org.eclipse.mylar.core.model.edges.containment" OriginId="org.eclipse.mylar.core.model.interest.propagation" StartDate="2006-02-01 12:05:01.166 PST" StructureHandle="=org.eclipse.mylar.bugzilla.ui/src&lt;org.eclipse.mylar.internal.bugzilla.ui.editor" StructureKind="java"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:43:55.253 PST" Interest="-0.08500001" Kind="manipulation" Navigation="null" OriginId="org.eclipse.mylar.core.model.interest.decay" StartDate="2006-02-01 12:43:55.253 PST" StructureHandle="=org.eclipse.mylar.doc" StructureKind="*"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:42:19.555 PST" Interest="3.9490001" Kind="propagation" Navigation="org.eclipse.mylar.core.model.edges.containment" OriginId="org.eclipse.mylar.core.model.interest.propagation" StartDate="2006-02-01 12:13:59.791 PST" StructureHandle="=org.eclipse.mylar.doc" StructureKind="*"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:42:06.516 PST" Interest="2.0" Kind="selection" Navigation="null" OriginId="org.eclipse.jdt.ui.PackageExplorer" StartDate="2006-02-01 12:13:52.761 PST" StructureHandle="=org.eclipse.mylar.doc" StructureKind="java"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:43:55.253 PST" Interest="-0.25500003" Kind="manipulation" Navigation="null" OriginId="org.eclipse.mylar.core.model.interest.decay" StartDate="2006-02-01 12:43:55.253 PST" StructureHandle="=org.eclipse.mylar.bugzilla.ui/src&lt;org.eclipse.mylar.internal.bugzilla.ui.editor{AbstractBugEditor.java" StructureKind="java"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:05:06.454 PST" Interest="-2.0" Kind="manipulation" Navigation="null" OriginId="org.eclipse.mylar.ide.editor.tracker.interest" StartDate="2006-02-01 12:05:08.898 PST" StructureHandle="=org.eclipse.mylar.bugzilla.ui/src&lt;org.eclipse.mylar.internal.bugzilla.ui.editor{AbstractBugEditor.java" StructureKind="java"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:12:47.968 PST" Interest="6.7490005" Kind="propagation" Navigation="org.eclipse.mylar.core.model.edges.containment" OriginId="org.eclipse.mylar.core.model.interest.propagation" StartDate="2006-02-01 12:05:01.166 PST" StructureHandle="=org.eclipse.mylar.bugzilla.ui/src&lt;org.eclipse.mylar.internal.bugzilla.ui.editor{AbstractBugEditor.java" StructureKind="java"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:12:59.174 PST" Interest="1.0" Kind="selection" Navigation="null" OriginId="org.eclipse.jdt.ui.PackageExplorer" StartDate="2006-02-01 12:12:59.174 PST" StructureHandle="=org.eclipse.mylar.bugzilla.ui/src&lt;org.eclipse.mylar.internal.bugzilla.ui.editor{AbstractBugEditor.java" StructureKind="java"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:43:55.253 PST" Interest="-0.068" Kind="manipulation" Navigation="null" OriginId="org.eclipse.mylar.core.model.interest.decay" StartDate="2006-02-01 12:43:55.253 PST" StructureHandle="/org.eclipse.mylar.doc/doc" StructureKind="*"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:42:19.555 PST" Interest="3.9490001" Kind="propagation" Navigation="org.eclipse.mylar.core.model.edges.containment" OriginId="org.eclipse.mylar.core.model.interest.propagation" StartDate="2006-02-01 12:13:59.791 PST" StructureHandle="/org.eclipse.mylar.doc/doc" StructureKind="*"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:43:55.253 PST" Interest="-0.238" Kind="manipulation" Navigation="null" OriginId="org.eclipse.mylar.core.model.interest.decay" StartDate="2006-02-01 12:43:55.253 PST" StructureHandle="=org.eclipse.mylar.bugzilla.ui/src&lt;org.eclipse.mylar.internal.bugzilla.ui.editor{AbstractBugEditor.java[AbstractBugEditor" StructureKind="java"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:12:47.968 PST" Interest="4.0" Kind="edit" Navigation="null" OriginId="org.eclipse.mylar.java.ui.editor.MylarCompilationUnitEditor" StartDate="2006-02-01 12:08:22.256 PST" StructureHandle="=org.eclipse.mylar.bugzilla.ui/src&lt;org.eclipse.mylar.internal.bugzilla.ui.editor{AbstractBugEditor.java[AbstractBugEditor" StructureKind="java"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:05:11.932 PST" Interest="-0.98300004" Kind="manipulation" Navigation="null" OriginId="org.eclipse.mylar.core.model.interest.decay.correction" StartDate="2006-02-01 12:05:08.898 PST" StructureHandle="=org.eclipse.mylar.bugzilla.ui/src&lt;org.eclipse.mylar.internal.bugzilla.ui.editor{AbstractBugEditor.java[AbstractBugEditor" StructureKind="java"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:05:11.932 PST" Interest="2.0" Kind="selection" Navigation="null" OriginId="org.eclipse.mylar.java.ui.editor.MylarCompilationUnitEditor" StartDate="2006-02-01 12:05:01.166 PST" StructureHandle="=org.eclipse.mylar.bugzilla.ui/src&lt;org.eclipse.mylar.internal.bugzilla.ui.editor{AbstractBugEditor.java[AbstractBugEditor" StructureKind="java"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:43:55.253 PST" Interest="-0.25500003" Kind="manipulation" Navigation="null" OriginId="org.eclipse.mylar.core.model.interest.decay" StartDate="2006-02-01 12:43:55.253 PST" StructureHandle="=org.eclipse.mylar.bugzilla.ui/src" StructureKind="java"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:05:08.898 PST" Interest="-0.0" Kind="manipulation" Navigation="null" OriginId="org.eclipse.mylar.core.model.interest.decay" StartDate="2006-02-01 12:05:08.898 PST" StructureHandle="=org.eclipse.mylar.bugzilla.ui/src" StructureKind="java"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:12:59.174 PST" Interest="9.766001" Kind="propagation" Navigation="org.eclipse.mylar.core.model.edges.containment" OriginId="org.eclipse.mylar.core.model.interest.propagation" StartDate="2006-02-01 12:05:01.166 PST" StructureHandle="=org.eclipse.mylar.bugzilla.ui/src" StructureKind="java"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:43:55.253 PST" Interest="-0.25500003" Kind="manipulation" Navigation="null" OriginId="org.eclipse.mylar.core.model.interest.decay" StartDate="2006-02-01 12:43:55.253 PST" StructureHandle="=org.eclipse.mylar.bugzilla.ui" StructureKind="java"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:05:08.898 PST" Interest="-0.017" Kind="manipulation" Navigation="null" OriginId="org.eclipse.mylar.core.model.interest.decay" StartDate="2006-02-01 12:05:08.898 PST" StructureHandle="=org.eclipse.mylar.bugzilla.ui" StructureKind="java"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:12:59.174 PST" Interest="10.783001" Kind="propagation" Navigation="org.eclipse.mylar.core.model.edges.containment" OriginId="org.eclipse.mylar.core.model.interest.propagation" StartDate="2006-02-01 12:05:01.166 PST" StructureHandle="=org.eclipse.mylar.bugzilla.ui" StructureKind="java"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:13:50.578 PST" Interest="2.0" Kind="selection" Navigation="null" OriginId="org.eclipse.jdt.ui.PackageExplorer" StartDate="2006-02-01 12:05:00.956 PST" StructureHandle="=org.eclipse.mylar.bugzilla.ui" StructureKind="java"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:43:55.253 PST" Interest="-0.25500003" Kind="manipulation" Navigation="null" OriginId="org.eclipse.mylar.core.model.interest.decay" StartDate="2006-02-01 12:43:55.253 PST" StructureHandle="" StructureKind="java"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:05:08.898 PST" Interest="-0.017" Kind="manipulation" Navigation="null" OriginId="org.eclipse.mylar.core.model.interest.decay" StartDate="2006-02-01 12:05:08.898 PST" StructureHandle="" StructureKind="java"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:42:19.555 PST" Interest="19.715" Kind="propagation" Navigation="org.eclipse.mylar.core.model.edges.containment" OriginId="org.eclipse.mylar.core.model.interest.propagation" StartDate="2006-02-01 12:05:00.956 PST" StructureHandle="" StructureKind="java"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:43:55.253 PST" Interest="-0.068" Kind="manipulation" Navigation="null" OriginId="org.eclipse.mylar.core.model.interest.decay" StartDate="2006-02-01 12:43:55.253 PST" StructureHandle="/org.eclipse.mylar.doc/doc/faq.html" StructureKind="*"/><InteractionEvent Delta="null" EndDate="2006-02-01 12:42:19.555 PST" Interest="4.0" Kind="selection" Navigation="null" OriginId="org.eclipse.jdt.ui.PackageExplorer" StartDate="2006-02-01 12:13:59.791 PST" StructureHandle="/org.eclipse.mylar.doc/doc/faq.html" StructureKind="*"/></InteractionHistory>
\ No newline at end of file |