Skip to content

Commit 2cb040e

Browse files
committed
Fix and simplify pde.ds.annotations.tests
Also convert assumptions to assertions since all of them should actually be assertions.
1 parent 2e87852 commit 2cb040e

15 files changed

Lines changed: 97 additions & 135 deletions

ds/org.eclipse.pde.ds.annotations.tests/META-INF/MANIFEST.MF

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@ Bundle-Activator: org.eclipse.pde.ds.internal.annotations.tests.Activator
77
Bundle-Vendor: Eclipse.org
88
Bundle-RequiredExecutionEnvironment: JavaSE-21
99
Bundle-ActivationPolicy: lazy
10-
Require-Bundle: org.eclipse.pde.ds.annotations;bundle-version="[1.4.0,1.5.0)",
11-
org.eclipse.pde.ds.core;bundle-version="[1.3.0,2.0.0)",
12-
org.eclipse.pde.ui;bundle-version="[3.16.0,4.0.0)",
13-
org.eclipse.core.resources;bundle-version="[3.23.0,4.0.0)",
14-
org.eclipse.core.runtime;bundle-version="[3.34.0,4.0.0)",
15-
org.eclipse.text;bundle-version="[3.14.0,4.0.0)"
10+
Require-Bundle: org.eclipse.pde.ds.annotations;bundle-version="[1.1.0,1.5.0)",
11+
org.eclipse.pde.ds.core;bundle-version="[1.1.0,2.0.0)",
12+
org.eclipse.pde.ui;bundle-version="[3.9.0,4.0.0)",
13+
org.eclipse.core.resources;bundle-version="[3.11.0,4.0.0)",
14+
org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)",
15+
org.eclipse.text;bundle-version="[3.6.0,4.0.0)",
16+
org.osgi.service.component.annotations;bundle-version="[1.5.0,2.0.0)"
1617
Export-Package: org.eclipse.pde.ds.internal.annotations.tests;x-internal:=true
17-
Import-Package: org.junit.jupiter.api;version="[5.14.0,6.0.0)",
18+
Import-Package: org.assertj.core.api;version="[3.27.0,4.0.0)",
19+
org.junit.jupiter.api;version="[5.14.0,6.0.0)",
1820
org.junit.jupiter.api.extension;version="[5.14.0,6.0.0)",
19-
org.junit.platform.suite.api;version="[1.14.0,2.0.0)",
20-
org.opentest4j;version="[1.3.0,2.0.0)"
21+
org.junit.platform.suite.api;version="[1.14.0,2.0.0)"
2122
Eclipse-BundleShape: dir
2223
Bundle-ClassPath: tests.jar
2324
Automatic-Module-Name: org.eclipse.pde.ds.annotations.tests
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
requires.0.namespace = org.eclipse.equinox.p2.iu
2+
requires.0.name = org.eclipse.jdt.launching.macosx
3+
requires.0.filter = (osgi.os=macosx)

ds/org.eclipse.pde.ds.annotations.tests/projects/test2/test.project

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
<arguments>
2121
</arguments>
2222
</buildCommand>
23+
<buildCommand>
24+
<name>org.eclipse.pde.ds.core.builder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
2328
</buildSpec>
2429
<natures>
2530
<nature>org.eclipse.pde.PluginNature</nature>

ds/org.eclipse.pde.ds.annotations.tests/src/org/eclipse/pde/ds/internal/annotations/tests/AnnotationProcessorTest.java

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22

33
import static org.junit.jupiter.api.Assertions.assertNotNull;
44
import static org.junit.jupiter.api.Assertions.assertTrue;
5-
import static org.junit.jupiter.api.Assumptions.assumeTrue;
6-
7-
import java.io.ByteArrayOutputStream;
8-
import java.io.InputStream;
95

