Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 5d4ab8ef54beaabde0dcfd8cab6bd78aab87df58 (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
/*******************************************************************************
 * Copyright (c) 2010 IBM Corporation 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:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.ua.tests.help.remote;

import org.eclipse.help.internal.base.BaseHelpSystem;
import org.eclipse.ua.tests.help.search.SearchTestUtils;
import org.eclipse.ua.tests.help.util.ParallelTestSupport;

import junit.framework.TestCase;

public class ParallelSearchUsingRemote extends TestCase {
	
	private class Searcher implements ParallelTestSupport.ITestCase {
	
	private int count = 0;
		@Override
		public String runTest() throws Exception {
			count++;
			return SearchTestUtils.searchForExpectedResults
					(searchWords[count%3], expectedResults[count%3], "en");
		}	
	}
	
	private int mode;
	private String[] searchWords = new String[] {"endfdsadsads", "dedfdsadsads", "jehcyqpfjs" };
	private String[][] expectedResults = new String[][] { 
			new String[] { "http://www.eclipse.org" },
			new String[0],
			new String[] { "/org.eclipse.ua.tests/data/help/search/test1.xhtml" }
	}; 

	@Override
	protected void setUp() throws Exception {
        RemotePreferenceStore.savePreferences();
        mode = BaseHelpSystem.getMode();
	}
	
	@Override
	protected void tearDown() throws Exception {
		RemotePreferenceStore.restorePreferences();
		BaseHelpSystem.setMode(mode);
	}

	public void testSearchOnOneThreadWithRemote() throws Exception {
		BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
		RemotePreferenceStore.setMockRemoteServer();
		ParallelTestSupport.testSingleCase(new Searcher(), 100);
	    RemotePreferenceStore.disableRemoteHelp();
	}

	public void testSearchInParallelWithRemote() throws Exception {
		BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
		RemotePreferenceStore.setMockRemoteServer();
		ParallelTestSupport.ITestCase[] testCases = new Searcher[3];
		for (int i = 0; i < 3; i++) {
			testCases[i] = new Searcher();
		}
		ParallelTestSupport.testInParallel(testCases, 100);
	    RemotePreferenceStore.disableRemoteHelp();
	}

}

Back to the top