Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable java 17 for testing project #903

Merged
Merged
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
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
<module>rosetta-testing</module>
<module>rosetta-maven-plugin</module>
<module>rosetta-profiling</module>
<module>rosetta-integration-tests</module>
</modules>

<dependencyManagement>
Expand Down
83 changes: 83 additions & 0 deletions rosetta-integration-tests/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.regnosys.rosetta</groupId>
<artifactId>com.regnosys.rosetta.parent</artifactId>
<version>0.0.0.main-SNAPSHOT</version>
</parent>

<name>Rosetta DSL Integration Test Project</name>
<artifactId>rosetta-integration-tests</artifactId>
<properties>
<maven.compiler.release>17</maven.compiler.release>
</properties>

<dependencies>
<!-- Inter-project dependencies -->
<dependency>
<groupId>com.regnosys.rosetta</groupId>
<artifactId>com.regnosys.rosetta</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.regnosys.rosetta</groupId>
<artifactId>com.regnosys.rosetta.tests</artifactId>
<version>${project.version}</version>
</dependency>


<!-- External dependencies -->
<dependency>
<groupId>org.eclipse.xtext</groupId>
<artifactId>org.eclipse.xtext.testing</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.xtext</groupId>
<artifactId>org.eclipse.xtext.xbase.testing</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
</dependency>
<dependency>
<groupId>org.mdkt.compiler</groupId>
<artifactId>InMemoryJavaCompiler</artifactId>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.eclipse.xtend</groupId>
<artifactId>xtend-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets combine.children="append">
<fileset>
<directory>${basedir}/xtend-gen</directory>
<includes>
<include>**/*</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
</plugins>
</build>


</project>
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ Workflow {
srcGen = "${parentDir}/rosetta-lang/src-gen/main/java"
}
runtimeTest = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should actually refer to the test utility project. It's where Xtext will generate it's test utilities.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the MWE2 runtimeTest points to rosetta-testing
The issue is that it generates 2 things

  1. A Unit test (in rosetta-testing/src/test) - which is a Hello World test intended to be overriden.
  2. A type called RosettaInjectorProvider.java which (in rosetta-testing/src/main) which we need in the testing utils

When I just moved the all the tests to integration testing - it started to generate point 1 which caused a unit test failure.

When I move the MWE2 runtimeTest to point to rosetta-integration-tests, then we are generating point 2 int he wrong place.

I made a change to just disable the runtime test automation. The automation is meant to be a starting point and does not really (I think) provide much value any more.

The other option is that we move the MWE2 runtimeTest back to rosetta-testing, and check in the generated xtend test and live with 1 test being in rosetta-testing. I prefer the first option. @SimonCockx - take a look at the PR now and tell me what you think.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good!

enabled = true
name = "rosetta-testing"
root = "${parentDir}/rosetta-testing"
src = "${parentDir}/rosetta-testing/src/test/java"
srcGen = "${parentDir}/rosetta-testing/src-gen/main/java"
enabled = false
}
genericIde = {
enabled = true
Expand Down
2 changes: 1 addition & 1 deletion rosetta-testing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<version>0.0.0.main-SNAPSHOT</version>
</parent>

<name>Rosetta DSL Test Project</name>
<name>Rosetta DSL Testing Utilities</name>
<artifactId>com.regnosys.rosetta.tests</artifactId>

<properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright (c) REGnosys 2018 (www.regnosys.com)
* generated by Xtext 2.38.0.M1
*/
package com.regnosys.rosetta.tests;

import com.google.inject.Guice;
import com.google.inject.Injector;
import com.regnosys.rosetta.RosettaRuntimeModule;
import com.regnosys.rosetta.RosettaStandaloneSetup;
import org.eclipse.xtext.testing.GlobalRegistries;
import org.eclipse.xtext.testing.GlobalRegistries.GlobalStateMemento;
import org.eclipse.xtext.testing.IInjectorProvider;
import org.eclipse.xtext.testing.IRegistryConfigurator;

public class RosettaInjectorProvider implements IInjectorProvider, IRegistryConfigurator {

protected GlobalStateMemento stateBeforeInjectorCreation;
protected GlobalStateMemento stateAfterInjectorCreation;
protected Injector injector;

static {
GlobalRegistries.initializeDefaults();
}

@Override
public Injector getInjector() {
if (injector == null) {
this.injector = internalCreateInjector();
stateAfterInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
}
return injector;
}

protected Injector internalCreateInjector() {
return new RosettaStandaloneSetup() {
@Override
public Injector createInjector() {
return Guice.createInjector(createRuntimeModule());
}
}.createInjectorAndDoEMFRegistration();
}

protected RosettaRuntimeModule createRuntimeModule() {
// make it work also with Maven/Tycho and OSGI
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=493672
return new RosettaRuntimeModule() {
@Override
public ClassLoader bindClassLoaderToInstance() {
return RosettaInjectorProvider.class
.getClassLoader();
}
};
}

@Override
public void restoreRegistry() {
stateBeforeInjectorCreation.restoreGlobalState();
stateBeforeInjectorCreation = null;
}

@Override
public void setupRegistry() {
stateBeforeInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
if (injector == null) {
getInjector();
}
stateAfterInjectorCreation.restoreGlobalState();
}
}
Loading