diff options
Diffstat (limited to 'org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote')
21 files changed, 60 insertions, 23 deletions
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ContentServletTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ContentServletTest.java index 1ad0dd1be..b6aa0acb6 100644 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ContentServletTest.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ContentServletTest.java @@ -21,12 +21,14 @@ public class ContentServletTest extends TestCase { private static final String UA_TESTS = "org.eclipse.ua.tests"; private int mode; + @Override protected void setUp() throws Exception { BaseHelpSystem.ensureWebappRunning(); mode = BaseHelpSystem.getMode(); BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER); } + @Override protected void tearDown() throws Exception { BaseHelpSystem.setMode(mode); } diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ContextServletTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ContextServletTest.java index 16bb41b58..f6d22f2f9 100644 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ContextServletTest.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ContextServletTest.java @@ -39,12 +39,14 @@ public class ContextServletTest extends TestCase { private int mode; + @Override protected void setUp() throws Exception { BaseHelpSystem.ensureWebappRunning(); mode = BaseHelpSystem.getMode(); BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER); } + @Override protected void tearDown() throws Exception { BaseHelpSystem.setMode(mode); } diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/GetContentUsingRemoteHelp.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/GetContentUsingRemoteHelp.java index f806b9326..57d3958dc 100644 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/GetContentUsingRemoteHelp.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/GetContentUsingRemoteHelp.java @@ -40,6 +40,7 @@ public class GetContentUsingRemoteHelp extends TestCase { private int mode; + @Override protected void setUp() throws Exception { BaseHelpSystem.ensureWebappRunning(); mode = BaseHelpSystem.getMode(); @@ -50,6 +51,7 @@ public class GetContentUsingRemoteHelp extends TestCase { HelpPlugin.getTocManager().getTocs("en"); } + @Override protected void tearDown() throws Exception { RemotePreferenceStore.restorePreferences(); BaseHelpSystem.setMode(mode); diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/GetContextUsingRemoteHelp.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/GetContextUsingRemoteHelp.java index 2a6cc2dce..b4154052f 100644 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/GetContextUsingRemoteHelp.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/GetContextUsingRemoteHelp.java @@ -23,6 +23,7 @@ public class GetContextUsingRemoteHelp extends TestCase { private int mode; + @Override protected void setUp() throws Exception { RemotePreferenceStore.savePreferences(); mode = BaseHelpSystem.getMode(); @@ -30,6 +31,7 @@ public class GetContextUsingRemoteHelp extends TestCase { BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER); } + @Override protected void tearDown() throws Exception { RemotePreferenceStore.restorePreferences(); BaseHelpSystem.setMode(mode); diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/IndexServletTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/IndexServletTest.java index 2f4c41d79..3e9f66a9b 100644 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/IndexServletTest.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/IndexServletTest.java @@ -34,12 +34,14 @@ public class IndexServletTest extends TestCase { private int mode; + @Override protected void setUp() throws Exception { BaseHelpSystem.ensureWebappRunning(); mode = BaseHelpSystem.getMode(); BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER); } + @Override protected void tearDown() throws Exception { BaseHelpSystem.setMode(mode); } diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/JettyTestServer.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/JettyTestServer.java index e09bbeb21..c1c58b5d0 100644 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/JettyTestServer.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/JettyTestServer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 IBM Corporation and others. + * Copyright (c) 2009, 2015 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 @@ -20,10 +20,12 @@ import org.osgi.framework.ServiceReference; public class JettyTestServer extends JettyHelpServer { + @Override protected String getOtherInfo() { return "org.eclipse.ua.tests"; } + @Override protected int getPortParameter() { return AUTO_SELECT_JETTY_PORT; } @@ -32,6 +34,7 @@ public class JettyTestServer extends JettyHelpServer { * Ensures that the bundle with the specified name and the highest available * version is started and reads the port number */ + @Override protected void checkBundle() throws InvalidSyntaxException, BundleException { Bundle bundle = Platform.getBundle("org.eclipse.equinox.http.registry"); //$NON-NLS-1$if (bundle != null) { if (bundle.getState() == Bundle.RESOLVED) { @@ -39,7 +42,7 @@ public class JettyTestServer extends JettyHelpServer { } if (port == -1) { // Jetty selected a port number for us - ServiceReference[] reference = bundle.getBundleContext().getServiceReferences("org.osgi.service.http.HttpService", "(other.info=" + getOtherInfo() + ')'); //$NON-NLS-1$ //$NON-NLS-2$ + ServiceReference<?>[] reference = bundle.getBundleContext().getServiceReferences("org.osgi.service.http.HttpService", "(other.info=" + getOtherInfo() + ')'); //$NON-NLS-1$ //$NON-NLS-2$ Object assignedPort = reference[reference.length - 1].getProperty("http.port"); //$NON-NLS-1$ port = Integer.parseInt((String)assignedPort); } diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/LoadIndexUsingRemoteHelp.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/LoadIndexUsingRemoteHelp.java index 7715a6982..4c33b7993 100644 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/LoadIndexUsingRemoteHelp.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/LoadIndexUsingRemoteHelp.java @@ -25,12 +25,14 @@ public class LoadIndexUsingRemoteHelp extends TestCase { private int mode; + @Override protected void setUp() throws Exception { RemotePreferenceStore.savePreferences(); mode = BaseHelpSystem.getMode(); BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER); } + @Override protected void tearDown() throws Exception { RemotePreferenceStore.restorePreferences(); BaseHelpSystem.setMode(mode); @@ -72,9 +74,9 @@ public class LoadIndexUsingRemoteHelp extends TestCase { private IIndexEntry[] matchingEntries(IIndex index, String keyword) { List<IIndexEntry> matches = new ArrayList<IIndexEntry>(); IIndexEntry[] entries = index.getEntries(); - for (int i = 0; i < entries.length; i++) { - if (keyword.equals(entries[i].getKeyword())) { - matches.add(entries[i]); + for (IIndexEntry entrie : entries) { + if (keyword.equals(entrie.getKeyword())) { + matches.add(entrie); } } return matches.toArray(new IIndexEntry[matches.size()]); diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/LoadTocUsingRemoteHelp.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/LoadTocUsingRemoteHelp.java index 764102076..44bb38ac6 100644 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/LoadTocUsingRemoteHelp.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/LoadTocUsingRemoteHelp.java @@ -21,11 +21,13 @@ public class LoadTocUsingRemoteHelp extends TestCase { private int mode; + @Override protected void setUp() throws Exception { RemotePreferenceStore.savePreferences(); mode = BaseHelpSystem.getMode(); } + @Override protected void tearDown() throws Exception { RemotePreferenceStore.restorePreferences(); BaseHelpSystem.setMode(mode); @@ -80,8 +82,8 @@ public class LoadTocUsingRemoteHelp extends TestCase { */ private int matchingTocs(Toc[] tocs, String label) { int result = 0; - for (int i = 0; i < tocs.length; i++) { - if (label.equals(tocs[i].getLabel())) { + for (Toc toc : tocs) { + if (label.equals(toc.getLabel())) { result += 1; } } diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/MockContentServlet.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/MockContentServlet.java index b07248ee7..87683db5a 100644 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/MockContentServlet.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/MockContentServlet.java @@ -29,6 +29,7 @@ public class MockContentServlet extends HttpServlet { * Return a create page based on the path and locale unless the path * starts with "/invalid" in which case return an I/O error */ + @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String locale = UrlUtil.getLocale(req, resp); diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/MockContextServlet.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/MockContextServlet.java index 49100a4fb..795e56e26 100644 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/MockContextServlet.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/MockContextServlet.java @@ -21,6 +21,7 @@ public class MockContextServlet extends ContextServlet { private static final String ORG_ECLIPSE_UA_TESTS_TEST = "org.eclipse.ua.tests.test"; private static final long serialVersionUID = 3615294041471900830L; + @Override protected IContext getContext(String locale, String id) { if (id.startsWith(ORG_ECLIPSE_UA_TESTS_TEST)) { String suffix = id.substring(ORG_ECLIPSE_UA_TESTS_TEST.length()); diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/MockIndexServlet.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/MockIndexServlet.java index 6f7d67605..299166c85 100644 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/MockIndexServlet.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/MockIndexServlet.java @@ -30,6 +30,7 @@ public class MockIndexServlet extends IndexServlet { private static final long serialVersionUID = -930969620357059313L; + @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String locale = UrlUtil.getLocale(req, resp); diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/MockSearchServlet.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/MockSearchServlet.java index e38d6227c..7e13964ca 100644 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/MockSearchServlet.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/MockSearchServlet.java @@ -28,6 +28,7 @@ public class MockSearchServlet extends HttpServlet { private static final long serialVersionUID = -5115067950875335923L; + @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String phrase = req.getParameter("phrase"); diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/MockTocServlet.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/MockTocServlet.java index d9f1b211d..70ff37ea7 100644 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/MockTocServlet.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/MockTocServlet.java @@ -29,6 +29,7 @@ public class MockTocServlet extends TocServlet { private static final long serialVersionUID = 2934062693291854845L; + @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String locale = UrlUtil.getLocale(req, resp); diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ParallelSearchServletTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ParallelSearchServletTest.java index e8219d8dc..01857aae7 100644 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ParallelSearchServletTest.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ParallelSearchServletTest.java @@ -38,12 +38,14 @@ public class ParallelSearchServletTest extends TestCase { private int mode; + @Override protected void setUp() throws Exception { BaseHelpSystem.ensureWebappRunning(); mode = BaseHelpSystem.getMode(); BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER); } + @Override protected void tearDown() throws Exception { BaseHelpSystem.setMode(mode); } @@ -57,6 +59,7 @@ public class ParallelSearchServletTest extends TestCase { this.expectedHits = expectedHits; } + @Override public String runTest() throws Exception { Node[] hits = getSearchHitsFromServlet(phrase); if (hits.length != expectedHits) { diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ParallelSearchUsingRemote.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ParallelSearchUsingRemote.java index e8eaa315c..5d4ab8ef5 100644 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ParallelSearchUsingRemote.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ParallelSearchUsingRemote.java @@ -22,6 +22,7 @@ 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 @@ -37,11 +38,13 @@ public class ParallelSearchUsingRemote extends TestCase { 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); diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/RemotePreferenceTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/RemotePreferenceTest.java index 59320f1fd..e33874ea1 100644 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/RemotePreferenceTest.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/RemotePreferenceTest.java @@ -27,10 +27,12 @@ public class RemotePreferenceTest extends TestCase { prefs.put(name, value); } + @Override protected void setUp() throws Exception { RemotePreferenceStore.savePreferences(); } + @Override protected void tearDown() throws Exception { RemotePreferenceStore.restorePreferences(); } diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchIndexCreation.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchIndexCreation.java index e9f9c3fde..9bb23b494 100644 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchIndexCreation.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchIndexCreation.java @@ -27,6 +27,7 @@ public class SearchIndexCreation extends TestCase { private int mode; private AnalyzerDescriptor analyzerDesc; + @Override protected void setUp() throws Exception { BaseHelpSystem.ensureWebappRunning(); mode = BaseHelpSystem.getMode(); @@ -38,6 +39,7 @@ public class SearchIndexCreation extends TestCase { analyzerDesc = new AnalyzerDescriptor("en-us"); } + @Override protected void tearDown() throws Exception { RemotePreferenceStore.restorePreferences(); BaseHelpSystem.setMode(mode); diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchServletTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchServletTest.java index 4cc36c1dc..b724b326a 100755 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchServletTest.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchServletTest.java @@ -38,12 +38,14 @@ public class SearchServletTest extends TestCase { private int mode; + @Override protected void setUp() throws Exception { BaseHelpSystem.ensureWebappRunning(); mode = BaseHelpSystem.getMode(); BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER); } + @Override protected void tearDown() throws Exception { BaseHelpSystem.setMode(mode); } diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchUsingRemoteHelp.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchUsingRemoteHelp.java index 017a457df..cf1296749 100644 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchUsingRemoteHelp.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchUsingRemoteHelp.java @@ -20,11 +20,13 @@ public class SearchUsingRemoteHelp extends TestCase { private int mode; + @Override protected void setUp() throws Exception { RemotePreferenceStore.savePreferences(); mode = BaseHelpSystem.getMode(); } + @Override protected void tearDown() throws Exception { RemotePreferenceStore.restorePreferences(); BaseHelpSystem.setMode(mode); diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/TocManagerTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/TocManagerTest.java index 31b829c01..d9f9ac50e 100644 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/TocManagerTest.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/TocManagerTest.java @@ -24,6 +24,7 @@ public class TocManagerTest extends TestCase { private int mode; + @Override protected void setUp() throws Exception { BaseHelpSystem.ensureWebappRunning(); mode = BaseHelpSystem.getMode(); @@ -31,6 +32,7 @@ public class TocManagerTest extends TestCase { BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER); } + @Override protected void tearDown() throws Exception { BaseHelpSystem.setMode(mode); RemotePreferenceStore.restorePreferences(); @@ -59,13 +61,12 @@ public class TocManagerTest extends TestCase { RemotePreferenceStore.setMockLocalPriority(); HelpPlugin.getTocManager().clearCache(); AbstractTocProvider [] tocProviders = HelpPlugin.getTocManager().getTocProviders(); - for(int i=0;i<tocProviders.length;i++) - { - if(tocProviders[i] instanceof TocFileProvider) - localPriority = tocProviders[i].getPriority(); + for (AbstractTocProvider tocProvider : tocProviders) { + if(tocProvider instanceof TocFileProvider) + localPriority = tocProvider.getPriority(); - if(tocProviders[i] instanceof RemoteTocProvider) - remotePriority = tocProviders[i].getPriority(); + if(tocProvider instanceof RemoteTocProvider) + remotePriority = tocProvider.getPriority(); } assertTrue(localPriority<remotePriority); @@ -79,13 +80,12 @@ public class TocManagerTest extends TestCase { int localPriority=0,remotePriority=0; AbstractTocProvider [] tocProviders = HelpPlugin.getTocManager().getTocProviders(); - for(int i=0;i<tocProviders.length;i++) - { - if(tocProviders[i] instanceof TocFileProvider) - localPriority = tocProviders[i].getPriority(); + for (AbstractTocProvider tocProvider : tocProviders) { + if(tocProvider instanceof TocFileProvider) + localPriority = tocProvider.getPriority(); - if(tocProviders[i] instanceof RemoteTocProvider) - remotePriority = tocProviders[i].getPriority(); + if(tocProvider instanceof RemoteTocProvider) + remotePriority = tocProvider.getPriority(); } assertTrue(remotePriority<localPriority); @@ -95,12 +95,11 @@ public class TocManagerTest extends TestCase { { HashSet<String> contributionsFound = new HashSet<String>(); - for(int i=0;i<tocContributions.length;i++) - { - if(contributionsFound.contains(tocContributions[i].getId())) + for (TocContribution tocContribution : tocContributions) { + if(contributionsFound.contains(tocContribution.getId())) return true; else - contributionsFound.add(tocContributions[i].getId()); + contributionsFound.add(tocContribution.getId()); } return false; diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/TocServletTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/TocServletTest.java index bd1fe780a..3ff00b139 100644 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/TocServletTest.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/TocServletTest.java @@ -34,12 +34,14 @@ public class TocServletTest extends TestCase { private int mode; + @Override protected void setUp() throws Exception { BaseHelpSystem.ensureWebappRunning(); mode = BaseHelpSystem.getMode(); BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER); } + @Override protected void tearDown() throws Exception { BaseHelpSystem.setMode(mode); } |