Skip to content

Commit

Permalink
#167 Allow EMF Tests to run in p2 build
Browse files Browse the repository at this point in the history
- Update to mockito 4.9.0
  - Due to the update of the mockito versions, we are now able to run the emf tests again also in the p2 build
  - New version is not available via orbit, consume missing via org.eclipse.emfcloud.modelserver.tests bundle
  - Add mockito dependency libs to tests bundle
- If emf.tests are running via p2 the test resources are saved differently, hence let's execute tests on resources in a .temp directory to avoid having git changes on each p2 build.

Resolves #167
  • Loading branch information
ndoschek committed Jan 12, 2023
1 parent 4a5de6d commit abf1c02
Show file tree
Hide file tree
Showing 16 changed files with 58 additions and 24 deletions.
5 changes: 2 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@
<emfjson.jackson.version>2.0.0</emfjson.jackson.version>
<commons.io.version>2.8.0</commons.io.version>
<junit.version>4.13.2</junit.version>
<mockito.version>4.8.1</mockito.version>
<hamcrest.version>2.2</hamcrest.version>
<net.bytebuddy.version>1.12.16</net.bytebuddy.version>
<org.objenesis.version>3.3</org.objenesis.version>
<json-patch.version>1.13</json-patch.version>
Expand All @@ -120,8 +118,9 @@
<jetty.version>9.4.44.v20210927</jetty.version>
<jetty.websocket.version>9.4.44.v20210927</jetty.websocket.version>
<javalin.version>4.3.0</javalin.version>
<mockito.inline.version>4.8.1</mockito.inline.version>
<mockito.version>4.9.0</mockito.version>
<gmazzo.okhttp.mock.version>1.5.0</gmazzo.okhttp.mock.version>
<hamcrest.version>2.2</hamcrest.version>

