Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2020-02-11 07:24:07 +0000
committerAlexander Kurtakov2020-02-11 07:24:07 +0000
commite4f3868ae8573bb929302ccdab51c05aa8646476 (patch)
tree38cb6ea8e4f05c8a67773b23d5903233ede26c82
parent92414ec9b8d97154c74e6232cdd6057ec9a059ab (diff)
downloadrt.equinox.p2-e4f3868ae8573bb929302ccdab51c05aa8646476.tar.gz
rt.equinox.p2-e4f3868ae8573bb929302ccdab51c05aa8646476.tar.xz
rt.equinox.p2-e4f3868ae8573bb929302ccdab51c05aa8646476.zip
Convert p2.tests to JUnit 4.
Chunk 2. All direct TestCase children handled. Change-Id: I0866834dc92e01f7968bf3445818c5b2ada2f007 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/IUListFormatterTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/ArtifactKeyParsingTest.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatArrayTest.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatNTest.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatRTest.java33
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatSTest.java115
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatTest.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/IntersectionTest.java19
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/MultiplicityTest.java214
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/PerformanceTest.java17
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/GeneralPublisherTests.java17
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java62
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileTest.java78
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/VersionAdviceTest.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/repository/CacheManagerTest.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/repository/RepositoryHelperTest.java13
16 files changed, 324 insertions, 310 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/IUListFormatterTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/IUListFormatterTest.java
index 5822f7983..efa48f080 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/IUListFormatterTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/IUListFormatterTest.java
@@ -19,19 +19,19 @@ import static org.easymock.EasyMock.createNiceMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.getCurrentArguments;
import static org.easymock.EasyMock.replay;
+import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import junit.framework.TestCase;
import org.easymock.IAnswer;
import org.eclipse.equinox.internal.p2.director.app.IUListFormatter;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.Version;
import org.junit.Test;
-public class IUListFormatterTest extends TestCase {
+public class IUListFormatterTest {
@Test
public void testFormat() {
IUListFormatter format = new IUListFormatter("${id}=${id},${version},${org.eclipse.equinox.p2.name}");
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/ArtifactKeyParsingTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/ArtifactKeyParsingTest.java
index 00e37563d..51dc24b02 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/ArtifactKeyParsingTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/ArtifactKeyParsingTest.java
@@ -13,9 +13,10 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.metadata;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThrows;
-import junit.framework.TestCase;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.metadata.Version;
@@ -24,7 +25,7 @@ import org.junit.Test;
/**
* Test <code>ArtifactkeyDeSerializer</code>
*/
-public class ArtifactKeyParsingTest extends TestCase {
+public class ArtifactKeyParsingTest {
@Test
public void testSerialize() {
IArtifactKey key = new ArtifactKey("classifier", "identifier", Version.create("1.0"));
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatArrayTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatArrayTest.java
index b5e76760b..b716e8ceb 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatArrayTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatArrayTest.java
@@ -14,9 +14,10 @@
package org.eclipse.equinox.p2.tests.omniVersion;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThrows;
-import junit.framework.TestCase;
import org.eclipse.equinox.p2.metadata.Version;
import org.junit.Test;
@@ -24,7 +25,7 @@ import org.junit.Test;
* Tests format(<>) - arrays.
*
*/
-public class FormatArrayTest extends TestCase {
+public class FormatArrayTest {
@Test
public void testEmptyArray() {
assertThrows("Uncaught error: empty array group is not allowed:", IllegalArgumentException.class,
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatNTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatNTest.java
index 83014c0b2..760a30158 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatNTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatNTest.java
@@ -14,9 +14,10 @@
package org.eclipse.equinox.p2.tests.omniVersion;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThrows;
-import junit.framework.TestCase;
import org.eclipse.equinox.p2.metadata.Version;
import org.junit.Test;
@@ -24,7 +25,7 @@ import org.junit.Test;
* Tests format(n) and format(N)
*
*/
-public class FormatNTest extends TestCase {
+public class FormatNTest {
@Test
public void testNonNegative() {
Version v = Version.parseVersion("format(n):1");
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatRTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatRTest.java
index 2676a70b0..5e11aa595 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatRTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatRTest.java
@@ -14,27 +14,33 @@
package org.eclipse.equinox.p2.tests.omniVersion;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThrows;
+
import org.eclipse.equinox.p2.metadata.Version;
+import org.junit.Test;
/**
* Tests format(r)
*
*/
-public class FormatRTest extends TestCase {
-
+public class FormatRTest {
+ @Test
public void testNumeric() {
Version v = Version.parseVersion("format(r):1");
assertNotNull(v);
assertEquals(Version.parseVersion("raw:1"), v);
}
+ @Test
public void testNegativeNumeric() {
Version v = Version.parseVersion("format(r):-1");
assertNotNull(v);
assertEquals(Version.parseVersion("raw:-1"), v);
}
+ @Test
public void testString() {
Version v = Version.parseVersion("format(r):'a'");
assertNotNull(v);
@@ -44,6 +50,7 @@ public class FormatRTest extends TestCase {
assertEquals(Version.parseVersion("raw:'a'"), v);
}
+ @Test
public void testConcatentatedStrings() {
Version v = Version.parseVersion("format(r):'a''b'");
assertNotNull(v);
@@ -53,36 +60,32 @@ public class FormatRTest extends TestCase {
assertEquals(Version.parseVersion("raw:'a has a \"hat\" it is '\"a's\""), v);
}
+ @Test
public void testMaxString() {
Version v = Version.parseVersion("format(r):m");
assertNotNull(v);
assertEquals(Version.parseVersion("raw:m"), v);
}
+ @Test
public void testMaxNumeric() {
Version v = Version.parseVersion("format(r):M");
assertNotNull(v);
assertEquals(Version.parseVersion("raw:M"), v);
}
+ @Test
public void testArray() {
Version v = Version.parseVersion("format(r):<1>");
assertNotNull(v);
assertEquals(Version.parseVersion("raw:<1>"), v);
}
+ @Test
public void testNonRElements() {
- try {
- Version.parseVersion("format(r):aaa");
- fail("a is not a valid raw element");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
- try {
- Version.parseVersion("format(r):1,2");
- fail("comma is not a delimiter in raw format");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
+ assertThrows("a is not a valid raw element", IllegalArgumentException.class,
+ () -> Version.parseVersion("format(r):aaa"));
+ assertThrows("comma is not a delimiter in raw format", IllegalArgumentException.class,
+ () -> Version.parseVersion("format(r):1,2"));
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatSTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatSTest.java
index 4ec6cad23..f72a1eaba 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatSTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatSTest.java
@@ -14,29 +14,32 @@
package org.eclipse.equinox.p2.tests.omniVersion;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThrows;
+
import org.eclipse.equinox.p2.metadata.Version;
+import org.junit.Test;
/**
* Tests format(s), and format(S)
- *
- * a string group matching any character except any following
- * explicit/optional delimiter. Use processing rules =[]; or =[^] to define the set of allowed characters.
- *
+ *
+ * a string group matching any character except any following explicit/optional
+ * delimiter. Use processing rules =[]; or =[^] to define the set of allowed
+ * characters.
+ *
*/
-public class FormatSTest extends TestCase {
+public class FormatSTest {
+ @Test
public void testStringAcceptDigit() {
Version v = Version.parseVersion("format(S):1");
assertNotNull(v);
assertEquals(Version.parseVersion("raw:'1'"), v);
- try {
- Version.parseVersion("format(s):1");
- fail("Uncaught error: s should not accept digits");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
+ assertThrows("Uncaught error: s should not accept digits", IllegalArgumentException.class,
+ () -> Version.parseVersion("format(s):1"));
}
+ @Test
public void testStringAcceptAlpha() {
Version v = Version.parseVersion("format(s):a");
assertNotNull(v);
@@ -46,18 +49,16 @@ public class FormatSTest extends TestCase {
assertEquals(Version.parseVersion("raw:'a'"), v);
}
+ @Test
public void testStringDelimitedByNumeric() {
Version v = Version.parseVersion("format(sn):foobar123");
assertNotNull(v);
assertEquals(Version.parseVersion("raw:'foobar'.123"), v);
- try {
- Version.parseVersion("format(Sn):foobar123");
- fail("Uncaught error: S should eat entire string, no n found at the end");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
+ assertThrows("Uncaught error: S should eat entire string, no n found at the end",
+ IllegalArgumentException.class, () -> Version.parseVersion("format(Sn):foobar123"));
}
+ @Test
public void testStringWithSpace() {
Version v;
@@ -65,15 +66,11 @@ public class FormatSTest extends TestCase {
assertEquals(Version.parseVersion("raw:'foo bar'.123"), v);
// Test 's' with attempt to include 'space' and delimiters
- //
- try {
- Version.parseVersion("format(s=[^];n):foo bar123");
- fail("Uncaught error: format(s) can not match non letters (space).");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
+ assertThrows("Uncaught error: format(s) can not match non letters (space).", IllegalArgumentException.class,
+ () -> Version.parseVersion("format(s=[^];n):foo bar123"));
}
+ @Test
public void testStringDelimitedByDelimiter() {
Version v = Version.parseVersion("format(s.n):foobar.123");
assertNotNull(v);
@@ -83,24 +80,28 @@ public class FormatSTest extends TestCase {
assertEquals(Version.parseVersion("raw:'foobar'.123"), v);
}
+ @Test
public void testStringDelimitedByExplicitDelimiter() {
Version v = Version.parseVersion("format(s=[^r];d=[r];n):foobar123");
assertNotNull(v);
assertEquals(Version.parseVersion("raw:'fooba'.123"), v);
}
+ @Test
public void testStringWithAllowedSet() {
Version v = Version.parseVersion("format(s=[a-z];sn):fooBAR123");
assertNotNull(v);
assertEquals(Version.parseVersion("raw:'foo'.'BAR'.123"), v);
}
+ @Test
public void testStringWithDisallowedSet() {
Version v = Version.parseVersion("format(s=[^a-z];sn):FOObar123");
assertNotNull(v);
assertEquals(Version.parseVersion("raw:'FOO'.'bar'.123"), v);
}
+ @Test
public void testExact() {
Version v = Version.parseVersion("format(S={4};S):123abc456'def'");
assertNotNull(v);
@@ -121,30 +122,20 @@ public class FormatSTest extends TestCase {
assertNotNull(v = Version.parseVersion("format(S={2};.S={1};s={3};):12.3abc"));
assertEquals(Version.parseVersion("raw:'12'.'3'.'abc'"), v);
- try {
- Version.parseVersion("format(s={4};.s):aaa.abc456'def'");
- fail("Uncaught error: first segment is less than 4 chars long");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
- try {
- Version.parseVersion("format(s={4};.s):123.abc456'def'");
- fail("Uncaught error: first segment has digits");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
- try {
- Version.parseVersion("format(S={4}=[^.];.S):123.abc456'def'");
- fail("Uncaught error: first segment has only 3 characters");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
+ assertThrows("Uncaught error: first segment is less than 4 chars long", IllegalArgumentException.class,
+ () -> Version.parseVersion("format(s={4};.s):aaa.abc456'def'"));
+ assertThrows("Uncaught error: first segment has digits", IllegalArgumentException.class,
+ () -> Version.parseVersion("format(s={4};.s):123.abc456'def'"));
+ assertThrows("Uncaught error: first segment has only 3 characters", IllegalArgumentException.class,
+ () -> Version.parseVersion("format(S={4}=[^.];.S):123.abc456'def'"));
}
/**
- * Test that unbound upper range is just a limit on lower range. Upper delimiter must be a delimiter.
+ * Test that unbound upper range is just a limit on lower range. Upper delimiter
+ * must be a delimiter.
*/
+ @Test
public void testAtLeast() {
Version v = Version.parseVersion("format(S={2,};):123abc456'def'");
assertNotNull(v);
@@ -153,20 +144,13 @@ public class FormatSTest extends TestCase {
assertNotNull(v = Version.parseVersion("format(S={2,};=[^.];.S):123a.bc456'def'"));
assertEquals(Version.parseVersion("raw:'123a'.\"bc456'def'\""), v);
- try {
- Version.parseVersion("format(s={2,};.S):a.abc456'def'");
- fail("uncaught error: first segment is shorter than 2");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
- try {
- Version.parseVersion("format(s={2,};.s={10,};):aa.abcd");
- fail("Uncaught error: secont segment too short");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
+ assertThrows("Uncaught error: first segment is shorter than 2", IllegalArgumentException.class,
+ () -> Version.parseVersion("format(s={2,};.S):a.abc456'def'"));
+ assertThrows("Uncaught error: second segment too short", IllegalArgumentException.class,
+ () -> Version.parseVersion("format(s={2,};.s={10,};):aa.abcd"));
}
+ @Test
public void testAtMost() {
Version v = Version.parseVersion("format(S={1,3};S={1,2};S):123abc456'def'");
assertNotNull(v);
@@ -176,19 +160,10 @@ public class FormatSTest extends TestCase {
assertNotNull(v = Version.parseVersion("format(S={1,4};=[^.];.S={1,4};.S):123.abc4.56'def'"));
assertEquals(Version.parseVersion("raw:'123'.'abc4'.\"56'def'\""), v);
- try {
- // fails because of delimiter after one char
- Version.parseVersion("format(s={2,3};s):a.abc456'def'");
- fail();
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
- try {
- // fails because there are trailing characters after 'c'
- Version.parseVersion("format(s={2,3};.S={2,3};):aa.abc456'd'");
- fail();
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
+ // fails because of delimiter after one char
+ assertThrows(IllegalArgumentException.class, () -> Version.parseVersion("format(s={2,3};s):a.abc456'def'"));
+ // fails because there are trailing characters after 'c'
+ assertThrows(IllegalArgumentException.class,
+ () -> Version.parseVersion("format(s={2,3};.S={2,3};):aa.abc456'd'"));
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatTest.java
index d3335a34b..6fc5fd1a4 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatTest.java
@@ -14,15 +14,19 @@
package org.eclipse.equinox.p2.tests.omniVersion;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import org.eclipse.equinox.p2.metadata.Version;
+import org.junit.Test;
/**
* Test of format() performing tests not covered by tests per rule.
- *
+ *
*/
-public class FormatTest extends TestCase {
+public class FormatTest {
+ @Test
public void testEmptySegmentsRemoved() {
Version v = Version.parseVersion("format(ndddn):1...2");
assertNotNull(v);
@@ -30,6 +34,7 @@ public class FormatTest extends TestCase {
assertEquals(v.getSegment(1), Integer.valueOf(2));
}
+ @Test
public void testGreedyParsing() {
Version v = Version.parseVersion("format(n(.n)*(.s)*):1.2.3.hello");
assertNotNull(v);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/IntersectionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/IntersectionTest.java
index 858dc8c77..33f2e41ab 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/IntersectionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/IntersectionTest.java
@@ -14,9 +14,12 @@
package org.eclipse.equinox.p2.tests.omniVersion;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.metadata.VersionRange;
+import org.junit.Test;
/**
* Tests intersection of VersionRanges.
@@ -25,12 +28,13 @@ import org.eclipse.equinox.p2.metadata.VersionRange;
* - equal range
* - same lower bound - upper inside
* - same upper bound - lower inside
- * - inside
- *
+ * - inside
+ *
* Tests made with both inclusive and non inclusive values.
- *
+ *
*/
-public class IntersectionTest extends TestCase {
+public class IntersectionTest {
+ @Test
public void testIntersectsEmpty() {
VersionRange a = new VersionRange("raw:[1.0.0,3.0.0]");
VersionRange b = new VersionRange("raw:[4.0.0,6.0.0]");
@@ -48,6 +52,7 @@ public class IntersectionTest extends TestCase {
assertTrue("Non overlapping ranges b/a should be empty #6", b.intersect(a) == null);
}
+ @Test
public void testStraddleBoundary() {
VersionRange a = new VersionRange("raw:[1.0.0,3.0.0]");
VersionRange b = new VersionRange("raw:[2.0.0,6.0.0]");
@@ -79,6 +84,7 @@ public class IntersectionTest extends TestCase {
}
+ @Test
public void testEqualRanges() {
VersionRange a = new VersionRange("raw:[1.0.0,3.0.0]");
VersionRange b = new VersionRange("raw:[1.0.0,3.0.0]");
@@ -107,6 +113,7 @@ public class IntersectionTest extends TestCase {
assertTrue("#2.8", !r.getIncludeMinimum());
}
+ @Test
public void testPartialEqualLower() {
VersionRange a = new VersionRange("raw:[1.0.0,3.0.0]");
VersionRange b = new VersionRange("raw:[1.0.0,2.0.0]");
@@ -135,6 +142,7 @@ public class IntersectionTest extends TestCase {
}
+ @Test
public void testPartialEqualUpper() {
VersionRange a = new VersionRange("raw:[1.0.0,3.0.0]");
VersionRange b = new VersionRange("raw:[2.0.0,3.0.0]");
@@ -162,6 +170,7 @@ public class IntersectionTest extends TestCase {
assertTrue("#2.8", !r.getIncludeMinimum());
}
+ @Test
public void testFullyInside() {
VersionRange a = new VersionRange("raw:[1.0.0,3.0.0]");
VersionRange b = new VersionRange("raw:[2.0.0,2.5.0]");
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/MultiplicityTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/MultiplicityTest.java
index 93b52de37..37e7026c1 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/MultiplicityTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/MultiplicityTest.java
@@ -14,16 +14,21 @@
package org.eclipse.equinox.p2.tests.omniVersion;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThrows;
+
import org.eclipse.equinox.p2.metadata.Version;
+import org.junit.Test;
/**
* Tests {n.m} in different combinations and the special +?*
*
*/
-public class MultiplicityTest extends TestCase {
+public class MultiplicityTest {
+ @Test
public void test01() {
- // n? == [n] == n{0,1}
+ // n? == [n] == n{0,1}
Version v = Version.parseVersion("format(n?):1");
assertNotNull(v);
assertEquals(Version.parseVersion("raw:1"), v);
@@ -33,12 +38,8 @@ public class MultiplicityTest extends TestCase {
assertNotNull(v = Version.parseVersion("format(n.?n?):1"));
assertEquals(Version.parseVersion("raw:1"), v);
- try {
- Version.parseVersion("format(n?):a");
- fail("Uncaught error: format(n?):a");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
+ assertThrows("Uncaught error: format(n?):a", IllegalArgumentException.class,
+ () -> Version.parseVersion("format(n?):a"));
// with []
assertNotNull(v = Version.parseVersion("format([n]):1"));
assertEquals(Version.parseVersion("raw:1"), v);
@@ -48,12 +49,8 @@ public class MultiplicityTest extends TestCase {
assertNotNull(v = Version.parseVersion("format(n[.][n]):1"));
assertEquals(Version.parseVersion("raw:1"), v);
- try {
- Version.parseVersion("format([n]):a");
- fail("Uncaught error: format([n]):a");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
+ assertThrows("Uncaught error: format([n]):a", IllegalArgumentException.class,
+ () -> Version.parseVersion("format([n]):a"));
// with {0,1}
assertNotNull(v = Version.parseVersion("format(n{0,1}):1"));
@@ -65,14 +62,11 @@ public class MultiplicityTest extends TestCase {
assertNotNull(v = Version.parseVersion("format(n.?n{0,}):1"));
assertEquals(Version.parseVersion("raw:1"), v);
- try {
- Version.parseVersion("format(n{0,1}):a");
- fail("Uncaught error: format(n{0,1}):a");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
+ assertThrows("Uncaught error: format(n{0,1}):a", IllegalArgumentException.class,
+ () -> Version.parseVersion("format(n{0,1}):a"));
}
+ @Test
public void test1M() {
// n+ == n{1,}
Version v = Version.parseVersion("format((nd?)+):1.2.3");
@@ -82,18 +76,10 @@ public class MultiplicityTest extends TestCase {
assertNotNull(v = Version.parseVersion("format(n+):1"));
assertEquals(Version.parseVersion("raw:1"), v);
- try {
- Version.parseVersion("format(n+):");
- fail("Uncaught error: format(n+):");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
- try {
- Version.parseVersion("format(n+):a");
- fail("Uncaught error: format(n+):a");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
+ assertThrows("Uncaught error: format(n+):", IllegalArgumentException.class,
+ () -> Version.parseVersion("format(n+):"));
+ assertThrows("Uncaught error: format(n+):a", IllegalArgumentException.class,
+ () -> Version.parseVersion("format(n+):a"));
// with {1,}
assertNotNull(v = Version.parseVersion("format((nd?){1,}):1.2.3"));
assertEquals(Version.parseVersion("raw:1.2.3"), v);
@@ -101,21 +87,14 @@ public class MultiplicityTest extends TestCase {
assertNotNull(v = Version.parseVersion("format(n{1,}):1"));
assertEquals(Version.parseVersion("raw:1"), v);
- try {
- Version.parseVersion("format(n{1,}):");
- fail("Uncaught error: format(n{1,}):");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
- try {
- Version.parseVersion("format(n{1,}):a");
- fail("Uncaught error: format(n{1,}):a");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
+ assertThrows("Uncaught error: format(n{1,}):", IllegalArgumentException.class,
+ () -> Version.parseVersion("format(n{1,}):"));
+ assertThrows("Uncaught error: format(n{1,}):a", IllegalArgumentException.class,
+ () -> Version.parseVersion("format(n{1,}):a"));
}
+ @Test
public void test0M() {
// n* == n{0,}
Version v = Version.parseVersion("format((nd?)*):1.2.3");
@@ -128,12 +107,8 @@ public class MultiplicityTest extends TestCase {
assertNotNull(v = Version.parseVersion("format(sn*):a"));
assertEquals(Version.parseVersion("raw:'a'"), v);
- try {
- Version.parseVersion("format(n*):a");
- fail("Uncaught error: format(n*):a");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
+ assertThrows("Uncaught error: format(n*):a", IllegalArgumentException.class,
+ () -> Version.parseVersion("format(n*):a"));
// with {0,}
assertNotNull(v = Version.parseVersion("format((nd?){0,}):1.2.3"));
assertEquals(Version.parseVersion("raw:1.2.3"), v);
@@ -144,15 +119,12 @@ public class MultiplicityTest extends TestCase {
assertNotNull(v = Version.parseVersion("format(sn{0,}):a"));
assertEquals(Version.parseVersion("raw:'a'"), v);
- try {
- Version.parseVersion("format(n{0,}):a");
- fail("Uncaught error: format(n{0,}):a");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
+ assertThrows("Uncaught error: format(n{0,}):a", IllegalArgumentException.class,
+ () -> Version.parseVersion("format(n{0,}):a"));
}
+ @Test
public void testExact() {
// n{1}
Version v = Version.parseVersion("format((nd?){3}):1.2.3");
@@ -162,26 +134,15 @@ public class MultiplicityTest extends TestCase {
assertNotNull(v = Version.parseVersion("format(n{1}):1"));
assertEquals(Version.parseVersion("raw:1"), v);
- try {
- Version.parseVersion("format(n{1}):");
- fail("Uncaught error: format(n{1}):");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
- try {
- Version.parseVersion("format((nd?){3}):1.2");
- fail("Uncaught error: format((nd?){3}):1.2");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
- try {
- Version.parseVersion("format(n{1}):a");
- fail("Uncaught error: format(n{1}):a");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
+ assertThrows("Uncaught error: format(n{1}):", IllegalArgumentException.class,
+ () -> Version.parseVersion("format(n{1}):"));
+ assertThrows("Uncaught error: format((nd?){3}):1.2", IllegalArgumentException.class,
+ () -> Version.parseVersion("format((nd?){3}):1.2"));
+ assertThrows("Uncaught error: format(n{1}):a", IllegalArgumentException.class,
+ () -> Version.parseVersion("format(n{1}):a"));
}
+ @Test
public void testAtLeast() {
// n{>1,}
Version v = null;
@@ -193,21 +154,14 @@ public class MultiplicityTest extends TestCase {
assertNotNull(v = Version.parseVersion("format(n{1,}):1"));
assertEquals(Version.parseVersion("raw:1"), v);
- try {
- Version.parseVersion("format(n{2,}):1");
- fail("Uncaught error: format(n{1,}):1");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
- try {
- Version.parseVersion("format((nd?){3,}):1.2");
- fail("Uncaught error: format(n{3,1}):1.2");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
+ assertThrows("Uncaught error: format(n{1,}):1", IllegalArgumentException.class,
+ () -> Version.parseVersion("format(n{2,}):1"));
+ assertThrows("Uncaught error: format(n{3,1}):1.2", IllegalArgumentException.class,
+ () -> Version.parseVersion("format((nd?){3,}):1.2"));
}
+ @Test
public void testAtMost() {
Version v = null;
assertNotNull(v = Version.parseVersion("format((nd?){2,3}):1.2.3"));
@@ -216,82 +170,48 @@ public class MultiplicityTest extends TestCase {
assertNotNull(v = Version.parseVersion("format((nd?){2,3}):1.2"));
assertEquals(Version.parseVersion("raw:1.2"), v);
- try {
- Version.parseVersion("format(n{2,3}):1");
- fail("Uncaught error: format(n{2,3}):1");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
- try {
- Version.parseVersion("format(n{2,3}):1.2.3.4");
- fail("Uncaught error: format(n{2,3}):1.2.3.4");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
+ assertThrows("Uncaught error: format(n{2,3}):1", IllegalArgumentException.class,
+ () -> Version.parseVersion("format(n{2,3}):1"));
+ assertThrows("Uncaught error: format(n{2,3}):1.2.3.4", IllegalArgumentException.class,
+ () -> Version.parseVersion("format(n{2,3}):1.2.3.4"));
}
+ @Test
public void testZeroExact() {
// Should not have entered a n{0} as it is meaningless.
- try {
- Version.parseVersion("format(n{0}):");
- fail("Uncaught error: format(n{0}):");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
- try {
- Version.parseVersion("format(n{0,0}):");
- fail("Uncaught error: format(n{0,0}):");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
+ assertThrows("Uncaught error: format(n{0}):", IllegalArgumentException.class,
+ () -> Version.parseVersion("format(n{0}):"));
+ assertThrows("Uncaught error: fformat(n{0,0}):", IllegalArgumentException.class,
+ () -> Version.parseVersion("format(n{0,0}):"));
}
+ @Test
public void testMinGreaterThanMax() {
- try {
- Version.parseVersion("format((nd?){3,2}):1.2.3");
- fail("Uncaught error: format((nd?){3,2}):1.2.3");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
+ assertThrows("Uncaught error: format((nd?){3,2}):1.2.3", IllegalArgumentException.class,
+ () -> Version.parseVersion("format((nd?){3,2}):1.2.3"));
}
+ @Test
public void testUnbalancedBraceR() {
- try {
- Version.parseVersion("format((nd?){3,2):1.2.3");
- fail("Uncaught error: format((nd?){3,2):1.2.3");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
+ assertThrows("Uncaught error: format((nd?){3,2):1.2.3",
+ IllegalArgumentException.class,
+ () -> Version.parseVersion("format((nd?){3,2):1.2.3"));
}
+ @Test
public void testNegativeRange() {
- try {
- Version.parseVersion("format((nd?){-1,2}):1.2.3");
- fail("Uncaught error: format((nd?){-1,2}):1.2.3");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
- try {
- Version.parseVersion("format((nd?){1,-2}):1.2.3");
- fail("Uncaught error: format((nd?){1,-2}):1.2.3");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
+ assertThrows("Uncaught error: format((nd?){-1,2}):1.2.3", IllegalArgumentException.class,
+ () -> Version.parseVersion("format((nd?){-1,2}):1.2.3"));
+ assertThrows("Uncaught error: format((nd?){1,-2}):1.2.3", IllegalArgumentException.class,
+ () -> Version.parseVersion("format((nd?){1,-2}):1.2.3"));
}
+ @Test
public void testStringRange() {
- try {
- Version.parseVersion("format((nd?){a,2}):1.2.3");
- fail("Uncaught error: format((nd?){a,2}):1.2.3");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
- try {
- Version.parseVersion("format((nd?){1,a}):1.2.3");
- fail("Uncaught error: format((nd?){1,a}):1.2.3");
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
+ assertThrows("Uncaught error: format((nd?){a,2}):1.2.3", IllegalArgumentException.class,
+ () -> Version.parseVersion("format((nd?){a,2}):1.2.3"));
+ assertThrows("Uncaught error: format((nd?){1,a}):1.2.3", IllegalArgumentException.class,
+ () -> Version.parseVersion("format((nd?){1,a}):1.2.3"));
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/PerformanceTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/PerformanceTest.java
index 5b5dc265a..660abed53 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/PerformanceTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/PerformanceTest.java
@@ -14,23 +14,24 @@
package org.eclipse.equinox.p2.tests.omniVersion;
-import junit.framework.TestCase;
import org.eclipse.equinox.p2.metadata.Version;
+import org.junit.Test;
/**
* Simple performance comparison between OSGi version implementation and Omni Version.
* Tests performance of creating version instances using 4 values, as well as string parsing.
* Tests comparison of versions.
- *
+ *
* Aprox 10000 instances are created.
* Comparison compares all instances against all other (i.e. about 10 milj).
- *
+ *
*/
-public class PerformanceTest extends TestCase {
+public class PerformanceTest {
static final int MUL = 24;
static final String qualifierTemplate = "r20090112-12345-abcdefghijklmnopqrstuvwxyz"; // longer than MUL chars
+ @Test
public void testStringCreationPerformance() {
// Ensure that classes are loaded etc.
Version.MAX_VERSION.compareTo(Version.emptyVersion);
@@ -52,6 +53,7 @@ public class PerformanceTest extends TestCase {
// System.out.printf("String creation: osgi=%d, omni=%d, factor=%.2f\n", osgiTime, omniTime, factor(omniTime, osgiTime));
}
+ @Test
public void testCreationPerformance() {
// Ensure that classes are loaded etc.
Version.MAX_VERSION.compareTo(Version.emptyVersion);
@@ -71,6 +73,7 @@ public class PerformanceTest extends TestCase {
// System.out.printf("Creation: osgi=%d, omni=%d, factor=%f2\n", osgiTime, omniTime, factor(omniTime, osgiTime));
}
+ @Test
public void testComparePerformance() {
Version[] omniVersions = createOmniVersions();
org.osgi.framework.Version osgiVersions[] = createOsgiVersions();
@@ -88,6 +91,7 @@ public class PerformanceTest extends TestCase {
//System.out.printf("Compare (%d comparisons): osgi=%d, omni=%d\n, factor=%d", units, osgiTime, omniTime, omniTime / osgiTime);
}
+ @Test
public void testEqualsPerformance() {
Version[] omniVersions = createOmniVersions();
org.osgi.framework.Version osgiVersions[] = createOsgiVersions();
@@ -105,6 +109,7 @@ public class PerformanceTest extends TestCase {
//System.out.printf("Equals (%d comparisons): osgi=%d, omni=%d, factor=%d\n", units, osgiTime, omniTime, omniTime / osgiTime);
}
+ @Test
public void testToStringPerformance() {
Version[] omniVersions = createOmniVersions();
org.osgi.framework.Version osgiVersions[] = createOsgiVersions();
@@ -123,26 +128,22 @@ public class PerformanceTest extends TestCase {
//System.out.printf("toString (%d versions): osgi=%d, omni=%d\n", units, osgiTime, omniTime);
}
-
public static void osgiVersionToString(org.osgi.framework.Version versions[]) {
// compare every version against all other versions
for (int i = 0; i < MUL * MUL * MUL; i++)
versions[i].toString();
}
-
public static void omniVersionToString(Version versions[]) {
// compare every version against all other versions
for (int i = 0; i < MUL * MUL * MUL; i++)
versions[i].toString();
}
-
public static void omniVersionCreate() {
for (int i = 0; i < MUL; i++)
for (int j = 0; j < MUL; j++)
for (int k = 0; k < MUL; k++)
Version.createOSGi(i, j, k, qualifierTemplate);
}
-
public static void omniVersionCompare(Version versions[]) {
//compare every version against all other versions
for (int i = 0; i < MUL * MUL * MUL; i++)
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/GeneralPublisherTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/GeneralPublisherTests.java
index be1776f12..e04b716e9 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/GeneralPublisherTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/GeneralPublisherTests.java
@@ -7,24 +7,30 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.equinox.p2.tests.publisher;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.PrintStream;
import java.lang.reflect.Method;
import java.util.NoSuchElementException;
-import junit.framework.TestCase;
import org.eclipse.equinox.internal.p2.publisher.Messages;
import org.eclipse.equinox.internal.p2.publisher.QuotedTokenizer;
import org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile;
import org.eclipse.equinox.p2.publisher.eclipse.FeaturesAndBundlesPublisherApplication;
import org.eclipse.equinox.p2.tests.StringBufferStream;
+import org.junit.Test;
-public class GeneralPublisherTests extends TestCase {
-
+public class GeneralPublisherTests {
+ @Test
public void testBug255820_Product_normalize() throws Exception {
Method normalizeMethod = ProductFile.class.getDeclaredMethod("normalize", String.class);
normalizeMethod.setAccessible(true);
@@ -34,6 +40,7 @@ public class GeneralPublisherTests extends TestCase {
assertEquals(normalizeMethod.invoke(null, "a\fbd\r\n e"), "a bd e");
}
+ @Test
public void testInvalidConfiguration1() {
FeaturesAndBundlesPublisherApplication application = new FeaturesAndBundlesPublisherApplication();
Integer retValue = 0;
@@ -52,6 +59,7 @@ public class GeneralPublisherTests extends TestCase {
assertEquals("1.1", Messages.exception_noMetadataRepo, application.getStatus().getMessage());
}
+ @Test
public void testInvalidConfiguration2() {
FeaturesAndBundlesPublisherApplication application = new FeaturesAndBundlesPublisherApplication();
Integer retValue = 0;
@@ -71,6 +79,7 @@ public class GeneralPublisherTests extends TestCase {
}
+ @Test
public void testQuotedTokenizer() throws Exception {
QuotedTokenizer tokenizer = new QuotedTokenizer("abra ca dabra");
assertEquals("abra", tokenizer.nextToken());
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java
index 4ebce017a..db6d1105e 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java
@@ -13,17 +13,38 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.publisher.actions;
-import java.util.*;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThrows;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
import org.eclipse.equinox.internal.p2.metadata.RequiredCapability;
-import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.IInstallableUnitFragment;
+import org.eclipse.equinox.p2.metadata.IProvidedCapability;
+import org.eclipse.equinox.p2.metadata.IRequirement;
+import org.eclipse.equinox.p2.metadata.ITouchpointInstruction;
+import org.eclipse.equinox.p2.metadata.ITouchpointType;
+import org.eclipse.equinox.p2.metadata.IUpdateDescriptor;
+import org.eclipse.equinox.p2.metadata.MetadataFactory;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.VersionRange;
import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;
import org.eclipse.equinox.p2.publisher.AdviceFileParser;
import org.eclipse.equinox.p2.query.QueryUtil;
+import org.junit.Test;
-public class AdviceFileParserTest extends TestCase {
+public class AdviceFileParserTest {
+ @Test
public void testNoAdvice() {
AdviceFileParser parser = new AdviceFileParser("id", Version.emptyVersion, Collections.EMPTY_MAP);
parser.parse();
@@ -34,6 +55,7 @@ public class AdviceFileParserTest extends TestCase {
assertNull(parser.getTouchpointInstructions());
}
+ @Test
public void testAdviceVersion() {
Map<String, String> map = new HashMap<>();
map.put("advice.version", "1.0");
@@ -41,15 +63,11 @@ public class AdviceFileParserTest extends TestCase {
parser.parse();
map.put("advice.version", "999");
- parser = new AdviceFileParser("id", Version.emptyVersion, map);
- try {
- parser.parse();
- } catch (IllegalStateException e) {
- return;
- }
- fail("expected version parse problem");
+ assertThrows("expected version parse problem", IllegalStateException.class,
+ () -> new AdviceFileParser("id", Version.emptyVersion, map).parse());
}
+ @Test
public void testUpdateDescriptorAdvice() {
Map<String, String> map = new HashMap<>();
map.put("update.id", "testName");
@@ -70,6 +88,7 @@ public class AdviceFileParserTest extends TestCase {
assertEquals("Test Description", updateDescriptor.getDescription());
}
+ @Test
public void testUpdateDescriptorAdviceDefaultBound() {
Map<String, String> map = new HashMap<>();
map.put("update.id", "testName");
@@ -90,6 +109,7 @@ public class AdviceFileParserTest extends TestCase {
assertEquals("Test Description", updateDescriptor.getDescription());
}
+ @Test
public void testUpdateDescriptorWithMatch() {
Map<String, String> map = new HashMap<>();
map.put("update.matchExp", "providedCapabilities.exists(pc | pc.namespace == 'org.eclipse.equinox.p2.iu' && (pc.name == 'B' || pc.name == 'C'))");
@@ -103,15 +123,11 @@ public class AdviceFileParserTest extends TestCase {
assertEquals("Test Description", updateDescriptor.getDescription());
assertEquals(10, updateDescriptor.getSeverity());
//Here we test that the extraction of the name fails since this is not of an appropriate format
- boolean exceptionRaised = false;
- try {
- RequiredCapability.extractName(updateDescriptor.getIUsBeingUpdated().iterator().next());
- } catch (IllegalArgumentException e) {
- exceptionRaised = true;
- }
- assertTrue(exceptionRaised);
+ assertThrows(IllegalArgumentException.class,
+ () -> RequiredCapability.extractName(updateDescriptor.getIUsBeingUpdated().iterator().next()));
}
+ @Test
public void testUpdateDescriptorAdviceDefaultBound2() {
Map<String, String> map = new HashMap<>();
map.put("update.id", "testName");
@@ -131,6 +147,7 @@ public class AdviceFileParserTest extends TestCase {
assertEquals("Test Description", updateDescriptor.getDescription());
}
+ @Test
public void testUpdateDescriptorAdviceDefaultID() {
Map<String, String> map = new HashMap<>();
map.put("update.severity", "10");
@@ -149,6 +166,7 @@ public class AdviceFileParserTest extends TestCase {
assertEquals("Test Description", updateDescriptor.getDescription());
}
+ @Test
public void testUpdateDescriptorAdviceDefaults() {
Map<String, String> map = new HashMap<>();
map.put("update.id", "id");
@@ -166,6 +184,7 @@ public class AdviceFileParserTest extends TestCase {
assertEquals(null, updateDescriptor.getDescription());
}
+ @Test
public void testPropertyAdvice() {
Map<String, String> map = new HashMap<>();
map.put("properties.0.name", "testName1");
@@ -179,6 +198,7 @@ public class AdviceFileParserTest extends TestCase {
assertEquals("testValue2", parser.getProperties().get("testName2"));
}
+ @Test
public void testProvidesAdvice() {
Map<String, String> map = new HashMap<>();
map.put("provides.0.namespace", "testNamespace1");
@@ -209,6 +229,7 @@ public class AdviceFileParserTest extends TestCase {
assertEquals(Version.emptyVersion, capabilities[1].getVersion());
}
+ @Test
public void testRequiresAdvice() {
Map<String, String> map = new HashMap<>();
map.put("requires.0.namespace", "testNamespace1");
@@ -250,6 +271,7 @@ public class AdviceFileParserTest extends TestCase {
assertEquals(1, reqs[1].getMin());
}
+ @Test
public void testRequireWithExpression() {
Map<String, String> map = new HashMap<>();
String matchExp = "properties[abc] == 'def'";
@@ -268,6 +290,7 @@ public class AdviceFileParserTest extends TestCase {
assertEquals(matchExpression, reqs[0].getMatches());
}
+ @Test
public void testRequireWithExpressionAndOptional() {
Map<String, String> map = new HashMap<>();
String matchExp = "properties[abc] == 'def'";
@@ -287,6 +310,7 @@ public class AdviceFileParserTest extends TestCase {
assertEquals(1, reqs[0].getMax());
}
+ @Test
public void testMetaRequiresAdvice() {
Map<String, String> map = new HashMap<>();
map.put("metaRequirements.0.namespace", "testNamespace1");
@@ -328,6 +352,7 @@ public class AdviceFileParserTest extends TestCase {
assertEquals(1, reqs[1].getMin());
}
+ @Test
public void testInstructionsAdvice() {
Map<String, String> map = new HashMap<>();
map.put("instructions.configure", "addProgramArg(programArg:-startup); addProgramArg(programArg:@artifact);");
@@ -346,6 +371,7 @@ public class AdviceFileParserTest extends TestCase {
assertEquals("removeProgramArg(programArg:-startup); removeProgramArg(programArg:@artifact);)", unconfigure.getBody());
}
+ @Test
public void testAdditionalInstallableUnitDescriptionsAdvice() {
Map<String, String> map = new HashMap<>();
map.put("units.0.id", "testid0");
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileTest.java
index 9920b0ad4..c994a5f4c 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileTest.java
@@ -18,10 +18,12 @@ import static org.eclipse.equinox.p2.tests.AdditionalCoreMatchers.hasSize;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import java.util.List;
import java.util.Map;
-import junit.framework.TestCase;
import org.eclipse.core.runtime.Platform;
import org.eclipse.equinox.frameworkadmin.BundleInfo;
import org.eclipse.equinox.internal.p2.publisher.eclipse.IProductDescriptor;
@@ -30,11 +32,13 @@ import org.eclipse.equinox.p2.metadata.IVersionedId;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.metadata.VersionedId;
import org.eclipse.equinox.p2.tests.TestData;
+import org.junit.Before;
+import org.junit.Test;
/**
* Tests the product file parser found in the publisher.
*/
-public class ProductFileTest extends TestCase {
+public class ProductFileTest {
String productFileLocation = null;
ProductFile productFile = null;
@@ -47,8 +51,8 @@ public class ProductFileTest extends TestCase {
private String uidProductFileLocation;
private ProductFile uidProductFile;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
productFileLocation = TestData.getFile("ProductActionTest/productWithConfig", "sample.product").toString();
noLauncherFlag = new ProductFile(TestData.getFile("ProductActionTest/launcherFlags", "noLauncherFlag.product").toString());
falseLauncherFlag = new ProductFile(TestData.getFile("ProductActionTest/launcherFlags", "falseLauncherFlag.product").toString());
@@ -62,6 +66,7 @@ public class ProductFileTest extends TestCase {
/**
* Test method for {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getLauncherName()}.
*/
+ @Test
public void testGetLauncherName() {
assertEquals("1.0", "sample", productFile.getLauncherName());
}
@@ -69,6 +74,7 @@ public class ProductFileTest extends TestCase {
/**
* Test method for {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getLocation()}.
*/
+ @Test
public void testGetLocation() {
assertEquals("1.0", productFileLocation, productFile.getLocation().toString());
}
@@ -76,6 +82,7 @@ public class ProductFileTest extends TestCase {
/**
* Test method for {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getProperties()}.
*/
+ @Test
public void testGetConfigurationProperties() {
Map<String, String> properties = productFile.getConfigurationProperties();
assertEquals("1.0", 4, properties.size());
@@ -86,8 +93,10 @@ public class ProductFileTest extends TestCase {
}
/**
- * Test method for {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getBundles(boolean)}.
+ * Test method for
+ * {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getBundles(boolean)}.
*/
+ @Test
public void testGetBundles() {
List<IVersionedId> bundles = productFile.getBundles(false);
assertEquals("1.0", 1, bundles.size());
@@ -98,8 +107,10 @@ public class ProductFileTest extends TestCase {
}
/**
- * Test method for {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getBundleInfos()}.
+ * Test method for
+ * {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getBundleInfos()}.
*/
+ @Test
public void testGetBundleInfos() {
List<BundleInfo> bundleInfos = productFile.getBundleInfos();
BundleInfo info = bundleInfos.iterator().next();
@@ -110,8 +121,10 @@ public class ProductFileTest extends TestCase {
}
/**
- * Test method for {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getFragments()}.
+ * Test method for
+ * {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getFragments()}.
*/
+ @Test
public void testGetFragments() {
List<IVersionedId> fragments = productFile.getFragments();
assertEquals("1.0", 1, fragments.size());
@@ -119,8 +132,10 @@ public class ProductFileTest extends TestCase {
}
/**
- * Test method for {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getFeatures()}.
+ * Test method for
+ * {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getFeatures()}.
*/
+ @Test
public void testGetFeatures() {
List<IVersionedId> features = productFile.getFeatures();
assertEquals("1.0", 1, features.size());
@@ -128,6 +143,7 @@ public class ProductFileTest extends TestCase {
assertEquals("1.2", Version.create("3.5.0.v20081110-9C9tEvNEla71LZ2jFz-RFB-t"), features.get(0).getVersion());
}
+ @Test
public void testGetRootFeatures() {
List<IVersionedId> features = rootFeaturesProduct.getFeatures(IProductDescriptor.ROOT_FEATURES);
assertThat(features, hasItem(new VersionedId("org.eclipse.help", "2.0.102.v20140128")));
@@ -135,6 +151,7 @@ public class ProductFileTest extends TestCase {
assertThat(features, hasSize(2));
}
+ @Test
public void testGetIncludedFeatures() {
List<IVersionedId> features = rootFeaturesProduct.getFeatures(IProductDescriptor.INCLUDED_FEATURES);
assertThat(features, hasItem(new VersionedId("org.eclipse.rcp", "4.4.0.v20140128")));
@@ -142,10 +159,12 @@ public class ProductFileTest extends TestCase {
assertThat(features, hasSize(2));
}
+ @Test
public void testGetFeaturesOnlyReturnsIncludedFeatures() {
assertThat(rootFeaturesProduct.getFeatures(), is(rootFeaturesProduct.getFeatures(IProductDescriptor.INCLUDED_FEATURES)));
}
+ @Test
public void testHasFeatures() throws Exception {
ProductFile featuresOnly = new ProductFile(TestData.getFile("ProductActionTest", "onlyFeatures.product").toString());
assertThat(featuresOnly.hasFeatures(), is(true));
@@ -153,6 +172,7 @@ public class ProductFileTest extends TestCase {
assertThat(featuresOnly.hasBundles(true), is(false));
}
+ @Test
public void testHasBundles() throws Exception {
ProductFile bundlesOnly = new ProductFile(TestData.getFile("ProductActionTest", "onlyBundles.product").toString());
assertThat(bundlesOnly.hasFeatures(), is(false));
@@ -160,6 +180,7 @@ public class ProductFileTest extends TestCase {
assertThat(bundlesOnly.hasBundles(true), is(true));
}
+ @Test
public void testHasFragments() throws Exception {
ProductFile bundlesOnly = new ProductFile(TestData.getFile("ProductActionTest", "onlyFragments.product").toString());
assertThat(bundlesOnly.hasFeatures(), is(false));
@@ -177,69 +198,86 @@ public class ProductFileTest extends TestCase {
// assertEquals("1.1", absolutePath, icons[0]);
// }
/**
- * Test method for {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getConfigIniPath()}.
+ * Test method for
+ * {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getConfigIniPath()}.
*/
+ @Test
public void testGetConfigIniPath() {
String configIni = productFile.getConfigIniPath("win32");
assertEquals("1.0", "config.ini", configIni);
}
/**
- * Test method for {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getId()}.
+ * Test method for
+ * {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getId()}.
*/
+ @Test
public void testGetId() {
String id = productFile.getId();
assertEquals("1.0", "test.product", id);
}
+ @Test
public void testGetUID() {
String id = uidProductFile.getId();
assertEquals("1.0", "UID.test.product", id);
}
/**
- * Test method for {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getSplashLocation()}.
+ * Test method for
+ * {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getSplashLocation()}.
*/
+ @Test
public void testGetSplashLocation() {
String splashLocation = productFile.getSplashLocation();
assertEquals("1.0", "org.eclipse.equinox.p2.tests", splashLocation);
}
/**
- * Test method for {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getProductName()}.
+ * Test method for
+ * {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getProductName()}.
*/
+ @Test
public void testGetProductName() {
String productName = productFile.getProductName();
assertEquals("1.0", "aaTestProduct", productName);
}
/**
- * Test method for {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getApplication()}.
+ * Test method for
+ * {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getApplication()}.
*/
+ @Test
public void testGetApplication() {
String application = productFile.getApplication();
assertEquals("1.0", "test.app", application);
}
/**
- * Test method for {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#useFeatures()}.
+ * Test method for
+ * {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#useFeatures()}.
*/
+ @Test
public void testUseFeatures() {
boolean useFeatures = productFile.useFeatures();
assertTrue("1.0", !useFeatures);
}
/**
- * Test method for {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getVersion()}.
+ * Test method for
+ * {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getVersion()}.
*/
+ @Test
public void testGetVersion() {
String version = productFile.getVersion();
assertEquals("1.0", Version.create("1"), Version.create(version));
}
/**
- * Test method for {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getVMArguments(java.lang.String)}.
+ * Test method for
+ * {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getVMArguments(java.lang.String)}.
*/
+ @Test
public void testGetVMArguments() {
String vmArguments = productFile.getVMArguments("");
assertEquals("1.0", "vmArg -Dfoo=\"b a r\"", vmArguments);
@@ -247,6 +285,7 @@ public class ProductFileTest extends TestCase {
assertEquals("1.1", "vmArg -Dfoo=\"b a r\"", vmArguments);
}
+ @Test
public void testIncludeLaunchers() {
assertEquals("1.0", true, noLauncherFlag.includeLaunchers());
assertEquals("1.1", false, falseLauncherFlag.includeLaunchers());
@@ -254,8 +293,10 @@ public class ProductFileTest extends TestCase {
}
/**
- * Test method for {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getProgramArguments(java.lang.String)}.
+ * Test method for
+ * {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getProgramArguments(java.lang.String)}.
*/
+ @Test
public void testGetProgramArguments() {
String programArguments = productFile.getProgramArguments("");
assertEquals("1.0", "programArg -name \"My Name\"", programArguments);
@@ -263,18 +304,21 @@ public class ProductFileTest extends TestCase {
assertEquals("1.1", "programArg -name \"My Name\"", programArguments);
}
+ @Test
public void testGetLicenseURL() throws Exception {
String productWithLicense = TestData.getFile("ProductActionTest", "productWithLicense.product").toString();
ProductFile product = new ProductFile(productWithLicense);
assertEquals("1.0", "http://www.example.com", product.getLicenseURL());
}
+ @Test
public void testGetLicenseText() throws Exception {
String productWithLicense = TestData.getFile("ProductActionTest", "productWithLicense.product").toString();
ProductFile product = new ProductFile(productWithLicense);
assertEquals("1.0", "This is the liCenSE.", product.getLicenseText().trim());
}
+ @Test
public void testGetVM() throws Exception {
String productWithVM = TestData.getFile("ProductActionTest", "productWithVM.product").toString();
ProductFile product = new ProductFile(productWithVM);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/VersionAdviceTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/VersionAdviceTest.java
index 744d93338..9d8df9cec 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/VersionAdviceTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/VersionAdviceTest.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2009, 2010 EclipseSource and others.
*
* This
@@ -14,21 +14,24 @@
******************************************************************************/
package org.eclipse.equinox.p2.tests.publisher.actions;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.publisher.actions.VersionAdvice;
import org.eclipse.equinox.p2.tests.TestData;
+import org.junit.Test;
/**
* Test cases for VersionAdvice
*/
-public class VersionAdviceTest extends TestCase {
-
+public class VersionAdviceTest {
+ @Test
public void testBadVersionPropertyFile() {
VersionAdvice versionAdvice = new VersionAdvice();
versionAdvice.load(null, "some random string");
}
+ @Test
public void testLoadNullVersionAdvice() throws Exception {
String versionAdviceFoo = TestData.getFile("publisher", "versionadvicefoo.prop").toString();
VersionAdvice versionAdvice = new VersionAdvice();
@@ -38,6 +41,7 @@ public class VersionAdviceTest extends TestCase {
assertEquals("3.0", Version.create("1.4.0"), versionAdvice.getVersion(null, "org.eclipse.tptp"));
}
+ @Test
public void testLoadNullVersionAdvice2() throws Exception {
String versionAdviceFoo = TestData.getFile("publisher", "versionadvicefoo.prop").toString();
VersionAdvice versionAdvice = new VersionAdvice();
@@ -47,6 +51,7 @@ public class VersionAdviceTest extends TestCase {
assertEquals("3.0", Version.create("1.4.0"), versionAdvice.getVersion(null, "org.eclipse.tptp"));
}
+ @Test
public void testOverloadNull() throws Exception {
String versionAdviceFoo = TestData.getFile("publisher", "versionadvicefoo.prop").toString();
String versionAdviceBar = TestData.getFile("publisher", "versionadvicebar.prop").toString();
@@ -59,6 +64,7 @@ public class VersionAdviceTest extends TestCase {
assertEquals("3.0", Version.create("1.5.0"), versionAdvice.getVersion(null, "org.eclipse.tptp"));
}
+ @Test
public void testLoadVersionAdviceFoo() throws Exception {
String versionAdviceFoo = TestData.getFile("publisher", "versionadvicefoo.prop").toString();
VersionAdvice versionAdvice = new VersionAdvice();
@@ -69,6 +75,7 @@ public class VersionAdviceTest extends TestCase {
assertEquals("4.0", null, versionAdvice.getVersion(null, "org.eclipse.tptp"));
}
+ @Test
public void testLoadVersionAdviceBar() throws Exception {
String versionAdviceBar = TestData.getFile("publisher", "versionadvicebar.prop").toString();
VersionAdvice versionAdvice = new VersionAdvice();
@@ -79,6 +86,7 @@ public class VersionAdviceTest extends TestCase {
assertEquals("4.0", Version.create("1.5.0"), versionAdvice.getVersion("bar", "org.eclipse.tptp"));
}
+ @Test
public void testLoadVersionAdviceFooBar() throws Exception {
String versionAdviceFoo = TestData.getFile("publisher", "versionadvicefoo.prop").toString();
String versionAdviceBar = TestData.getFile("publisher", "versionadvicebar.prop").toString();
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/repository/CacheManagerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/repository/CacheManagerTest.java
index 245ab1551..20ccc0762 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/repository/CacheManagerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/repository/CacheManagerTest.java
@@ -10,10 +10,12 @@
******************************************************************************/
package org.eclipse.equinox.p2.tests.repository;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.io.File;
import java.io.IOException;
import java.net.URI;
-import junit.framework.TestCase;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
@@ -24,10 +26,13 @@ import org.eclipse.equinox.p2.core.IAgentLocation;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.IProvisioningAgentProvider;
import org.eclipse.equinox.p2.core.ProvisionException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
-public class CacheManagerTest extends TestCase {
+public class CacheManagerTest {
private static final int ONE_HOUR = 3600000;
private URI repositoryLocation;
@@ -35,8 +40,8 @@ public class CacheManagerTest extends TestCase {
private CacheManager cacheManager;
private final String cachePrefix = "content"; //$NON-NLS-1$
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
repositoryLocation = createRepistory();
BundleContext bundle = Platform.getBundle("org.eclipse.equinox.p2.repository").getBundleContext();
ServiceReference<IProvisioningAgentProvider> serviceReference = bundle.getServiceReference(IProvisioningAgentProvider.class);
@@ -46,12 +51,13 @@ public class CacheManagerTest extends TestCase {
cacheManager = new CacheManager(new AgentLocationMock(), transport);
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
Path repositoryLocationPath = new Path(repositoryLocation.getPath());
deleteFileOrDirectory(repositoryLocationPath.toFile());
}
+ @Test
public void testRepositoryDowngraded() throws ProvisionException, IOException {
File cache = cacheManager.createCache(repositoryLocation, cachePrefix, new NullProgressMonitor());
long lastModifiedInitial = cache.lastModified();
@@ -65,6 +71,7 @@ public class CacheManagerTest extends TestCase {
lastModifiedInitial == cache2.lastModified());
}
+ @Test
public void testClientDifferentTimeZone() throws ProvisionException, IOException {
File cache = cacheManager.createCache(repositoryLocation, cachePrefix, new NullProgressMonitor());
long lastModifiedInitial = cache.lastModified();
@@ -79,6 +86,7 @@ public class CacheManagerTest extends TestCase {
lastModifiedInitial + ONE_HOUR == cache2.lastModified());
}
+ @Test
public void testRepositoryUpdate() throws ProvisionException, IOException {
File cache = cacheManager.createCache(repositoryLocation, cachePrefix, new NullProgressMonitor());
long lastModifiedInitial = cache.lastModified();
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/repository/RepositoryHelperTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/repository/RepositoryHelperTest.java
index 916a2f113..0da2613d7 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/repository/RepositoryHelperTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/repository/RepositoryHelperTest.java
@@ -1,30 +1,33 @@
/*******************************************************************************
* Copyright (c) 2009 Cloudsmith Inc and others.
*
- * This program and the accompanying materials
+ * This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* Cloudsmith Inc - initial API and implementation
*******************************************************************************/
package org.eclipse.equinox.p2.tests.repository;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.net.URI;
import java.net.URISyntaxException;
-import junit.framework.TestCase;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.internal.p2.repository.helpers.RepositoryHelper;
+import org.junit.Test;
/**
* Tests RepositoryHandler
*/
-public class RepositoryHelperTest extends TestCase {
-
+public class RepositoryHelperTest {
+ @Test
public void testURISyntaxChecker() throws URISyntaxException {
URI location = new URI("http://somwhere.com/path");
IStatus result = RepositoryHelper.checkRepositoryLocationSyntax(location);

Back to the top