summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManju Mathew2013-02-05 08:29:05 (EST)
committerDani Megert2013-02-05 08:29:05 (EST)
commitf747cca80cf934d4f9777294b175eebb3d262fc4 (patch)
tree4f55e14909201dc86c4c5d8cd15f492b7e6777eb
parent7a7a7b54f02ab46df5eae936f5b63cfb9cc5d8fd (diff)
downloadeclipse.jdt.ui-f747cca80cf934d4f9777294b175eebb3d262fc4.zip
eclipse.jdt.ui-f747cca80cf934d4f9777294b175eebb3d262fc4.tar.gz
eclipse.jdt.ui-f747cca80cf934d4f9777294b175eebb3d262fc4.tar.bz2
Fixed test that fails when there is no internet connection
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageHover/PackageJavadocTests.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageHover/PackageJavadocTests.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageHover/PackageJavadocTests.java
index 623b6ec..71bea2c 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageHover/PackageJavadocTests.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageHover/PackageJavadocTests.java
@@ -11,6 +11,7 @@
package org.eclipse.jdt.ui.tests.packageHover;
import java.io.File;
+import java.net.URL;
import junit.framework.Assert;
import junit.framework.Test;
@@ -36,6 +37,7 @@ import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.internal.core.JavaElement;
+import org.eclipse.jdt.internal.corext.CorextMessages;
import org.eclipse.jdt.ui.tests.core.CoreTests;
import org.eclipse.jdt.ui.tests.core.ProjectTestSetup;
@@ -221,7 +223,14 @@ public class PackageJavadocTests extends CoreTests {
String actualHtmlContent= hoverInfo.getHtml();
Assert.assertNotNull(actualHtmlContent);
- Assert.assertTrue(actualHtmlContent.contains("Provides classes for performing arbitrary-precision integer arithmetic"));
+ try {
+ //trying to connect to the internet. Exception will be thrown if there is no net connection.
+ new URL("url:http://download.oracle.com/").openConnection().connect();
+ Assert.assertTrue(actualHtmlContent.contains("Provides classes for performing arbitrary-precision integer arithmetic"));
+ } catch (Exception e) {
+ //there is no internet connection, so the Javadoc cannot be retrieved.
+ Assert.assertTrue(actualHtmlContent.contains(CorextMessages.JavaDocLocations_noAttachedSource));
+ }
}
@@ -278,8 +287,8 @@ public class PackageJavadocTests extends CoreTests {
packageFragment= (IPackageFragment)codeSelect[0];
JavadocBrowserInformationControlInput hoverInfo= JavadocHover.getHoverInfo(new IJavaElement[] { packageFragment }, cu, new Region(offset, length), null);
String actualHtmlContent= hoverInfo.getHtml();
-
- Assert.assertTrue(actualHtmlContent.contains("Note: This element has no attached Javadoc and the Javadoc could not be found in the attached source."));
+
+ Assert.assertTrue(actualHtmlContent.contains(CorextMessages.JavaDocLocations_noAttachedJavadoc));
}
public static Test setUpTest(Test test) {