<!-- Release Dependencies for M2 -->
<nexus.maven.version>1.6.8</nexus.maven.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
<target name="EMF.cloud Model Server Targetplatform" sequenceNumber="1673534083">
<target name="EMF.cloud Model Server Targetplatform" sequenceNumber="1673536165">
<locations>
<location includeMode="planner" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="false" type="InstallableUnit">
<unit id="org.eclipse.platform.feature.group" version="4.23.0.v20220308-0722"/>
Expand All @@ -19,7 +19,6 @@
<unit id="com.google.inject" version="5.0.1.v20221112-0806"/>
<unit id="com.google.guava" version="30.1.0.v20221112-0806"/>
<unit id="org.apache.commons.io" version="2.8.0.v20210415-0900"/>
<unit id="org.mockito.mockito-core" version="4.8.1.v20221103-2317"/>
<unit id="net.bytebuddy.byte-buddy" version="1.12.18.v20221114-2102"/>
<unit id="net.bytebuddy.byte-buddy-agent" version="1.12.18.v20221114-2102"/>
<unit id="org.objenesis" version="3.3.0.v20221103-2317"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ location "https://download.eclipse.org/tools/orbit/downloads/drops/R202211230215
com.google.inject [5.0.1,6.0.0)
com.google.guava [30.1.0,31.0.0)
org.apache.commons.io [2.8.0,3.0.0)
org.mockito.mockito-core [4.8.1,5.0.0)
net.bytebuddy.byte-buddy [1.12.18,2.0.0)
net.bytebuddy.byte-buddy-agent [1.12.18,2.0.0)
org.objenesis [3.3.0,4.0.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Require-Bundle: com.fasterxml.jackson.core.jackson-annotations;bundle-version="[
org.eclipse.emfcloud.modelserver.tests;bundle-version="[0.7.0,1.0.0)",
org.eclipse.emfcloud.emfjson-jackson;bundle-version="[2.0.0,3.0.0)",
org.junit;bundle-version="[4.12.0,5.0.0)",
org.mockito.mockito-core;bundle-version="[4.8.1,5.0.0)",
net.bytebuddy.byte-buddy;bundle-version="[1.9.0,2.0.0)",
net.bytebuddy.byte-buddy-agent;bundle-version="[1.9.0,2.0.0)",
org.objenesis;bundle-version="[3.3.0,4.0.0)"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.temp/
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Require-Bundle: com.fasterxml.jackson.core.jackson-annotations;bundle-version="[
org.eclipse.emfcloud.modelserver.tests;bundle-version="[0.7.0,1.0.0)",
org.eclipse.emfcloud.emfjson-jackson;bundle-version="[2.0.0,3.0.0)",
org.junit;bundle-version="[4.12.0,5.0.0)",
org.mockito.mockito-core;bundle-version="[4.8.1,5.0.0)",
org.objenesis;bundle-version="[3.3.0,4.0.0)"
Import-Package: javax.inject;version="1.0.0",
org.apache.logging.log4j;version="[2.17.1,3.0.0)",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2019 EclipseSource and others.
* Copyright (c) 2019-2023 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -10,9 +10,11 @@
********************************************************************************/
package org.eclipse.emfcloud.modelserver.emf;

import java.io.File;
import java.io.IOException;
import java.util.Collections;

import org.apache.commons.io.FileUtils;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
Expand All @@ -21,12 +23,23 @@
import org.eclipse.emfcloud.modelserver.common.codecs.EMFJsonConverter;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;

public abstract class AbstractResourceTest {
public static final String RESOURCE_PATH = "resources/";
public static final String TEST_RESOURCES_PATH = "resources/";
public static final String RESOURCE_PATH = ".temp/";
@SuppressWarnings({ "checkstyle:VisibilityModifier" })
protected ResourceSetImpl resourceSet; // needed in ResourceManagerTest.java

@BeforeClass
public static void setupTestResources() throws IOException {
// copy test resources to a temporary resource location to avoid
// git changes if executing tests due to saving resources
File sourceDirectory = new File(TEST_RESOURCES_PATH);
File destinationDirectory = new File(RESOURCE_PATH);
FileUtils.copyDirectory(sourceDirectory, destinationDirectory);
}

@Before
public void initializeResourceSet() {
resourceSet = new ResourceSetImpl();
Expand Down
5 changes: 3 additions & 2 deletions tests/org.eclipse.emfcloud.modelserver.tests/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
</classpathentry>
<classpathentry exported="true" kind="lib" path="lib/hamcrest-2.2.jar" sourcepath="lib/hamcrest-2.2-sources.jar"/>
<classpathentry exported="true" kind="lib" path="lib/hamcrest-core-2.2.jar" sourcepath="lib/hamcrest-core-2.2-sources.jar"/>
<classpathentry exported="true" kind="lib" path="lib/mockito-inline-4.8.1.jar" sourcepath="lib/mockito-inline-4.8.1-sources.jar"/>
<classpathentry exported="true" kind="lib" path="lib/okhttp-mock-1.5.0.jar" sourcepath="lib/okhttp-mock-1.5.0-sources.jar"/>
<classpathentry exported="true" kind="lib" path="lib/mockito-core-4.9.0.jar" sourcepath="lib/mockito-core-4.9.0-sources.jar"/>
<classpathentry exported="true" kind="lib" path="lib/mockito-inline-4.9.0.jar" sourcepath="lib/mockito-inline-4.9.0-source.jar"/>
<classpathentry exported="true" kind="lib" path="lib/okhttp-mock-1.5.0.jar" sourcepath="lib/okhttp-mock-1.5.0-source.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
17 changes: 14 additions & 3 deletions tests/org.eclipse.emfcloud.modelserver.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,25 @@ Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: org.eclipse.emf.common;bundle-version="[2.17.0,3.0.0)",
org.eclipse.emf.ecore;bundle-version="[2.20.0,3.0.0)",
org.eclipse.emf.edit;bundle-version="[2.16.0,3.0.0)",
org.eclipse.emfcloud.modelserver.lib;bundle-version="[0.7.0,1.0.0)"
org.eclipse.emfcloud.modelserver.lib;bundle-version="[0.7.0,1.0.0)",
org.junit;bundle-version="4.13.2",
net.bytebuddy.byte-buddy;bundle-version="[1.12.18,2.0.0)",
net.bytebuddy.byte-buddy-agent;bundle-version="[1.12.18,2.0.0)",
org.objenesis;bundle-version="[3.3.0,4.0.0)"
Export-Package: okhttp3.mock,
okhttp3.mock.matchers,
org.eclipse.emfcloud.modelserver.tests.util,
org.hamcrest
org.hamcrest,
org.mockito,
org.mockito.hamcrest,
org.mockito.invocation,
org.mockito.junit,
org.mockito.plugins,
org.mockito.stubbing
Bundle-ClassPath: .,
lib/hamcrest-2.2.jar,
lib/hamcrest-core-2.2.jar,
lib/mockito-inline-4.8.1.jar,
lib/mockito-core-4.9.0.jar,
lib/mockito-inline-4.9.0.jar,
lib/okhttp-mock-1.5.0.jar
Bundle-Vendor: EclipseSource
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ bin.includes = META-INF/,\
lib/hamcrest-2.2.jar,\
lib/hamcrest-core-2.2.jar,\
lib/okhttp-mock-1.5.0.jar,\
lib/mockito-inline-4.8.1.jar
lib/mockito-core-4.9.0.jar,\
lib/mockito-inline-4.9.0.jar
Binary file not shown.
Binary file not shown.
22 changes: 19 additions & 3 deletions tests/org.eclipse.emfcloud.modelserver.tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@
<packaging>${package.type}</packaging>

<dependencies>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>${mockito.inline.version}</version>
<version>${mockito.version}</version>
</dependency>
<dependency>
<groupId>com.github.gmazzo</groupId>
Expand Down Expand Up @@ -52,12 +57,23 @@
<artifactItem>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>${mockito.inline.version}</version>
<version>${mockito.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>${mockito.inline.version}</version>
<version>${mockito.version}</version>
<classifier>sources</classifier>
</artifactItem>
<artifactItem>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<classifier>sources</classifier>
</artifactItem>
<artifactItem>
Expand Down
6 changes: 1 addition & 5 deletions tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,14 @@
<module>org.eclipse.emfcloud.modelserver.client.tests</module>
<module>org.eclipse.emfcloud.modelserver.common.tests</module>
<module>org.eclipse.emfcloud.modelserver.edit.tests</module>
<module>org.eclipse.emfcloud.modelserver.emf.tests</module>
<module>org.eclipse.emfcloud.modelserver.tests</module>
</modules>

<profiles>
<profile>
<id>m2</id>

<!-- mockito cannot properly mock some classes so tests fail in p2 -->
<modules>
<module>org.eclipse.emfcloud.modelserver.emf.tests</module>
</modules>

<build>
<plugins>
<plugin>
Expand Down

0 comments on commit abf1c02

Please sign in to comment.