Skip to content

Commit

Permalink
Adding a first test for OSGi service implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
vogella committed Nov 20, 2024
1 parent 642ebdd commit 3917322
Show file tree
Hide file tree
Showing 10 changed files with 145 additions and 4 deletions.
11 changes: 11 additions & 0 deletions com.vogella.tasks.services.tests/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>
28 changes: 28 additions & 0 deletions com.vogella.tasks.services.tests/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.vogella.tasks.services.tests</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=21
org.eclipse.jdt.core.compiler.compliance=21
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=21
10 changes: 10 additions & 0 deletions com.vogella.tasks.services.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Tests for OSGi services
Bundle-SymbolicName: com.vogella.tasks.services.tests
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: VOGELLA
Fragment-Host: com.vogella.tasks.services;bundle-version="1.0.0"
Require-Bundle: junit-jupiter-api;bundle-version="5.11.0"
Automatic-Module-Name: com.vogella.tasks.services.tests
Bundle-RequiredExecutionEnvironment: JavaSE-21
4 changes: 4 additions & 0 deletions com.vogella.tasks.services.tests/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.vogella.tasks.services.tests;

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

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import com.vogella.tasks.services.internal.TransientTaskServiceImpl;

class TransientTaskServiceImplMoreTests {

@Test
@DisplayName("TransientTaskServiceImpl can be initialized")
void assertThatTaskServiceCanBeInitialized() {
TransientTaskServiceImpl service = new TransientTaskServiceImpl();
assertNotNull(service);
assertTrue(service.getAll().size()>0);
}


@Test
@DisplayName("TransientTaskServiceImpl provides at least one task ")
void assertThatTaskServiceProvidesData() {
TransientTaskServiceImpl service = new TransientTaskServiceImpl();
assertTrue(service.getAll().size()>0);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.vogella.tasks.services.tests;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import com.vogella.tasks.services.internal.TransientTaskServiceImpl;

class TransientTaskServiceImplTests {

@Test
@DisplayName("TransientTaskServiceImpl can be initialized")
void assertThatTaskServiceCanBeInitialized() {
TransientTaskServiceImpl service = new TransientTaskServiceImpl();
assertNotNull(service);
assertTrue(service.getAll().size()>0);
}


@Test
@DisplayName("TransientTaskServiceImpl provides at least one task ")
void assertThatTaskServiceProvidesData() {
TransientTaskServiceImpl service = new TransientTaskServiceImpl();
assertTrue(service.getAll().size()>0);
}

}
25 changes: 21 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>3.0.0-M9</version>

<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
Expand Down Expand Up @@ -77,7 +91,6 @@
<modules>
<module>com.vogella.ide.first</module>
<module>com.vogella.ide.feature</module>
<module>com.vogella.ide.product</module>
<module>com.vogella.tasks.model</module>
<module>com.vogella.tasks.services</module>
<module>com.vogella.tasks.ui</module>
Expand All @@ -91,10 +104,14 @@
<module>com.vogella.adapters</module>
<module>com.vogella.tasks.extendedsupplier</module>
<module>com.vogella.preferences.page</module>
<module>com.vogella.ide.editor.gradle</module>
<module>target-platform</module>
<module>com.vogella.ide.editor.gradle</module>

<!--Tests-->
<module>com.vogella.tasks.services.tests</module>
<module>updatesite</module>
<!--releng-->
<module>com.vogella.ide.product</module>

<!--TODO ADD YOUR MODULES HERE-->

</modules>
</project>
1 change: 1 addition & 0 deletions target-platform/target-platform.target
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<unit id="org.eclipse.equinox.sdk.feature.group" version="0.0.0"/>
<unit id="org.eclipse.platform.feature.group" version="0.0.0"/>
<unit id="org.eclipse.pde.spies.feature.group" version="0.0.0"/>
<unit id="junit-jupiter-engine" version="0.0.0"/>
</location>

<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
Expand Down

0 comments on commit 3917322

Please sign in to comment.