Skip to main content
summaryrefslogtreecommitdiffstats
blob: ca3f0ffa21d18257ef742427721ca06684e6b3dc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*******************************************************************************
 * Copyright (c) 2003 - 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.IOException;
import java.io.Reader;
import java.net.URL;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.security.auth.login.LoginException;

import junit.framework.TestCase;

import org.eclipse.core.runtime.Path;
import org.eclipse.mylar.core.tests.support.FileTool;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin;
import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylar.internal.bugzilla.core.internal.ProductParser;
import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin;
import org.eclipse.mylar.provisional.tasklist.TaskRepository;

/**
 * Tests for parsing Product Page for new Bugzilla reports
 * 
 * @author Mik Kersten
 */
public class BugzillaProductParserTest extends TestCase {

	private TaskRepository repository;

	@Override
	protected void setUp() throws Exception {
		super.setUp();
		repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND,
				new URL(IBugzillaConstants.ECLIPSE_BUGZILLA_URL));
		MylarTaskListPlugin.getRepositoryManager().addRepository(repository);
	}

	@Override
	protected void tearDown() throws Exception {
		super.tearDown();
		MylarTaskListPlugin.getRepositoryManager().removeRepository(repository);
	}

	public BugzillaProductParserTest(String arg0) {
		super(arg0);
	}

	public void test220Products() throws LoginException, IOException, ParseException {
		BugzillaPlugin.getDefault().getPluginPreferences().setValue(IBugzillaConstants.SERVER_VERSION,
				IBugzillaConstants.SERVER_220);

		File file = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path(
				"testdata/pages/test-products-220.html"));
		Reader in = new FileReader(file);
		List<String> productList = new ArrayList<String>();
		productList = new ProductParser(in).getProducts(repository);

		Iterator<String> itr = productList.iterator();
		assertTrue(itr.hasNext());
		assertEquals("AJDT", "AJDT", itr.next());
		assertEquals("ALF", "ALF", itr.next());
		assertEquals("AspectJ", "AspectJ", itr.next());
		assertEquals("BIRT", "BIRT", itr.next());
	}

	public void test218Products() throws LoginException, IOException, ParseException {
		BugzillaPlugin.getDefault().getPluginPreferences().setValue(IBugzillaConstants.SERVER_VERSION,
				IBugzillaConstants.SERVER_218);

		File file = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path(
				"testdata/pages/test-products-218.html"));
		Reader in = new FileReader(file);
		List<String> productList = new ArrayList<String>();
		productList = new ProductParser(in).getProducts(repository);

		Iterator<String> itr = productList.iterator();
		assertTrue(itr.hasNext());
		assertEquals("AJDT", "AJDT", itr.next());
		assertEquals("ALF", "ALF", itr.next());
		assertEquals("AspectJ", "AspectJ", itr.next());
		assertEquals("BIRT", "BIRT", itr.next());
	}

	public void testFullReportBugNoBug() throws Exception {

		BugzillaPlugin.getDefault().getPluginPreferences().setValue(IBugzillaConstants.SERVER_VERSION,
				IBugzillaConstants.SERVER_218);

		File file = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path(
				"testdata/pages/product-page.html"));
		Reader in = new FileReader(file);
		List<String> productList = new ArrayList<String>();
		productList = new ProductParser(in).getProducts(repository);

		Iterator<String> itr = productList.iterator();
		assertTrue(itr.hasNext());
		assertEquals("AJDT", "AJDT", itr.next());
		assertEquals("ALF", "ALF", itr.next());
		assertEquals("AspectJ", "AspectJ", itr.next());
		assertEquals("BIRT", "BIRT", itr.next());

		// assertEquals("CME", "CME", itr.next());
		// assertEquals("ECESIS", "ECESIS", itr.next());
		// assertEquals("EMF", "EMF", itr.next());
		// assertEquals("Equinox", "Equinox", itr.next());
		// assertEquals("GEF", "GEF", itr.next());
		// assertEquals("GMT", "GMT", itr.next());
		// assertEquals("Hyades", "Hyades", itr.next());
		// assertEquals("JDT", "JDT", itr.next());
		// assertEquals("PDE", "PDE", itr.next());
		// assertEquals("Platform", "Platform", itr.next());
		// assertEquals("Stellation", "Stellation", itr.next());
		// assertEquals("UML2", "UML2", itr.next());
		// assertEquals("VE", "VE", itr.next());
		// assertEquals("WSVT", "WSVT", itr.next());
		// assertEquals("XSD", "XSD", itr.next());
		// }
	}
}

Back to the top