Skip to content

Commit

Permalink
enable java 17 for testing project (#903)
Browse files Browse the repository at this point in the history
* Updated testing pom to allow J17
* Added integration tests using J17
* Stopped the MWE2 Automation for testing and checked in required generated files
  • Loading branch information
minesh-s-patel authored Jan 22, 2025
1 parent 41d996f commit f81de67
Show file tree
Hide file tree
Showing 88 changed files with 156 additions and 6 deletions.
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 = {
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();
}
}

0 comments on commit f81de67

Please sign in to comment.