diff options
author | Markus Keller | 2015-01-15 20:47:42 +0000 |
---|---|---|
committer | Markus Keller | 2015-01-15 20:47:42 +0000 |
commit | 01d2aec6ff87feab0e11e6b8d5eae44d5bc548c7 (patch) | |
tree | eb33aee33f34987851b7cb19c74abafa56f2b28f /org.eclipse.ua.tests/intro/org | |
parent | a8649f0ddf43acb7b6b732a1c8e5d2c5eeda5a87 (diff) | |
download | eclipse.platform.ua-01d2aec6ff87feab0e11e6b8d5eae44d5bc548c7.tar.gz eclipse.platform.ua-01d2aec6ff87feab0e11e6b8d5eae44d5bc548c7.tar.xz eclipse.platform.ua-01d2aec6ff87feab0e11e6b8d5eae44d5bc548c7.zip |
Move to JavaSE-1.6 (triggered by bug 457396)I20150203-1300I20150203-0800I20150129-1830I20150128-2000I20150128-0900I20150127-2000I20150127-0900I20150126-2000I20150126-0930I20150126-0800I20150125-2000I20150120-0800I20150116-1000
Diffstat (limited to 'org.eclipse.ua.tests/intro/org')
6 files changed, 76 insertions, 76 deletions
diff --git a/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/anchors/ExtensionReorderingTest.java b/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/anchors/ExtensionReorderingTest.java index 9f1cdb198..a22e4848b 100644 --- a/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/anchors/ExtensionReorderingTest.java +++ b/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/anchors/ExtensionReorderingTest.java @@ -90,8 +90,8 @@ public class ExtensionReorderingTest extends TestCase { private String toString(int[] order) { String result = ""; - for (int i = 0; i < order.length; i++) { - result = result + order[i]; + for (int element : order) { + result = result + element; } return result; } @@ -149,12 +149,12 @@ public class ExtensionReorderingTest extends TestCase { // find all configs with given attribute and attribute value. Vector<IConfigurationElement> elements = new Vector<IConfigurationElement>(); - for (int i = 0; i < configElements.length; i++) { - String currentAttributeValue = configElements[i] + for (IConfigurationElement configElement : configElements) { + String currentAttributeValue = configElement .getAttribute(attributeName); if (currentAttributeValue != null && currentAttributeValue.equals(attributeValue)) - elements.add(configElements[i]); + elements.add(configElement); } // now return array. diff --git a/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/contentdetect/ContentDetectorTest.java b/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/contentdetect/ContentDetectorTest.java index 841a792eb..1c99fcd17 100644 --- a/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/contentdetect/ContentDetectorTest.java +++ b/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/contentdetect/ContentDetectorTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2012 IBM Corporation and others. + * Copyright (c) 2007, 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 @@ -18,7 +18,6 @@ import junit.framework.Test; import junit.framework.TestCase; import org.eclipse.test.OrderedTestSuite; - import org.eclipse.ui.internal.intro.impl.model.ExtensionMap; import org.eclipse.ui.internal.intro.universal.contentdetect.ContentDetectHelper; import org.eclipse.ui.internal.intro.universal.contentdetect.ContentDetector; @@ -62,8 +61,7 @@ public class ContentDetectorTest extends TestCase { contributors.add("two"); contributors.add("three"); helper.saveContributors(contributors); - @SuppressWarnings("unchecked") - Set<String> savedContributors = helper.getContributors(); + Set<?> savedContributors = helper.getContributors(); assertTrue(savedContributors.size() == 3); assertTrue(savedContributors.contains("one")); assertTrue(savedContributors.contains("two")); @@ -81,7 +79,7 @@ public class ContentDetectorTest extends TestCase { previous.add("five"); previous.add("two"); previous.add("one"); - Set newContributors = helper.findNewContributors(contributors, previous); + Set<?> newContributors = helper.findNewContributors(contributors, previous); assertTrue(newContributors.size() == 2); assertTrue(newContributors.contains("four")); assertTrue(newContributors.contains("three")); @@ -94,7 +92,7 @@ public class ContentDetectorTest extends TestCase { assertEquals(ContentDetectHelper.NO_STATE, helper.getExtensionCount()); ContentDetector detector = new ContentDetector(); assertFalse(detector.isNewContentAvailable()); - Set newContent = ContentDetector.getNewContributors(); + Set<?> newContent = ContentDetector.getNewContributors(); assertTrue(newContent == null || newContent.size() == 0); String firstContribution = (String) helper.getContributors().iterator().next(); assertFalse(ContentDetector.isNew(firstContribution)); @@ -113,9 +111,8 @@ public class ContentDetectorTest extends TestCase { assertFalse(detector.isNewContentAvailable()); // Make the first extension appear new helper.saveExtensionCount(extensionCount - 1); - @SuppressWarnings("unchecked") - Set<String> contributors = helper.getContributors(); - String firstContribution = contributors.iterator().next(); + Set<?> contributors = helper.getContributors(); + String firstContribution = (String) contributors.iterator().next(); String copyOfFirstContribution = "" + firstContribution; contributors.remove(firstContribution); helper.saveContributors(contributors); @@ -159,6 +156,7 @@ public class ContentDetectorTest extends TestCase { assertNull(map.getStartPage()); } + @Override protected void finalize() throws Throwable { // Delete state files so that if we start Eclipse we don't see all content as new ContentDetectHelper helper = new ContentDetectHelper(); diff --git a/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/parser/ValidTest.java b/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/parser/ValidTest.java index d39e3b636..bc571d3dc 100644 --- a/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/parser/ValidTest.java +++ b/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/parser/ValidTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2013 IBM Corporation and others. + * Copyright (c) 2005, 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 @@ -13,25 +13,23 @@ package org.eclipse.ua.tests.intro.parser; import java.io.IOException; import java.util.Iterator; import java.util.Map; +import java.util.Map.Entry; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; -import org.junit.Assert; -import org.osgi.framework.Bundle; - +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.Platform; import org.eclipse.help.ui.internal.HelpUIPlugin; import org.eclipse.ua.tests.intro.util.IntroModelSerializer; import org.eclipse.ua.tests.intro.util.IntroModelSerializerTest; import org.eclipse.ua.tests.plugin.UserAssistanceTestPlugin; import org.eclipse.ua.tests.util.FileUtil; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.Platform; - import org.eclipse.ui.internal.intro.impl.model.IntroModelRoot; import org.eclipse.ui.internal.intro.impl.model.loader.ExtensionPointManager; +import org.junit.Assert; +import org.osgi.framework.Bundle; /* * Tests the intro parser on valid intro content. @@ -49,6 +47,7 @@ public class ValidTest extends TestCase { * Ensure that org.eclipse.help.ui is started. It contributes extra content * filtering that is used by this test. See UIContentFilterProcessor. */ + @Override protected void setUp() throws Exception { HelpUIPlugin.getDefault(); } @@ -81,13 +80,13 @@ public class ValidTest extends TestCase { */ private void singleConfigTest(String configId) throws IOException { IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.ui.intro.config"); - for (int i=0;i<elements.length;++i) { + for (IConfigurationElement element : elements) { /* * Only use the ones from this test plugin. */ - if (elements[i].getDeclaringExtension().getContributor().getName().equals(UserAssistanceTestPlugin.getDefault().getBundle().getSymbolicName())) { - String content = elements[i].getAttribute("content"); - String id = elements[i].getAttribute("id"); + if (element.getDeclaringExtension().getContributor().getName().equals(UserAssistanceTestPlugin.getDefault().getBundle().getSymbolicName())) { + String content = element.getAttribute("content"); + String id = element.getAttribute("id"); if (id.equals(configId)) { for (int x = 0; x < 10; x++) { // Perform 10 times to better detect intermittent ordering bugs @@ -100,14 +99,14 @@ public class ValidTest extends TestCase { String actual = serializer.toString(); Assert.assertEquals("The model parsed for intro did not match the expected result for: " + id, expected, actual); - Map map = IntroModelSerializerTest.getXHTMLFiles(model); - Iterator iter = map.entrySet().iterator(); + Map<String, String> map = IntroModelSerializerTest.getXHTMLFiles(model); + Iterator<Entry<String, String>> iter = map.entrySet().iterator(); while (iter.hasNext()) { - Map.Entry entry = (Map.Entry)iter.next(); - String relativePath = (String)entry.getKey(); + Entry<String, String> entry = iter.next(); + String relativePath = entry.getKey(); expected = FileUtil.getContents(bundle, FileUtil.getResultFile(relativePath)); - actual = (String)entry.getValue(); + actual = entry.getValue(); Assert.assertEquals("The XHTML generated for intro did not match the expected result for: " + relativePath, expected, actual); } } diff --git a/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/performance/OpenIntroTest.java b/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/performance/OpenIntroTest.java index 3173e8ff9..3637c142c 100644 --- a/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/performance/OpenIntroTest.java +++ b/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/performance/OpenIntroTest.java @@ -36,6 +36,7 @@ public class OpenIntroTest extends PerformanceTestCase { /* (non-Javadoc) * @see org.eclipse.test.performance.PerformanceTestCase#setUp() */ + @Override protected void setUp() throws Exception { super.setUp(); closeIntro(); @@ -47,6 +48,7 @@ public class OpenIntroTest extends PerformanceTestCase { /* (non-Javadoc) * @see org.eclipse.test.performance.PerformanceTestCase#tearDown() */ + @Override protected void tearDown() throws Exception { super.tearDown(); closeIntro(); diff --git a/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/util/IntroModelSerializer.java b/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/util/IntroModelSerializer.java index 8f449f3dc..3b8a1ea2e 100644 --- a/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/util/IntroModelSerializer.java +++ b/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/util/IntroModelSerializer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2011 IBM Corporation and others. + * Copyright (c) 2004, 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 @@ -104,29 +104,28 @@ public class IntroModelSerializer { printPageStyles(rootPage, text); } - @SuppressWarnings("unchecked") private void printPageStyles(AbstractIntroPage page, StringBuffer text) { text.append("\n\tpage styles are = "); //$NON-NLS-1$ String[] styles = page.getStyles(); - for (int i = 0; i < styles.length; i++) - text.append(filterURL(styles[i] + "\n\t\t\t")); //$NON-NLS-1$ + for (String style : styles) + text.append(filterURL(style + "\n\t\t\t")); //$NON-NLS-1$ text.append("\n\tpage alt-styles are = "); //$NON-NLS-1$ - final Hashtable altStylesHashtable = page.getAltStyles(); + final Hashtable<String, Bundle> altStylesHashtable = page.getAltStyles(); if (altStylesHashtable == null) return; - Set set = altStylesHashtable.keySet(); + Set<String> set = altStylesHashtable.keySet(); String[] sorted = new String[set.size()]; set.toArray(sorted); for (int i=0;i<sorted.length;++i) { - Bundle bundle = (Bundle) altStylesHashtable.get(sorted[i]); + Bundle bundle = altStylesHashtable.get(sorted[i]); sorted[i] = filterURL(sorted[i]) + " from " + bundle.getSymbolicName(); //$NON-NLS-1$ } Arrays.sort(sorted); - for (int i=0;i<sorted.length;++i) { - text.append(sorted[i] + "\n\t\t"); //$NON-NLS-1$ + for (String element : sorted) { + text.append(element + "\n\t\t"); //$NON-NLS-1$ } } @@ -142,41 +141,41 @@ public class IntroModelSerializer { StringBuffer text, String indent) { AbstractIntroElement[] children = container.getChildren(); - for (int i = 0; i < children.length; i++) { - int childType = children[i].getType(); + for (AbstractIntroElement element : children) { + int childType = element.getType(); switch (childType) { case AbstractIntroElement.ELEMENT: text.append("SHOULD NEVER BE HERE"); //$NON-NLS-1$ break; case AbstractIntroElement.GROUP: - printGroup(text, (IntroGroup) children[i], indent); + printGroup(text, (IntroGroup) element, indent); break; case AbstractIntroElement.LINK: - printLink(text, (IntroLink) children[i], indent); + printLink(text, (IntroLink) element, indent); break; case AbstractIntroElement.TEXT: - printText(text, (IntroText) children[i], indent); + printText(text, (IntroText) element, indent); break; case AbstractIntroElement.IMAGE: - printImage(text, (IntroImage) children[i], indent); + printImage(text, (IntroImage) element, indent); break; case AbstractIntroElement.HTML: - printHtml(text, (IntroHTML) children[i], indent); + printHtml(text, (IntroHTML) element, indent); break; case AbstractIntroElement.INCLUDE: - printInclude(text, (IntroInclude) children[i], indent); + printInclude(text, (IntroInclude) element, indent); break; case AbstractIntroElement.HEAD: - printHead(text, (IntroHead) children[i], indent); + printHead(text, (IntroHead) element, indent); break; case AbstractIntroElement.PAGE_TITLE: - printPageTitle(text, (IntroPageTitle) children[i], indent); + printPageTitle(text, (IntroPageTitle) element, indent); break; case AbstractIntroElement.ANCHOR: - printAnchor(text, (IntroAnchor) children[i], indent); + printAnchor(text, (IntroAnchor) element, indent); break; case AbstractIntroElement.CONTENT_PROVIDER: - printContentProvidor(text, (IntroContentProvider) children[i], + printContentProvidor(text, (IntroContentProvider) element, indent); break; @@ -272,15 +271,15 @@ public class IntroModelSerializer { * @param text */ private void printPages(IntroPage[] pages, StringBuffer text) { - for (int i = 0; i < pages.length; i++) { - text.append("\n\nPAGE id = " + pages[i].getId()); //$NON-NLS-1$ + for (IntroPage page : pages) { + text.append("\n\nPAGE id = " + page.getId()); //$NON-NLS-1$ text.append("\n----------"); //$NON-NLS-1$ - text.append("\n\ttitle = " + pages[i].getTitle()); //$NON-NLS-1$ - text.append("\n\tstyle = " + filterURL(pages[i].getStyle())); //$NON-NLS-1$ - text.append("\n\talt-style = " + filterURL(pages[i].getAltStyle())); //$NON-NLS-1$ - text.append("\n\tstyle-id = " + pages[i].getStyleId()); //$NON-NLS-1$ - printPageStyles(pages[i], text); - printPageChildren(pages[i], text); + text.append("\n\ttitle = " + page.getTitle()); //$NON-NLS-1$ + text.append("\n\tstyle = " + filterURL(page.getStyle())); //$NON-NLS-1$ + text.append("\n\talt-style = " + filterURL(page.getAltStyle())); //$NON-NLS-1$ + text.append("\n\tstyle-id = " + page.getStyleId()); //$NON-NLS-1$ + printPageStyles(page, text); + printPageChildren(page, text); } } @@ -353,7 +352,8 @@ public class IntroModelSerializer { /** * @return Returns the textUI. */ - public String toString() { + @Override + public String toString() { return buffer.toString(); } } diff --git a/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/util/IntroModelSerializerTest.java b/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/util/IntroModelSerializerTest.java index 417505d8b..0a167ac0a 100644 --- a/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/util/IntroModelSerializerTest.java +++ b/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/util/IntroModelSerializerTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2011 IBM Corporation and others. + * Copyright (c) 2005, 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 @@ -69,6 +69,7 @@ public class IntroModelSerializerTest extends TestCase { * content filtering that is used by this test. See * UIContentFilterProcessor. */ + @Override protected void setUp() throws Exception { HelpUIPlugin.getDefault(); } @@ -78,14 +79,14 @@ public class IntroModelSerializerTest extends TestCase { * Serialize the test intros. */ IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.ui.intro.config"); - for (int i=0;i<elements.length;++i) { + for (IConfigurationElement element : elements) { /* * Only use the ones from this test plugin. */ - if (elements[i].getDeclaringExtension().getContributor().getName().equals(UserAssistanceTestPlugin.getDefault().getBundle().getSymbolicName())) { + if (element.getDeclaringExtension().getContributor().getName().equals(UserAssistanceTestPlugin.getDefault().getBundle().getSymbolicName())) { String pluginRoot = UserAssistanceTestPlugin.getDefault().getBundle().getLocation().substring("update@".length()); - String content = elements[i].getAttribute("content"); - String id = elements[i].getAttribute("id"); + String content = element.getAttribute("content"); + String id = element.getAttribute("id"); /* * First do the intro XML files. @@ -102,13 +103,13 @@ public class IntroModelSerializerTest extends TestCase { * Now do the intro XHTML files. Find all the XHTML files * referenced from the model. */ - Map map = getXHTMLFiles(model); - Iterator iter = map.entrySet().iterator(); + Map<String, String> map = getXHTMLFiles(model); + Iterator<Map.Entry<String, String>> iter = map.entrySet().iterator(); while (iter.hasNext()) { - Map.Entry entry = (Map.Entry)iter.next(); + Map.Entry<String, String> entry = iter.next(); file = FileUtil.getResultFile(pluginRoot + entry.getKey()); out = new PrintWriter(new FileOutputStream(file)); - out.print((String)entry.getValue()); + out.print(entry.getValue()); out.close(); } } @@ -121,18 +122,17 @@ public class IntroModelSerializerTest extends TestCase { * mapping of filenames relative to the test plugin to Strings, the * contents of the XHTML files. */ - @SuppressWarnings("unchecked") - public static Map getXHTMLFiles(IntroModelRoot model) { - Map map = new HashMap(); + public static Map<String, String> getXHTMLFiles(IntroModelRoot model) { + Map<String, String> map = new HashMap<String, String>(); Collection<AbstractIntroPage> pages = new ArrayList<AbstractIntroPage>(); IntroHomePage home = model.getRootPage(); if (home.isXHTMLPage()) { pages.add(home); } IntroPage[] otherPages = model.getPages(); - for (int i=0;i<otherPages.length;++i) { - if (otherPages[i].isXHTMLPage()) { - pages.add(otherPages[i]); + for (IntroPage otherPage : otherPages) { + if (otherPage.isXHTMLPage()) { + pages.add(otherPage); } } Iterator<AbstractIntroPage> iter = pages.iterator(); @@ -140,6 +140,7 @@ public class IntroModelSerializerTest extends TestCase { AbstractIntroPage page = iter.next(); BrowserIntroPartImplementation impl = new BrowserIntroPartImplementation(); String xhtml = impl.generateXHTMLPage(page, new IIntroContentProviderSite() { + @Override public void reflow(IIntroContentProvider provider, boolean incremental) { // dummy site } |