Skip to content

Commit

Permalink
Add back tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas-Boltz committed Nov 5, 2023
1 parent f2678c1 commit 2ac7292
Show file tree
Hide file tree
Showing 98 changed files with 9,725 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
with:
use-display-output: true
no-caching: true
skip-branch-deploy: false
deploy-updatesite: 'releng/org.palladiosimulator.simulizar.updatesite/target/repository'
secrets:
SERVER_SSH_KEY: ${{ secrets.DEPLOYMENT_SERVER_SSH_KEY }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,14 @@
<unit id="org.palladiosimulator.experimentanalysis.tests.feature.feature.group" version="0.0.0"/>
<repository location="https://updatesite.palladio-simulator.com/palladio-qual-experimentanalysis/branches/testingDay5.2.0/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="false" type="InstallableUnit" filter="nightly">
<unit id="org.palladiosimulator.examples.package" version="0.0.0"/>
<repository location="https://updatesite.palladio-simulator.com/palladio-example-models-package/branches/testingDay5.2.0/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="false" type="InstallableUnit" filter="release">
<unit id="org.palladiosimulator.examples.package" version="0.0.0"/>
<repository location="https://updatesite.palladio-simulator.com/palladio-example-models-package/releases/latest"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="false" type="InstallableUnit" filter="nightly">
<unit id="org.mockito.core-with-junit-extension.feature.feature.group" version="0.0.0"/>
<unit id="net.bytebuddy.byte-buddy.feature.feature.group" version="0.0.0"/>
Expand Down
13 changes: 13 additions & 0 deletions tests/org.palladiosimulator.simulizar.tests/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="xtend-gen"/>
<classpathentry kind="src" path="src-gen"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Empty file.
2 changes: 2 additions & 0 deletions tests/org.palladiosimulator.simulizar.tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/bin/
*.html
34 changes: 34 additions & 0 deletions tests/org.palladiosimulator.simulizar.tests/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.palladiosimulator.simulizar.tests</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=17
41 changes: 41 additions & 0 deletions tests/org.palladiosimulator.simulizar.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: SimuLizar Tests
Bundle-SymbolicName: org.palladiosimulator.simulizar.tests;singleton:=true
Bundle-Version: 5.2.0.qualifier
Bundle-Vendor: palladiosimulator.org
Bundle-RequiredExecutionEnvironment: JavaSE-17
Fragment-Host: org.palladiosimulator.simulizar
Require-Bundle: org.eclipse.xtext.xbase.lib,
org.eclipse.xtend.lib,
org.eclipse.xtend.lib.macro,
org.palladiosimulator.simulizar.reconfiguration.qvto;bundle-version="5.2.0",
org.palladiosimulator.edp2.repository.local;bundle-version="4.3.0",
org.palladiosimulator.pcm.resources;bundle-version="4.3.0",
de.uka.ipd.sdq.simulation.abstractsimengine.desmoj;bundle-version="4.3.0",
de.uka.ipd.sdq.errorhandling;bundle-version="4.3.0",
tools.mdsd.library.standalone.initialization;bundle-version="0.1.0",
de.desmoj;bundle-version="2.3.3",
tools.mdsd.junit5utils;bundle-version="0.1.0",
org.palladiosimulator.examples.package,
org.palladiosimulator.simulizar.test.commons;bundle-version="5.2.0",
org.palladiosimulator.simulizar.events,
org.palladiosimulator.simulizar.monitorrepository.feedthrough;bundle-version="5.2.0"
Import-Package: com.google.common.util.concurrent.internal;version="1.0.1",
net.bytebuddy.dynamic.loading;version="1.6.0",
org.hamcrest;version="2.2.0",
org.hamcrest.collection;version="2.2.0",
org.hamcrest.core;version="2.2.0",
org.junit.jupiter.api;version="5.4.2",
org.junit.jupiter.api.extension;version="5.4.2",
org.junit.jupiter.api.function;version="5.4.2",
org.junit.jupiter.api.io;version="5.4.2",
org.junit.jupiter.params;version="5.4.2",
org.junit.jupiter.params.provider;version="5.4.2",
org.junit.platform.commons;version="1.4.0",
org.junit.platform.commons.support;version="1.4.0",
org.mockito,
org.mockito.invocation,
org.mockito.junit.jupiter,
org.mockito.stubbing,
org.objenesis;version="2.6.0"
7 changes: 7 additions & 0 deletions tests/org.palladiosimulator.simulizar.tests/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
source.. = src/,\
xtend-gen/,\
src-gen/
output.. = bin/
bin.includes = META-INF/,\
.,\
testmodels/
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
<booleanAttribute key="append.args" value="true"/>
<booleanAttribute key="askclear" value="false"/>
<booleanAttribute key="automaticAdd" value="true"/>
<booleanAttribute key="automaticValidate" value="false"/>
<stringAttribute key="bootstrap" value=""/>
<stringAttribute key="checked" value="[NONE]"/>
<booleanAttribute key="clearConfig" value="true"/>
<booleanAttribute key="clearws" value="true"/>
<booleanAttribute key="clearwslog" value="false"/>
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
<booleanAttribute key="default" value="true"/>
<booleanAttribute key="includeOptional" value="true"/>
<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/org.palladiosimulator.simulizar.tests"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=org.palladiosimulator.simulizar.tests"/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit5"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -clean"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.palladiosimulator.simulizar.tests"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dosgi.requiredJavaVersion=1.8 -Xmx1536m -XX:MaxPermSize=512m -Xms1024m"/>
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.eclipse.platform.ide"/>
<booleanAttribute key="run_in_ui_thread" value="true"/>
<booleanAttribute key="show_selected_only" value="false"/>
<booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useCustomFeatures" value="false"/>
<booleanAttribute key="useDefaultConfig" value="true"/>
<booleanAttribute key="useDefaultConfigArea" value="false"/>
<booleanAttribute key="useProduct" value="true"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
package org.palladiosimulator.simulizar.di.extension;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.collection.IsEmptyCollection.empty;
import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;

import java.util.Set;

import org.junit.jupiter.api.Test;
import org.palladiosimulator.simulizar.modelobserver.IModelObserver;
import org.palladiosimulator.simulizar.runtimestate.RuntimeStateEntityObserver;

import com.google.common.collect.ImmutableSet;

class GenericExtensionComponentTest {

@Test
void testComponentWithoutExtension() {
var underTest = new GenericExtensionComponent(new ExtensionComponent() {
});
assertThat(underTest.getExtensions(IModelObserver.class).get(), is(empty()));
}

@Test
void testSingleExtension() {
var observer = new IModelObserver() {
};

var underTest = new GenericExtensionComponent(new ExtensionComponent() {
@SuppressWarnings("unused")
public IModelObserver provideObserver() {
return observer;
}
});

assertThat(underTest.getExtensions(IModelObserver.class).get(), containsInAnyOrder(observer));
}

@Test
void testMultipleSingleExtension() {
var observer = new IModelObserver() {
};
var observer2 = new IModelObserver() {
};
var observer3 = new IModelObserver() {
};

var underTest = new GenericExtensionComponent(new ExtensionComponent() {
@SuppressWarnings("unused")
public IModelObserver provideObserver1() {
return observer;
}

@SuppressWarnings("unused")
public IModelObserver provideObserver2() {
return observer2;
}

@SuppressWarnings("unused")
public IModelObserver provideObserver3() {
return observer3;
}
});

assertThat(underTest.getExtensions(IModelObserver.class).get(), containsInAnyOrder(observer, observer2, observer3));
}

@Test
void testSetExtension() {
var observer = new IModelObserver() {
};
var observer2 = new IModelObserver() {
};
var observer3 = new IModelObserver() {
};

var underTest = new GenericExtensionComponent(new ExtensionComponent() {
@SuppressWarnings("unused")
public Set<IModelObserver> provideObservers() {
return ImmutableSet.of(observer, observer2, observer3);
}
});

assertThat(underTest.getExtensions(IModelObserver.class).get(), containsInAnyOrder(observer, observer2, observer3));
}


@Test
void testCombineSingleAndSetExtension() {
var observer = new IModelObserver() {
};
var observer2 = new IModelObserver() {
};
var observer3 = new IModelObserver() {
};
var observer4 = new IModelObserver() {
};
var observer5 = new IModelObserver() {
};

var underTest = new GenericExtensionComponent(new ExtensionComponent() {
@SuppressWarnings("unused")
public Set<IModelObserver> provideObservers() {
return ImmutableSet.of(observer, observer2);
}

@SuppressWarnings("unused")
public Set<IModelObserver> provideObservers2() {
return ImmutableSet.of(observer3);
}

@SuppressWarnings("unused")
public IModelObserver provideObserver4() {
return observer4;
}

@SuppressWarnings("unused")
public IModelObserver provideObserver5() {
return observer5;
}
});

assertThat(underTest.getExtensions(IModelObserver.class).get(), containsInAnyOrder(observer, observer2, observer3, observer4, observer5));
}

static class MergedExtensionType implements IModelObserver, RuntimeStateEntityObserver {
@Override
public void initialize() {
}
}

@Test
void testExtentionWithTwoTypesAdheresToStaticTypeSignature() {
var mergedExtension = new MergedExtensionType();

var underTest = new GenericExtensionComponent(new ExtensionComponent() {
@SuppressWarnings("unused")
public MergedExtensionType provide() {
return mergedExtension;
}
});

assertThat(underTest.getExtensions(IModelObserver.class).get(), containsInAnyOrder(mergedExtension));
assertThat(underTest.getExtensions(RuntimeStateEntityObserver.class).get(), containsInAnyOrder(mergedExtension));

underTest = new GenericExtensionComponent(new ExtensionComponent() {
@SuppressWarnings("unused")
public IModelObserver provide() {
return mergedExtension;
}
});

assertThat(underTest.getExtensions(IModelObserver.class).get(), containsInAnyOrder(mergedExtension));
assertThat(underTest.getExtensions(RuntimeStateEntityObserver.class).get(), is(empty()));


}

}
Loading

0 comments on commit 2ac7292

Please sign in to comment.