Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2005-06-17 20:51:27 +0000
committermkersten2005-06-17 20:51:27 +0000
commit7320e6f5ba8114f927eeeed9f0b11ecd2041f414 (patch)
treee9a9d5d9e0ffb37dc8e575c8402a2008cea563d3 /org.eclipse.mylyn.tasks.tests/src/org
downloadorg.eclipse.mylyn.tasks-7320e6f5ba8114f927eeeed9f0b11ecd2041f414.tar.gz
org.eclipse.mylyn.tasks-7320e6f5ba8114f927eeeed9f0b11ecd2041f414.tar.xz
org.eclipse.mylyn.tasks-7320e6f5ba8114f927eeeed9f0b11ecd2041f414.zip
Initial mylar contribution
Diffstat (limited to 'org.eclipse.mylyn.tasks.tests/src/org')
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaSearchPluginTest.java329
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaStackTraceTest.java170
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/MylarBugzillaTestsPlugin.java39
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/Job.java87
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/MylarTasksTestsPlugin.java39
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/People.java67
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/Person.java106
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java50
8 files changed, 887 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaSearchPluginTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaSearchPluginTest.java
new file mode 100644
index 000000000..52e2d21b8
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaSearchPluginTest.java
@@ -0,0 +1,329 @@
+/*******************************************************************************
+ * Copyright (c) 2004 - 2005 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
+ *******************************************************************************/
+/*
+ * Created on Nov 19, 2004
+ */
+package org.eclipse.mylar.tasks.bugzilla.tests;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.mylar.core.search.IActiveSearchListener;
+import org.eclipse.mylar.core.tests.support.WorkspaceSetupHelper;
+import org.eclipse.mylar.core.tests.support.search.SearchPluginTestHelper;
+import org.eclipse.mylar.tasks.BugzillaTask;
+import org.eclipse.mylar.tasks.ITask;
+import org.eclipse.mylar.tasks.MylarTasksPlugin;
+import org.eclipse.mylar.tasks.Task;
+import org.eclipse.mylar.tasks.TaskList;
+import org.eclipse.mylar.tasks.BugzillaTask.BugTaskState;
+import org.eclipse.mylar.tasks.bugzilla.BugzillaReportNode;
+import org.eclipse.mylar.tasks.bugzilla.search.BugzillaMylarSearch;
+
+/*TEST CASES TO HANDLE
+ * 1. what is here
+ * 2. different scopes ( local and remote )
+ * 3. no bugs
+ * 4. offline bugs
+ *
+ * DEGREE OF SEPARATIONS
+ * 1 Local bug, qualified reference
+ * 2 local bug, unqualified reference
+ * 3 remote bug, qualified reference
+ * 4 remote bug, unqualified reference
+ * 5 NONE
+ */
+
+/**
+ * Test the bugzilla search functionality of the bridge
+ * @author sminto
+ */
+public class BugzillaSearchPluginTest extends TestCase{
+
+ //SHAWNTODO Add tests for the different types of searches (local qual, local unqual, fully qual, unqual) and mock up a bugs db for testing
+
+ /** The expected number of results when searching for astNode */
+// SHAWNTODO add back in when we have a test server mocked up
+// private static final int NUM_AST_RESULTS = 302;
+//
+// private static final int NUM_AST_SETSOURCERANGE_RESULTS = 15;
+
+ /** list to add collectors to when notified */
+ private List<List<?>> lists = new ArrayList<List<?>>();
+
+ private IType astNodeType;
+
+ @Override
+ protected void setUp() throws Exception {
+ WorkspaceSetupHelper.setupWorkspace();
+ IJavaProject jp = WorkspaceSetupHelper.getJdtCoreDomProject();
+ astNodeType = WorkspaceSetupHelper.getType(jp, "org.eclipse.jdt.core.dom.ASTNode");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ WorkspaceSetupHelper.clearDoiModel();
+ }
+
+ /**
+ * Test adding and removing ISearchCompletedListeners
+ */
+ public void testSearchCompletedListenerAddAndRemove(){
+ lists.clear();
+
+ // create 2 listeners
+ IActiveSearchListener l1 =new IActiveSearchListener() {
+ private boolean gathered = false;
+
+ public void searchCompleted(List<?> l)
+ {
+ lists.add(l);
+ gathered = true;
+ }
+
+ public boolean resultsGathered() {
+ return gathered;
+ }
+ };
+ IActiveSearchListener l2 =new IActiveSearchListener() {
+ private boolean gathered = false;
+
+ public void searchCompleted(List<?> l)
+ {
+ lists.add(l);
+ gathered = true;
+ }
+
+ public boolean resultsGathered() {
+ return gathered;
+ }
+ };
+
+ BugzillaMylarSearch s = new BugzillaMylarSearch(BugzillaMylarSearch.UNQUAL, astNodeType);
+
+ // add the first listener
+ s.addListener(l1);
+ // remove the first listener
+ s.removeListener(l1);
+
+ // perform the search
+ SearchPluginTestHelper.search(s, l2);
+
+ // make sure that only the second listener added has any results left
+ assertTrue("listener was not removed", lists.size() >= 1 && !l1.resultsGathered());
+ assertTrue("listener was not added", lists.size() == 1);
+
+ // display the time it took for the search
+// System.err.println("Search Took About " + time + " seconds");
+ MylarTasksPlugin.getBridge().removeFromLandmarksHash(astNodeType);
+ }
+
+ /**
+ * Tests that the bridge gets the right data for us
+ * This test is wierd because it waits on results.
+ */
+ public void testBridge() {
+ lists.clear();
+ BugzillaMylarSearch s = new BugzillaMylarSearch(BugzillaMylarSearch.UNQUAL, astNodeType);
+
+ IActiveSearchListener l = new IActiveSearchListener() {
+ private boolean gathered = false;
+
+ public void searchCompleted(List<?> results)
+ {
+ lists.add(results);
+ gathered = true;
+ }
+
+ public boolean resultsGathered() {
+ return gathered;
+ }
+ };
+
+ // perform the search
+ SearchPluginTestHelper.search(s, l);
+
+ // make sure we got the right number of bugs back
+ assertTrue("No collector returned", lists.size() != 0);
+ List<?> c = lists.get(0);
+ assertTrue("Results not the right size", c.size() > 0); // TODO should be assertEquals on expected size
+
+ // display the time it took for the search and the results returned
+// System.err.println("Search Took About " + time + " seconds");
+// System.err.println(c);
+ MylarTasksPlugin.getBridge().removeFromLandmarksHash(astNodeType);
+
+ }
+
+
+ /**
+ * Tests that the bridge saves the results of a search so that it
+ * can be used later
+ */
+ public void testSaveResults() {
+ lists.clear();
+ BugzillaMylarSearch s = new BugzillaMylarSearch(BugzillaMylarSearch.UNQUAL, astNodeType);
+
+ IActiveSearchListener l = new IActiveSearchListener() {
+ private boolean gathered = false;
+
+ public void searchCompleted(List<?> results)
+ {
+ lists.add(results);
+ gathered = true;
+ }
+
+ public boolean resultsGathered() {
+ return gathered;
+ }
+ };
+
+ // perform the search
+ SearchPluginTestHelper.search(s, l);
+// System.err.println("Search Took About " + time + " seconds");
+
+ // do an inital search
+ assertTrue("No collectors returned", lists.size() != 0);
+ List<?> c = lists.get(0);
+ assertTrue("Results not the right size", c.size() > 0); // TODO should be assertEquals on expected size
+
+ // check that the search has been saved
+ List<BugzillaReportNode> saved = MylarTasksPlugin.getBridge().getFromLandmarksHash(astNodeType, BugzillaMylarSearch.UNQUAL);
+ assertTrue("Results not cached", saved != null);
+ assertTrue("Results not the right size", saved.size() > 0); // TODO should be assertEquals on expected size
+
+ assertTrue(c.containsAll(saved) && saved.containsAll(c));
+ MylarTasksPlugin.getBridge().removeFromLandmarksHash(astNodeType);
+ }
+
+ public void testLocalBugUnqual() throws InterruptedException {
+ lists.clear();
+
+ String bugPrefix = "Bugzilla-";
+
+ TaskList t = MylarTasksPlugin.getTaskListManager().createNewTaskList();
+ MylarTasksPlugin.getTaskListManager().setTaskList(t);
+ ITask cat = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "Testing Category");
+ t.addRootTask(cat);
+ BugzillaTask bugTask1 = new BugzillaTask(bugPrefix +94185, "<bugzilla info>");
+ cat.addSubtask(bugTask1);
+ while(bugTask1.getState() != BugTaskState.FREE){
+ Thread.sleep(500);
+ }
+ BugzillaTask bugTask2 = new BugzillaTask(bugPrefix + 3692, "<bugzilla info>");
+ bugTask1.addSubtask(bugTask2);
+ while(bugTask2.getState() != BugTaskState.FREE){
+ Thread.sleep(500);
+ }
+ BugzillaTask bugTask3 = new BugzillaTask(bugPrefix + 3693, "<bugzilla info>");
+ cat.addSubtask(bugTask3);
+ while(bugTask3.getState() != BugTaskState.FREE){
+ Thread.sleep(500);
+ }
+
+ BugzillaTask bugTask4 = new BugzillaTask(bugPrefix + 9583, "<bugzilla info>");
+ bugTask3.addSubtask(bugTask4);
+ while(bugTask4.getState() != BugTaskState.FREE){
+ Thread.sleep(500);
+ }
+
+ BugzillaMylarSearch s = new BugzillaMylarSearch(BugzillaMylarSearch.LOCAL_UNQUAL, astNodeType);
+
+ IActiveSearchListener l = new IActiveSearchListener() {
+ private boolean gathered = false;
+
+ public void searchCompleted(List<?> results)
+ {
+ lists.add(results);
+ gathered = true;
+ }
+
+ public boolean resultsGathered() {
+ return gathered;
+ }
+ };
+
+ // perform the search
+ SearchPluginTestHelper.search(s, l);
+// System.err.println("Search Took About " + time + " seconds");
+
+ // do an inital search
+ assertTrue("No collectors returned", lists.size() != 0);
+ List<?> c = lists.get(0);
+ assertEquals("Results not the right size", 3, c.size());
+
+ MylarTasksPlugin.getBridge().removeFromLandmarksHash(astNodeType);
+ MylarTasksPlugin.getTaskListManager().deleteTask(cat);
+ }
+
+ //TODO need to test a bug that wraps...should fail since we can only search on a single line
+ public void testLocalBugFullyQual() throws InterruptedException{
+ lists.clear();
+
+ String bugPrefix = "Bugzilla-";
+
+
+ TaskList t = MylarTasksPlugin.getTaskListManager().createNewTaskList();
+ MylarTasksPlugin.getTaskListManager().setTaskList(t);
+ ITask cat = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "Testing Category");
+ t.addRootTask(cat);
+ BugzillaTask bugTask1 = new BugzillaTask(bugPrefix + 94185, "<bugzilla info>");
+ cat.addSubtask(bugTask1);
+ while(bugTask1.getState() != BugTaskState.FREE){
+ Thread.sleep(500);
+ }
+
+ BugzillaTask bugTask2 = new BugzillaTask(bugPrefix + 9583, "<bugzilla info>");
+ bugTask1.addSubtask(bugTask2);
+ while(bugTask2.getState() != BugTaskState.FREE){
+ Thread.sleep(500);
+ }
+ BugzillaTask bugTask3 = new BugzillaTask(bugPrefix + 3693, "<bugzilla info>");
+ cat.addSubtask(bugTask3);
+ while(bugTask3.getState() != BugTaskState.FREE){
+ Thread.sleep(500);
+ }
+
+
+ BugzillaMylarSearch s = new BugzillaMylarSearch(BugzillaMylarSearch.LOCAL_QUAL, astNodeType);
+
+ IActiveSearchListener l = new IActiveSearchListener() {
+ private boolean gathered = false;
+
+ public void searchCompleted(List<?> results)
+ {
+ lists.add(results);
+ gathered = true;
+ }
+
+ public boolean resultsGathered() {
+ return gathered;
+ }
+ };
+
+ // perform the search
+ SearchPluginTestHelper.search(s, l);
+// System.err.println("Search Took About " + time + " seconds");
+
+ // do an inital search
+ assertTrue("No collectors returned", lists.size() != 0);
+ List<?> c = lists.get(0);
+ assertEquals("Results not the right size", 1, c.size());
+
+ MylarTasksPlugin.getBridge().removeFromLandmarksHash(astNodeType);
+ MylarTasksPlugin.getTaskListManager().deleteTask(cat);
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaStackTraceTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaStackTraceTest.java
new file mode 100644
index 000000000..d78bae0aa
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaStackTraceTest.java
@@ -0,0 +1,170 @@
+/*******************************************************************************
+ * Copyright (c) 2004 - 2005 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
+ *******************************************************************************/
+////Created on Oct 12, 2004
+package org.eclipse.mylar.tasks.bugzilla.tests;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.Path;
+import org.eclipse.mylar.bugzilla.core.internal.BugParser;
+import org.eclipse.mylar.bugzilla.search.BugzillaSearchHit;
+import org.eclipse.mylar.core.tests.MylarCoreTestsPlugin;
+import org.eclipse.mylar.core.tests.support.FileTool;
+import org.eclipse.mylar.tasks.bugzilla.BugzillaReportNode;
+import org.eclipse.mylar.tasks.bugzilla.StackTrace;
+import org.eclipse.mylar.tasks.bugzilla.search.BugzillaMylarSearchOperation;
+
+
+/**
+ * Class to test the Bridge methods that do not require server queries
+ * @author sminto
+ */
+public class BugzillaStackTraceTest extends TestCase {
+
+ private static final String TEST_FILE_LOC = "testdata/BugzillaBridgeData/";
+
+ private static final String BUGZILLA_SERVER_NAME = "https://bugs.eclipse.org/bugs";
+
+ /**
+ * Test that the regular expression escaping mechanism works properly
+ */
+ public void testREGEX(){
+ String r = ".*+(){}[]^$|?/\\";
+ String r2 = StackTrace.escapeForRegex(r);
+ String ans = "\\.\\*\\+\\(\\)\\{\\}\\[\\]\\^\\$\\|\\?\\/\\\\";
+ String msg = "Regular Expression matching wrong:\nwas: " + r2 + "\nshould be:" + ans;
+ assertTrue(msg, r2.equals(ans));
+ }
+
+ /**
+ * Test parsing the bug for multiple stacks in in
+ */
+ public void testMultipleStacksDiffComments(){
+ // BUG 4862 - 2 stack traces - 1 in description, 1 in comment - text before and after
+ performParse(4862, "4862.html", 2, false);
+
+ }
+
+ /**
+ * Test parsing the bug for a single stack in the description with some
+ * text before it
+ */
+ public void testSingleStackCodeBeforeInDescription(){
+
+ // BUG 76388 - 1 stack trace - description - text before and formatted ugly
+ performParse(76388, "76388.html", 1, false);
+ }
+
+ /**
+ * Test parsing the bug for a single stack trace in the description with
+ * text before and after it
+ */
+ public void testSingleStackCodeBeforeAndAfterInDescription(){
+
+ // BUG 76146 - 1 stack trace - description - text before and code after
+ performParse(76146, "76146.html", 1, false);
+ }
+
+ /**
+ * Test parsing a bug that has 1 stack trace in the description with no extra
+ * text, but has lines in it that span 3 lines
+ */
+ public void testSingleStackPoorFormatInDescription(){
+ // BUG 67395 - 1 stack trace - description - no extra text, 1 at line spans 3 lines
+ performParse(67395, "67395.html", 1, false);
+ }
+
+ /**
+ * Test parsing a bug with no stack traces and no qualified exception names
+ */
+ public void testNoStackNoQualified(){
+ // BUG 4548 - no stack traces, no qualified reference to an exception
+ performParse(4548, "4548.html", 0, false);
+ }
+
+ /**
+ * Test parsing a bug with no stack traces, but a qualified reference to
+ * an exception
+ */
+ public void testNoStackQual(){
+ // BUG 1 - no stack traces, qualified reference to exception - made up bug
+ performParse(1, "1.html", 0, false);
+ }
+
+
+ /**
+ * Test parsing of a bug with 1 stack trace and multiple qualified references
+ */
+ public void testSingleStackQual(){
+ // BUG 2 - 1 stack trace- 2 qual ref, stack trace, 1 qual ref - made up bug
+ performParse(2, "2.html", 1, false);
+ }
+
+ /**
+ * Test parsing of a bug with many stacks traces in a single comment
+ */
+ public void testMultipleStackSingleComment(){
+ // BUG 40152 - 1 stack trace- 2 qual ref, stack trace, 1 qual ref - made up bug
+ performParse(40152, "40152.html", 33, false);
+ }
+
+ /**
+ * Print out the stack traces
+ * @param l List of stack traces
+ */
+ private void printStackTraces(List<StackTrace> l){
+ System.out.println("\n\n");
+ for(int i = 0; i < l.size(); i++){
+ StackTrace trace = l.get(i);
+ System.out.println("*****************?????????????????*****************\n");
+ System.out.println("OFFSET: " + trace.getOffset() + " LENGTH: " + trace.getLength());
+ System.out.println(trace.getStackTrace());
+ System.out.println("*****************?????????????????*****************\n\n");
+ }
+ }
+
+ private void performParse(int bugNumber, String bugFileName, int numTracesExpected, boolean printStackTraces){
+
+ BugzillaSearchHit hit = new BugzillaSearchHit(bugNumber,"","","","","","","",""); // stack trace in desc and com
+
+ // create a new doi info
+ BugzillaReportNode doi = new BugzillaReportNode(0, hit, false);
+ try {
+
+ // read the bug in from a file
+ File f = FileTool.getFileInPlugin(MylarCoreTestsPlugin.getDefault(), new Path(TEST_FILE_LOC+bugFileName)); // used if run as a plugin test
+// File f = new File(TEST_FILE_LOC+bugFileName); // used if run as a standalone test
+ Reader reader = new FileReader(f);
+ doi.setBug(BugParser.parseBug(reader, hit.getId(), BUGZILLA_SERVER_NAME, true, null, null));
+ reader.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // do a second pass parse on the bug
+ List<BugzillaReportNode> l = new ArrayList<BugzillaReportNode>();
+ l.add(doi);
+ BugzillaMylarSearchOperation.secondPassBugzillaParser(l);
+
+ // make sure that we received the right number of stack traces back
+// System.out.println("*** BUG " + hit.getId() + " ***");
+// System.out.println("NumStackTraces = " + doi.getStackTraces().size());
+ assertEquals("Wrong Number stack traces", numTracesExpected, doi.getStackTraces().size());
+ if(printStackTraces)
+ printStackTraces(doi.getStackTraces());
+ }
+}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/MylarBugzillaTestsPlugin.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/MylarBugzillaTestsPlugin.java
new file mode 100644
index 000000000..e8a41427d
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/MylarBugzillaTestsPlugin.java
@@ -0,0 +1,39 @@
+package org.eclipse.mylar.tasks.bugzilla.tests;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class MylarBugzillaTestsPlugin extends Plugin {
+ //The shared instance.
+ private static MylarBugzillaTestsPlugin plugin;
+
+ /**
+ * The constructor.
+ */
+ public MylarBugzillaTestsPlugin() {
+ super();
+ plugin = this;
+ }
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ super.stop(context);
+ plugin = null;
+ }
+
+ /**
+ * Returns the shared instance.
+ */
+ public static MylarBugzillaTestsPlugin getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/Job.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/Job.java
new file mode 100644
index 000000000..62d95fcce
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/Job.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2004 - 2005 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.tasks.tests;
+
+public class Job {
+ private String company;
+ private String position;
+ private int salary;
+ private String email;
+ private String supervisor;
+
+ public static String foo = "TESTING STATIC FOR XSTREAM";
+
+ public Job() {
+ this.company = "Foo";
+ this.position = "slave";
+ this.salary = 100;
+ this.email = "a@bc.com";
+ //this.supervisor = "bill gates";
+ }
+
+ public Job(String comp, String pos, int salary, String email, String supervisor) {
+ this.company = comp;
+ this.position = pos;
+ this.salary = salary;
+ this.email = email;
+ this.supervisor = supervisor;
+ }
+
+ public boolean equals(Job j) {
+ boolean result = true;
+ result = result && j.company == this.company;
+ result = result && j.position == this.position;
+ result = result && j.salary == this.salary;
+ result = result && j.email == this.email;
+ result = result && j.supervisor == this.supervisor;
+ return result;
+ }
+
+ public String getCompany() {
+ return company;
+ }
+
+ public void setCompany(String company) {
+ this.company = company;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public String getPosition() {
+ return position;
+ }
+
+ public void setPosition(String position) {
+ this.position = position;
+ }
+
+ public int getSalary() {
+ return salary;
+ }
+
+ public void setSalary(int salary) {
+ this.salary = salary;
+ }
+
+ public String getSupervisor() {
+ return supervisor;
+ }
+
+ public void setSupervisor(String supervisor) {
+ this.supervisor = supervisor;
+ }
+}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/MylarTasksTestsPlugin.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/MylarTasksTestsPlugin.java
new file mode 100644
index 000000000..e528cbcec
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/MylarTasksTestsPlugin.java
@@ -0,0 +1,39 @@
+package org.eclipse.mylar.tasks.tests;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class MylarTasksTestsPlugin extends Plugin {
+ //The shared instance.
+ private static MylarTasksTestsPlugin plugin;
+
+ /**
+ * The constructor.
+ */
+ public MylarTasksTestsPlugin() {
+ super();
+ plugin = this;
+ }
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ super.stop(context);
+ plugin = null;
+ }
+
+ /**
+ * Returns the shared instance.
+ */
+ public static MylarTasksTestsPlugin getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/People.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/People.java
new file mode 100644
index 000000000..2e88dcca4
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/People.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2004 - 2005 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.tasks.tests;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+
+public class People {
+ private List<Person> list = new ArrayList<Person>();
+
+ public People() {
+ // don't need to do any initialization
+ }
+
+ public void createDefault() {
+ Person p = new Person("Ken Sueda", "ksueda@hotmail.com", "123-4567", 22, 1);
+ Job j = new Job("UBCCS", "developer", 1000, "ksueda@cs.ubc.ca", "foo");
+ p.setJob(j);
+ list.add(p);
+
+ p = new Person("Shawn Minto", "minto@hotmail.com", "798-1234", 23, 2);
+ j = new Job("UBCCS", "grad student", 3000, "minto@cs.ubc.ca", "foo");
+ p.setJob(j);
+ list.add(p);
+
+
+ p = new Person("Mik Kersten", "kersten@hotmail.com", "456-7891", 24, 3);
+ j = new Job("UBCCS", "PhD", 1000000, "kersten@cs.ubc.ca", "foo");
+ p.setJob(j);
+ list.add(p);
+
+ p = new Person("Gail Murphy", "murphy@hotmail.com", "987-6543", 25, 4);
+ j = new Job("UBCCS", "Professor", 100000000, "", "");
+ p.setJob(j);
+ list.add(p);
+ }
+
+ public boolean equals(People people) {
+ boolean result = true;
+ if (list.size() == people.list.size()) {
+ Iterator<Person> itr = list.iterator();
+ Iterator<Person> itr2 = people.list.iterator();
+
+ while(itr.hasNext()) {
+ Person p = itr.next();
+ Person p2 = itr2.next();
+ result = result && p.equals(p2);
+ if (!result) {
+ break;
+ }
+ }
+ } else {
+ result = false;
+ }
+ return result;
+ }
+}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/Person.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/Person.java
new file mode 100644
index 000000000..b4064f1b1
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/Person.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2004 - 2005 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.tasks.tests;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Person {
+ private String name;
+ private String emailAddress;
+ private String phoneNumber;
+ private int age;
+ private int id;
+ private Job job;
+
+ private List<Person> list = new ArrayList<Person>();
+
+ public Person() {
+ name = "Ken Sueda";
+ id = 1;
+ age = 22;
+ emailAddress = "ksueda@hotmail.com";
+ phoneNumber = "123-4567";
+ job = null;
+ }
+
+ public Person(String name, String email, String phone, int age, int id) {
+ this.name = name;
+ this.emailAddress = email;
+ this.phoneNumber = phone;
+ this.age = age;
+ this.id = id;
+ this.job = null;
+ }
+
+ public void add(Person p) {
+ list.add(p);
+ }
+
+ public boolean equals(Person p) {
+ boolean result = true;
+ result = result && p.name == this.name;
+ result = result && p.emailAddress == this.emailAddress;
+ result = result && p.phoneNumber == this.phoneNumber;
+ result = result && p.age == this.age;
+ result = result && p.id == this.id;
+ result = result && p.job.equals(this.job);
+ return result;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getEmailAddress() {
+ return emailAddress;
+ }
+
+ public void setEmailAddress(String emailAddress) {
+ this.emailAddress = emailAddress;
+ }
+
+ public String getPhoneNumber() {
+ return phoneNumber;
+ }
+
+ public void setPhoneNumber(String phoneNumber) {
+ this.phoneNumber = phoneNumber;
+ }
+
+ public Job getJob() {
+ return job;
+ }
+
+ public void setJob(Job job) {
+ this.job = job;
+ }
+}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java
new file mode 100644
index 000000000..c5ce152db
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2004 - 2005 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
+ *******************************************************************************/
+/*
+ * Created on Dec 21, 2004
+ */
+package org.eclipse.mylar.tasks.tests;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.eclipse.mylar.tasks.MylarTasksPlugin;
+import org.eclipse.mylar.tasks.Task;
+import org.eclipse.mylar.tasks.TaskListManager;
+
+/**
+ * @author Mik Kersten
+ */
+public class TaskListManagerTest extends TestCase {
+
+ public void testCreationAndExternalization() {
+ File file = new File("foo" + MylarTasksPlugin.FILE_EXTENSION);
+ file.deleteOnExit();
+ TaskListManager manager = new TaskListManager(file);
+
+ manager.createNewTaskList();
+// Category category = taskList.createCategory("category");
+ Task task1 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 1");
+// category.addTask(task1);
+ task1.addSubtask(new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 1"));
+ assertEquals(task1.getChildren().size(), 1);
+
+ manager.saveTaskList();
+ assertNotNull(manager.getTaskList());
+ manager.setTaskList(null);
+// manager.readTaskList();
+// assertNotNull(manager.getTaskList());
+// assertEquals(manager.getTaskList().getCategories().size(), 1);
+// assertEquals(manager.getTaskList().findCategory("category").getTasks().size(), 1);
+// assertEquals(manager.getTaskList().findCategory("category").getTasks().get(0).getLabel(), "task 1");
+ }
+}

Back to the top