diff options
author | Julian Honnen | 2019-02-06 15:56:59 +0000 |
---|---|---|
committer | Julian Honnen | 2019-02-06 16:41:56 +0000 |
commit | 036a8c573d1e3fdceab9d026494a3c1e6ac0c846 (patch) | |
tree | b2fb1ea2d4e727e9f8130bd1776eb15169e1758a | |
parent | d8a9c10878fa399ee5484b648bd97a8c9dc8cd12 (diff) | |
download | rt.equinox.bundles-036a8c573d1e3fdceab9d026494a3c1e6ac0c846.tar.gz rt.equinox.bundles-036a8c573d1e3fdceab9d026494a3c1e6ac0c846.tar.xz rt.equinox.bundles-036a8c573d1e3fdceab9d026494a3c1e6ac0c846.zip |
Bug 263880 - moved equinox tests from core.tests.runtime
Created new common test bundle for tests of Equinox components from
org.eclipse.core.tests.runtime.
Change-Id: Ic838b8038322940051701c4d1e270ad75e9a8470
Signed-off-by: Julian Honnen <julian.honnen@vector.com>
10 files changed, 356 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.common.tests/.classpath b/bundles/org.eclipse.equinox.common.tests/.classpath new file mode 100644 index 000000000..3e5654f17 --- /dev/null +++ b/bundles/org.eclipse.equinox.common.tests/.classpath @@ -0,0 +1,11 @@ +<?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-1.8"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"> + <attributes> + <attribute name="test" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/bundles/org.eclipse.equinox.common.tests/.project b/bundles/org.eclipse.equinox.common.tests/.project new file mode 100644 index 000000000..c42041129 --- /dev/null +++ b/bundles/org.eclipse.equinox.common.tests/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.equinox.common.tests</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <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> + </natures> +</projectDescription> diff --git a/bundles/org.eclipse.equinox.common.tests/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.common.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..0c68a61dc --- /dev/null +++ b/bundles/org.eclipse.equinox.common.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/bundles/org.eclipse.equinox.common.tests/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.common.tests/META-INF/MANIFEST.MF new file mode 100644 index 000000000..229262788 --- /dev/null +++ b/bundles/org.eclipse.equinox.common.tests/META-INF/MANIFEST.MF @@ -0,0 +1,11 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Common Eclipse Runtime Tests +Bundle-SymbolicName: org.eclipse.equinox.common.tests +Bundle-Version: 3.10.300.qualifier +Automatic-Module-Name: org.eclipse.equinox.common.tests +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-ActivationPolicy: lazy +Require-Bundle: org.junit, + org.eclipse.equinox.common;bundle-version="3.10.300", + org.eclipse.core.tests.harness;bundle-version="3.11.400" diff --git a/bundles/org.eclipse.equinox.common.tests/build.properties b/bundles/org.eclipse.equinox.common.tests/build.properties new file mode 100644 index 000000000..d1444fea4 --- /dev/null +++ b/bundles/org.eclipse.equinox.common.tests/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + test.xml diff --git a/bundles/org.eclipse.equinox.common.tests/pom.xml b/bundles/org.eclipse.equinox.common.tests/pom.xml new file mode 100644 index 000000000..d9507a2c6 --- /dev/null +++ b/bundles/org.eclipse.equinox.common.tests/pom.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (c) 2012 Eclipse Foundation. + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Distribution License v1.0 + which accompanies this distribution, and is available at + http://www.eclipse.org/org/documents/edl-v10.php + + Contributors: + Igor Fedorenko - initial implementation +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>tests-pom</artifactId> + <groupId>org.eclipse.equinox.bundles</groupId> + <version>4.11.0-SNAPSHOT</version> + <relativePath>../../tests-pom/</relativePath> + </parent> + <groupId>org.eclipse.equinox</groupId> + <artifactId>org.eclipse.equinox.common.tests</artifactId> + <version>3.10.300-SNAPSHOT</version> + <packaging>eclipse-test-plugin</packaging> +</project> diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/AllTests.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/AllTests.java new file mode 100644 index 000000000..868cc12fc --- /dev/null +++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/AllTests.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 1997-2009 by ProSyst Software GmbH + * http://www.prosyst.com + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ProSyst Software GmbH - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.common.tests; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +@RunWith(Suite.class) +@SuiteClasses(StatusTest.class) +public class AllTests { + // intentionally left blank +} diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/StatusTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/StatusTest.java new file mode 100644 index 000000000..172214e99 --- /dev/null +++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/StatusTest.java @@ -0,0 +1,181 @@ +/******************************************************************************* + * Copyright (c) 2000, 2018 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.common.tests; + +import java.util.Arrays; +import org.eclipse.core.runtime.*; +import org.eclipse.core.tests.harness.CoreTest; + +public class StatusTest extends CoreTest { + + private int status1Severity = IStatus.OK; + private String status1PluginId = "org.eclipse.core.tests.runtime"; + private int status1Code = -20; + private String status1Message = "Something was canceled"; + private Exception status1Exception = new OperationCanceledException(); + private Status status1; + + private int status2Severity = IStatus.ERROR; + private String status2PluginId = " "; + private int status2Code = IStatus.OK; + private String status2Message = ""; + private Exception status2Exception = null; + private Status status2; + + private String multistatus1PluginId = "org.eclipse.core.tests.multistatus1"; + private int multistatus1Code = 20; + private IStatus[] multistatus1Children = new IStatus[0]; + private String multistatus1Message = "Multistatus #1 message"; + private Throwable multistatus1Exception = new OperationCanceledException(); + private MultiStatus multistatus1; + + private MultiStatus multistatus2; + + public StatusTest() { + super(null); + } + + public StatusTest(String name) { + super(name); + } + + @Override + protected void setUp() { + status1 = new Status(status1Severity, status1PluginId, status1Code, status1Message, status1Exception); + status2 = new Status(status2Severity, status2PluginId, status2Code, status2Message, status2Exception); + + multistatus1 = new MultiStatus(multistatus1PluginId, multistatus1Code, multistatus1Children, multistatus1Message, multistatus1Exception); + multistatus2 = new MultiStatus(" ", 45, new Status[0], "", null); + multistatus2.add(status1); + multistatus2.add(status1); + } + + public void testMultiStatusReturnValues() { + assertEquals("1.1", multistatus1PluginId, multistatus1.getPlugin()); + assertEquals("1.2", multistatus1Code, multistatus1.getCode()); + assertTrue("1.3", Arrays.equals(multistatus1Children, multistatus1.getChildren())); + assertEquals("1.4", multistatus1Message, multistatus1.getMessage()); + assertEquals("1.5", multistatus1Exception, multistatus1.getException()); + assertTrue("1.6", multistatus1.isMultiStatus()); + assertEquals("1.7", IStatus.OK, multistatus1.getSeverity()); + assertTrue("1.8", multistatus1.isOK()); + assertEquals("1.9", false, status1.matches(IStatus.ERROR | IStatus.WARNING | IStatus.INFO)); + } + + public void testSingleStatusReturnValues() { + assertEquals("1.0", status1Severity, status1.getSeverity()); + assertEquals("1.1", status1PluginId, status1.getPlugin()); + assertEquals("1.2", status1Code, status1.getCode()); + assertEquals("1.3", status1Message, status1.getMessage()); + assertEquals("1.4", status1Exception, status1.getException()); + assertEquals("1.5", 0, status1.getChildren().length); + assertEquals("1.6", false, status1.isMultiStatus()); + assertEquals("1.7", status1Severity == IStatus.OK, status1.isOK()); + assertEquals("1.8", status1.matches(IStatus.ERROR | IStatus.WARNING | IStatus.INFO), !status1.isOK()); + + assertEquals("2.0", status2Severity, status2.getSeverity()); + assertEquals("2.1", status2PluginId, status2.getPlugin()); + assertEquals("2.2", status2Code, status2.getCode()); + assertEquals("2.3", status2Message, status2.getMessage()); + assertEquals("2.4", status2Exception, status2.getException()); + assertEquals("2.5", 0, status2.getChildren().length); + assertEquals("2.6", false, status2.isMultiStatus()); + assertEquals("2.7", status2Severity == IStatus.OK, status2.isOK()); + assertEquals("2.8", status2.matches(IStatus.ERROR), !status2.isOK()); + } + + public void testAdd() { + + multistatus1.add(status1); + assertEquals("1.0", status1, (multistatus1.getChildren())[0]); + + multistatus1.add(multistatus2); + assertEquals("1.1", multistatus2, (multistatus1.getChildren())[1]); + + multistatus1.add(multistatus1); + assertEquals("1.2", multistatus1, (multistatus1.getChildren())[2]); + + } + + public void testAddAll() { + + multistatus1.add(status2); + multistatus1.addAll(multistatus2); + Status[] array = new Status[3]; + array[0] = status2; + array[1] = status1; + array[2] = status1; + + assertTrue("1.0", multistatus1.getChildren().length == 3); + assertTrue("1.1", Arrays.equals(array, multistatus1.getChildren())); + + multistatus1.add(multistatus2); + multistatus1.addAll(multistatus1); + Status[] array2 = new Status[8]; + array2[0] = status2; + array2[1] = status1; + array2[2] = status1; + array2[3] = multistatus2; + array2[4] = status2; + array2[5] = status1; + array2[6] = status1; + array2[7] = multistatus2; + + assertTrue("2.0", multistatus1.getChildren().length == 8); + assertTrue("2.1", Arrays.equals(array2, multistatus1.getChildren())); + + } + + public void testIsOK() { + + assertTrue("1.0", multistatus2.isOK()); + + multistatus1.add(status2); + multistatus1.addAll(multistatus2); + assertTrue("1.1", !multistatus1.isOK()); + + } + + public void testMerge() { + + multistatus1.merge(status2); + multistatus1.merge(multistatus2); + Status[] array = new Status[3]; + array[0] = status2; + array[1] = status1; + array[2] = status1; + + assertTrue("1.0", multistatus1.getChildren().length == 3); + assertTrue("1.1", Arrays.equals(array, multistatus1.getChildren())); + + multistatus1.merge(multistatus1); + Status[] array2 = new Status[6]; + array2[0] = status2; + array2[1] = status1; + array2[2] = status1; + array2[3] = status2; + array2[4] = status1; + array2[5] = status1; + + assertTrue("2.0", multistatus1.getChildren().length == 6); + assertTrue("2.1", Arrays.equals(array2, multistatus1.getChildren())); + + multistatus2.add(multistatus1); + assertTrue("3.0", !multistatus2.isOK()); + multistatus2.merge(multistatus2.getChildren()[2]); + assertTrue("3.1", multistatus2.getChildren().length == 9); + + } + +} diff --git a/bundles/org.eclipse.equinox.common.tests/test.xml b/bundles/org.eclipse.equinox.common.tests/test.xml new file mode 100644 index 000000000..60d8d58d4 --- /dev/null +++ b/bundles/org.eclipse.equinox.common.tests/test.xml @@ -0,0 +1,63 @@ +<?xml version="1.0"?> +<project name="Equinox DS Automated Tests" default="run" basedir="."> + + <!-- The property ${eclipse-home} should be passed into this script --> + <!-- sets the properties eclipse-home, and library-file --> + <property name="eclipse-home" value="${basedir}/../../"/> + <property name="library-file" value="${eclipse-home}/plugins/org.eclipse.test/library.xml"/> + <property name="osgi_location" value="${eclipse-home}/ds_sniff_folder"/> + <property name="plugin-name" value="org.eclipse.equinox.common.tests"/> + + <!-- This target holds all initialization code that needs to be done for --> + <!-- all tests that are to be run. Initialization for individual tests --> + <!-- should be done within the body of the suite target. --> + <target name="init"> + <tstamp/> + </target> + + <!-- This target holds code to cleanup the testing environment after the tests --> + <!-- have been run. You can use this to delete temporary files that are created. --> + <target name="cleanup"> + <delete dir="${osgi_location}" quiet="true"/> + </target> + + <!-- This target runs the test suite. Any actions that need to happen after all --> + <!-- the tests have been run should go here. --> + <target name="run" depends="init,suite,cleanup"> + <ant target="collect" antfile="${library-file}" dir="${eclipse-home}"> + <property name="includes" value="org*.xml"/> + <property name="output-file" value="${plugin-name}.xml"/> + </ant> + </target> + + <!-- This target runs the performance test suites. Any actions that need to happen after all --> + <!-- the tests have been run should go here. --> + <!-- + <target name="performance" depends="init,performance-suite,cleanup"> + <ant target="collect" antfile="${library-file}" dir="${eclipse-home}"> + <property name="includes" value="org*.xml"/> + <property name="output-file" value="${plugin-name}.xml"/> + </ant> + </target> + --> + + <target name="CommonTests" depends="init,cleanup"> + <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}"> + <property name="data-dir" value="${osgi_location}"/> + <property name="plugin-name" value="org.eclipse.equinox.common.tests"/> + <property name="classname" value="org.eclipse.equinox.common.tests.AllTests"/> + </ant> + </target> + + <target name="CommonPerformanceTests"> + <!-- TODO --> + </target> + + <!-- This target defines the tests that need to be run. --> + <target name="suite" depends="CommonTests"/> + + <!-- This target defines the performance tests that need to be run. --> + <!-- + <target name="performance-suite" depends="CommonPerformanceTests"/> + --> + </project> @@ -68,6 +68,7 @@ <module>features/org.eclipse.equinox.serverside.sdk</module> <module>bundles/org.eclipse.equinox.bidi.tests</module> <module>bundles/org.eclipse.equinox.cm.test</module> + <module>bundles/org.eclipse.equinox.common.tests</module> <module>bundles/org.eclipse.equinox.compendium.tests</module> <!-- no longer built in M6 |