blob: 5d4ab8ef54beaabde0dcfd8cab6bd78aab87df58 [file] [log] [blame]
/*******************************************************************************
* 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();
}
}