106
import org.eclipse.core.resources.IFile;
117
import org.eclipse.core.resources.IProject;
8+
import org.eclipse.core.resources.IResource;
129
import org.eclipse.core.resources.ResourcesPlugin;
1310
import org.eclipse.core.runtime.IPath;
1411
import org.eclipse.jface.text.Document;
@@ -31,21 +28,13 @@ public abstract class AnnotationProcessorTest extends TestBase {
3128
@BeforeEach
3229
public void setUp() throws Exception {
3330
testProject = ResourcesPlugin.getWorkspace().getRoot().getProject(getTestProjectName());
34-
assumeTrue(testProject.exists(), "Test project does not exist!");
31+
assertTrue(testProject.exists(), "Test project does not exist!");
3532

3633
IFile dsFile = testProject.getFile(IPath.fromOSString(getComponentDescriptorPath()));
37-
assertTrue(dsFile.exists(),"Missing component descriptor!");
38-
39-
ByteArrayOutputStream buf = new ByteArrayOutputStream();
40-
try (InputStream src = dsFile.getContents()) {
41-
byte[] bytes = new byte[4096];
42-
int c;
43-
while ((c = src.read(bytes)) != -1) {
44-
buf.write(bytes, 0, c);
45-
}
46-
}
47-
48-
dsModel = new DSModel(new Document(buf.toString(dsFile.getCharset())), false);
34+
dsFile.refreshLocal(IResource.DEPTH_ZERO, null);
35+
assertTrue(dsFile.exists(), "Missing component descriptor:" + dsFile);
36+
String dsFileContent = dsFile.readString();
37+
dsModel = new DSModel(new Document(dsFileContent), false);
4938
dsModel.setUnderlyingResource(dsFile);
5039
dsModel.load();
5140

ds/org.eclipse.pde.ds.annotations.tests/src/org/eclipse/pde/ds/internal/annotations/tests/CompilationParticipantTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.eclipse.pde.ds.internal.annotations.tests;
22

3-
import static org.junit.jupiter.api.Assumptions.assumeTrue;
3+
import static org.junit.jupiter.api.Assertions.assertTrue;
44

55
import org.eclipse.core.resources.IProject;
66
import org.eclipse.core.resources.ResourcesPlugin;
@@ -15,6 +15,6 @@ public abstract class CompilationParticipantTest extends TestBase {
1515
@BeforeEach
1616
public void setUp() {
1717
testProject = ResourcesPlugin.getWorkspace().getRoot().getProject(getTestProjectName());
18-
assumeTrue(testProject.exists(), "Test project does not exist!");
18+
assertTrue(testProject.exists(), "Test project does not exist!");
1919
}
2020
}

ds/org.eclipse.pde.ds.annotations.tests/src/org/eclipse/pde/ds/internal/annotations/tests/DefaultComponentTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
import org.eclipse.pde.internal.ds.core.IDSProvide;
1313
import org.eclipse.pde.internal.ds.core.IDSReference;
1414
import org.eclipse.pde.internal.ds.core.IDSService;
15-
import org.junit.jupiter.api.Disabled;
1615
import org.junit.jupiter.api.Test;
1716

18-
@Disabled("Simply doesn't work in the new build environment yet")
1917
@SuppressWarnings("restriction")
2018
public class DefaultComponentTest extends AnnotationProcessorTest {
2119

ds/org.eclipse.pde.ds.annotations.tests/src/org/eclipse/pde/ds/internal/annotations/tests/ErrorProjectTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
import org.eclipse.core.resources.IMarker;
88
import org.eclipse.core.resources.IResource;
99
import org.eclipse.core.runtime.IPath;
10-
import org.junit.jupiter.api.Disabled;
1110
import org.junit.jupiter.api.Test;
1211

13-
@Disabled("Simply doesn't work in the new build environment yet")
1412
public class ErrorProjectTest extends CompilationParticipantTest {
1513

1614
private static final IPath PATH_PREFIX = IPath.fromOSString("src/ds/annotations/test2/");

ds/org.eclipse.pde.ds.annotations.tests/src/org/eclipse/pde/ds/internal/annotations/tests/ExtendedLifeCycleMethodComponentTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
import static org.junit.jupiter.api.Assertions.assertEquals;
44
import static org.junit.jupiter.api.Assertions.assertNull;
55

6-
import org.junit.jupiter.api.Disabled;
76
import org.junit.jupiter.api.Test;
87

9-
@Disabled("Simply doesn't work in the new build environment yet")
108
@SuppressWarnings("restriction")
119
public class ExtendedLifeCycleMethodComponentTest extends AnnotationProcessorTest {
1210

ds/org.eclipse.pde.ds.annotations.tests/src/org/eclipse/pde/ds/internal/annotations/tests/ExtendedReferenceMethodComponentTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
import java.util.concurrent.Executor;
77

88
import org.eclipse.pde.internal.ds.core.IDSReference;
9-
import org.junit.jupiter.api.Disabled;
109
import org.junit.jupiter.api.Test;
1110

12-
@Disabled("Simply doesn't work in the new build environment yet")
1311
@SuppressWarnings("restriction")
1412
public class ExtendedReferenceMethodComponentTest extends AnnotationProcessorTest {
1513

ds/org.eclipse.pde.ds.annotations.tests/src/org/eclipse/pde/ds/internal/annotations/tests/FullComponentTest.java

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import static org.junit.jupiter.api.Assertions.assertFalse;
55
import static org.junit.jupiter.api.Assertions.assertNotNull;
66
import static org.junit.jupiter.api.Assertions.assertNull;
7-
import static org.junit.jupiter.api.Assumptions.assumeTrue;
7+
import static org.junit.jupiter.api.Assertions.assertTrue;
88

99
import java.util.Map;
1010
import java.util.Set;
@@ -16,10 +16,8 @@
1616
import org.eclipse.pde.internal.ds.core.IDSProvide;
1717
import org.eclipse.pde.internal.ds.core.IDSReference;
1818
import org.eclipse.pde.internal.ds.core.IDSService;
19-
import org.junit.jupiter.api.Disabled;
2019
import org.junit.jupiter.api.Test;
2120

22-
@Disabled("Simply doesn't work in the new build environment yet")
2321
@SuppressWarnings("restriction")
2422
public class FullComponentTest extends AnnotationProcessorTest {
2523

@@ -111,9 +109,9 @@ public void componentProperties() throws Exception {
111109
@Test
112110
public void componentPropertyString() throws Exception {
113111
IDSProperty[] properties = dsModel.getDSComponent().getPropertyElements();
114-
assumeTrue(properties != null);
112+
assertNotNull(properties);
115113
final int PROPERTY_INDEX = 0;
116-
assumeTrue(properties.length > PROPERTY_INDEX);
114+
assertTrue(properties.length > PROPERTY_INDEX);
117115
assertEquals("stringProperty", properties[PROPERTY_INDEX].getPropertyName());
118116
assertEquals("stringValue", properties[PROPERTY_INDEX].getPropertyValue());
119117
assertEquals("String", properties[PROPERTY_INDEX].getPropertyType());
@@ -123,9 +121,9 @@ public void componentPropertyString() throws Exception {
123121
@Test
124122
public void componentPropertyImplicitString() throws Exception {
125123
IDSProperty[] properties = dsModel.getDSComponent().getPropertyElements();
126-
assumeTrue(properties != null);
124+
assertNotNull(properties);
127125
final int PROPERTY_INDEX = 1;
128-
assumeTrue(properties.length > PROPERTY_INDEX);
126+
assertTrue(properties.length > PROPERTY_INDEX);
129127
assertEquals("implicitStringProperty", properties[PROPERTY_INDEX].getPropertyName());
130128
assertEquals("implicitStringValue", properties[PROPERTY_INDEX].getPropertyValue());
131129
assertNull(properties[PROPERTY_INDEX].getPropertyType());
@@ -135,9 +133,9 @@ public void componentPropertyImplicitString() throws Exception {
135133
@Test
136134
public void componentPropertyExplicitString() throws Exception {
137135
IDSProperty[] properties = dsModel.getDSComponent().getPropertyElements();
138-
assumeTrue(properties != null);
136+
assertNotNull(properties);
139137
final int PROPERTY_INDEX = 2;
140-
assumeTrue(properties.length > PROPERTY_INDEX);
138+
assertTrue(properties.length > PROPERTY_INDEX);
141139
assertEquals("explicitStringProperty", properties[PROPERTY_INDEX].getPropertyName());
142140
assertEquals("explicitStringValue", properties[PROPERTY_INDEX].getPropertyValue());
143141
assertEquals("String", properties[PROPERTY_INDEX].getPropertyType());
@@ -147,9 +145,9 @@ public void componentPropertyExplicitString() throws Exception {
147145
@Test
148146
public void componentPropertyInteger() throws Exception {
149147
IDSProperty[] properties = dsModel.getDSComponent().getPropertyElements();
150-
assumeTrue(properties != null);
148+
assertNotNull(properties);
151149
final int PROPERTY_INDEX = 3;
152-
assumeTrue(properties.length > PROPERTY_INDEX);
150+
assertTrue(properties.length > PROPERTY_INDEX);
153151
assertEquals("integerProperty", properties[PROPERTY_INDEX].getPropertyName());
154152
assertEquals("1", properties[PROPERTY_INDEX].getPropertyValue());
155153
assertEquals("Integer", properties[PROPERTY_INDEX].getPropertyType());
@@ -159,9 +157,9 @@ public void componentPropertyInteger() throws Exception {
159157
@Test
160158
public void componentPropertyLong() throws Exception {
161159
IDSProperty[] properties = dsModel.getDSComponent().getPropertyElements();
162-
assumeTrue(properties != null);
160+
assertNotNull(properties);
163161
final int PROPERTY_INDEX = 4;
164-
assumeTrue(properties.length > PROPERTY_INDEX);
162+
assertTrue(properties.length > PROPERTY_INDEX);
165163
assertEquals("longProperty", properties[PROPERTY_INDEX].getPropertyName());
166164
assertEquals("2", properties[PROPERTY_INDEX].getPropertyValue());
167165
assertEquals("Long", properties[PROPERTY_INDEX].getPropertyType());
@@ -171,9 +169,9 @@ public void componentPropertyLong() throws Exception {
171169
@Test
172170
public void componentPropertyShort() throws Exception {
173171
IDSProperty[] properties = dsModel.getDSComponent().getPropertyElements();
174-
assumeTrue(properties != null);
172+
assertNotNull(properties);
175173
final int PROPERTY_INDEX = 5;
176-
assumeTrue(properties.length > PROPERTY_INDEX);
174+
assertTrue(properties.length > PROPERTY_INDEX);
177175
assertEquals("shortProperty", properties[PROPERTY_INDEX].getPropertyName());
178176
assertEquals("3", properties[PROPERTY_INDEX].getPropertyValue());
179177
assertEquals("Short", properties[PROPERTY_INDEX].getPropertyType());
@@ -183,9 +181,9 @@ public void componentPropertyShort() throws Exception {
183181
@Test
184182
public void componentPropertyByte() throws Exception {
185183
IDSProperty[] properties = dsModel.getDSComponent().getPropertyElements();
186-
assumeTrue(properties != null);
184+
assertNotNull(properties);
187185
final int PROPERTY_INDEX = 6;
188-
assumeTrue(properties.length > PROPERTY_INDEX);
186+
assertTrue(properties.length > PROPERTY_INDEX);
189187
assertEquals("byteProperty", properties[PROPERTY_INDEX].getPropertyName());
190188
assertEquals("4", properties[PROPERTY_INDEX].getPropertyValue());
191189
assertEquals("Byte", properties[PROPERTY_INDEX].getPropertyType());
@@ -195,9 +193,9 @@ public void componentPropertyByte() throws Exception {
195193
@Test
196194
public void componentPropertyCharacter() throws Exception {
197195
IDSProperty[] properties = dsModel.getDSComponent().getPropertyElements();
198-
assumeTrue(properties != null);
196+
assertNotNull(properties);
199197
final int PROPERTY_INDEX = 7;
200-
assumeTrue(properties.length > PROPERTY_INDEX);
198+
assertTrue(properties.length > PROPERTY_INDEX);
201199
assertEquals("characterProperty", properties[PROPERTY_INDEX].getPropertyName());
202200
assertEquals("53", properties[PROPERTY_INDEX].getPropertyValue());
203201
assertEquals("Character", properties[PROPERTY_INDEX].getPropertyType());
@@ -207,9 +205,9 @@ public void componentPropertyCharacter() throws Exception {
207205
@Test
208206
public void componentPropertyFloat() throws Exception {
209207
IDSProperty[] properties = dsModel.getDSComponent().getPropertyElements();
210-
assumeTrue(properties != null);
208+
assertNotNull(properties);
211209
final int PROPERTY_INDEX = 8;
212-
assumeTrue(properties.length > PROPERTY_INDEX);
210+
assertTrue(properties.length > PROPERTY_INDEX);
213211
assertEquals("floatProperty", properties[PROPERTY_INDEX].getPropertyName());
214212
assertEquals("6.7", properties[PROPERTY_INDEX].getPropertyValue());
215213
assertEquals("Float", properties[PROPERTY_INDEX].getPropertyType());
@@ -219,9 +217,9 @@ public void componentPropertyFloat() throws Exception {
219217
@Test
220218
public void componentPropertyDouble() throws Exception {
221219
IDSProperty[] properties = dsModel.getDSComponent().getPropertyElements();
222-
assumeTrue(properties != null);
220+
assertNotNull(properties);
223221
final int PROPERTY_INDEX = 9;
224-
assumeTrue(properties.length > PROPERTY_INDEX);
222+
assertTrue(properties.length > PROPERTY_INDEX);
225223
assertEquals("doubleProperty", properties[PROPERTY_INDEX].getPropertyName());
226224
assertEquals("8.9", properties[PROPERTY_INDEX].getPropertyValue());
227225
assertEquals("Double", properties[PROPERTY_INDEX].getPropertyType());
@@ -231,9 +229,9 @@ public void componentPropertyDouble() throws Exception {
231229
@Test
232230
public void componentPropertyImplicitStringArray() throws Exception {
233231
IDSProperty[] properties = dsModel.getDSComponent().getPropertyElements();
234-
assumeTrue(properties != null);
232+
assertNotNull(properties);
235233
final int PROPERTY_INDEX = 10;
236-
assumeTrue(properties.length > PROPERTY_INDEX);
234+
assertTrue(properties.length > PROPERTY_INDEX);
237235
assertEquals("implicitStringArrayProperty", properties[PROPERTY_INDEX].getPropertyName());
238236
assertNull(properties[PROPERTY_INDEX].getPropertyValue());
239237
assertNull(properties[PROPERTY_INDEX].getPropertyType());
@@ -243,9 +241,9 @@ public void componentPropertyImplicitStringArray() throws Exception {
243241
@Test
244242
public void componentPropertyExplicitStringArray() throws Exception {
245243
IDSProperty[] properties = dsModel.getDSComponent().getPropertyElements();
246-
assumeTrue(properties != null);
244+
assertNotNull(properties);
247245
final int PROPERTY_INDEX = 11;
248-
assumeTrue(properties.length > PROPERTY_INDEX);
246+
assertTrue(properties.length > PROPERTY_INDEX);
249247
assertEquals("explicitStringArrayProperty", properties[PROPERTY_INDEX].getPropertyName());
250248
assertNull(properties[PROPERTY_INDEX].getPropertyValue());
251249
assertEquals("String", properties[PROPERTY_INDEX].getPropertyType());

0 commit comments

Comments
 (0)