Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2016-01-18 08:47:45 +0000
committerAlexander Kurtakov2016-01-18 09:02:51 +0000
commit676f2102b0670602884d3f3ad4371cbbb49e68dd (patch)
tree64060b606afe3b614f2afc962ad393adfc928d90 /org.eclipse.ua.tests
parentc8e3215c7447f99761589ef453ed4923c0b39eba (diff)
downloadeclipse.platform.ua-676f2102b0670602884d3f3ad4371cbbb49e68dd.tar.gz
eclipse.platform.ua-676f2102b0670602884d3f3ad4371cbbb49e68dd.tar.xz
eclipse.platform.ua-676f2102b0670602884d3f3ad4371cbbb49e68dd.zip
Bug 485918 - Convert org.eclipse.ua.tests to JUnit 4
Port AllBrowserTests. Change-Id: I2ba17d127afd8efdc6441870616fbb9834c16a09 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'org.eclipse.ua.tests')
-rw-r--r--org.eclipse.ua.tests/browser/org/eclipse/ua/tests/browser/external/TestParameterSubstitution.java37
-rw-r--r--org.eclipse.ua.tests/browser/org/eclipse/ua/tests/browser/other/TestInput.java27
2 files changed, 40 insertions, 24 deletions
diff --git a/org.eclipse.ua.tests/browser/org/eclipse/ua/tests/browser/external/TestParameterSubstitution.java b/org.eclipse.ua.tests/browser/org/eclipse/ua/tests/browser/external/TestParameterSubstitution.java
index e23160194..cefd29bb2 100644
--- a/org.eclipse.ua.tests/browser/org/eclipse/ua/tests/browser/external/TestParameterSubstitution.java
+++ b/org.eclipse.ua.tests/browser/org/eclipse/ua/tests/browser/external/TestParameterSubstitution.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2015 IBM Corporation and others.
+ * Copyright (c) 2008, 2016 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
@@ -11,59 +11,62 @@
package org.eclipse.ua.tests.browser.external;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.ui.internal.browser.WebBrowserUtil;
+import org.junit.Test;
-import junit.framework.TestCase;
+public class TestParameterSubstitution {
-public class TestParameterSubstitution extends TestCase {
-
private static final String URL = "http://127.0.0.1:3873/help/index.jsp";
+ @Test
public void testNullParameters() {
assertEquals(URL, WebBrowserUtil.createParameterString(null, URL));
}
+ @Test
public void testEmptyParameters() {
assertEquals(URL, WebBrowserUtil.createParameterString("", URL));
}
-
+
+ @Test
public void testNullURL() {
assertEquals("", WebBrowserUtil.createParameterString("", null));
}
+ @Test
public void testNoSubstitution() {
assertEquals("-console " + URL, WebBrowserUtil.createParameterString("-console", URL));
}
-
+
+ @Test
public void testSubstitution() {
assertEquals("-url " + URL + " -console", WebBrowserUtil.createParameterString("-url %URL% -console", URL));
}
- // Remove when we move to JUnit 4
- private void assertArrayEquals(String[] a1, String[] a2) {
- assertEquals("Arrays have different lengths", a1.length, a2.length);
- for(int i = 0; i < a1.length; i++) {
- assertEquals("Elements differ at index " + i, a1[i], a2[i]);
- }
- }
-
+ @Test
public void testArrayNullParameters() {
assertArrayEquals(new String[] { URL }, WebBrowserUtil.createParameterArray(null, URL));
}
-
+ @Test
public void testArrayEmptyParameters() {
assertArrayEquals(new String[] { URL }, WebBrowserUtil.createParameterArray("", URL));
}
-
+
+ @Test
public void testArrayNullURL() {
assertArrayEquals(new String[0], WebBrowserUtil.createParameterArray("", null));
}
+ @Test
public void testArrayNoSubstitution() {
assertArrayEquals(new String[] { "-console", URL }, WebBrowserUtil.createParameterArray("-console", URL));
}
-
+
+ @Test
public void testArraySubstitution() {
assertArrayEquals(new String[] { "-url", URL, "-console"}, WebBrowserUtil.createParameterArray("-url %URL% -console", URL));
}
diff --git a/org.eclipse.ua.tests/browser/org/eclipse/ua/tests/browser/other/TestInput.java b/org.eclipse.ua.tests/browser/org/eclipse/ua/tests/browser/other/TestInput.java
index 10767fdd0..62b16184f 100644
--- a/org.eclipse.ua.tests/browser/org/eclipse/ua/tests/browser/other/TestInput.java
+++ b/org.eclipse.ua.tests/browser/org/eclipse/ua/tests/browser/other/TestInput.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
+ * Copyright (c) 2009, 2016 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
@@ -11,26 +11,31 @@
package org.eclipse.ua.tests.browser.other;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.net.MalformedURLException;
import java.net.URL;
import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
import org.eclipse.ui.internal.browser.WebBrowserEditorInput;
-import junit.framework.TestCase;
+import org.junit.Test;
-public class TestInput extends TestCase {
+public class TestInput {
private final String URL1 = "http://www.eclipse.org";
private final String URL2 = "http://bugs.eclipse.org";
private static final String ID1 = "browser.id1";
private static final String ID2 = "browser.id2";
+ @Test
public void testCompareWithNull() throws MalformedURLException {
WebBrowserEditorInput input = new WebBrowserEditorInput(new URL(URL1),
0, ID1);
assertFalse(input.equals(null));
}
-
+
+ @Test
public void testCompareWithNullURL() throws MalformedURLException {
WebBrowserEditorInput input = new WebBrowserEditorInput(new URL(URL1),
0, ID1);
@@ -40,12 +45,14 @@ public class TestInput extends TestCase {
assertFalse(input2.equals(input));
}
+ @Test
public void testCompareWithSelf() throws MalformedURLException {
WebBrowserEditorInput input = new WebBrowserEditorInput(new URL(URL1),
0, ID1);
assertTrue(input.equals(input));
}
+ @Test
public void testCompareWithSimilar() throws MalformedURLException {
WebBrowserEditorInput input = new WebBrowserEditorInput(new URL(URL1),
0, ID1);
@@ -55,6 +62,7 @@ public class TestInput extends TestCase {
assertTrue(input.hashCode() == input2.hashCode());
}
+ @Test
public void testCompareWithDifferentUrl() throws MalformedURLException {
WebBrowserEditorInput input = new WebBrowserEditorInput(new URL(URL1),
0, ID1);
@@ -63,6 +71,7 @@ public class TestInput extends TestCase {
assertFalse(input.equals(input2));
}
+ @Test
public void testCompareWithDifferentId() throws MalformedURLException {
WebBrowserEditorInput input = new WebBrowserEditorInput(new URL(URL1),
0, ID1);
@@ -71,6 +80,7 @@ public class TestInput extends TestCase {
assertFalse(input.equals(input2));
}
+ @Test
public void testCompareWithDifferentStyle() throws MalformedURLException {
WebBrowserEditorInput input = new WebBrowserEditorInput(new URL(URL1),
0, ID1);
@@ -79,7 +89,8 @@ public class TestInput extends TestCase {
assertTrue(input.equals(input2));
assertTrue(input.hashCode() == input2.hashCode());
}
-
+
+ @Test
public void testCompareWithStatusbarVisible() throws MalformedURLException {
WebBrowserEditorInput input = new WebBrowserEditorInput(new URL(URL1),
0, ID1);
@@ -88,14 +99,16 @@ public class TestInput extends TestCase {
assertFalse(input.equals(input2));
}
+ @Test
public void testHashWithNullURL() {
WebBrowserEditorInput input = new WebBrowserEditorInput(null,0, ID1);
input.hashCode(); // Fails if exception thrown
}
-
+
+ @Test
public void testHashWithNullID() throws MalformedURLException {
WebBrowserEditorInput input = new WebBrowserEditorInput(new URL(URL1),0, null);
input.hashCode(); // Fails if exception thrown
}
-
+
}

Back to the top