diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index b7bf06c43..88c916b41 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -5,9 +5,8 @@ name: Java CI with Maven on: push: - branches: [ 1.x.x-development ] + pull_request: - branches: [ 1.x.x-development ] @@ -18,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-18.04, macos-10.15, windows-2019] + os: [ubuntu-20.04, macos-latest, windows-2019] steps: - uses: actions/checkout@v2 - name: Set up JDK 1.8 @@ -30,18 +29,8 @@ jobs: - name: Maven Test run: mvn test - name: Artifact Name - if: runner.os == 'macOS' - run: | - JARPATH=$(find . -type f -iname 'coe-*-SNAPSHOT-jar-with-dependencies.jar') - echo "Found jar path: ${JARPATH}" - echo "Setting artifactpath to ${JARPATH}" - echo "::set-env name=artifactpath::${JARPATH}" - JARNAME=$(basename $JARPATH) - echo "Setting artifactname to ${JARNAME}" - echo "::set-env name=artifactname::${JARNAME}" - - name: Upload artifact - uses: actions/upload-artifact@v2 - if: runner.os == 'macOS' + uses: actions/upload-artifact@v3 with: - name: ${{env.artifactname}} - path: ${{env.artifactpath}} + name: maestro.jar + path: orchestration/coe/target/coe-*-SNAPSHOT-jar-with-dependencies.jar + retention-days: 5 diff --git a/.gitignore b/.gitignore index 734f23fbf..cb94c2245 100644 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,8 @@ orchestration/coe/interpreter.log* repository orchestration/coe/src/main/resources/coe-protocol/.texlipse orchestration/coe/src/main/java/META-INF/MANIFEST.MF +simulate.json +initialize.json +outputs.csv +.java-version +orchestration/coe/failed diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 4cea74169..000000000 --- a/Jenkinsfile +++ /dev/null @@ -1,66 +0,0 @@ -node { - try - { - - - stage ('Checkout'){ - checkout scm - } - - // Mark the code build - stage ('Build'){ - - withMaven(mavenLocalRepo: '.repository', mavenSettingsFilePath: "${env.MVN_SETTINGS_PATH}") { - - lock('FMU-SHM') { - // Run the maven build - sh "mvn clean install -U -Phtlatex -Dsimulation.profile.executiontime=true" - } - - step([$class: 'ArtifactArchiver', artifacts: '**/target/*.jar', fingerprint: true]) - step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml']) - step([$class: 'JacocoPublisher']) - step([$class: 'TasksPublisher', canComputeNew: false, defaultEncoding: '', excludePattern: '', healthy: '', high: 'FIXME', ignoreCase: true, low: '', normal: 'TODO', pattern: '', unHealthy: '']) - } - } - - stage ('Publish Artifactory'){ - - if (env.BRANCH_NAME == 'development') { - - def server = Artifactory.server "-844406945@1404457436085" - def buildInfo = Artifactory.newBuildInfo() - buildInfo.env.capture = true - //buildInfo.env.filter.addExclude("org/destecs/ide/**") - def rtMaven = Artifactory.newMavenBuild() - rtMaven.tool = "Maven 3.1.1" // Tool name from Jenkins configuration - rtMaven.opts = "-Xmx1024m -XX:MaxPermSize=256M" - rtMaven.deployer releaseRepo:'into-cps', snapshotRepo:'into-cps', server: server - - rtMaven.run pom: 'pom.xml', goals: 'install', buildInfo: buildInfo - - //get rid of old snapshots only keep then for a short amount of time - //Retention is commercial license only - //buildInfo.retention maxBuilds: 5, maxDays: 7, deleteBuildArtifacts: true - - // Publish build info. - server.publishBuildInfo buildInfo - } - } - - - } catch (any) { - currentBuild.result = 'FAILURE' - throw any //rethrow exception to prevent the build from proceeding - } finally { - - stage('Reporting'){ - - // Notify on build failure using the Email-ext plugin - emailext(body: '${DEFAULT_CONTENT}', mimeType: 'text/html', - replyTo: '$DEFAULT_REPLYTO', subject: '${DEFAULT_SUBJECT}', - to: emailextrecipients([[$class: 'CulpritsRecipientProvider'], - [$class: 'RequesterRecipientProvider']])) - }} -} - diff --git a/README.md b/README.md index 7232bfc16..b2d44ec63 100644 --- a/README.md +++ b/README.md @@ -98,3 +98,4 @@ for more see https://github.com/overturetool/overture/wiki/Release-Process remember to create github release from the released tag and upload: `target/checkout/orchestration/coe/target/coe-0.0.2-jar-with-dependencies.jar`. Furthermore, remember to update the download.json file in the development branch of INTO-CPS/github.io + diff --git a/orchestration/coe/pom.xml b/orchestration/coe/pom.xml index 9c737db63..b902911b3 100644 --- a/orchestration/coe/pom.xml +++ b/orchestration/coe/pom.xml @@ -10,12 +10,14 @@ 2.9.10.3 + 2.20.0 org.into-cps.orchestration coe The orchestration engine + scala-tools.org @@ -90,6 +92,12 @@ org.into-cps.fmi jnifmuapi + + + org.slf4j + slf4j-log4j12 + + @@ -131,12 +139,6 @@ test - - - log4j - apache-log4j-extras - 1.2.17 - @@ -175,7 +177,43 @@ test + + org.apache.logging.log4j + log4j-api + ${log4j2.version} + + + org.apache.logging.log4j + log4j-core + ${log4j2.version} + + + + + + + + + + + + + org.apache.logging.log4j + log4j-slf4j2-impl + ${log4j2.version} + runtime + + + org.apache.logging.log4j + log4j-slf4j-impl + ${log4j2.version} + + + org.slf4j + slf4j-api + 2.0.7 + diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/BasicInitializer.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/BasicInitializer.java index 8ba9cf8bf..281d73da3 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/BasicInitializer.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/BasicInitializer.java @@ -34,17 +34,7 @@ */ package org.intocps.orchestration.coe; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.*; -import java.util.function.Function; -import java.util.stream.Collector; -import java.util.stream.Collectors; -import java.util.stream.Stream; - import org.intocps.fmi.*; -import org.intocps.orchestration.coe.config.ModelConnection; import org.intocps.orchestration.coe.config.ModelConnection.ModelInstance; import org.intocps.orchestration.coe.config.ModelParameter; import org.intocps.orchestration.coe.cosim.base.CoSimInitializer; @@ -63,11 +53,14 @@ import org.intocps.orchestration.coe.util.Util; import org.jgrapht.DirectedGraph; import org.jgrapht.alg.CycleDetector; -import org.jgrapht.ext.DOTExporter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.xml.xpath.XPathExpressionException; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; public class BasicInitializer implements CoSimInitializer { diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/FmuFactory.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/FmuFactory.java index f04bcd649..f42d0fbc7 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/FmuFactory.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/FmuFactory.java @@ -34,11 +34,6 @@ */ package org.intocps.orchestration.coe; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.net.URI; - import org.apache.commons.io.FileUtils; import org.intocps.fmi.FmuInvocationException; import org.intocps.fmi.IFmu; @@ -47,6 +42,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.URI; + public class FmuFactory { final static Logger logger = LoggerFactory.getLogger(FmuFactory.class); diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/IFmuFactory.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/IFmuFactory.java index 90bc7aab7..6093d16d1 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/IFmuFactory.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/IFmuFactory.java @@ -34,11 +34,11 @@ */ package org.intocps.orchestration.coe; +import org.intocps.fmi.IFmu; + import java.io.File; import java.net.URI; -import org.intocps.fmi.IFmu; - public interface IFmuFactory { /** diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/BasicFixedStepSizeCalculator.scala b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/BasicFixedStepSizeCalculator.scala index 8c386d4af..c9be4e635 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/BasicFixedStepSizeCalculator.scala +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/BasicFixedStepSizeCalculator.scala @@ -35,12 +35,9 @@ package org.intocps.orchestration.coe.cosim import org.intocps.orchestration.coe.config.ModelConnection -import org.intocps.orchestration.coe.config.ModelConnection.Variable -import org.intocps.orchestration.coe.scala.CoeObject -import org.slf4j.LoggerFactory -import scala.collection.JavaConverters._ -import org.intocps.orchestration.coe.scala.VariableResolver import org.intocps.orchestration.coe.cosim.base.FmiSimulationInstance +import org.intocps.orchestration.coe.scala.{CoeObject, VariableResolver} +import org.slf4j.LoggerFactory class BasicFixedStepSizeCalculator(val size: Double) extends CoSimStepSizeCalculator { diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/CoSimStepSizeCalculator.scala b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/CoSimStepSizeCalculator.scala index ba4af34d5..5450cfe8f 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/CoSimStepSizeCalculator.scala +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/CoSimStepSizeCalculator.scala @@ -34,11 +34,9 @@ */ package org.intocps.orchestration.coe.cosim -import org.intocps.fmi.IFmiComponent -import org.intocps.orchestration.coe.scala.CoeObject import org.intocps.orchestration.coe.config.ModelConnection -import org.intocps.orchestration.coe.scala.VariableResolver import org.intocps.orchestration.coe.cosim.base.FmiSimulationInstance +import org.intocps.orchestration.coe.scala.{CoeObject, VariableResolver} /** * Interface that provides features to determine a step size which can be taken diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/ExternalSignalsStepSizeCalculator.scala b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/ExternalSignalsStepSizeCalculator.scala index bb6dd0700..8bcd3fa6d 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/ExternalSignalsStepSizeCalculator.scala +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/ExternalSignalsStepSizeCalculator.scala @@ -37,8 +37,8 @@ package org.intocps.orchestration.coe.cosim import org.intocps.orchestration.coe.config.ModelConnection.ModelInstance import org.intocps.orchestration.coe.cosim.base.FmiSimulationInstance -import org.intocps.orchestration.coe.scala.{Coe, VariableResolver} import org.intocps.orchestration.coe.scala.CoeObject.{GlobalState, Inputs, Outputs} +import org.intocps.orchestration.coe.scala.{Coe, VariableResolver} /** * Created by kel on 04/10/2017. diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/VariableStepSizeCalculator.scala b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/VariableStepSizeCalculator.scala index 6b324fc3d..474a96329 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/VariableStepSizeCalculator.scala +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/VariableStepSizeCalculator.scala @@ -34,30 +34,19 @@ */ package org.intocps.orchestration.coe.cosim -import java.lang - -import org.intocps.orchestration.coe.json.InitializationMsgJson - -import scala.collection.JavaConverters.mapAsJavaMapConverter -import scala.collection.JavaConverters.mapAsScalaMapConverter +import org.intocps.fmi.Fmi2Status import org.intocps.orchestration.coe.config.ModelConnection import org.intocps.orchestration.coe.config.ModelConnection.Variable -import org.intocps.orchestration.coe.scala.CoeObject +import org.intocps.orchestration.coe.cosim.base.FmiSimulationInstance +import org.intocps.orchestration.coe.cosim.varstep.{StepsizeCalculator, StepsizeInterval} +import org.intocps.orchestration.coe.json.InitializationMsgJson +import org.intocps.orchestration.coe.json.InitializationMsgJson.Constraint +import org.intocps.orchestration.coe.scala.CoeObject.FmiInstanceConfigScalaWrapper +import org.intocps.orchestration.coe.scala.{CoeObject, VariableResolver} import org.slf4j.LoggerFactory -import org.intocps.orchestration.coe.cosim.varstep.StepsizeCalculator -import InitializationMsgJson.Constraint -import org.intocps.orchestration.coe.cosim.varstep.StepsizeInterval -import org.intocps.orchestration.coe.scala.VariableResolver import scala.collection.JavaConversions._ -import org.intocps.orchestration.coe.scala.CoeObject.FmiInstanceConfigScalaWrapper -import org.intocps.orchestration.coe.cosim.varstep.StepsizeCalculator -import org.intocps.orchestration.coe.cosim.base.FmiSimulationInstance -import org.intocps.orchestration.coe.cosim.varstep.StepsizeCalculator -import InitializationMsgJson.Constraint -import org.intocps.fmi.Fmi2Status - -import scala.collection.immutable +import scala.collection.JavaConverters.mapAsJavaMapConverter class VariableStepSizeCalculator(constraints: java.util.Set[Constraint], val stepsizeInterval: StepsizeInterval, diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/base/CoSimInitializer.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/base/CoSimInitializer.java index da0e5fdca..673cab96d 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/base/CoSimInitializer.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/base/CoSimInitializer.java @@ -34,15 +34,15 @@ */ package org.intocps.orchestration.coe.cosim.base; -import java.util.List; -import java.util.Map; - import org.intocps.fmi.FmuInvocationException; import org.intocps.orchestration.coe.AbortSimulationException; -import org.intocps.orchestration.coe.config.*; import org.intocps.orchestration.coe.config.ModelConnection.ModelInstance; +import org.intocps.orchestration.coe.config.ModelParameter; import org.intocps.orchestration.coe.modeldefinition.ModelDescription.ScalarVariable; +import java.util.List; +import java.util.Map; + /** * initializer interface responsible for initializing all components.
Methods on this interface will be called in * the FMI initialization state diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/base/CoSimMasterAlgorithm.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/base/CoSimMasterAlgorithm.java index 6b8c49e0a..aca748867 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/base/CoSimMasterAlgorithm.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/base/CoSimMasterAlgorithm.java @@ -34,10 +34,10 @@ */ package org.intocps.orchestration.coe.cosim.base; -import java.util.Set; - import org.intocps.fmi.IFmiComponent; +import java.util.Set; + /** * The master algorithm on the COE that is responsible for calling * {@link CoSimInitializer} looping over {@link CoSimStepSizeCalculator} diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/base/FmiInstanceConfig.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/base/FmiInstanceConfig.java index 85577ba71..ca1456221 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/base/FmiInstanceConfig.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/base/FmiInstanceConfig.java @@ -34,11 +34,11 @@ */ package org.intocps.orchestration.coe.cosim.base; -import java.util.List; - import org.intocps.orchestration.coe.modeldefinition.ModelDescription; import org.intocps.orchestration.coe.modeldefinition.ModelDescription.ScalarVariable; +import java.util.List; + /** * Temporary class for a fmi component model description, It needs to fetch and cache the model description for faster * simulation access diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/CurrentSolutionPoint.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/CurrentSolutionPoint.java index d88f7ad55..61f06928f 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/CurrentSolutionPoint.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/CurrentSolutionPoint.java @@ -42,15 +42,15 @@ */ package org.intocps.orchestration.coe.cosim.varstep; -import java.util.HashMap; -import java.util.Map; -import java.util.Observable; - import org.intocps.orchestration.coe.config.ModelConnection.ModelInstance; import org.intocps.orchestration.coe.config.ModelConnection.Variable; import org.intocps.orchestration.coe.modeldefinition.ModelDescription.ScalarVariable; import org.intocps.orchestration.coe.modeldefinition.ModelDescription.Types; +import java.util.HashMap; +import java.util.Map; +import java.util.Observable; + public class CurrentSolutionPoint extends Observable { diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/StepsizeCalculator.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/StepsizeCalculator.java index 19d3aa8ce..6b1fe1f94 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/StepsizeCalculator.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/StepsizeCalculator.java @@ -42,14 +42,6 @@ */ package org.intocps.orchestration.coe.cosim.varstep; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Vector; - import org.intocps.orchestration.coe.AbortSimulationException; import org.intocps.orchestration.coe.config.ModelConnection; import org.intocps.orchestration.coe.config.ModelConnection.ModelInstance; @@ -66,6 +58,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.*; + public class StepsizeCalculator { diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/constraint/ConstraintHandlerFactory.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/constraint/ConstraintHandlerFactory.java index 3cc36993c..7ee5c228d 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/constraint/ConstraintHandlerFactory.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/constraint/ConstraintHandlerFactory.java @@ -42,13 +42,6 @@ */ package org.intocps.orchestration.coe.cosim.varstep.constraint; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Observable; -import java.util.Set; - import org.intocps.orchestration.coe.AbortSimulationException; import org.intocps.orchestration.coe.config.ModelConnection.Variable; import org.intocps.orchestration.coe.cosim.varstep.StepsizeInterval; @@ -59,6 +52,8 @@ import org.intocps.orchestration.coe.modeldefinition.ModelDescription.Types; import org.slf4j.Logger; +import java.util.*; + public class ConstraintHandlerFactory { diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/constraint/boundeddifference/BoundedDifferenceCalculator.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/constraint/boundeddifference/BoundedDifferenceCalculator.java index a2b0d4c93..db1b4f36f 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/constraint/boundeddifference/BoundedDifferenceCalculator.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/constraint/boundeddifference/BoundedDifferenceCalculator.java @@ -42,14 +42,14 @@ */ package org.intocps.orchestration.coe.cosim.varstep.constraint.boundeddifference; +import org.intocps.orchestration.coe.config.ModelConnection.Variable; +import org.intocps.orchestration.coe.cosim.varstep.valuetracker.DoubleValueTracker; + import java.util.Collections; import java.util.List; import java.util.Observable; import java.util.Vector; -import org.intocps.orchestration.coe.config.ModelConnection.Variable; -import org.intocps.orchestration.coe.cosim.varstep.valuetracker.DoubleValueTracker; - public class BoundedDifferenceCalculator { private List tracker = new Vector(); diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/constraint/boundeddifference/BoundedDifferenceHandler.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/constraint/boundeddifference/BoundedDifferenceHandler.java index 57a1dd971..8aecd9efc 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/constraint/boundeddifference/BoundedDifferenceHandler.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/constraint/boundeddifference/BoundedDifferenceHandler.java @@ -42,12 +42,9 @@ */ package org.intocps.orchestration.coe.cosim.varstep.constraint.boundeddifference; -import java.util.Observable; -import java.util.Observer; - import org.intocps.orchestration.coe.cosim.varstep.CurrentSolutionPoint; -import org.intocps.orchestration.coe.cosim.varstep.StepsizeInterval; import org.intocps.orchestration.coe.cosim.varstep.CurrentSolutionPoint.Operation; +import org.intocps.orchestration.coe.cosim.varstep.StepsizeInterval; import org.intocps.orchestration.coe.cosim.varstep.constraint.ConstraintHandler; import org.intocps.orchestration.coe.cosim.varstep.constraint.boundeddifference.stepsize.BdStepsizeAdjustmentStrategy; import org.intocps.orchestration.coe.cosim.varstep.constraint.boundeddifference.stepsize.SimpleBdStepsizeAdjustmentStrategy; @@ -56,6 +53,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Observable; +import java.util.Observer; + public class BoundedDifferenceHandler implements Observer, ConstraintHandler { diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/constraint/boundeddifference/stepsize/SimpleBdStepsizeAdjustmentStrategy.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/constraint/boundeddifference/stepsize/SimpleBdStepsizeAdjustmentStrategy.java index 6bd74bb7d..82a73a705 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/constraint/boundeddifference/stepsize/SimpleBdStepsizeAdjustmentStrategy.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/constraint/boundeddifference/stepsize/SimpleBdStepsizeAdjustmentStrategy.java @@ -42,15 +42,15 @@ */ package org.intocps.orchestration.coe.cosim.varstep.constraint.boundeddifference.stepsize; -import java.util.Observable; -import java.util.Observer; - import org.intocps.orchestration.coe.cosim.varstep.CurrentSolutionPoint; import org.intocps.orchestration.coe.cosim.varstep.CurrentSolutionPoint.Operation; import org.intocps.orchestration.coe.cosim.varstep.StepsizeInterval; import org.intocps.orchestration.coe.cosim.varstep.constraint.boundeddifference.BoundedDifferenceCalculator; import org.intocps.orchestration.coe.json.InitializationMsgJson.Constraint; +import java.util.Observable; +import java.util.Observer; + public class SimpleBdStepsizeAdjustmentStrategy implements Observer, BdStepsizeAdjustmentStrategy { diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/constraint/samplingrate/SamplingRateHandler.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/constraint/samplingrate/SamplingRateHandler.java index 661a3fa83..2d42db3de 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/constraint/samplingrate/SamplingRateHandler.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/constraint/samplingrate/SamplingRateHandler.java @@ -42,14 +42,14 @@ */ package org.intocps.orchestration.coe.cosim.varstep.constraint.samplingrate; -import java.util.Observable; -import java.util.Observer; - import org.intocps.orchestration.coe.cosim.varstep.CurrentSolutionPoint; import org.intocps.orchestration.coe.cosim.varstep.StepsizeInterval; import org.intocps.orchestration.coe.cosim.varstep.constraint.ConstraintHandler; import org.intocps.orchestration.coe.json.InitializationMsgJson.Constraint; +import java.util.Observable; +import java.util.Observer; + public class SamplingRateHandler implements Observer, ConstraintHandler { private Double currentTime; diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/constraint/zerocrossing/ZerocrossingHandler.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/constraint/zerocrossing/ZerocrossingHandler.java index 53907a1a0..166ebbd26 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/constraint/zerocrossing/ZerocrossingHandler.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/constraint/zerocrossing/ZerocrossingHandler.java @@ -42,9 +42,6 @@ */ package org.intocps.orchestration.coe.cosim.varstep.constraint.zerocrossing; -import java.util.Observable; -import java.util.Observer; - import org.intocps.orchestration.coe.cosim.varstep.CurrentSolutionPoint; import org.intocps.orchestration.coe.cosim.varstep.CurrentSolutionPoint.Operation; import org.intocps.orchestration.coe.cosim.varstep.StepsizeInterval; @@ -59,6 +56,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Observable; +import java.util.Observer; + public class ZerocrossingHandler implements Observer, ConstraintHandler { diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/derivatives/DerivativeEstimator.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/derivatives/DerivativeEstimator.java index d0ca79d89..f5d9195db 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/derivatives/DerivativeEstimator.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/derivatives/DerivativeEstimator.java @@ -42,13 +42,13 @@ */ package org.intocps.orchestration.coe.cosim.varstep.derivatives; -import java.util.HashMap; -import java.util.Map; - import org.intocps.orchestration.coe.config.ModelConnection.ModelInstance; import org.intocps.orchestration.coe.modeldefinition.ModelDescription.ScalarVariable; import org.intocps.orchestration.coe.modeldefinition.ModelDescription.Types; +import java.util.HashMap; +import java.util.Map; + public class DerivativeEstimator { diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/valuetracker/DoubleValueTracker.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/valuetracker/DoubleValueTracker.java index eb716b531..6aa70013e 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/valuetracker/DoubleValueTracker.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/valuetracker/DoubleValueTracker.java @@ -42,15 +42,15 @@ */ package org.intocps.orchestration.coe.cosim.varstep.valuetracker; -import java.util.Observable; -import java.util.Observer; - import org.intocps.orchestration.coe.config.ModelConnection.Variable; import org.intocps.orchestration.coe.cosim.varstep.CurrentSolutionPoint; import org.intocps.orchestration.coe.cosim.varstep.CurrentSolutionPoint.Operation; import org.intocps.orchestration.coe.cosim.varstep.derivatives.ScalarDerivativeEstimator; import org.intocps.orchestration.coe.cosim.varstep.extrapolationerror.ExtrapolationErrorEstimator; +import java.util.Observable; +import java.util.Observer; + public class DoubleValueTracker implements Observer, ValueTracker { diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/valuetracker/OptionalDifferenceTracker.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/valuetracker/OptionalDifferenceTracker.java index c3dcf92ae..942256571 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/valuetracker/OptionalDifferenceTracker.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/cosim/varstep/valuetracker/OptionalDifferenceTracker.java @@ -42,11 +42,11 @@ */ package org.intocps.orchestration.coe.cosim.varstep.valuetracker; +import org.intocps.orchestration.coe.config.ModelConnection.Variable; + import java.util.List; import java.util.Observable; -import org.intocps.orchestration.coe.config.ModelConnection.Variable; - public class OptionalDifferenceTracker implements ValueTracker { private ValueTracker value1 = null; diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/hierarchical/GlobalStateMerger.scala b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/hierarchical/GlobalStateMerger.scala index cb8dcf18d..319cbcbab 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/hierarchical/GlobalStateMerger.scala +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/hierarchical/GlobalStateMerger.scala @@ -37,8 +37,8 @@ package org.intocps.orchestration.coe.hierarchical import org.intocps.orchestration.coe.config.ModelConnection.ModelInstance import org.intocps.orchestration.coe.modeldefinition.ModelDescription.ScalarVariable -import org.intocps.orchestration.coe.scala.{CoeObject, InstanceState} import org.intocps.orchestration.coe.scala.CoeObject.GlobalState +import org.intocps.orchestration.coe.scala.InstanceState import scala.collection.JavaConversions._ diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/hierarchical/HierarchicalCoeComponent.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/hierarchical/HierarchicalCoeComponent.java index d05864a62..8d0076302 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/hierarchical/HierarchicalCoeComponent.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/hierarchical/HierarchicalCoeComponent.java @@ -50,7 +50,6 @@ import org.intocps.orchestration.coe.modeldefinition.xml.NodeIterator; import org.intocps.orchestration.coe.scala.Coe; import org.intocps.orchestration.coe.scala.CoeObject; -import org.intocps.orchestration.coe.scala.IStateChangeListener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Document; diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/hierarchical/HierarchicalExternalFmuStub.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/hierarchical/HierarchicalExternalFmuStub.java index 0e799dc6b..416e28145 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/hierarchical/HierarchicalExternalFmuStub.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/hierarchical/HierarchicalExternalFmuStub.java @@ -44,7 +44,6 @@ import java.io.InputStream; import java.net.URI; import java.nio.file.Paths; -import java.util.zip.ZipException; /** * Created by kel on 05/10/2017. diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/hierarchical/HierarchicalExternalFmuStubComponent.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/hierarchical/HierarchicalExternalFmuStubComponent.java index d31399523..79030ff5f 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/hierarchical/HierarchicalExternalFmuStubComponent.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/hierarchical/HierarchicalExternalFmuStubComponent.java @@ -34,23 +34,10 @@ */ package org.intocps.orchestration.coe.hierarchical; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import fi.iki.elonen.NanoHTTPD; -import org.apache.commons.io.IOUtils; import org.intocps.fmi.*; -import org.intocps.orchestration.coe.FmuFactory; -import org.intocps.orchestration.coe.IFmuFactory; -import org.intocps.orchestration.coe.httpserver.RequestProcessors; -import org.intocps.orchestration.coe.httpserver.SessionController; -import org.intocps.orchestration.coe.json.ProdSessionLogicFactory; -import org.intocps.orchestration.coe.scala.Coe; -import org.intocps.orchestration.coe.scala.CoeObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.IOException; - /** * Created by kel on 04/10/2017. */ diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/httpserver/RequestHandler.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/httpserver/RequestHandler.java index 1a039be36..f201d896c 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/httpserver/RequestHandler.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/httpserver/RequestHandler.java @@ -34,19 +34,17 @@ */ package org.intocps.orchestration.coe.httpserver; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; - import fi.iki.elonen.NanoHTTPD; import fi.iki.elonen.NanoWSD; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; /** * Created by ctha on 29-03-2016. diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/httpserver/RequestProcessors.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/httpserver/RequestProcessors.java index c06c75a5e..3e0ca052d 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/httpserver/RequestProcessors.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/httpserver/RequestProcessors.java @@ -38,9 +38,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import fi.iki.elonen.NanoHTTPD; import org.apache.commons.io.FileUtils; -import org.apache.log4j.FileAppender; -import org.apache.log4j.Level; -import org.apache.log4j.LogManager; import org.intocps.orchestration.coe.config.InvalidVariableStringException; import org.intocps.orchestration.coe.config.ModelConnection; import org.intocps.orchestration.coe.config.ModelParameter; @@ -56,6 +53,7 @@ import org.intocps.orchestration.coe.scala.CoeStatus; import org.intocps.orchestration.coe.scala.LogVariablesContainer; import org.intocps.orchestration.coe.util.DeleteOnCloseFileInputStream; +import org.intocps.orchestration.coe.util.Util; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -192,7 +190,8 @@ public NanoHTTPD.Response processInitialize(String sessionId, String data) throw } if (st.overrideLogLevel != null) { - LogManager.getRootLogger().setLevel(Level.toLevel(st.overrideLogLevel)); + org.intocps.orchestration.coe.util.Util.setLogLevel(st.overrideLogLevel); + } if (st.getFmuFiles() == null) { @@ -421,36 +420,7 @@ public NanoHTTPD.Response processResult(String sessionId, boolean zip) throws IO } public NanoHTTPD.Response processDestroy(String sessionId) throws IOException { - logger.debug("Destroying session {}.", sessionId); - org.apache.log4j.Logger rootLogger = org.apache.log4j.Logger.getRootLogger(); - ArrayList appendersToRemove = new ArrayList<>(); - Enumeration appenders = rootLogger.getAllAppenders(); - - if (appenders != null) { - while (appenders.hasMoreElements()) { - try { - Object element = appenders.nextElement(); - if (element != null && element instanceof FileAppender) { - FileAppender fileAppender = (FileAppender) element; - logger.debug("Checking if appender to file {} belongs to session {}", fileAppender.getFile(), sessionId); - if (fileAppender.getFile() != null && fileAppender.getFile() - .matches("(.*)(" + sessionId + ")[/\\\\](.*)[/\\\\].*(\\.log)$")) { - // Log files for fmu instances. - // Regex matches +sessionId++++anything.log - logger.debug("Closing appender to file {}", fileAppender.getFile()); - fileAppender.close(); - appendersToRemove.add(fileAppender); - } - } - } catch (NoSuchElementException e) { - //this is not synchronized so this can happen - } - } - appendersToRemove.forEach(fa -> { - rootLogger.removeAppender(fa); - }); - - } + Util.removeCoSimInstanceLogAppenders(sessionId); File resultFile = this.sessionController.getSessionRootDir(sessionId); logger.debug("Deleting directory {}.", resultFile.getPath()); FileUtils.deleteDirectory(resultFile); diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/httpserver/Response.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/httpserver/Response.java index 35eccffc0..beedc53da 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/httpserver/Response.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/httpserver/Response.java @@ -34,7 +34,8 @@ */ package org.intocps.orchestration.coe.httpserver; -import java.io.*; +import java.io.ByteArrayInputStream; +import java.io.InputStream; import java.util.Properties; /** diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/httpserver/SessionController.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/httpserver/SessionController.java index 466cc725d..e5b773b98 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/httpserver/SessionController.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/httpserver/SessionController.java @@ -34,7 +34,6 @@ */ package org.intocps.orchestration.coe.httpserver; -import org.intocps.orchestration.coe.httpserver.SessionLogic; import org.intocps.orchestration.coe.json.SessionLogicFactory; import org.intocps.orchestration.coe.json.StatusMsgJson; import org.intocps.orchestration.coe.scala.Coe; diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/initializing/GraphBuilder.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/initializing/GraphBuilder.java index 15895e038..a7510423a 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/initializing/GraphBuilder.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/initializing/GraphBuilder.java @@ -35,7 +35,6 @@ package org.intocps.orchestration.coe.initializing; import org.intocps.orchestration.coe.AbortSimulationException; -import org.intocps.orchestration.coe.BasicInitializer; import org.intocps.orchestration.coe.config.ModelConnection; import org.intocps.orchestration.coe.cosim.base.FmiSimulationInstance; import org.intocps.orchestration.coe.cosim.base.Tuple2; diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/initializing/Port.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/initializing/Port.java index b3beca4fd..a0c5b2963 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/initializing/Port.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/initializing/Port.java @@ -35,7 +35,6 @@ package org.intocps.orchestration.coe.initializing; import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.intocps.orchestration.coe.BasicInitializer; import org.intocps.orchestration.coe.config.ModelConnection; import org.intocps.orchestration.coe.cosim.base.FmiSimulationInstance; import org.intocps.orchestration.coe.modeldefinition.ModelDescription; diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/json/InitializationMsgJson.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/json/InitializationMsgJson.java index 50b8c0b77..52f7c4c64 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/json/InitializationMsgJson.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/json/InitializationMsgJson.java @@ -41,11 +41,9 @@ import org.intocps.orchestration.coe.config.ModelConnection.Variable; import org.intocps.orchestration.coe.cosim.varstep.constraint.ConstraintType; import org.intocps.orchestration.coe.cosim.varstep.constraint.samplingrate.Sampling; -import org.intocps.orchestration.coe.cosim.varstep.valuetracker.DoubleValueTracker; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; import java.lang.reflect.Field; import java.net.URI; import java.util.HashMap; diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/json/InitializationStatusJson.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/json/InitializationStatusJson.java index 87411a5b6..7eae9d22a 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/json/InitializationStatusJson.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/json/InitializationStatusJson.java @@ -34,11 +34,11 @@ */ package org.intocps.orchestration.coe.json; +import org.intocps.orchestration.coe.modeldefinition.ModelDescription.LogCategory; + import java.util.List; import java.util.Map; -import org.intocps.orchestration.coe.modeldefinition.ModelDescription.LogCategory; - public class InitializationStatusJson extends StatusMsgJson { public Map> avaliableLogLevels; diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/Coe.scala b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/Coe.scala index 0da1f9c5d..5c3b32d78 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/Coe.scala +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/Coe.scala @@ -34,11 +34,6 @@ */ package org.intocps.orchestration.coe.scala -import java.io.File -import java.net.URI -import java.util -import java.util.List - import org.apache.commons.io.{FileUtils, FilenameUtils} import org.apache.commons.lang3.time.DurationFormatUtils import org.intocps.orchestration.coe.config.ModelConnection.ModelInstance @@ -53,6 +48,10 @@ import org.intocps.orchestration.coe.scala.CoeObject.{FmiSimulationInstanceScala import org.intocps.orchestration.coe.{AbortSimulationException, BasicInitializer} import org.slf4j.LoggerFactory +import java.io.File +import java.net.URI +import java.util +import java.util.List import scala.collection.JavaConversions._ import scala.collection.JavaConverters._ import scala.collection.mutable.{LinkedList, ListBuffer} diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/CoeInitialize.scala b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/CoeInitialize.scala index e4c958298..d6fa51caa 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/CoeInitialize.scala +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/CoeInitialize.scala @@ -34,19 +34,19 @@ */ package org.intocps.orchestration.coe.scala -import java.io.{File, FileNotFoundException, IOException} -import java.net.URI - import org.intocps.fmi.{Fmi2Status, IFmu, IFmuCallback} -import org.intocps.orchestration.coe.{AbortSimulationException, FmuFactory} import org.intocps.orchestration.coe.config.ModelConnection import org.intocps.orchestration.coe.config.ModelConnection.ModelInstance import org.intocps.orchestration.coe.modeldefinition.ModelDescription import org.intocps.orchestration.coe.modeldefinition.ModelDescription._ +import org.intocps.orchestration.coe.util.Util +import org.intocps.orchestration.coe.{AbortSimulationException, FmuFactory} import org.intocps.orchestration.fmi.VdmSvChecker import org.intocps.orchestration.fmi.VdmSvChecker.ScalarVariableConfigException import org.xml.sax.SAXParseException +import java.io.{File, FileNotFoundException, IOException} +import java.net.URI import scala.collection.JavaConversions.{asJavaCollection, asScalaBuffer, bufferAsJavaList} import scala.collection.immutable.{HashMap, Map} import scala.util.{Failure, Try} @@ -385,7 +385,7 @@ object CoeInitialize } val instanceName = mi.instanceName logger.debug(String.format("Loading native FMU. GUID: %s, NAME: %s", "" + fm._2._1.getGuid, "" + mi.instanceName)) - val compLogger = getCoSimInstanceLogger(fmuFolder, instanceName) + val compLogger = Util.getCoSimInstanceLogger(fmuFolder, instanceName) val md: ModelDescription = fm._2._1 logger.info("Instantiating FMU. ModelName: '{}', GUID: '{}', Vendor tool: '{}', Generated by: '{}', at: {} Execution tool required: {}", Array(md.getModelId, md.getGuid, md.getVendorToolName, md.getGenerationTool, md.getGenerationDateAndTime, md.getNeedsExecutionTool).asInstanceOf[Array[Object]]: _*) diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/CoeObject.scala b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/CoeObject.scala index f3274a652..7427cdc8f 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/CoeObject.scala +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/CoeObject.scala @@ -34,48 +34,17 @@ */ package org.intocps.orchestration.coe.scala -import java.io.File -import java.io.FileNotFoundException -import java.io.IOException -import scala.collection.JavaConversions.asJavaCollection -import scala.collection.JavaConversions.asScalaBuffer -import scala.collection.JavaConversions.bufferAsJavaList -import scala.collection.JavaConversions.seqAsJavaList -import scala.collection.JavaConverters.mapAsScalaMapConverter -import scala.collection.immutable.Map -import scala.util.Failure -import scala.util.Success -import scala.util.Try -import org.apache.log4j.FileAppender -import org.apache.log4j.Logger -import org.apache.log4j.PatternLayout -import org.apache.log4j.spi.Filter -import org.apache.log4j.spi.LoggingEvent -import org.intocps.fmi.Fmi2Status -import org.intocps.fmi.Fmi2StatusKind -import org.intocps.fmi.IFmiComponent -import org.intocps.fmi.IFmu -import org.intocps.fmi.IFmuCallback +import org.intocps.fmi.{Fmi2Status, IFmiComponent} import org.intocps.orchestration.coe.AbortSimulationException -import org.intocps.orchestration.coe.FmuFactory import org.intocps.orchestration.coe.config.ModelConnection import org.intocps.orchestration.coe.config.ModelConnection.ModelInstance -import org.intocps.orchestration.coe.cosim.base.FmiInstanceConfig -import org.intocps.orchestration.coe.cosim.base.FmiSimulationInstance +import org.intocps.orchestration.coe.cosim.base.{FmiInstanceConfig, FmiSimulationInstance} import org.intocps.orchestration.coe.modeldefinition.ModelDescription -import org.intocps.orchestration.coe.modeldefinition.ModelDescription.Causality -import org.intocps.orchestration.coe.modeldefinition.ModelDescription.LogCategory -import org.intocps.orchestration.coe.modeldefinition.ModelDescription.ModelDescriptionParseException -import org.intocps.orchestration.coe.modeldefinition.ModelDescription.ScalarVariable -import org.intocps.orchestration.coe.modeldefinition.ModelDescription.Types -import org.intocps.orchestration.coe.util.Util -import org.intocps.orchestration.fmi.VdmSvChecker -import org.intocps.orchestration.fmi.VdmSvChecker.ScalarVariableConfigException +import org.intocps.orchestration.coe.modeldefinition.ModelDescription.{ScalarVariable, Types} import org.slf4j.LoggerFactory -import org.xml.sax.SAXParseException -import java.io.OutputStream -import scala.util.Success -import scala.util.Success + +import scala.collection.JavaConversions.seqAsJavaList +import scala.util.{Failure, Success, Try} object CoeObject { @@ -152,28 +121,5 @@ object CoeObject } } - def getCoSimInstanceLogger(root: File,logName:String): org.slf4j.Logger = - { - //Define log pattern layout - val layout = new PatternLayout("%d{ISO8601} %-5p - %m%n") - val logger = LoggerFactory.getLogger("fmi.instance."+logName) - //Define file appender with layout and output log file name - val fileAppender = new FileAppender(layout, new File(root, logName+".log").getAbsolutePath, false) - val f = new Filter() - { - def decide(event: LoggingEvent): Int = - { - if (event.getLoggerName.equals(logger.getName)) - { - return Filter.ACCEPT - } - return Filter.DENY - } - } - fileAppender.addFilter(f) - Logger.getRootLogger().addAppender(fileAppender) - - return logger - } } diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/CoeScalaUtil.scala b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/CoeScalaUtil.scala index ada7243d0..4035c37ad 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/CoeScalaUtil.scala +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/CoeScalaUtil.scala @@ -36,6 +36,7 @@ package org.intocps.orchestration.coe.scala import org.intocps.orchestration.coe.config.ModelConnection.ModelInstance import org.intocps.orchestration.coe.modeldefinition.ModelDescription.ScalarVariable + import java.util.HashMap object CoeScalaUtil { diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/CoeSimulator.scala b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/CoeSimulator.scala index c3d31460b..1b8075b95 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/CoeSimulator.scala +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/CoeSimulator.scala @@ -34,9 +34,6 @@ */ package org.intocps.orchestration.coe.scala -import java.io.File -import java.util - import org.apache.commons.lang3.StringUtils import org.intocps.fmi._ import org.intocps.orchestration.coe.AbortSimulationException @@ -48,6 +45,8 @@ import org.intocps.orchestration.coe.modeldefinition.ModelDescription import org.intocps.orchestration.coe.modeldefinition.ModelDescription.{ScalarVariable, Types} import org.intocps.orchestration.coe.util.{Numpy, Util} +import java.io.File +import java.util import scala.collection.JavaConversions import scala.collection.JavaConversions.{asJavaCollection, _} import scala.collection.JavaConverters._ diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/CoeTrait.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/CoeTrait.java index b82da57e3..940021350 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/CoeTrait.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/CoeTrait.java @@ -37,11 +37,7 @@ import org.intocps.orchestration.coe.config.ModelConnection; import org.intocps.orchestration.coe.config.ModelParameter; import org.intocps.orchestration.coe.cosim.CoSimStepSizeCalculator; -import org.intocps.orchestration.coe.modeldefinition.ModelDescription; import org.intocps.orchestration.coe.modeldefinition.ModelDescription.LogCategory; -import scala.Double; -import scala.Long; -import scala.collection.immutable.List; import java.util.Map; diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/InstanceState.scala b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/InstanceState.scala index 8d7c382b3..b662d77ea 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/InstanceState.scala +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/InstanceState.scala @@ -35,11 +35,8 @@ package org.intocps.orchestration.coe.scala import org.intocps.orchestration.coe.modeldefinition.ModelDescription.ScalarVariable -import org.intocps.fmi.IFmiComponentState import scala.collection.JavaConversions._ -import scala.collection.JavaConverters.mapAsJavaMapConverter -import scala.collection.JavaConverters.mapAsScalaMapConverter class InstanceState(val time: Double, val state: Map[ScalarVariable, Object], diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/LiveStreamLogger.scala b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/LiveStreamLogger.scala index 30511f43d..13b8b06b5 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/LiveStreamLogger.scala +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/LiveStreamLogger.scala @@ -34,11 +34,11 @@ */ package org.intocps.orchestration.coe.scala +import argonaut.Argonaut._ +import argonaut._ import org.intocps.orchestration.coe.config.ModelConnection.ModelInstance import org.intocps.orchestration.coe.modeldefinition.ModelDescription.ScalarVariable import org.intocps.orchestration.coe.scala.CoeObject.GlobalState -import argonaut.Argonaut._ -import argonaut._ /** * Created by kel on 18/07/16. diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/LiveStreamProgressLogger.scala b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/LiveStreamProgressLogger.scala index 7dace42ab..fa15a93d9 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/LiveStreamProgressLogger.scala +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/LiveStreamProgressLogger.scala @@ -34,12 +34,6 @@ */ package org.intocps.orchestration.coe.scala -import argonaut.Argonaut._ -import argonaut._ -import org.intocps.orchestration.coe.config.ModelConnection.ModelInstance -import org.intocps.orchestration.coe.modeldefinition.ModelDescription.ScalarVariable -import org.intocps.orchestration.coe.scala.CoeObject.GlobalState - /** * Created by kel on 18/07/16. */ diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/ResultLogger.scala b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/ResultLogger.scala index 84c4633a9..ae630121e 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/ResultLogger.scala +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/ResultLogger.scala @@ -34,21 +34,14 @@ */ package org.intocps.orchestration.coe.scala -import java.io.{BufferedOutputStream, File, FileOutputStream, OutputStream} - +import org.intocps.orchestration.coe.config.ModelConnection.ModelInstance import org.intocps.orchestration.coe.modeldefinition.ModelDescription.ScalarVariable import org.intocps.orchestration.coe.scala.CoeObject.GlobalState import org.slf4j.LoggerFactory -import org.apache.commons.io.FileUtils -import org.intocps.orchestration.coe.config.ModelConnection.ModelInstance -import java.io.BufferedOutputStream -import java.io.FileOutputStream -import java.io.OutputStream +import java.io.{BufferedOutputStream, File, FileOutputStream, OutputStream} import scala.collection.immutable.SortedMap -import java.io.File - /** * Created by kel on 18/07/16. */ @@ -91,8 +84,7 @@ class ResultLogger(file: File, enabledVariables: Map[ModelInstance, Set[ScalarVa } override def stop(): Unit = - { - logger.debug("Closing file {}.", file) + { if (resultOutputStream != null) resultOutputStream.close() } diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/ResultStorage.scala b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/ResultStorage.scala index aca82ec93..c118f11c6 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/ResultStorage.scala +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/ResultStorage.scala @@ -34,15 +34,6 @@ */ package org.intocps.orchestration.coe.scala -import org.apache.commons.io.FileUtils -import org.intocps.orchestration.coe.config.ModelConnection.ModelInstance -import java.io.BufferedOutputStream -import java.io.FileOutputStream -import java.io.OutputStream -import scala.collection.immutable.SortedMap - -import java.io.File - object ResultStorage { diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/VariableResolver.scala b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/VariableResolver.scala index 50cec58a6..1c7859867 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/VariableResolver.scala +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/scala/VariableResolver.scala @@ -35,10 +35,9 @@ package org.intocps.orchestration.coe.scala import org.intocps.fmi.IFmu +import org.intocps.orchestration.coe.config.ModelConnection.{ModelInstance, Variable} import org.intocps.orchestration.coe.modeldefinition.ModelDescription import org.intocps.orchestration.coe.modeldefinition.ModelDescription.ScalarVariable -import org.intocps.orchestration.coe.config.ModelConnection.ModelInstance -import org.intocps.orchestration.coe.config.ModelConnection.Variable class VariableResolver( fmuMap: Map[String, (IFmu, (ModelDescription, List[ScalarVariable]))]) { diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/single/SingleSimMain.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/single/SingleSimMain.java index 5e22c4106..8bc5e77d0 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/single/SingleSimMain.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/single/SingleSimMain.java @@ -42,8 +42,6 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; import org.intocps.fmi.IFmu; import org.intocps.orchestration.coe.FmuFactory; import org.intocps.orchestration.coe.json.InitializationMsgJson; @@ -203,14 +201,14 @@ public static void main(String[] args) throws Exception { System.setProperty("coe.csv.quote.header", "true"); System.setProperty("coe.csv.boolean.numeric", "true"); - if (cmd.hasOption(logLevelOpt.getOpt())) { - Logger l = Logger.getRootLogger(); - l.setLevel(Level.toLevel(cmd.getOptionValue(logLevelOpt.getOpt()))); - } + if (cmd.hasOption(logLevelOpt.getOpt())) { + org.intocps.orchestration.coe.util.Util.setLogLevel(cmd.getOptionValue(logLevelOpt.getOpt())); + } + + URI fmuUri = new File(fmuPath).toURI(); + if (fmuUri.getScheme() == null || fmuUri.getScheme().equals("file")){ - URI fmuUri = new File(fmuPath).toURI(); - if (fmuUri.getScheme() == null || fmuUri.getScheme().equals("file")) { - if (!fmuUri.isAbsolute()) { + if (!fmuUri.isAbsolute()) { System.out.println("resolving: " + fmuUri); fmuUri = new File(".").toURI().resolve(fmuUri); } diff --git a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/util/Util.java b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/util/Util.java index c78ce70b8..3287ebb92 100644 --- a/orchestration/coe/src/main/java/org/intocps/orchestration/coe/util/Util.java +++ b/orchestration/coe/src/main/java/org/intocps/orchestration/coe/util/Util.java @@ -1,241 +1,347 @@ /* -* This file is part of the INTO-CPS toolchain. -* -* Copyright (c) 2017-CurrentYear, INTO-CPS Association, -* c/o Professor Peter Gorm Larsen, Department of Engineering -* Finlandsgade 22, 8200 Aarhus N. -* -* All rights reserved. -* -* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR -* THIS INTO-CPS ASSOCIATION PUBLIC LICENSE VERSION 1.0. -* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES -* RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL -* VERSION 3, ACCORDING TO RECIPIENTS CHOICE. -* -* The INTO-CPS toolchain and the INTO-CPS Association Public License -* are obtained from the INTO-CPS Association, either from the above address, -* from the URLs: http://www.into-cps.org, and in the INTO-CPS toolchain distribution. -* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html. -* -* This program is distributed WITHOUT ANY WARRANTY; without -* even the implied warranty of MERCHANTABILITY or FITNESS FOR -* A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH IN THE -* BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF -* THE INTO-CPS ASSOCIATION. -* -* See the full INTO-CPS Association Public License conditions for more details. -*/ + * This file is part of the INTO-CPS toolchain. + * + * Copyright (c) 2017-CurrentYear, INTO-CPS Association, + * c/o Professor Peter Gorm Larsen, Department of Engineering + * Finlandsgade 22, 8200 Aarhus N. + * + * All rights reserved. + * + * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR + * THIS INTO-CPS ASSOCIATION PUBLIC LICENSE VERSION 1.0. + * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES + * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL + * VERSION 3, ACCORDING TO RECIPIENTS CHOICE. + * + * The INTO-CPS toolchain and the INTO-CPS Association Public License + * are obtained from the INTO-CPS Association, either from the above address, + * from the URLs: http://www.into-cps.org, and in the INTO-CPS toolchain distribution. + * GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html. + * + * This program is distributed WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH IN THE + * BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF + * THE INTO-CPS ASSOCIATION. + * + * See the full INTO-CPS Association Public License conditions for more details. + */ /* -* Author: -* Kenneth Lausdahl -* Casper Thule -*/ + * Author: + * Kenneth Lausdahl + * Casper Thule + */ package org.intocps.orchestration.coe.util; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.FilenameFilter; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Vector; - import org.apache.commons.lang3.ArrayUtils; -import org.apache.commons.lang3.StringUtils; -import org.intocps.fmi.Fmi2Status; -import org.intocps.fmi.FmiInvalidNativeStateException; -import org.intocps.fmi.FmuInvocationException; -import org.intocps.fmi.FmuResult; -import org.intocps.fmi.IFmiComponent; -import org.intocps.fmi.InvalidParameterException; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.core.Appender; +import org.apache.logging.log4j.core.Filter; +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.LoggerContext; +import org.apache.logging.log4j.core.appender.OutputStreamAppender; +import org.apache.logging.log4j.core.config.Configuration; +import org.apache.logging.log4j.core.config.Configurator; +import org.apache.logging.log4j.core.config.LoggerConfig; +import org.apache.logging.log4j.core.filter.AbstractFilter; +import org.apache.logging.log4j.core.layout.PatternLayout; +import org.intocps.fmi.*; import org.intocps.orchestration.coe.config.ModelConnection; import org.intocps.orchestration.coe.modeldefinition.ModelDescription; import org.intocps.orchestration.coe.modeldefinition.ModelDescription.ScalarVariable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class Util -{ - final static Logger logger = LoggerFactory.getLogger(Util.class); - - public static FilenameFilter fmuFileFilter = new FilenameFilter() - { - - @Override public boolean accept(File dir, String name) - { - return name.endsWith(".fmu"); - } - }; - - public static List parseConnections() throws Exception - { - List connections = new Vector(); - - BufferedReader br = new BufferedReader(new FileReader(new File("src/test/resources/links.property".replace('/', File.separatorChar)))); - String line; - while ((line = br.readLine()) != null) - { - if (line.trim().startsWith("//")) - continue; - connections.add(ModelConnection.parse(line)); - } - br.close(); - - return connections; - } - - /** - * Method to set variables in an fmu instance - * - * @param comp - * @param type - * @param indices - * @param values - * @throws InvalidParameterException - * @throws FmiInvalidNativeStateException - */ - public static void setRaw(IFmiComponent comp, ModelDescription.Types type, - Map indexToValue) - throws InvalidParameterException, FmiInvalidNativeStateException - { - long[] a = new long[indexToValue.size()]; - ArrayList values = new ArrayList(indexToValue.size()); - - List indices = new Vector(); - indices.addAll(indexToValue.keySet()); - Collections.sort(indices); - - for (int i = 0; i < indices.size(); i++) - { - a[i] = indices.get(i); - values.add(i, indexToValue.get(a[i])); - } - - setRaw(comp, type, a, values); - } - - private static void setRaw(IFmiComponent comp, ModelDescription.Types type, - long[] indices, List values) - throws InvalidParameterException, FmiInvalidNativeStateException - { - Fmi2Status status = Fmi2Status.Error; - logger.trace("setRaw with comp: {}, type: {}, indices: {}, values: {}", comp, type, indices, values); - switch (type) - { - case Boolean: - status = comp.setBooleans(indices, ArrayUtils.toPrimitive((Boolean[]) values.toArray(new Boolean[] {}))); - break; - case Integer: - case Enumeration: - status = comp.setIntegers(indices, ArrayUtils.toPrimitive((Integer[]) values.toArray(new Integer[] {}))); - break; - case Real: - status = comp.setReals(indices, ArrayUtils.toPrimitive((Double[]) values.toArray(new Double[] {}))); - break; - case String: - status = comp.setStrings(indices, values.toArray(new String[] {})); - break; - default: - break; - - } - - logger.trace("setRaw complete. Type='" + type + "', indices {} values " - + values + " Status returned='" + status + "'", indices); - - if (!(status == Fmi2Status.OK || status==Fmi2Status.Warning)) - { - logger.error("Error setting var of type='" + type - + "', indices {} values " + values + " Status returned='" - + status + "'", indices); - } - } - - /** - * MEthod to get variables in an fmu instance - * - * @param comp the instance - * @param indices the indices to get - * @param type the types - * @return a map from index to read value - * @throws FmuInvocationException - */ - public static Map getRaw(IFmiComponent comp, - ScalarVariable[] indicesSv, long[] indices, - ModelDescription.Types type) throws FmuInvocationException - { - if (indices.length <= 0) - { - return null; - } - FmuResult res = null; - Object[] resVal = null; - - logger.trace("getRaw {}, comp: {} indices: {}", type, comp, indices); - switch (type) - { - case Boolean: - { - FmuResult r = comp.getBooleans(indices); - res = r; - resVal = ArrayUtils.toObject(r.result); - break; - } - case Integer: - case Enumeration: - { - FmuResult r = comp.getInteger(indices); - res = r; - resVal = ArrayUtils.toObject(r.result); - break; - } - case Real: - { - FmuResult r = comp.getReal(indices); - res = r; - resVal = ArrayUtils.toObject(r.result); - break; - } - case String: - { - FmuResult r = comp.getStrings(indices); - res = r; - resVal = r.result; - break; - } - default: - break; - - } - logger.trace("getRaw {}, comp: {} indices: {} got values: {}", type, comp, indices, resVal); - - Map readVars = new HashMap(); - - if (res != null && (res.status == Fmi2Status.OK|| res.status == Fmi2Status.Warning)) - { - if(res.status==Fmi2Status.Warning) - { - logger.warn("received warning from getRaw {}, comp: {} indices: {} got values: {}", type, comp, indices, resVal); - } - for (int i = 0; i < indices.length; i++) - { - readVars.put(indicesSv[i], resVal[i]); - } - } else - { - return null; - } - - return readVars; - } - - public static String[] getArray(List list) - { - return list.toArray(new String[list.size()]); - } +import java.io.*; +import java.util.*; +import java.util.function.Function; + +public class Util { + final static Logger logger = LoggerFactory.getLogger(Util.class); + + public static FilenameFilter fmuFileFilter = new FilenameFilter() { + + @Override + public boolean accept(File dir, String name) { + return name.endsWith(".fmu"); + } + }; + + public static List parseConnections() throws Exception { + List connections = new Vector(); + + BufferedReader br = new BufferedReader(new FileReader(new File("src/test/resources/links.property".replace('/', File.separatorChar)))); + String line; + while ((line = br.readLine()) != null) { + if (line.trim().startsWith("//")) { + continue; + } + connections.add(ModelConnection.parse(line)); + } + br.close(); + + return connections; + } + + /** + * Method to set variables in an fmu instance + * + * @param comp + * @param type + * @param indices + * @param values + * @throws InvalidParameterException + * @throws FmiInvalidNativeStateException + */ + public static void setRaw(IFmiComponent comp, ModelDescription.Types type, + Map indexToValue) throws InvalidParameterException, FmiInvalidNativeStateException { + long[] a = new long[indexToValue.size()]; + ArrayList values = new ArrayList(indexToValue.size()); + + List indices = new Vector(); + indices.addAll(indexToValue.keySet()); + Collections.sort(indices); + + for (int i = 0; i < indices.size(); i++) { + a[i] = indices.get(i); + values.add(i, indexToValue.get(a[i])); + } + + setRaw(comp, type, a, values); + } + + private static void setRaw(IFmiComponent comp, ModelDescription.Types type, long[] indices, + List values) throws InvalidParameterException, FmiInvalidNativeStateException { + Fmi2Status status = Fmi2Status.Error; + logger.trace("setRaw with comp: {}, type: {}, indices: {}, values: {}", comp, type, indices, values); + switch (type) { + case Boolean: + status = comp.setBooleans(indices, ArrayUtils.toPrimitive((Boolean[]) values.toArray(new Boolean[]{}))); + break; + case Integer: + case Enumeration: + status = comp.setIntegers(indices, ArrayUtils.toPrimitive((Integer[]) values.toArray(new Integer[]{}))); + break; + case Real: + status = comp.setReals(indices, ArrayUtils.toPrimitive((Double[]) values.toArray(new Double[]{}))); + break; + case String: + status = comp.setStrings(indices, values.toArray(new String[]{})); + break; + default: + break; + + } + + logger.trace("setRaw complete. Type='" + type + "', indices {} values " + values + " Status returned='" + status + "'", indices); + + if (!(status == Fmi2Status.OK || status == Fmi2Status.Warning)) { + logger.error("Error setting var of type='" + type + "', indices {} values " + values + " Status returned='" + status + "'", indices); + } + } + + /** + * MEthod to get variables in an fmu instance + * + * @param comp the instance + * @param indices the indices to get + * @param type the types + * @return a map from index to read value + * @throws FmuInvocationException + */ + public static Map getRaw(IFmiComponent comp, ScalarVariable[] indicesSv, long[] indices, + ModelDescription.Types type) throws FmuInvocationException { + if (indices.length <= 0) { + return null; + } + FmuResult res = null; + Object[] resVal = null; + + logger.trace("getRaw {}, comp: {} indices: {}", type, comp, indices); + switch (type) { + case Boolean: { + FmuResult r = comp.getBooleans(indices); + res = r; + resVal = ArrayUtils.toObject(r.result); + break; + } + case Integer: + case Enumeration: { + FmuResult r = comp.getInteger(indices); + res = r; + resVal = ArrayUtils.toObject(r.result); + break; + } + case Real: { + FmuResult r = comp.getReal(indices); + res = r; + resVal = ArrayUtils.toObject(r.result); + break; + } + case String: { + FmuResult r = comp.getStrings(indices); + res = r; + resVal = r.result; + break; + } + default: + break; + + } + logger.trace("getRaw {}, comp: {} indices: {} got values: {}", type, comp, indices, resVal); + + Map readVars = new HashMap(); + + if (res != null && (res.status == Fmi2Status.OK || res.status == Fmi2Status.Warning)) { + if (res.status == Fmi2Status.Warning) { + logger.warn("received warning from getRaw {}, comp: {} indices: {} got values: {}", type, comp, indices, resVal); + } + for (int i = 0; i < indices.length; i++) { + readVars.put(indicesSv[i], resVal[i]); + } + } else { + return null; + } + + return readVars; + } + + public static String[] getArray(List list) { + return list.toArray(new String[list.size()]); + } + + final static Map> appenderStreams = new HashMap<>(); + + public static Logger getCoSimInstanceLogger(File root, String logName) { + //Define log pattern layout + PatternLayout layout = PatternLayout.newBuilder().withPattern("%d{ISO8601} %-5p - %m%n").build(); + String loggerName = "fmi.instance." + logName+"_"+root.getPath().hashCode(); + + // Initialize the logger context + LoggerContext context = (LoggerContext) LogManager.getContext(false); + Configuration config = context.getConfiguration(); + + // Create a LoggerNameFilter + Filter filter = new AbstractFilter() { + + @Override + public Result filter(LogEvent event) { + if (event.getLoggerName().equals(loggerName)) { + return Result.ACCEPT; + } + return Result.DENY; + } + + }; + root.mkdirs(); + OutputStreamAppender appender = null; + try { + File logFile = new File(root, logName + ".log"); + logger.debug("Opening log file: {}",logFile); + FileOutputStream fileOutputStream = new FileOutputStream(logFile); + appender = OutputStreamAppender.newBuilder().withName(loggerName + ".file_appender").setLayout(layout).setTarget(fileOutputStream) + .withFilter(filter).build(); + + synchronized (appenderStreams) { + appenderStreams.put(appender, new AbstractMap.SimpleEntry<>(logFile, fileOutputStream)); + } + + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } + appender.start(); + + // Create a LoggerConfig with the appender and filter + LoggerConfig loggerConfig = LoggerConfig.newBuilder().withLoggerName(loggerName).withtFilter(filter).withLevel(Level.ALL).withConfig(config) + .build(); + loggerConfig.addAppender(appender, Level.ALL, filter); + + // Add the LoggerConfig to the configuration + config.addLogger(loggerName, loggerConfig); + + // Update the configuration + context.updateLoggers(); + + + // Get the logger + return LoggerFactory.getLogger(loggerName); + } + + private static boolean removeAppender(String sessionId, org.apache.logging.log4j.core.Logger configuration) { + boolean found = false; + ArrayList appendersToRemove = new ArrayList<>(); + Map appenders = configuration.getAppenders(); + + if (appenders != null) { + + for (Map.Entry appender : appenders.entrySet()) { + if (appender.getValue() instanceof OutputStreamAppender) { + OutputStreamAppender fileAppender = (OutputStreamAppender) appender.getValue(); + + Map.Entry map = appenderStreams.get(fileAppender); + + if (map != null && map.getKey().getPath() != null && (sessionId == null || map.getKey().getPath() + .matches("(.*)(" + sessionId + ")[/\\\\](.*)[/\\\\].*(\\.log)$"))) { + // Log files for fmu instances. + // Regex matches +sessionId++++anything.log + try { + map.getValue().flush(); + } catch (IOException e) { + //ignore + } + fileAppender.stop(); + try { + map.getValue().close(); + logger.debug("Closed log file: {}",map.getKey()); + } catch (IOException e) { + //ignore + } + appendersToRemove.add(fileAppender.getName()); + found = true; + } + } + + + appendersToRemove.forEach(fa -> { + configuration.removeAppender(appender.getValue()); + if (configuration.getAppenders().isEmpty()) { + //lets clean up the logger as well + final LoggerContext ctx = (LoggerContext) LogManager.getContext(false); + final Configuration config = ctx.getConfiguration(); + config.removeLogger(configuration.getName()); + ctx.updateLoggers(); + + synchronized (appenderStreams) { + appenderStreams.remove(appender.getValue()); + } + } + }); + } + } + return found; + } + + + public static boolean removeCoSimInstanceLogAppenders(String sessionId) { + logger.debug("Close loggers for session: {}",sessionId); + LoggerContext context = LoggerContext.getContext(false); + + boolean found = removeAppender(sessionId, context.getRootLogger()); + + for(org.apache.logging.log4j.core.Logger l :context.getLoggers()) { + found |= removeAppender(sessionId, l); + } + return found; + } + + public static void setLogLevel(String level) { + Configurator.setLevel("root", org.apache.logging.log4j.Level.valueOf(level)); + } + + public static void setLogLevel(org.apache.logging.log4j.Level level) { + Configurator.setLevel("root", level); + } } + diff --git a/orchestration/coe/src/main/resources/log4j.properties b/orchestration/coe/src/main/resources/log4j.properties deleted file mode 100644 index d54ea461f..000000000 --- a/orchestration/coe/src/main/resources/log4j.properties +++ /dev/null @@ -1,23 +0,0 @@ -log4j.rootLogger=INFO, stdout, R - -log4j.appender.stdout.Threshold=WARN -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout - -# Pattern to output the caller's file name and line number. -log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n - -log4j.appender.R=org.apache.log4j.rolling.RollingFileAppender -log4j.appender.R.rollingPolicy.FileNamePattern=coe-%i.log.gz -log4j.appender.R.rollingPolicy.ActiveFileName=coe.log -log4j.appender.R.rollingPolicy=org.apache.log4j.rolling.FixedWindowRollingPolicy -log4j.appender.R.rollingPolicy.maxIndex=13 -log4j.appender.R.triggeringPolicy=org.apache.log4j.rolling.SizeBasedTriggeringPolicy -# Value is in bytes -log4j.appender.R.triggeringPolicy.MaxFileSize=100000000 - -log4j.appender.R.layout=org.apache.log4j.PatternLayout -log4j.appender.R.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n - -# This fmi logger needs to be ALL since this is the messages received from the individual FMUs -log4j.logger.fmi.instance=ALL diff --git a/orchestration/coe/src/main/resources/log4j2.xml b/orchestration/coe/src/main/resources/log4j2.xml new file mode 100644 index 000000000..a6a891342 --- /dev/null +++ b/orchestration/coe/src/main/resources/log4j2.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/Api/ApiTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/Api/ApiTest.java index cd303ca80..e326aec63 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/Api/ApiTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/Api/ApiTest.java @@ -46,11 +46,11 @@ import org.intocps.orchestration.coe.cosim.CoSimStepSizeCalculator; import org.intocps.orchestration.coe.httpserver.RequestHandler; import org.intocps.orchestration.coe.httpserver.RequestProcessors; +import org.intocps.orchestration.coe.httpserver.SessionController; import org.intocps.orchestration.coe.httpserver.SessionLogic; import org.intocps.orchestration.coe.json.SessionLogicFactory; import org.intocps.orchestration.coe.json.StartMsgJson; import org.intocps.orchestration.coe.json.StatusMsgJson; -import org.intocps.orchestration.coe.httpserver.SessionController; import org.intocps.orchestration.coe.modeldefinition.ModelDescription; import org.intocps.orchestration.coe.scala.Coe; import org.intocps.orchestration.coe.scala.CoeStatus; @@ -62,6 +62,7 @@ import org.mockito.ArgumentCaptor; import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -73,9 +74,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyListOf; -import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.*; +import static org.mockito.Mockito.anyMapOf; import static org.mockito.Mockito.*; /** @@ -83,6 +83,7 @@ */ @RunWith(PowerMockRunner.class) @PrepareForTest(FileUtils.class) +@PowerMockIgnore("javax.management.*") public class ApiTest { final static String DEFAULT_CONFIG_PATH = "/online-models/watertank-c/config.json"; diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/Api/CoeRequestHandlerTests.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/Api/CoeRequestHandlerTests.java index fa783ca96..9b016d2a2 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/Api/CoeRequestHandlerTests.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/Api/CoeRequestHandlerTests.java @@ -49,7 +49,10 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; -import java.util.*; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Vector; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.*; diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/Api/SessionControllerTests.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/Api/SessionControllerTests.java index 91b8f97a2..1e52f1a25 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/Api/SessionControllerTests.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/Api/SessionControllerTests.java @@ -34,16 +34,6 @@ */ package org.intocps.orchestration.coe.Api; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.io.File; -import java.util.List; -import java.util.Vector; - import org.intocps.orchestration.coe.httpserver.NanoWebSocketImpl; import org.intocps.orchestration.coe.httpserver.SessionController; import org.intocps.orchestration.coe.httpserver.SessionLogic; @@ -54,6 +44,12 @@ import org.junit.Before; import org.junit.Test; +import java.io.File; +import java.util.List; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.*; + /** * Created by ctha on 17-03-2016. */ diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/BasicTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/BasicTest.java index 65e2e21a9..498866166 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/BasicTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/BasicTest.java @@ -36,23 +36,21 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; - import difflib.Delta; import difflib.DiffUtils; import difflib.Patch; import fi.iki.elonen.NanoHTTPD; - import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.intocps.orchestration.coe.Api.ApiTest; import org.intocps.orchestration.coe.httpserver.RequestHandler; import org.intocps.orchestration.coe.httpserver.RequestProcessors; import org.intocps.orchestration.coe.httpserver.Response; +import org.intocps.orchestration.coe.httpserver.SessionController; import org.intocps.orchestration.coe.json.InitializationStatusJson; import org.intocps.orchestration.coe.json.ProdSessionLogicFactory; import org.intocps.orchestration.coe.json.StartMsgJson; import org.intocps.orchestration.coe.json.StatusMsgJson; -import org.intocps.orchestration.coe.httpserver.SessionController; import org.junit.Assert; import java.io.*; diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/CascadingWatertankTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/CascadingWatertankTest.java index dfe55a6a6..280c864a1 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/CascadingWatertankTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/CascadingWatertankTest.java @@ -34,12 +34,12 @@ */ package org.intocps.orchestration.coe; -import java.io.IOException; - import fi.iki.elonen.NanoHTTPD; import org.junit.Ignore; import org.junit.Test; +import java.io.IOException; + public class CascadingWatertankTest extends OnlineModelsCoSimTest { //ignoring this since it fails on linux https://github.com/twt-gmbh/org.intocps.fmi/issues/10 possibly because the export is old diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/CoeBaseTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/CoeBaseTest.java index 5536754fc..1b577d7c6 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/CoeBaseTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/CoeBaseTest.java @@ -37,7 +37,6 @@ import org.intocps.orchestration.coe.ConditionalIgnoreRule.IgnoreCondition; import org.intocps.orchestration.coe.httpserver.SessionController; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Rule; public class CoeBaseTest diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/ConditionalIgnoreRule.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/ConditionalIgnoreRule.java index eba252a34..439476804 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/ConditionalIgnoreRule.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/ConditionalIgnoreRule.java @@ -34,17 +34,17 @@ */ package org.intocps.orchestration.coe; +import org.junit.Assume; +import org.junit.rules.MethodRule; +import org.junit.runners.model.FrameworkMethod; +import org.junit.runners.model.Statement; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.reflect.Modifier; -import org.junit.Assume; -import org.junit.rules.MethodRule; -import org.junit.runners.model.FrameworkMethod; -import org.junit.runners.model.Statement; - public class ConditionalIgnoreRule implements MethodRule { diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/CycleTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/CycleTest.java index 8f986efbc..85b5ab8b3 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/CycleTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/CycleTest.java @@ -42,6 +42,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.modules.junit4.PowerMockRunner; import java.io.ByteArrayInputStream; @@ -57,7 +58,9 @@ /** * Created by kel on 01/09/16. */ -@RunWith(PowerMockRunner.class) public class CycleTest extends BasicTest +@RunWith(PowerMockRunner.class) +@PowerMockIgnore("javax.management.*") +public class CycleTest extends BasicTest { @After public void cleanup() { diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/DerivativeInOutTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/DerivativeInOutTest.java index ec63d7d27..54d917d4f 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/DerivativeInOutTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/DerivativeInOutTest.java @@ -40,33 +40,23 @@ import org.junit.After; import org.junit.Test; import org.junit.runner.RunWith; -import org.powermock.modules.junit4.PowerMockRunner; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.modules.junit4.PowerMockRunner; -import java.io.*; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; import java.net.URI; -import java.nio.file.Files; -import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyListOf; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.*; -import java.io.File; -import java.io.IOException; -import java.net.URI; - /** * Created by kel on 01/09/16. */ -@RunWith(PowerMockRunner.class) public class DerivativeInOutTest +@RunWith(PowerMockRunner.class) @PowerMockIgnore("javax.management.*") public class DerivativeInOutTest extends BasicTest { diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/DiscardGetTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/DiscardGetTest.java index 7d0fd296f..844e1a04e 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/DiscardGetTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/DiscardGetTest.java @@ -36,14 +36,9 @@ import fi.iki.elonen.NanoHTTPD; import org.apache.commons.io.IOUtils; -import org.apache.log4j.AppenderSkeleton; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.apache.log4j.spi.LoggingEvent; import org.intocps.fmi.*; import org.junit.After; import org.junit.Assert; -import org.junit.Before; import org.junit.Test; import java.io.ByteArrayInputStream; @@ -51,10 +46,8 @@ import java.io.IOException; import java.io.InputStream; import java.net.URI; -import java.util.ArrayList; import static org.mockito.Matchers.*; -import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/DymolaCompatibilityTests.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/DymolaCompatibilityTests.java index a1360a6e8..11fa53766 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/DymolaCompatibilityTests.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/DymolaCompatibilityTests.java @@ -35,11 +35,11 @@ package org.intocps.orchestration.coe; import fi.iki.elonen.NanoHTTPD; +import org.intocps.orchestration.coe.ConditionalIgnoreRule.ConditionalIgnore; import org.junit.Rule; import org.junit.Test; import java.io.IOException; -import org.intocps.orchestration.coe.ConditionalIgnoreRule.ConditionalIgnore; public class DymolaCompatibilityTests extends OnlineModelsCoSimTest { diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/HierarchicalCoeWatertankTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/HierarchicalCoeWatertankTest.java index d4a9e539e..5d81b5693 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/HierarchicalCoeWatertankTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/HierarchicalCoeWatertankTest.java @@ -36,7 +36,6 @@ import fi.iki.elonen.NanoHTTPD; import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; import org.intocps.orchestration.coe.hierarchical.HierarchicalCoeFactory; import org.intocps.orchestration.coe.util.FolderCompressor; import org.junit.AfterClass; diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/HttpUtil.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/HttpUtil.java index 7a9bdb262..16544bfe9 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/HttpUtil.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/HttpUtil.java @@ -34,14 +34,16 @@ */ package org.intocps.orchestration.coe; -import java.io.*; +import org.intocps.orchestration.coe.httpserver.Response; + +import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.Properties; -import org.apache.commons.io.IOUtils; -import org.intocps.orchestration.coe.httpserver.Response; - public class HttpUtil { public static BufferedInputStream toInput(String data) diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/JsonTests/InitializationMsgTests.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/JsonTests/InitializationMsgTests.java index f1d7dc138..4af7d7e2e 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/JsonTests/InitializationMsgTests.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/JsonTests/InitializationMsgTests.java @@ -36,12 +36,10 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; import org.intocps.orchestration.coe.json.InitializationMsgJson; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.mockito.internal.util.io.IOUtil; import java.io.File; import java.io.IOException; diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/MinMaxTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/MinMaxTest.java index a6797b981..6a089e8ab 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/MinMaxTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/MinMaxTest.java @@ -1,60 +1,63 @@ /* -* This file is part of the INTO-CPS toolchain. -* -* Copyright (c) 2017-CurrentYear, INTO-CPS Association, -* c/o Professor Peter Gorm Larsen, Department of Engineering -* Finlandsgade 22, 8200 Aarhus N. -* -* All rights reserved. -* -* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR -* THIS INTO-CPS ASSOCIATION PUBLIC LICENSE VERSION 1.0. -* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES -* RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL -* VERSION 3, ACCORDING TO RECIPIENTS CHOICE. -* -* The INTO-CPS toolchain and the INTO-CPS Association Public License -* are obtained from the INTO-CPS Association, either from the above address, -* from the URLs: http://www.into-cps.org, and in the INTO-CPS toolchain distribution. -* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html. -* -* This program is distributed WITHOUT ANY WARRANTY; without -* even the implied warranty of MERCHANTABILITY or FITNESS FOR -* A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH IN THE -* BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF -* THE INTO-CPS ASSOCIATION. -* -* See the full INTO-CPS Association Public License conditions for more details. -*/ + * This file is part of the INTO-CPS toolchain. + * + * Copyright (c) 2017-CurrentYear, INTO-CPS Association, + * c/o Professor Peter Gorm Larsen, Department of Engineering + * Finlandsgade 22, 8200 Aarhus N. + * + * All rights reserved. + * + * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR + * THIS INTO-CPS ASSOCIATION PUBLIC LICENSE VERSION 1.0. + * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES + * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL + * VERSION 3, ACCORDING TO RECIPIENTS CHOICE. + * + * The INTO-CPS toolchain and the INTO-CPS Association Public License + * are obtained from the INTO-CPS Association, either from the above address, + * from the URLs: http://www.into-cps.org, and in the INTO-CPS toolchain distribution. + * GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html. + * + * This program is distributed WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH IN THE + * BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF + * THE INTO-CPS ASSOCIATION. + * + * See the full INTO-CPS Association Public License conditions for more details. + */ /* -* Author: -* Kenneth Lausdahl -* Casper Thule -*/ + * Author: + * Kenneth Lausdahl + * Casper Thule + */ package org.intocps.orchestration.coe; import fi.iki.elonen.NanoHTTPD; import org.apache.commons.io.IOUtils; -import org.apache.log4j.AppenderSkeleton; -import org.apache.log4j.Level; -import org.apache.log4j.LogManager; -import org.apache.log4j.Logger; -import org.apache.log4j.spi.LoggingEvent; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.core.*; +import org.apache.logging.log4j.core.appender.AbstractAppender; +import org.apache.logging.log4j.core.appender.OutputStreamAppender; +import org.apache.logging.log4j.core.config.*; import org.intocps.fmi.*; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.modules.junit4.PowerMockRunner; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; import java.net.URI; import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import java.util.Vector; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; @@ -63,239 +66,274 @@ /** * Created by kel on 01/09/16. */ -@RunWith(PowerMockRunner.class) public class MinMaxTest extends BasicTest -{ - - @After public void cleanup() - { - FmuFactory.customFactory = null; - - } - - public static class MyAppender extends AppenderSkeleton - { - ArrayList eventsList = new ArrayList(); - - @Override protected void append(LoggingEvent event) - { - if (event.getLevel() == Level.WARN - || event.getLevel() == Level.ERROR - || event.getLevel() == Level.FATAL) - eventsList.add(event); - - } - - public void close() - { - } - - public boolean requiresLayout() - { - return false; - } - - } - - MyAppender appender; - - @Before public void setup() - { - Logger l = Logger.getRootLogger(); - - appender = new MyAppender(); - - l.addAppender(appender); - } - - boolean checkLogFor(String content) - { - for (LoggingEvent le : appender.eventsList) - { - if (le.getMessage().toString().contains(content)) - return true; - } - return false; - } - - public final static int INTEGER_MIN = 0; - public final static int INTEGER_MAX = 2; +@PowerMockIgnore("javax.management.*") +@RunWith(PowerMockRunner.class) +public class MinMaxTest extends BasicTest { + + @After + public void cleanup() { + FmuFactory.customFactory = null; + LoggerContext lc = (LoggerContext) LogManager.getContext(false); + lc.getRootLogger().removeAppender(appender); + lc.updateLoggers(); + + } + + public static class MyAppender extends AbstractAppender { + + + private final List eventsList = new Vector<>(); + + protected MyAppender() { + super(UUID.randomUUID().toString(), null, null, true, null); + } + + @Override + public void append(LogEvent event) { + if (event != null && event.getLevel() == Level.WARN || event.getLevel() == Level.ERROR || event.getLevel() == Level.FATAL) { + eventsList.add(event.getMessage().getFormattedMessage()); + // System.out.println("############ "+this.getName()+" "+event.getMessage().getFormattedMessage());} + + } + + + } + } + + MyAppender appender; + + + @Before + public void setup() { + Configurator.setRootLevel(Level.WARN); + appender = new MyAppender(); + //System.out.println("################# Changing appender: "+appender.getName()); + appender.start(); + // LoggerContext lc = (LoggerContext) LogManager.getContext(false); + // lc.getConfiguration().addAppender(appender); + // lc.getRootLogger().addAppender(lc.getConfiguration().getAppender(appender.getName())); - public final static int REAL_MIN = 0; - public final static int REAL_MAX = 2; + LoggerContext context = (LoggerContext) LogManager.getContext(false); + Configuration config = context.getConfiguration(); + // LoggerConfig loggerConfig = LoggerConfig.newBuilder().withLoggerName(appender.getName()).withLevel(Level.ALL).withConfig(config) + // .build(); + // loggerConfig.addAppender(appender, Level.ALL, null); - public final static int INTEGER_DEFAULT = 0; - public final static int REAL_DEFAULT = 0; + // Add the LoggerConfig to the configuration + // config.addLogger(appender.getName(), loggerConfig); + // config.getLoggerConfig("org.intocps.orchestration.coe.scala.CoeObject").setLevel(Level.ALL); + // config.getLoggerConfig("org.intocps.orchestration.coe.scala.CoeObject").addAppender(appender,Level.ALL,null); + config.getRootLogger().addAppender(appender, Level.ALL, null); - @Test public void testIntBoundOk() - throws IOException, NanoHTTPD.ResponseException - { + context.updateLoggers(); - configureInstances(REAL_DEFAULT, INTEGER_DEFAULT); - LogManager.getRootLogger().setLevel(Level.WARN); + //"org.intocps.orchestration.coe.scala.CoeObject + // + //// Logger l = Logger.getRootLogger(); + // Configurator.setRootLevel(Level.TRACE); + // appender = new MyAppender(); + // + //// l.addAppender(appender); + // + // LoggerContext context = (LoggerContext) LogManager.getContext(false); + // Configuration config = context.getConfiguration(); + // LoggerConfig loggerConfig = LoggerConfig.newBuilder().withLoggerName("test").withConfig(config).withLevel(Level.ALL).build(); + // a =OutputStreamAppender.newBuilder().setBufferedIo(false).setImmediateFlush(true).setName("dd").setTarget(ou).build();// + //a.start(); + // loggerConfig.addAppender(a, null,null); + // appender.start(); + // // .createLogger(false, org.apache.logging.log4j.Level.INFO, loggerName, "true", Array(appender), Array(filter), config, null) + // + // // Add the LoggerConfig to the configuration + // config.addLogger("test", loggerConfig); + // + // // Update the configuration + // context.updateLoggers(); - test("/derivativeInOutTest/config.json", 0, 1); + } - Assert.assertFalse("Did not expect any out of bounds warning", checkLogFor("is out of bounds")); - } + boolean checkLogFor(String content) { + for (String message : appender.eventsList) { + if (message.contains(content)) { + return true; + } + } + return false; + } - @Test public void testIntBoundMin() - throws IOException, NanoHTTPD.ResponseException - { + public final static int INTEGER_MIN = 0; + public final static int INTEGER_MAX = 2; - configureInstances(REAL_DEFAULT, INTEGER_MIN - 1); + public final static int REAL_MIN = 0; + public final static int REAL_MAX = 2; - test("/derivativeInOutTest/config.json", 0, 1); + public final static int INTEGER_DEFAULT = 0; + public final static int REAL_DEFAULT = 0; - Assert.assertTrue("Missing value out of bounds warning", checkLogFor("is out of bounds")); - } + void showAppenderCheckList() { + // System.out.println("##### Running check now: "+ this.appender.getName()); + // this.appender.eventsList.forEach(event->System.out.println(appender.getName()+" "+event)); - @Test public void testIntBoundMax() - throws IOException, NanoHTTPD.ResponseException - { + } - configureInstances(REAL_DEFAULT, INTEGER_MAX + 1); + @Test + public void testIntBoundOk() throws IOException, NanoHTTPD.ResponseException { - test("/derivativeInOutTest/config.json", 0, 1); + configureInstances(REAL_DEFAULT, INTEGER_DEFAULT); + // LogManager.getRootLogger().setLevel(Level.WARN); + // Configurator.setLevel("root", Level.WARN); - Assert.assertTrue("Missing value out of bounds warning", checkLogFor("is out of bounds")); - } - @Test public void testRealBoundMin() - throws IOException, NanoHTTPD.ResponseException - { + test("/derivativeInOutTest/config.json", 0, 1); + showAppenderCheckList(); + Assert.assertFalse("Did not expect any out of bounds warning", checkLogFor("is out of bounds")); + } - configureInstances(REAL_MIN - 0.1, INTEGER_DEFAULT); + @Test + public void testIntBoundMin() throws IOException, NanoHTTPD.ResponseException { - test("/derivativeInOutTest/config.json", 0, 1); + configureInstances(REAL_DEFAULT, INTEGER_MIN - 1); - Assert.assertTrue("Missing value out of bounds warning", checkLogFor("is out of bounds")); - } - - @Test public void testRealBoundMax() - throws IOException, NanoHTTPD.ResponseException - { - - configureInstances(REAL_MAX + 0.1, INTEGER_DEFAULT); - - test("/derivativeInOutTest/config.json", 0, 1); - - Assert.assertTrue("Missing value out of bounds warning", checkLogFor("is out of bounds")); - } - - private void configureInstances(double realValue, int integerValue) - { - FmuFactory.customFactory = new IFmuFactory() - { - @Override public boolean accept(URI uri) - { - return true; - } - - @Override public IFmu instantiate(File sessionRoot, URI uri) - throws Exception - { - IFmu fmu = mock(IFmu.class); - when(fmu.isValid()).thenReturn(true); - - IFmiComponent comp = mock(IFmiComponent.class); - when(fmu.instantiate(anyString(), anyString(), anyBoolean(), anyBoolean(), any())).thenReturn(comp); - - compMock(fmu, comp); - - String modelDescriptionPath; - if (uri.toASCIIString().contains("watertank-c")) - { - modelDescriptionPath = "src/test/resources/minMaxTest/watertank-c/modelDescription.xml"; - - when(comp.getReal(new long[] { - 2 })).thenReturn(new FmuResult<>(Fmi2Status.OK, new double[] { - realValue })); - - when(comp.getInteger(new long[] { - 6 })).thenReturn(new FmuResult<>(Fmi2Status.OK, new int[] { - integerValue })); - - } else - { - modelDescriptionPath = "src/test/resources/minMaxTest/watertankcontroller-c/modelDescription.xml"; - when(comp.getBooleans(new long[] { - 4 })).thenReturn(new FmuResult<>(Fmi2Status.OK, new boolean[] { - true })); - - } - - final InputStream md = new ByteArrayInputStream(IOUtils.toByteArray(new File(modelDescriptionPath.replace('/', File.separatorChar)).toURI())); - when(fmu.getModelDescription()).thenReturn(md); - return fmu; - } - - }; - } - - private void compMock(IFmu fmu, IFmiComponent comp) - throws FmuInvocationException, InvalidParameterException - { - - when(comp.getFmu()).thenReturn(fmu); - - // Fmi2Status setDebugLogging(boolean var1, String[] var2) throws FmuInvocationException; - when(comp.setDebugLogging(anyBoolean(), any())).thenReturn(Fmi2Status.OK); - - // Fmi2Status setupExperiment(boolean var1, double var2, double var4, boolean var6, double var7) throws FmuInvocationException; - when(comp.setupExperiment(anyBoolean(), anyDouble(), anyDouble(), anyBoolean(), anyDouble())).thenReturn(Fmi2Status.OK); - // Fmi2Status enterInitializationMode() throws FmuInvocationException; - when(comp.enterInitializationMode()).thenReturn(Fmi2Status.OK); - // Fmi2Status exitInitializationMode() throws FmuInvocationException; - when(comp.exitInitializationMode()).thenReturn(Fmi2Status.OK); - // Fmi2Status reset() throws FmuInvocationException; - // when(comp.reset()); - // Fmi2Status setRealInputDerivatives(long[] var1, int[] var2, double[] var3) throws FmuInvocationException; - //when(comp.setRealInputDerivatives(any(), any(), any())).thenReturn(Fmi2Status.OK); - // FmuResult getRealOutputDerivatives(long[] var1, int[] var2) throws FmuInvocationException; - // - // FmuResult getDirectionalDerivative(long[] var1, long[] var2, double[] var3) throws FmuInvocationException; - // - // Fmi2Status doStep(double var1, double var3, boolean var5) throws FmuInvocationException; - when(comp.doStep(anyDouble(), anyDouble(), anyBoolean())).thenReturn(Fmi2Status.OK); - // FmuResult getReal(long[] var1) throws FmuInvocationException; - // - // FmuResult getInteger(long[] var1) throws FmuInvocationException; - // - // FmuResult getBooleans(long[] var1) throws FmuInvocationException; - // - // FmuResult getStrings(long[] var1) throws FmuInvocationException; - // - // Fmi2Status setBooleans(long[] var1, boolean[] var2) throws InvalidParameterException, FmiInvalidNativeStateException; - when(comp.setBooleans(any(), any())).thenReturn(Fmi2Status.OK); - // Fmi2Status setReals(long[] var1, double[] var2) throws InvalidParameterException, FmiInvalidNativeStateException; - when(comp.setReals(any(), any())).thenReturn(Fmi2Status.OK); - // Fmi2Status setIntegers(long[] var1, int[] var2) throws InvalidParameterException, FmiInvalidNativeStateException; - when(comp.setIntegers(any(), any())).thenReturn(Fmi2Status.OK); - // Fmi2Status setStrings(long[] var1, String[] var2) throws InvalidParameterException, FmiInvalidNativeStateException; - when(comp.setStrings(any(), any())).thenReturn(Fmi2Status.OK); - // FmuResult getBooleanStatus(Fmi2StatusKind var1) throws FmuInvocationException; - // - // FmuResult getStatus(Fmi2StatusKind var1) throws FmuInvocationException; - // - // FmuResult getIntegerStatus(Fmi2StatusKind var1) throws FmuInvocationException; - // - // FmuResult getRealStatus(Fmi2StatusKind var1) throws FmuInvocationException; - // - // FmuResult getStringStatus(Fmi2StatusKind var1) throws FmuInvocationException; - // - // Fmi2Status terminate() throws FmuInvocationException; - when(comp.terminate()).thenReturn(Fmi2Status.OK); - // void freeInstance() throws FmuInvocationException; - // when(comp.freeInstance()); - // FmuResult getState() throws FmuInvocationException; - // - // Fmi2Status setState(IFmiComponentState var1) throws FmuInvocationException; - // - // Fmi2Status freeState(IFmiComponentState var1) throws FmuInvocationException; - // - // boolean isValid(); - when(comp.isValid()).thenReturn(true); - // FmuResult getMaxStepSize() throws FmiInvalidNativeStateException; - when(comp.getMaxStepSize()).thenReturn(new FmuResult(Fmi2Status.Discard, 0.0)); - } + test("/derivativeInOutTest/config.json", 0, 1); + showAppenderCheckList(); + Assert.assertTrue("Missing value out of bounds warning", checkLogFor("is out of bounds")); + } + + @Test + public void testIntBoundMax() throws IOException, NanoHTTPD.ResponseException { + + configureInstances(REAL_DEFAULT, INTEGER_MAX + 1); + + test("/derivativeInOutTest/config.json", 0, 1); + + showAppenderCheckList(); + Assert.assertTrue("Missing value out of bounds warning", checkLogFor("is out of bounds")); + } + + @Test + public void testRealBoundMin() throws IOException, NanoHTTPD.ResponseException { + + configureInstances(REAL_MIN - 0.1, INTEGER_DEFAULT); + + test("/derivativeInOutTest/config.json", 0, 1); + + showAppenderCheckList(); + Assert.assertTrue("Missing value out of bounds warning", checkLogFor("is out of bounds")); + } + + @Test + public void testRealBoundMax() throws IOException, NanoHTTPD.ResponseException { + + configureInstances(REAL_MAX + 0.1, INTEGER_DEFAULT); + + test("/derivativeInOutTest/config.json", 0, 1); + + showAppenderCheckList(); + Assert.assertTrue("Missing value out of bounds warning", checkLogFor("is out of bounds")); + } + + private void configureInstances(double realValue, int integerValue) { + FmuFactory.customFactory = new IFmuFactory() { + @Override + public boolean accept(URI uri) { + return true; + } + + @Override + public IFmu instantiate(File sessionRoot, URI uri) throws Exception { + IFmu fmu = mock(IFmu.class); + when(fmu.isValid()).thenReturn(true); + + IFmiComponent comp = mock(IFmiComponent.class); + when(fmu.instantiate(anyString(), anyString(), anyBoolean(), anyBoolean(), any())).thenReturn(comp); + + compMock(fmu, comp); + + String modelDescriptionPath; + if (uri.toASCIIString().contains("watertank-c")) { + modelDescriptionPath = "src/test/resources/minMaxTest/watertank-c/modelDescription.xml"; + + when(comp.getReal(new long[]{2})).thenReturn(new FmuResult<>(Fmi2Status.OK, new double[]{realValue})); + + when(comp.getInteger(new long[]{6})).thenReturn(new FmuResult<>(Fmi2Status.OK, new int[]{integerValue})); + + } else { + modelDescriptionPath = "src/test/resources/minMaxTest/watertankcontroller-c/modelDescription.xml"; + when(comp.getBooleans(new long[]{4})).thenReturn(new FmuResult<>(Fmi2Status.OK, new boolean[]{true})); + + } + + final InputStream md = new ByteArrayInputStream( + IOUtils.toByteArray(new File(modelDescriptionPath.replace('/', File.separatorChar)).toURI())); + when(fmu.getModelDescription()).thenReturn(md); + return fmu; + } + + }; + } + + private void compMock(IFmu fmu, IFmiComponent comp) throws FmuInvocationException, InvalidParameterException { + + when(comp.getFmu()).thenReturn(fmu); + + // Fmi2Status setDebugLogging(boolean var1, String[] var2) throws FmuInvocationException; + when(comp.setDebugLogging(anyBoolean(), any())).thenReturn(Fmi2Status.OK); + + // Fmi2Status setupExperiment(boolean var1, double var2, double var4, boolean var6, double var7) throws FmuInvocationException; + when(comp.setupExperiment(anyBoolean(), anyDouble(), anyDouble(), anyBoolean(), anyDouble())).thenReturn(Fmi2Status.OK); + // Fmi2Status enterInitializationMode() throws FmuInvocationException; + when(comp.enterInitializationMode()).thenReturn(Fmi2Status.OK); + // Fmi2Status exitInitializationMode() throws FmuInvocationException; + when(comp.exitInitializationMode()).thenReturn(Fmi2Status.OK); + // Fmi2Status reset() throws FmuInvocationException; + // when(comp.reset()); + // Fmi2Status setRealInputDerivatives(long[] var1, int[] var2, double[] var3) throws FmuInvocationException; + //when(comp.setRealInputDerivatives(any(), any(), any())).thenReturn(Fmi2Status.OK); + // FmuResult getRealOutputDerivatives(long[] var1, int[] var2) throws FmuInvocationException; + // + // FmuResult getDirectionalDerivative(long[] var1, long[] var2, double[] var3) throws FmuInvocationException; + // + // Fmi2Status doStep(double var1, double var3, boolean var5) throws FmuInvocationException; + when(comp.doStep(anyDouble(), anyDouble(), anyBoolean())).thenReturn(Fmi2Status.OK); + // FmuResult getReal(long[] var1) throws FmuInvocationException; + // + // FmuResult getInteger(long[] var1) throws FmuInvocationException; + // + // FmuResult getBooleans(long[] var1) throws FmuInvocationException; + // + // FmuResult getStrings(long[] var1) throws FmuInvocationException; + // + // Fmi2Status setBooleans(long[] var1, boolean[] var2) throws InvalidParameterException, FmiInvalidNativeStateException; + when(comp.setBooleans(any(), any())).thenReturn(Fmi2Status.OK); + // Fmi2Status setReals(long[] var1, double[] var2) throws InvalidParameterException, FmiInvalidNativeStateException; + when(comp.setReals(any(), any())).thenReturn(Fmi2Status.OK); + // Fmi2Status setIntegers(long[] var1, int[] var2) throws InvalidParameterException, FmiInvalidNativeStateException; + when(comp.setIntegers(any(), any())).thenReturn(Fmi2Status.OK); + // Fmi2Status setStrings(long[] var1, String[] var2) throws InvalidParameterException, FmiInvalidNativeStateException; + when(comp.setStrings(any(), any())).thenReturn(Fmi2Status.OK); + // FmuResult getBooleanStatus(Fmi2StatusKind var1) throws FmuInvocationException; + // + // FmuResult getStatus(Fmi2StatusKind var1) throws FmuInvocationException; + // + // FmuResult getIntegerStatus(Fmi2StatusKind var1) throws FmuInvocationException; + // + // FmuResult getRealStatus(Fmi2StatusKind var1) throws FmuInvocationException; + // + // FmuResult getStringStatus(Fmi2StatusKind var1) throws FmuInvocationException; + // + // Fmi2Status terminate() throws FmuInvocationException; + when(comp.terminate()).thenReturn(Fmi2Status.OK); + // void freeInstance() throws FmuInvocationException; + // when(comp.freeInstance()); + // FmuResult getState() throws FmuInvocationException; + // + // Fmi2Status setState(IFmiComponentState var1) throws FmuInvocationException; + // + // Fmi2Status freeState(IFmiComponentState var1) throws FmuInvocationException; + // + // boolean isValid(); + when(comp.isValid()).thenReturn(true); + // FmuResult getMaxStepSize() throws FmiInvalidNativeStateException; + when(comp.getMaxStepSize()).thenReturn(new FmuResult(Fmi2Status.Discard, 0.0)); + } } diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/OnlineModelsCoSimTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/OnlineModelsCoSimTest.java index 2bc304d9c..3c5285fd5 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/OnlineModelsCoSimTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/OnlineModelsCoSimTest.java @@ -38,6 +38,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import fi.iki.elonen.NanoHTTPD; import org.apache.commons.io.FileUtils; import org.intocps.orchestration.coe.json.InitializationMsgJson; import org.junit.BeforeClass; @@ -47,8 +48,6 @@ import java.net.URL; import java.util.List; import java.util.Vector; - -import fi.iki.elonen.NanoHTTPD; public abstract class OnlineModelsCoSimTest extends BasicTest { final static String prefix = "/online-models"; diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/PerformanceTests.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/PerformanceTests.java index 96df8a058..b097e84f6 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/PerformanceTests.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/PerformanceTests.java @@ -35,7 +35,6 @@ package org.intocps.orchestration.coe; import fi.iki.elonen.NanoHTTPD; -import org.junit.Ignore; import org.junit.Test; import java.io.IOException; diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/StabilityTestMassSpringDamperTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/StabilityTestMassSpringDamperTest.java index be8e5b6e7..1343cea21 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/StabilityTestMassSpringDamperTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/StabilityTestMassSpringDamperTest.java @@ -35,7 +35,6 @@ package org.intocps.orchestration.coe; import fi.iki.elonen.NanoHTTPD; -import org.junit.Ignore; import org.junit.Test; import java.io.IOException; diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/WatertankTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/WatertankTest.java index 851e7dfd9..a92ac04a7 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/WatertankTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/WatertankTest.java @@ -34,11 +34,11 @@ */ package org.intocps.orchestration.coe; -import java.io.IOException; - import fi.iki.elonen.NanoHTTPD; import org.junit.Test; +import java.io.IOException; + public class WatertankTest extends OnlineModelsCoSimTest { @Test diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/VarStepOnlyBdSrTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/VarStepOnlyBdSrTest.java index da5a79c46..af2ba1c1e 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/VarStepOnlyBdSrTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/VarStepOnlyBdSrTest.java @@ -42,13 +42,13 @@ */ package org.intocps.orchestration.coe.cosim.varstep; -import java.io.IOException; - import fi.iki.elonen.NanoHTTPD; import org.intocps.orchestration.coe.BasicTest; import org.intocps.orchestration.coe.ConditionalIgnoreRule.ConditionalIgnore; import org.junit.Test; +import java.io.IOException; + public class VarStepOnlyBdSrTest extends BasicTest { diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/VarStepOnlyBdTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/VarStepOnlyBdTest.java index f5a71e718..8cbbf3293 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/VarStepOnlyBdTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/VarStepOnlyBdTest.java @@ -42,14 +42,13 @@ */ package org.intocps.orchestration.coe.cosim.varstep; -import java.io.IOException; - import fi.iki.elonen.NanoHTTPD; import org.intocps.orchestration.coe.BasicTest; -import org.intocps.orchestration.coe.CoeBaseTest.Win32Only; import org.intocps.orchestration.coe.ConditionalIgnoreRule.ConditionalIgnore; import org.junit.Test; +import java.io.IOException; + public class VarStepOnlyBdTest extends BasicTest { @ConditionalIgnore(condition = DymolaLicenseWin32.class) diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/VarStepOnlySrTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/VarStepOnlySrTest.java index 0bab5f2e3..1d6b80584 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/VarStepOnlySrTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/VarStepOnlySrTest.java @@ -42,14 +42,13 @@ */ package org.intocps.orchestration.coe.cosim.varstep; -import java.io.IOException; - import fi.iki.elonen.NanoHTTPD; import org.intocps.orchestration.coe.BasicTest; -import org.intocps.orchestration.coe.CoeBaseTest.Win32Only; import org.intocps.orchestration.coe.ConditionalIgnoreRule.ConditionalIgnore; import org.junit.Test; +import java.io.IOException; + public class VarStepOnlySrTest extends BasicTest { @ConditionalIgnore(condition = DymolaLicenseWin32.class) diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/VarStepOnlyZcSrTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/VarStepOnlyZcSrTest.java index 38884ed52..6496e235c 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/VarStepOnlyZcSrTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/VarStepOnlyZcSrTest.java @@ -42,14 +42,13 @@ */ package org.intocps.orchestration.coe.cosim.varstep; -import java.io.IOException; - import fi.iki.elonen.NanoHTTPD; import org.intocps.orchestration.coe.BasicTest; import org.intocps.orchestration.coe.ConditionalIgnoreRule.ConditionalIgnore; -import org.intocps.orchestration.coe.CoeBaseTest.Win32Only; import org.junit.Test; +import java.io.IOException; + public class VarStepOnlyZcSrTest extends BasicTest { @ConditionalIgnore(condition = DymolaLicenseWin32.class) diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/VarStepOnlyZcTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/VarStepOnlyZcTest.java index a0b51e521..8ad7166b4 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/VarStepOnlyZcTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/VarStepOnlyZcTest.java @@ -42,14 +42,13 @@ */ package org.intocps.orchestration.coe.cosim.varstep; -import java.io.IOException; - import fi.iki.elonen.NanoHTTPD; import org.intocps.orchestration.coe.BasicTest; -import org.intocps.orchestration.coe.CoeBaseTest.Win32Only; import org.intocps.orchestration.coe.ConditionalIgnoreRule.ConditionalIgnore; import org.junit.Test; +import java.io.IOException; + public class VarStepOnlyZcTest extends BasicTest { @ConditionalIgnore(condition = DymolaLicenseWin32.class) diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/VarStepTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/VarStepTest.java index 6d6c35ed5..f264bf209 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/VarStepTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/VarStepTest.java @@ -42,14 +42,13 @@ */ package org.intocps.orchestration.coe.cosim.varstep; -import java.io.IOException; - import fi.iki.elonen.NanoHTTPD; import org.intocps.orchestration.coe.BasicTest; -import org.intocps.orchestration.coe.CoeBaseTest.Win32Only; import org.intocps.orchestration.coe.ConditionalIgnoreRule.ConditionalIgnore; import org.junit.Test; +import java.io.IOException; + public class VarStepTest extends BasicTest { @ConditionalIgnore(condition = DymolaLicenseWin32.class) diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/TestUtil.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/TestUtil.java index fdd54bc0e..d16535441 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/TestUtil.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/TestUtil.java @@ -42,11 +42,6 @@ */ package org.intocps.orchestration.coe.cosim.varstep.constraint; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import org.intocps.orchestration.coe.config.ModelConnection.ModelInstance; import org.intocps.orchestration.coe.json.InitializationMsgJson.Constraint; import org.intocps.orchestration.coe.modeldefinition.ModelDescription; @@ -54,6 +49,11 @@ import org.intocps.orchestration.coe.modeldefinition.ModelDescription.Type; import org.intocps.orchestration.coe.modeldefinition.ModelDescription.Types; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + public class TestUtil { private static final String GUID = "{12345}"; diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/bounddifference/BoundDifferenceCalculatorTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/bounddifference/BoundDifferenceCalculatorTest.java index 3bbca1448..b0540fee1 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/bounddifference/BoundDifferenceCalculatorTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/bounddifference/BoundDifferenceCalculatorTest.java @@ -42,8 +42,6 @@ */ package org.intocps.orchestration.coe.cosim.varstep.constraint.bounddifference; -import static org.junit.Assert.assertEquals; - import org.intocps.orchestration.coe.cosim.varstep.CurrentSolutionPoint; import org.intocps.orchestration.coe.cosim.varstep.constraint.TestUtil; import org.intocps.orchestration.coe.cosim.varstep.constraint.boundeddifference.BoundedDifferenceCalculator; @@ -51,6 +49,8 @@ import org.junit.Ignore; import org.junit.Test; +import static org.junit.Assert.assertEquals; + @Ignore public class BoundDifferenceCalculatorTest { diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/bounddifference/BoundDifferenceHandlerTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/bounddifference/BoundDifferenceHandlerTest.java index 933ed98ba..2a24abd70 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/bounddifference/BoundDifferenceHandlerTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/bounddifference/BoundDifferenceHandlerTest.java @@ -42,8 +42,6 @@ */ package org.intocps.orchestration.coe.cosim.varstep.constraint.bounddifference; -import static org.junit.Assert.assertTrue; - import org.intocps.orchestration.coe.cosim.varstep.CurrentSolutionPoint; import org.intocps.orchestration.coe.cosim.varstep.StepsizeInterval; import org.intocps.orchestration.coe.cosim.varstep.constraint.ConstraintHandler; @@ -53,6 +51,8 @@ import org.junit.Ignore; import org.junit.Test; +import static org.junit.Assert.assertTrue; + @Ignore public class BoundDifferenceHandlerTest { diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/samplingrate/SamplingRateHandlerTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/samplingrate/SamplingRateHandlerTest.java index 845950aef..724672a16 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/samplingrate/SamplingRateHandlerTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/samplingrate/SamplingRateHandlerTest.java @@ -42,11 +42,6 @@ */ package org.intocps.orchestration.coe.cosim.varstep.constraint.samplingrate; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; - import org.intocps.orchestration.coe.cosim.varstep.CurrentSolutionPoint; import org.intocps.orchestration.coe.cosim.varstep.StepsizeInterval; import org.intocps.orchestration.coe.cosim.varstep.constraint.ConstraintHandler; @@ -56,6 +51,11 @@ import org.intocps.orchestration.coe.json.InitializationMsgJson.Constraint; import org.junit.Test; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertTrue; + public class SamplingRateHandlerTest { diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/valuetracker/ValueTrackerTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/valuetracker/ValueTrackerTest.java index acee0f8d4..a0b4e9a33 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/valuetracker/ValueTrackerTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/valuetracker/ValueTrackerTest.java @@ -42,11 +42,6 @@ */ package org.intocps.orchestration.coe.cosim.varstep.constraint.valuetracker; -import static org.junit.Assert.assertEquals; - -import java.util.ArrayList; -import java.util.List; - import org.intocps.orchestration.coe.config.ModelConnection.Variable; import org.intocps.orchestration.coe.cosim.varstep.CurrentSolutionPoint; import org.intocps.orchestration.coe.cosim.varstep.constraint.TestUtil; @@ -56,6 +51,11 @@ import org.junit.Ignore; import org.junit.Test; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertEquals; + @Ignore public class ValueTrackerTest { diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/zerocrossing/ZeroCrossingHandlerTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/zerocrossing/ZeroCrossingHandlerTest.java index 884c2a47a..10c424dc8 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/zerocrossing/ZeroCrossingHandlerTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/zerocrossing/ZeroCrossingHandlerTest.java @@ -42,9 +42,6 @@ */ package org.intocps.orchestration.coe.cosim.varstep.constraint.zerocrossing; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import org.intocps.orchestration.coe.cosim.varstep.CurrentSolutionPoint; import org.intocps.orchestration.coe.cosim.varstep.StepsizeInterval; import org.intocps.orchestration.coe.cosim.varstep.constraint.ConstraintHandler; @@ -53,6 +50,9 @@ import org.junit.Ignore; import org.junit.Test; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + @Ignore public class ZeroCrossingHandlerTest { diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/zerocrossing/ZerocrossingCalculationsTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/zerocrossing/ZerocrossingCalculationsTest.java index 3d82120a0..81f97fcde 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/zerocrossing/ZerocrossingCalculationsTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/cosim/varstep/constraint/zerocrossing/ZerocrossingCalculationsTest.java @@ -42,10 +42,6 @@ */ package org.intocps.orchestration.coe.cosim.varstep.constraint.zerocrossing; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertEquals; - import org.intocps.orchestration.coe.cosim.varstep.CurrentSolutionPoint; import org.intocps.orchestration.coe.cosim.varstep.constraint.TestUtil; import org.intocps.orchestration.coe.cosim.varstep.constraint.zerocrossing.detection.ZerocrossingDetector; @@ -55,6 +51,8 @@ import org.junit.Ignore; import org.junit.Test; +import static org.junit.Assert.*; + @Ignore public class ZerocrossingCalculationsTest { diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/HX_single_fix_Test.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/HX_single_fix_Test.java index 176644e80..a0d5b7610 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/HX_single_fix_Test.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/HX_single_fix_Test.java @@ -42,13 +42,12 @@ */ package org.intocps.orchestration.coe.qmtest; -import java.io.IOException; - +import fi.iki.elonen.NanoHTTPD.ResponseException; import org.intocps.orchestration.coe.BasicTest; import org.intocps.orchestration.coe.ConditionalIgnoreRule.ConditionalIgnore; import org.junit.Test; -import fi.iki.elonen.NanoHTTPD.ResponseException; +import java.io.IOException; public class HX_single_fix_Test extends BasicTest { diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/HX_single_var_Test.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/HX_single_var_Test.java index 27e2f4501..29c72cc22 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/HX_single_var_Test.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/HX_single_var_Test.java @@ -42,13 +42,12 @@ */ package org.intocps.orchestration.coe.qmtest; -import java.io.IOException; - +import fi.iki.elonen.NanoHTTPD.ResponseException; import org.intocps.orchestration.coe.BasicTest; import org.intocps.orchestration.coe.ConditionalIgnoreRule.ConditionalIgnore; import org.junit.Test; -import fi.iki.elonen.NanoHTTPD.ResponseException; +import java.io.IOException; public class HX_single_var_Test extends BasicTest { diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/MassiveTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/MassiveTest.java index 6c96785da..40ee42ea7 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/MassiveTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/MassiveTest.java @@ -42,14 +42,11 @@ */ package org.intocps.orchestration.coe.qmtest; -import java.io.IOException; - -import org.intocps.orchestration.coe.BasicTest; -import org.intocps.orchestration.coe.ConditionalIgnoreRule; +import fi.iki.elonen.NanoHTTPD.ResponseException; import org.intocps.orchestration.coe.OnlineModelsCoSimTest; import org.junit.Test; -import fi.iki.elonen.NanoHTTPD.ResponseException; +import java.io.IOException; public class MassiveTest extends OnlineModelsCoSimTest { diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/BD_multi_Test.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/BD_multi_Test.java index f0a860fa3..48485b5fb 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/BD_multi_Test.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/BD_multi_Test.java @@ -42,14 +42,11 @@ */ package org.intocps.orchestration.coe.qmtest.build_varstep; -import java.io.IOException; - -import org.intocps.orchestration.coe.BasicTest; -import org.intocps.orchestration.coe.ConditionalIgnoreRule.ConditionalIgnore; +import fi.iki.elonen.NanoHTTPD; import org.intocps.orchestration.coe.OnlineModelsCoSimTest; import org.junit.Test; -import fi.iki.elonen.NanoHTTPD; +import java.io.IOException; public class BD_multi_Test extends OnlineModelsCoSimTest { diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/BD_single_Test.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/BD_single_Test.java index 3ae6726a0..bb46dd957 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/BD_single_Test.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/BD_single_Test.java @@ -42,14 +42,11 @@ */ package org.intocps.orchestration.coe.qmtest.build_varstep; -import java.io.IOException; - -import org.intocps.orchestration.coe.BasicTest; -import org.intocps.orchestration.coe.ConditionalIgnoreRule.ConditionalIgnore; +import fi.iki.elonen.NanoHTTPD; import org.intocps.orchestration.coe.OnlineModelsCoSimTest; import org.junit.Test; -import fi.iki.elonen.NanoHTTPD; +import java.io.IOException; public class BD_single_Test extends OnlineModelsCoSimTest { diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/Rollback_Test.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/Rollback_Test.java index fe5f76dc8..da800f198 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/Rollback_Test.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/Rollback_Test.java @@ -42,15 +42,12 @@ */ package org.intocps.orchestration.coe.qmtest.build_varstep; -import java.io.IOException; - -import org.intocps.orchestration.coe.BasicTest; -import org.intocps.orchestration.coe.ConditionalIgnoreRule.ConditionalIgnore; +import fi.iki.elonen.NanoHTTPD; import org.intocps.orchestration.coe.OnlineModelsCoSimTest; import org.junit.Ignore; import org.junit.Test; -import fi.iki.elonen.NanoHTTPD; +import java.io.IOException; public class Rollback_Test extends OnlineModelsCoSimTest { diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/Rollback_valid.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/Rollback_valid.java index 8e83a3fab..39f767c6b 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/Rollback_valid.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/Rollback_valid.java @@ -42,13 +42,12 @@ */ package org.intocps.orchestration.coe.qmtest.build_varstep; -import java.io.IOException; - +import fi.iki.elonen.NanoHTTPD; import org.intocps.orchestration.coe.BasicTest; import org.intocps.orchestration.coe.ConditionalIgnoreRule.ConditionalIgnore; import org.junit.Test; -import fi.iki.elonen.NanoHTTPD; +import java.io.IOException; public class Rollback_valid extends BasicTest { diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/SR_multi_Test.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/SR_multi_Test.java index 3096b0f71..86b16dd8b 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/SR_multi_Test.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/SR_multi_Test.java @@ -42,14 +42,11 @@ */ package org.intocps.orchestration.coe.qmtest.build_varstep; -import java.io.IOException; - -import org.intocps.orchestration.coe.BasicTest; -import org.intocps.orchestration.coe.ConditionalIgnoreRule.ConditionalIgnore; +import fi.iki.elonen.NanoHTTPD; import org.intocps.orchestration.coe.OnlineModelsCoSimTest; import org.junit.Test; -import fi.iki.elonen.NanoHTTPD; +import java.io.IOException; public class SR_multi_Test extends OnlineModelsCoSimTest { diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/SR_single_Test.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/SR_single_Test.java index bff706216..c03a8e4f2 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/SR_single_Test.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/SR_single_Test.java @@ -42,14 +42,11 @@ */ package org.intocps.orchestration.coe.qmtest.build_varstep; -import java.io.IOException; - -import org.intocps.orchestration.coe.BasicTest; -import org.intocps.orchestration.coe.ConditionalIgnoreRule.ConditionalIgnore; +import fi.iki.elonen.NanoHTTPD; import org.intocps.orchestration.coe.OnlineModelsCoSimTest; import org.junit.Test; -import fi.iki.elonen.NanoHTTPD; +import java.io.IOException; public class SR_single_Test extends OnlineModelsCoSimTest { diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/ZC_BD_SR_Test.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/ZC_BD_SR_Test.java index db6f76b52..0eb1f217b 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/ZC_BD_SR_Test.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/ZC_BD_SR_Test.java @@ -42,14 +42,11 @@ */ package org.intocps.orchestration.coe.qmtest.build_varstep; -import java.io.IOException; - -import org.intocps.orchestration.coe.BasicTest; -import org.intocps.orchestration.coe.ConditionalIgnoreRule.ConditionalIgnore; +import fi.iki.elonen.NanoHTTPD; import org.intocps.orchestration.coe.OnlineModelsCoSimTest; import org.junit.Test; -import fi.iki.elonen.NanoHTTPD; +import java.io.IOException; public class ZC_BD_SR_Test extends OnlineModelsCoSimTest { diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/ZC_multi_Test.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/ZC_multi_Test.java index f3f843fd9..2adeeea42 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/ZC_multi_Test.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/ZC_multi_Test.java @@ -42,14 +42,11 @@ */ package org.intocps.orchestration.coe.qmtest.build_varstep; -import java.io.IOException; - -import org.intocps.orchestration.coe.BasicTest; -import org.intocps.orchestration.coe.ConditionalIgnoreRule.ConditionalIgnore; +import fi.iki.elonen.NanoHTTPD; import org.intocps.orchestration.coe.OnlineModelsCoSimTest; import org.junit.Test; -import fi.iki.elonen.NanoHTTPD; +import java.io.IOException; public class ZC_multi_Test extends OnlineModelsCoSimTest { diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/ZC_single_Test.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/ZC_single_Test.java index d38ac59e2..910a10133 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/ZC_single_Test.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/qmtest/build_varstep/ZC_single_Test.java @@ -42,14 +42,11 @@ */ package org.intocps.orchestration.coe.qmtest.build_varstep; -import java.io.IOException; - -import org.intocps.orchestration.coe.BasicTest; -import org.intocps.orchestration.coe.ConditionalIgnoreRule.ConditionalIgnore; +import fi.iki.elonen.NanoHTTPD; import org.intocps.orchestration.coe.OnlineModelsCoSimTest; import org.junit.Test; -import fi.iki.elonen.NanoHTTPD; +import java.io.IOException; public class ZC_single_Test extends OnlineModelsCoSimTest { diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/single/SingleShotTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/single/SingleShotTest.java index e4a62930e..254d0edbc 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/single/SingleShotTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/single/SingleShotTest.java @@ -46,7 +46,6 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import java.util.Arrays; /** * Created by kel on 23/01/17. diff --git a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/stresstest/StressTest.java b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/stresstest/StressTest.java index 418aed41e..7549ed6b7 100644 --- a/orchestration/coe/src/test/java/org/intocps/orchestration/coe/stresstest/StressTest.java +++ b/orchestration/coe/src/test/java/org/intocps/orchestration/coe/stresstest/StressTest.java @@ -38,21 +38,15 @@ import org.apache.commons.collections.map.HashedMap; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; -import org.apache.commons.logging.Log; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.apache.log4j.spi.RootLogger; +import org.apache.logging.log4j.Level; import org.intocps.orchestration.coe.BasicTest; import org.intocps.orchestration.coe.OnlineModelsCoSimTest; -import org.intocps.orchestration.coe.scala.CoeObject; -import org.intocps.orchestration.coe.scala.CoeSimulator; +import org.intocps.orchestration.coe.util.Util; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; -import org.slf4j.LoggerFactory; import java.io.*; -import java.net.MalformedURLException; import java.net.URL; import java.nio.file.Paths; import java.util.*; @@ -196,7 +190,7 @@ void validateResult(File result) final int replications = 100; - Logger.getRootLogger().setLevel(Level.ERROR); + Util.setLogLevel(Level.ERROR); Map> parametersArg = new HashedMap(); Map parameters = new HashedMap(); @@ -237,7 +231,7 @@ void validateResult(File result) final int replications = 100; - Logger.getRootLogger().setLevel(Level.DEBUG); + Util.setLogLevel(Level.DEBUG); Map> parametersArg = new HashedMap(); Map parameters = new HashedMap(); diff --git a/orchestration/coe/src/test/resources/log4j.properties b/orchestration/coe/src/test/resources/log4j.properties deleted file mode 100644 index 904a66389..000000000 --- a/orchestration/coe/src/test/resources/log4j.properties +++ /dev/null @@ -1,29 +0,0 @@ -log4j.rootLogger=info, stdout, R - -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout - -# Pattern to output the caller's file name and line number. -log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n - -log4j.appender.R=org.apache.log4j.RollingFileAppender -log4j.appender.R.File=target/coe.log - -log4j.appender.R.MaxFileSize=100KB -# Keep one backup file -log4j.appender.R.MaxBackupIndex=1 - -log4j.appender.R.layout=org.apache.log4j.PatternLayout -log4j.appender.R.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n - - -# log4j.logger.org.intocps.orchestration.coe.Simulator=DEBUG - -# log4j.logger.org.intocps.fmi.jnifmuapi=ERROR - - -# log4j.logger.org.intocps.orchestration.coe.scala.CoeObject$=TRACE - -# log4j.logger.org.intocps.orchestration.coe.cosim.VariableStepSizeCalculator=TRACE - -# log4j.logger.fmi.instance=ALL diff --git a/orchestration/coe/src/test/resources/log4j2.xml b/orchestration/coe/src/test/resources/log4j2.xml new file mode 100644 index 000000000..e8cc93021 --- /dev/null +++ b/orchestration/coe/src/test/resources/log4j2.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/orchestration/webapi/pom.xml b/orchestration/webapi/pom.xml index 0679c6d3f..a12e2cadd 100644 --- a/orchestration/webapi/pom.xml +++ b/orchestration/webapi/pom.xml @@ -12,7 +12,7 @@ webapi 2.1.8.RELEASE - 2.12.1 + 2.20.0 @@ -33,7 +33,16 @@ spring-boot-starter-test test - + + org.apache.logging.log4j + log4j-api + ${log4j2.version} + + + org.apache.logging.log4j + log4j-core + ${log4j2.version} + io.springfox diff --git a/orchestration/webapi/src/main/java/org/intocps/orchestration/coe/webapi/controllers/EsaSimulationController.java b/orchestration/webapi/src/main/java/org/intocps/orchestration/coe/webapi/controllers/EsaSimulationController.java index 9c6b3a4e0..a70f5fe96 100644 --- a/orchestration/webapi/src/main/java/org/intocps/orchestration/coe/webapi/controllers/EsaSimulationController.java +++ b/orchestration/webapi/src/main/java/org/intocps/orchestration/coe/webapi/controllers/EsaSimulationController.java @@ -5,9 +5,8 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.io.FileUtils; -import org.apache.log4j.FileAppender; -import org.apache.log4j.Level; -import org.apache.log4j.LogManager; + +import org.apache.logging.log4j.core.config.Configurator; import org.intocps.orchestration.coe.config.InvalidVariableStringException; import org.intocps.orchestration.coe.config.ModelConnection; import org.intocps.orchestration.coe.config.ModelParameter; @@ -16,6 +15,7 @@ import org.intocps.orchestration.coe.httpserver.RequestProcessors; import org.intocps.orchestration.coe.modeldefinition.ModelDescription; import org.intocps.orchestration.coe.scala.Coe; +import org.intocps.orchestration.coe.util.Util; import org.intocps.orchestration.coe.util.ZipDirectory; import org.intocps.orchestration.coe.webapi.services.CoeService; import org.slf4j.Logger; @@ -70,7 +70,8 @@ public void initializeSession(@RequestBody EsaIninializationData body) throws Ex mapper.writeValue(new File(coeService.get().getResultRoot(), "initialize.json"), body); if (body.simulatorLogLevel != null) { - LogManager.getRootLogger().setLevel(Level.toLevel(body.simulatorLogLevel.name())); +// LogManager.getRootLogger().setLevel(Level.toLevel(body.simulatorLogLevel.name())); + Configurator.setLevel("root", org.apache.logging.log4j.Level.getLevel(body.simulatorLogLevel.name())); } CoSimStepSizeCalculator stepSizeCalculator = new BasicFixedStepSizeCalculator(body.stepSize); @@ -198,34 +199,34 @@ public void destroy() throws Exception { throw new Exception("bad session"); } - org.apache.log4j.Logger rootLogger = org.apache.log4j.Logger.getRootLogger(); - ArrayList appendersToRemove = new ArrayList<>(); - Enumeration appenders = rootLogger.getAllAppenders(); - - if (appenders != null) { - while (appenders.hasMoreElements()) { - try { - Object element = appenders.nextElement(); - if (element != null && element instanceof FileAppender) { - FileAppender fileAppender = (FileAppender) element; - // if (fileAppender.getFile() != null && fileAppender.getFile() - // .matches("(.*)(" + sessionId + ")[/\\\\](.*)[/\\\\].*(\\.log)$")) { - // // Log files for fmu instances. - // // Regex matches +sessionId++++anything.log - // fileAppender.close(); - // appendersToRemove.add(fileAppender); - // } - } - } catch (NoSuchElementException e) { - //this is not synchronized so this can happen - } - } - appendersToRemove.forEach(fa -> { - rootLogger.removeAppender(fa); - }); - - } - +// LoggerContext context = LoggerContext.getContext(false); +// Configuration configuration = context.getConfiguration(); +// +// +// ArrayList appendersToRemove = new ArrayList<>(); +// Map appenders = configuration.getAppenders(); +// +// if (appenders != null) { +// +// for(Map.Entry appender :appenders.entrySet()) { +// if (appender.getValue() instanceof FileAppender) { +// FileAppender fileAppender = (FileAppender) appender.getValue(); +// // if (fileAppender.getFileName() != null && fileAppender.getFileName() +// // .matches("(.*)(" + sessionId + ")[/\\\\](.*)[/\\\\].*(\\.log)$")) { +// // Log files for fmu instances. +// // Regex matches +sessionId++++anything.log +// fileAppender.stop(); +// appendersToRemove.add(fileAppender.getName()); +// // } +// } +// +// +// appendersToRemove.forEach(fa -> { +// configuration.getRootLogger().removeAppender(fa); +// }); +// } +// } + if( Util.removeCoSimInstanceLogAppenders(null)) FileUtils.deleteDirectory(coe.getResultRoot()); } diff --git a/orchestration/webapi/src/main/java/org/intocps/orchestration/coe/webapi/controllers/SimulationController.java b/orchestration/webapi/src/main/java/org/intocps/orchestration/coe/webapi/controllers/SimulationController.java index f942af4bf..170202aaa 100644 --- a/orchestration/webapi/src/main/java/org/intocps/orchestration/coe/webapi/controllers/SimulationController.java +++ b/orchestration/webapi/src/main/java/org/intocps/orchestration/coe/webapi/controllers/SimulationController.java @@ -7,7 +7,6 @@ import io.swagger.annotations.ApiParam; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; -import org.apache.log4j.FileAppender; import org.intocps.orchestration.coe.config.ModelConnection; import org.intocps.orchestration.coe.cosim.BasicFixedStepSizeCalculator; import org.intocps.orchestration.coe.cosim.CoSimStepSizeCalculator; @@ -19,6 +18,7 @@ import org.intocps.orchestration.coe.modeldefinition.ModelDescription; import org.intocps.orchestration.coe.scala.Coe; import org.intocps.orchestration.coe.scala.LogVariablesContainer; +import org.intocps.orchestration.coe.util.Util; import org.intocps.orchestration.coe.util.ZipDirectory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -325,37 +325,41 @@ public void destroy(@PathVariable String sessionId) throws Exception { throw new Exception("bad session"); } - org.apache.log4j.Logger rootLogger = org.apache.log4j.Logger.getRootLogger(); - ArrayList appendersToRemove = new ArrayList<>(); - Enumeration appenders = rootLogger.getAllAppenders(); - - if (appenders != null) { - while (appenders.hasMoreElements()) { - try { - Object element = appenders.nextElement(); - if (element != null && element instanceof FileAppender) { - FileAppender fileAppender = (FileAppender) element; - if (fileAppender.getFile() != null && fileAppender.getFile() - .matches("(.*)(" + sessionId + ")[/\\\\](.*)[/\\\\].*(\\.log)$")) { - // Log files for fmu instances. - // Regex matches +sessionId++++anything.log - fileAppender.close(); - appendersToRemove.add(fileAppender); - } - } - } catch (NoSuchElementException e) { - //this is not synchronized so this can happen - } - } - appendersToRemove.forEach(fa -> { - rootLogger.removeAppender(fa); - }); - - } + if(Util.removeCoSimInstanceLogAppenders(sessionId)){ +// LoggerContext context = LoggerContext.getContext(false); +// Configuration configuration = context.getConfiguration(); +// +// +// ArrayList appendersToRemove = new ArrayList<>(); +// Map appenders = configuration.getAppenders(); +// +// if (appenders != null) { +// +// for(Map.Entry appender :appenders.entrySet()) +// { +// if(appender.getValue() instanceof FileAppender) { +// FileAppender fileAppender = (FileAppender) appender.getValue(); +// if (fileAppender.getFileName() != null && fileAppender.getFileName() +// .matches("(.*)(" + sessionId + ")[/\\\\](.*)[/\\\\].*(\\.log)$")) { +// // Log files for fmu instances. +// // Regex matches +sessionId++++anything.log +// fileAppender.stop(); +// appendersToRemove.add(fileAppender.getName()); +// } +// } +// +// +// +// appendersToRemove.forEach(fa -> { +// configuration.getRootLogger().removeAppender(fa); +// }); + +// } FileUtils.deleteDirectory(coe.getResultRoot()); } + } // @RequestMapping(value = "/reset/{sessionId}", method = RequestMethod.GET) // public void reset(@PathVariable String sessionId) { diff --git a/orchestration/webapi/src/test/java/org/intocps/orchestration/coe/webapi/esav1/Stp3Instance1Test.java b/orchestration/webapi/src/test/java/org/intocps/orchestration/coe/webapi/esav1/Stp3Instance1Test.java index bb1189971..95734c83c 100644 --- a/orchestration/webapi/src/test/java/org/intocps/orchestration/coe/webapi/esav1/Stp3Instance1Test.java +++ b/orchestration/webapi/src/test/java/org/intocps/orchestration/coe/webapi/esav1/Stp3Instance1Test.java @@ -2,7 +2,6 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.log4j.Logger; import org.assertj.core.util.Files; import org.intocps.orchestration.coe.webapi.BaseTest; import org.intocps.orchestration.coe.webapi.ConditionalIgnoreRule; @@ -71,8 +70,8 @@ public void initializeTest() throws Exception { String data = Files.contentOf(Paths.get("src", "test", "resources", "esa", "STP3", "1-initialize.json").toFile(), StandardCharsets.UTF_8); data = data.replace("watertankController-Standalone.fmu", uriScheme + Paths.get("src", "test", "resources", "esa", "fmus", "watertankController-Standalone.fmu").toAbsolutePath().toString().replace('\\','/')); - Logger log = Logger.getLogger(Stp3Instance1Test.class); - log.info("Stp3Instance1Test uri: " + data); +// Logger log = Logger.getLogger(Stp3Instance1Test.class); +// log.info("Stp3Instance1Test uri: " + data); System.out.println("Stp3Instance1Test uri: " + data); data = data.replace("singlewatertank-20sim.fmu", uriScheme + Paths.get("src", "test", "resources", "esa", "fmus", "singlewatertank-20sim.fmu").toAbsolutePath().toString().replace('\\','/')); diff --git a/pom.xml b/pom.xml index 3c43ef981..304994ef6 100644 --- a/pom.xml +++ b/pom.xml @@ -261,11 +261,18 @@ http://mojo.codehaus.org/versions-maven-plugin/ 2.7 - - org.apache.maven.plugins + maven-surefire-plugin - 2.22.2 + 3.0.0-M5 + + true + + + + + **/FullSpecCppTest.java +