Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions ds/org.eclipse.pde.ds.annotations.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ Require-Bundle: org.eclipse.pde.ds.annotations;bundle-version="[1.1.0,1.5.0)",
org.eclipse.pde.ui;bundle-version="[3.9.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.11.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)",
org.eclipse.text;bundle-version="[3.6.0,4.0.0)"
org.eclipse.text;bundle-version="[3.6.0,4.0.0)",
org.osgi.annotation.bundle;bundle-version="[2.0.0,3.0.0)",
org.osgi.annotation.versioning;bundle-version="[1.1.0,2.0.0)",
org.osgi.service.component.annotations;bundle-version="[1.5.0,2.0.0)",
org.osgi.service.metatype.annotations;bundle-version="[1.2.0,2.0.0)"
Export-Package: org.eclipse.pde.ds.internal.annotations.tests;x-internal:=true
Import-Package: org.junit.jupiter.api;version="[5.14.0,6.0.0)",
Import-Package: org.assertj.core.api;version="[3.27.0,4.0.0)",
org.junit.jupiter.api;version="[5.14.0,6.0.0)",
org.junit.platform.suite.api;version="[1.14.0,2.0.0)"
Eclipse-BundleShape: dir
Bundle-ClassPath: tests.jar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ds.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ds.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.Enumeration;
import java.util.Map;
Expand Down Expand Up @@ -56,7 +55,7 @@ public static void setUpBeforeClass() throws Exception {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
// import test projects
Path wsRoot = Paths.get(ws.getRoot().getLocationURI());
Path wsRoot = ws.getRoot().getLocation().toPath();
for (Map.Entry<String, String> entry : projects.entrySet()) {
IProject project = ws.getRoot().getProject(entry.getKey());
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
package org.eclipse.pde.ds.internal.annotations.tests;

import static org.junit.Assume.assumeTrue;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.text.Document;
import org.eclipse.pde.internal.ds.core.IDSModel;
import org.eclipse.pde.internal.ds.core.text.DSModel;
import org.junit.After;
import org.junit.Before;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;

@SuppressWarnings("restriction")
public abstract class AnnotationProcessorTest extends TestBase {
Expand All @@ -28,31 +25,23 @@ public abstract class AnnotationProcessorTest extends TestBase {

protected abstract String getComponentDescriptorPath();

@Before
@BeforeEach
public void setUp() throws Exception {
testProject = ResourcesPlugin.getWorkspace().getRoot().getProject(getTestProjectName());
assumeTrue("Test project does not exist!", testProject.exists());
assertTrue(testProject.exists(), "Test project does not exist!");

IFile dsFile = testProject.getFile(IPath.fromOSString(getComponentDescriptorPath()));
assertTrue(dsFile.exists(),"Missing component descriptor!");

ByteArrayOutputStream buf = new ByteArrayOutputStream();
try (InputStream src = dsFile.getContents()) {
byte[] bytes = new byte[4096];
int c;
while ((c = src.read(bytes)) != -1) {
buf.write(bytes, 0, c);
}
}

dsModel = new DSModel(new Document(buf.toString(dsFile.getCharset())), false);
dsFile.refreshLocal(IResource.DEPTH_ZERO, null);
assertTrue(dsFile.exists(), "Missing component descriptor:" + dsFile);
String dsFileContent = dsFile.readString();
dsModel = new DSModel(new Document(dsFileContent), false);
dsModel.setUnderlyingResource(dsFile);
dsModel.load();

assertNotNull(dsModel.getDSComponent());
}

@After
@AfterEach
public void tearDown() throws Exception {
if (dsModel != null) {
dsModel.dispose();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package org.eclipse.pde.ds.internal.annotations.tests;

import static org.junit.Assume.assumeTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;

public abstract class CompilationParticipantTest extends TestBase {

protected IProject testProject;

protected abstract String getTestProjectName();

@Before
@BeforeEach
public void setUp() {
testProject = ResourcesPlugin.getWorkspace().getRoot().getProject(getTestProjectName());
assumeTrue("Test project does not exist!", testProject.exists());
assertTrue(testProject.exists(), "Test project does not exist!");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.Assume.assumeNotNull;
import static org.junit.Assume.assumeTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -110,9 +109,9 @@ public void componentProperties() throws Exception {
@Test
public void componentPropertyString() throws Exception {
IDSProperty[] properties = dsModel.getDSComponent().getPropertyElements();
assumeNotNull((Object) properties);
assertNotNull(properties);
final int PROPERTY_INDEX = 0;
assumeTrue(properties.length > PROPERTY_INDEX);
assertTrue(properties.length > PROPERTY_INDEX);
assertEquals("stringProperty", properties[PROPERTY_INDEX].getPropertyName());
assertEquals("stringValue", properties[PROPERTY_INDEX].getPropertyValue());
assertEquals("String", properties[PROPERTY_INDEX].getPropertyType());
Expand All @@ -122,9 +121,9 @@ public void componentPropertyString() throws Exception {
@Test
public void componentPropertyImplicitString() throws Exception {
IDSProperty[] properties = dsModel.getDSComponent().getPropertyElements();
assumeNotNull((Object) properties);
assertNotNull(properties);
final int PROPERTY_INDEX = 1;
assumeTrue(properties.length > PROPERTY_INDEX);
assertTrue(properties.length > PROPERTY_INDEX);
assertEquals("implicitStringProperty", properties[PROPERTY_INDEX].getPropertyName());
assertEquals("implicitStringValue", properties[PROPERTY_INDEX].getPropertyValue());
assertNull(properties[PROPERTY_INDEX].getPropertyType());
Expand All @@ -134,9 +133,9 @@ public void componentPropertyImplicitString() throws Exception {
@Test
public void componentPropertyExplicitString() throws Exception {
IDSProperty[] properties = dsModel.getDSComponent().getPropertyElements();
assumeNotNull((Object) properties);
assertNotNull(properties);
final int PROPERTY_INDEX = 2;
assumeTrue(properties.length > PROPERTY_INDEX);
assertTrue(properties.length > PROPERTY_INDEX);
assertEquals("explicitStringProperty", properties[PROPERTY_INDEX].getPropertyName());
assertEquals("explicitStringValue", properties[PROPERTY_INDEX].getPropertyValue());
assertEquals("String", properties[PROPERTY_INDEX].getPropertyType());
Expand All @@ -146,9 +145,9 @@ public void componentPropertyExplicitString() throws Exception {
@Test
public void componentPropertyInteger() throws Exception {
IDSProperty[] properties = dsModel.getDSComponent().getPropertyElements();
assumeNotNull((Object) properties);
assertNotNull(properties);
final int PROPERTY_INDEX = 3;
assumeTrue(properties.length > PROPERTY_INDEX);
assertTrue(properties.length > PROPERTY_INDEX);
assertEquals("integerProperty", properties[PROPERTY_INDEX].getPropertyName());
assertEquals("1", properties[PROPERTY_INDEX].getPropertyValue());
assertEquals("Integer", properties[PROPERTY_INDEX].getPropertyType());
Expand All @@ -158,9 +157,9 @@ public void componentPropertyInteger() throws Exception {
@Test
public void componentPropertyLong() throws Exception {
IDSProperty[] properties = dsModel.getDSComponent().getPropertyElements();
assumeNotNull((Object) properties);
assertNotNull(properties);
final int PROPERTY_INDEX = 4;
assumeTrue(properties.length > PROPERTY_INDEX);
assertTrue(properties.length > PROPERTY_INDEX);
assertEquals("longProperty", properties[PROPERTY_INDEX].getPropertyName());
assertEquals("2", properties[PROPERTY_INDEX].getPropertyValue());
assertEquals("Long", properties[PROPERTY_INDEX].getPropertyType());
Expand All @@ -170,9 +169,9 @@ public void componentPropertyLong() throws Exception {
@Test
public void componentPropertyShort() throws Exception {
IDSProperty[] properties = dsModel.getDSComponent().getPropertyElements();
assumeNotNull((Object) properties);
assertNotNull(properties);
final int PROPERTY_INDEX = 5;
assumeTrue(properties.length > PROPERTY_INDEX);
assertTrue(properties.length > PROPERTY_INDEX);
assertEquals("shortProperty", properties[PROPERTY_INDEX].getPropertyName());
assertEquals("3", properties[PROPERTY_INDEX].getPropertyValue());
assertEquals("Short", properties[PROPERTY_INDEX].getPropertyType());
Expand All @@ -182,9 +181,9 @@ public void componentPropertyShort() throws Exception {
@Test
public void componentPropertyByte() throws Exception {
IDSProperty[] properties = dsModel.getDSComponent().getPropertyElements();
assumeNotNull((Object) properties);
assertNotNull(properties);
final int PROPERTY_INDEX = 6;
assumeTrue(properties.length > PROPERTY_INDEX);
assertTrue(properties.length > PROPERTY_INDEX);
assertEquals("byteProperty", properties[PROPERTY_INDEX].getPropertyName());
assertEquals("4", properties[PROPERTY_INDEX].getPropertyValue());
assertEquals("Byte", properties[PROPERTY_INDEX].getPropertyType());
Expand All @@ -194,9 +193,9 @@ public void componentPropertyByte() throws Exception {
@Test
public void componentPropertyCharacter() throws Exception {
IDSProperty[] properties = dsModel.getDSComponent().getPropertyElements();
assumeNotNull((Object) properties);
assertNotNull(properties);
final int PROPERTY_INDEX = 7;
assumeTrue(properties.length > PROPERTY_INDEX);
assertTrue(properties.length > PROPERTY_INDEX);
assertEquals("characterProperty", properties[PROPERTY_INDEX].getPropertyName());
assertEquals("5", properties[PROPERTY_INDEX].getPropertyValue());
assertEquals("Character", properties[PROPERTY_INDEX].getPropertyType());
Expand All @@ -206,9 +205,9 @@ public void componentPropertyCharacter() throws Exception {
@Test
public void componentPropertyFloat() throws Exception {
IDSProperty[] properties = dsModel.getDSComponent().getPropertyElements();
assumeNotNull((Object) properties);
assertNotNull(properties);
final int PROPERTY_INDEX = 8;
assumeTrue(properties.length > PROPERTY_INDEX);
assertTrue(properties.length > PROPERTY_INDEX);
assertEquals("floatProperty", properties[PROPERTY_INDEX].getPropertyName());
assertEquals("6.7", properties[PROPERTY_INDEX].getPropertyValue());
assertEquals("Float", properties[PROPERTY_INDEX].getPropertyType());
Expand All @@ -218,9 +217,9 @@ public void componentPropertyFloat() throws Exception {
@Test
public void componentPropertyDouble() throws Exception {
IDSProperty[] properties = dsModel.getDSComponent().getPropertyElements();
assumeNotNull((Object) properties);
assertNotNull(properties);
final int PROPERTY_INDEX = 9;
assumeTrue(properties.length > PROPERTY_INDEX);
assertTrue(properties.length > PROPERTY_INDEX);
assertEquals("doubleProperty", properties[PROPERTY_INDEX].getPropertyName());
assertEquals("8.9", properties[PROPERTY_INDEX].getPropertyValue());
assertEquals("Double", properties[PROPERTY_INDEX].getPropertyType());
Expand All @@ -230,9 +229,9 @@ public void componentPropertyDouble() throws Exception {
@Test
public void componentPropertyImplicitStringArray() throws Exception {
IDSProperty[] properties = dsModel.getDSComponent().getPropertyElements();
assumeNotNull((Object) properties);
assertNotNull(properties);
final int PROPERTY_INDEX = 10;
assumeTrue(properties.length > PROPERTY_INDEX);
assertTrue(properties.length > PROPERTY_INDEX);
assertEquals("implicitStringArrayProperty", properties[PROPERTY_INDEX].getPropertyName());
assertNull(properties[PROPERTY_INDEX].getPropertyValue());
assertNull(properties[PROPERTY_INDEX].getPropertyType());
Expand All @@ -242,9 +241,9 @@ public void componentPropertyImplicitStringArray() throws Exception {
@Test
public void componentPropertyExplicitStringArray() throws Exception {
IDSProperty[] properties = dsModel.getDSComponent().getPropertyElements();
assumeNotNull((Object) properties);
assertNotNull(properties);
final int PROPERTY_INDEX = 11;
assumeTrue(properties.length > PROPERTY_INDEX);
assertTrue(properties.length > PROPERTY_INDEX);
assertEquals("explicitStringArrayProperty", properties[PROPERTY_INDEX].getPropertyName());
assertNull(properties[PROPERTY_INDEX].getPropertyValue());
assertEquals("String", properties[PROPERTY_INDEX].getPropertyType());
Expand Down
Loading
Loading