Skip to content

Commit

Permalink
[eclipse] Cleaning unit tests.
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Oct 27, 2016
1 parent 7649fa4 commit 172faff
Show file tree
Hide file tree
Showing 7 changed files with 749 additions and 559 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,63 @@
@SuppressWarnings("all")
public class JanusClasspathContainerTest extends AbstractSarlTest {

private static final String[] ECLIPSE_DEPENDENCIES = {
"aopalliance",
"com.google.gson",
"com.google.guava",
"com.google.inject",
"com.google.inject.multibindings",
"com.hazelcast",
"io.janusproject.plugin",
"io.sarl.core",
"io.sarl.lang.core",
"io.sarl.util",
"javax.cache.api",
"javax.inject",
"javax.servlet",
"org.apache.commons.cli",
"org.apache.log4j",
"org.arakhne.afc.core.util",
"org.arakhne.afc.core.vmutils",
"org.eclipse.core.contenttype",
"org.eclipse.core.jobs",
"org.eclipse.core.runtime",
"org.eclipse.equinox.app",
"org.eclipse.equinox.common",
"org.eclipse.equinox.preferences",
"org.eclipse.equinox.registry",
"org.eclipse.osgi",
"org.eclipse.osgi.compatibility.state",
"org.eclipse.osgi.services",
"org.eclipse.xtext.logging",
"org.eclipse.xtext.xbase.lib",
"org.slf4j.api",
"org.slf4j.impl.log4j12",
"org.zeromq.jeromq",
};

private static final String[] TYCHO_DEPENDENCIES = {
"aopalliance",
"com.google.gson",
"com.google.guava",
"com.google.inject",
"com.google.inject.multibindings",
"com.hazelcast",
"io.janusproject.plugin",
"io.sarl.core",
"io.sarl.lang.core",
"io.sarl.util",
"javax.cache.api",
"javax.inject",
"org.apache.commons.cli",
"org.apache.log4j",
"org.arakhne.afc.core.util",
"org.arakhne.afc.core.vmutils",
"org.eclipse.osgi",
"org.eclipse.xtext.xbase.lib",
"org.zeromq.jeromq",
};

@NonNullByDefault
private IPath containerPath;

Expand Down Expand Up @@ -98,33 +155,22 @@ public void getPath() {
public void getBundleDependencies() {
Iterable<String> iterable = this.container.getBundleDependencies();
assertNotNull(iterable);
assertPartlyContains(iterable,
"io.sarl.lang.core",
"javax.inject",
"org.eclipse.xtext.xbase.lib",
"com.google.guava",
"org.eclipse.osgi",
"org.eclipse.osgi.compatibility.state",
"io.sarl.util",
"io.sarl.core",
//
"io.janusproject.plugin",
"com.google.gson",
"com.google.inject",
"com.google.inject.multibindings",
"com.hazelcast",
"org.apache.commons.cli",
"org.arakhne.afc.core.vmutils",
"org.arakhne.afc.core.util",
"org.zeromq.jeromq",
"aopalliance");
if (isEclipseRuntimeEnvironment()) {
assertContains(iterable, ECLIPSE_DEPENDENCIES);
} else {
assertContains(iterable, TYCHO_DEPENDENCIES);
}
}

@Test
public void getClasspathEntries() {
IClasspathEntry[] iterable = this.container.getClasspathEntries();
assertNotNull(iterable);
assertEquals(32, iterable.length);
if (isEclipseRuntimeEnvironment()) {
assertEquals(ECLIPSE_DEPENDENCIES.length, iterable.length);
} else {
assertEquals(TYCHO_DEPENDENCIES.length, iterable.length);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.google.inject.Module;
import com.google.inject.util.Modules;
Expand Down Expand Up @@ -209,6 +211,14 @@ protected void runJanus(Class<? extends TestingAgent> type, boolean enableLoggin
public void write(int b) throws IOException {
//
}
@Override
public void write(byte[] b) throws IOException {
//
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
//
}
}));
this.results = new ArrayList<>();
if (!enableLogging) {
Expand All @@ -218,6 +228,13 @@ public void write(int b) throws IOException {
}
Boot.setOffline(offline);
this.janusKernel = Boot.startJanus(module, type, results);
Logger current = this.janusKernel.getLogger();
while (current.getParent() != null && current.getParent() != current) {
current = current.getParent();
}
if (current != null) {
current.setLevel(Level.OFF);
}
long endTime;
if (timeout >= 0) {
endTime = System.currentTimeMillis() + timeout * 1000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class BundleUtilTest {
* @mavengroupid $GroupId$
* @mavenartifactid $ArtifactId$
*/
public static class PathTests {
public static class PathTests extends AbstractSarlTest {

private static void assertEndsWith(String expected, String actual) {
if (actual == null || !actual.endsWith(expected)) {
Expand All @@ -75,78 +75,51 @@ private static void assertEndsWith(String expected, String actual) {
}

@Test
@TestScope(eclipse = true, tycho = false)
public void getBundlePath_withEclipse() {
public void getBundlePath() {
Bundle bundle = Platform.getBundle("io.sarl.lang.core");
Assume.assumeNotNull(bundle);
//
IPath path = BundleUtil.getBundlePath(bundle);
assertNotNull(path);
assertEndsWith("io.sarl.lang.core/target/classes/", path.toPortableString());
}

@Test
@TestScope(eclipse = false, tycho = true)
public void getBundlePath_withTycho() {
Bundle bundle = Platform.getBundle("io.sarl.lang.core");
Assume.assumeNotNull(bundle);
//
IPath path = BundleUtil.getBundlePath(bundle);
assertNotNull(path);
assertEndsWith("io.sarl.lang.core/target/classes/", path.toPortableString());
}

@Test
@TestScope(eclipse = true, tycho = false)
public void getJavadocBundlePath_withEclipse() {
Bundle bundle = Platform.getBundle("io.sarl.lang.core");
Assume.assumeNotNull(bundle);
IPath bundlePath = BundleUtil.getBundlePath(bundle);
Assume.assumeNotNull(bundlePath);
//
IPath path = BundleUtil.getJavadocBundlePath(bundle, bundlePath);
assertNotNull(path);
assertEndsWith("io.sarl.lang.core/", path.toPortableString());
if (isEclipseRuntimeEnvironment()) {
assertEndsWith("io.sarl.lang.core/target/classes/", path.toPortableString());
} else {
assertEquals("io.sarl.lang.core-" + SARLVersion.SARL_RELEASE_VERSION_MAVEN + ".jar", path.lastSegment());
}
}

@Test
@TestScope(eclipse = false, tycho = true)
public void getJavadocBundlePath_withTycho() {
public void getJavadocBundlePath() {
Bundle bundle = Platform.getBundle("io.sarl.lang.core");
Assume.assumeNotNull(bundle);
IPath bundlePath = BundleUtil.getBundlePath(bundle);
Assume.assumeNotNull(bundlePath);
//
IPath path = BundleUtil.getJavadocBundlePath(bundle, bundlePath);
assertNotNull(path);
assertEndsWith("io.sarl.lang.core/", path.toPortableString());
if (isEclipseRuntimeEnvironment()) {
assertNotNull(path);
assertEndsWith("io.sarl.lang.core/", path.toPortableString());
} else {
assertNull(path);
}
}

@Test
@TestScope(eclipse = true, tycho = false)
public void getSourceBundlePath_withEclipse() {
public void getSourceBundlePath() {
Bundle bundle = Platform.getBundle("io.sarl.lang.core");
Assume.assumeNotNull(bundle);
IPath bundlePath = BundleUtil.getBundlePath(bundle);
Assume.assumeNotNull(bundlePath);
//
IPath path = BundleUtil.getSourceBundlePath(bundle, bundlePath);
assertNotNull(path);
assertEndsWith("io.sarl.lang.core/", path.toPortableString());
if (isEclipseRuntimeEnvironment()) {
assertNotNull(path);
assertEndsWith("io.sarl.lang.core/", path.toPortableString());
} else {
assertNull(path);
}
}

@Test
@TestScope(eclipse = false, tycho = true)
public void getSourceBundlePath_withTycho() {
Bundle bundle = Platform.getBundle("io.sarl.lang.core");
Assume.assumeNotNull(bundle);
IPath bundlePath = BundleUtil.getBundlePath(bundle);
Assume.assumeNotNull(bundlePath);
//
IPath path = BundleUtil.getSourceBundlePath(bundle, bundlePath);
assertNotNull(path);
assertEndsWith("io.sarl.lang.core/", path.toPortableString());
}
}

/**
Expand All @@ -163,8 +136,7 @@ public void setUp() {
}

@Test
@TestScope(eclipse = true, tycho = false)
public void resolveBundleDependenciesBundleBundleURLMappingsStringArray_noRootDependencies_withEclipse() {
public void resolveBundleDependenciesBundleBundleURLMappingsStringArray_noRootDependencies() {
Bundle bundle = Platform.getBundle("io.sarl.lang.core");
Assume.assumeNotNull(bundle);
//
Expand All @@ -182,74 +154,26 @@ public void resolveBundleDependenciesBundleBundleURLMappingsStringArray_noRootDe
"org.eclipse.xtext.xbase.lib",
"com.google.guava",
"org.eclipse.osgi");
assertContains(dependencies.getTransitiveSymbolicNames(true),
"io.sarl.lang.core",
"javax.inject",
"org.eclipse.xtext.xbase.lib",
"com.google.guava",
"org.eclipse.osgi",
"org.eclipse.osgi.compatibility.state");
}

@Test
@TestScope(eclipse = false, tycho = true)
public void resolveBundleDependenciesBundleBundleURLMappingsStringArray_noRootDependencies_withTycho() {
Bundle bundle = Platform.getBundle("io.sarl.lang.core");
Assume.assumeNotNull(bundle);
//
IBundleDependencies dependencies = BundleUtil.resolveBundleDependencies(bundle, (BundleURLMappings) null);
assertNotNull(dependencies);
assertEquals("io.sarl.lang.core", dependencies.getBundleSymbolicName());
assertOsgiVersionEquals(Version.parseVersion(SARLVersion.SARL_RELEASE_VERSION_OSGI), dependencies.getBundleVersion());
assertContains(dependencies.getDirectSymbolicNames(),
"io.sarl.lang.core",
"javax.inject",
"org.eclipse.xtext.xbase.lib");
assertContains(dependencies.getTransitiveSymbolicNames(false),
"io.sarl.lang.core",
"javax.inject",
"org.eclipse.xtext.xbase.lib",
"com.google.guava",
"org.eclipse.osgi");
assertContains(dependencies.getTransitiveSymbolicNames(true),
"io.sarl.lang.core",
"javax.inject",
"org.eclipse.xtext.xbase.lib",
"com.google.guava",
"org.eclipse.osgi",
"org.eclipse.osgi.compatibility.state");
}

@Test
@TestScope(eclipse = true, tycho = false)
public void resolveBundleDependenciesBundleBundleURLMappingsStringArray_rootDependencies_withEclipse() {
Bundle bundle = Platform.getBundle("io.sarl.lang.core");
Assume.assumeNotNull(bundle);
//
IBundleDependencies dependencies = BundleUtil.resolveBundleDependencies(bundle, (BundleURLMappings) null,
"org.eclipse.xtext.xbase.lib");
assertNotNull(dependencies);
assertEquals("io.sarl.lang.core", dependencies.getBundleSymbolicName());
assertOsgiVersionEquals(Version.parseVersion(SARLVersion.SARL_RELEASE_VERSION_OSGI), dependencies.getBundleVersion());
assertContains(dependencies.getDirectSymbolicNames(),
"io.sarl.lang.core",
"org.eclipse.xtext.xbase.lib");
assertContains(dependencies.getTransitiveSymbolicNames(false),
"io.sarl.lang.core",
"org.eclipse.xtext.xbase.lib",
"com.google.guava",
"org.eclipse.osgi");
assertContains(dependencies.getTransitiveSymbolicNames(true),
"io.sarl.lang.core",
"org.eclipse.xtext.xbase.lib",
"com.google.guava",
"org.eclipse.osgi",
"org.eclipse.osgi.compatibility.state");
if (isEclipseRuntimeEnvironment()) {
assertContains(dependencies.getTransitiveSymbolicNames(true),
"io.sarl.lang.core",
"javax.inject",
"org.eclipse.xtext.xbase.lib",
"com.google.guava",
"org.eclipse.osgi",
"org.eclipse.osgi.compatibility.state");
} else {
assertContains(dependencies.getTransitiveSymbolicNames(true),
"io.sarl.lang.core",
"javax.inject",
"org.eclipse.xtext.xbase.lib",
"com.google.guava",
"org.eclipse.osgi");
}
}

@Test
@TestScope(eclipse = false, tycho = true)
public void resolveBundleDependenciesBundleBundleURLMappingsStringArray_rootDependencies_withTycho() {
public void resolveBundleDependenciesBundleBundleURLMappingsStringArray_rootDependencies() {
Bundle bundle = Platform.getBundle("io.sarl.lang.core");
Assume.assumeNotNull(bundle);
//
Expand All @@ -266,12 +190,20 @@ public void resolveBundleDependenciesBundleBundleURLMappingsStringArray_rootDepe
"org.eclipse.xtext.xbase.lib",
"com.google.guava",
"org.eclipse.osgi");
assertContains(dependencies.getTransitiveSymbolicNames(true),
"io.sarl.lang.core",
"org.eclipse.xtext.xbase.lib",
"com.google.guava",
"org.eclipse.osgi",
"org.eclipse.osgi.compatibility.state");
if (isEclipseRuntimeEnvironment()) {
assertContains(dependencies.getTransitiveSymbolicNames(true),
"io.sarl.lang.core",
"org.eclipse.xtext.xbase.lib",
"com.google.guava",
"org.eclipse.osgi",
"org.eclipse.osgi.compatibility.state");
} else {
assertContains(dependencies.getTransitiveSymbolicNames(true),
"io.sarl.lang.core",
"org.eclipse.xtext.xbase.lib",
"com.google.guava",
"org.eclipse.osgi");
}
}

}
Expand Down

0 comments on commit 172faff

Please sign in to comment.