From 761ff9391949499f3a7c787ae54666fd584a6809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=8A?= =?UTF-8?q?=D1=80=20=D0=9A=D1=83=D1=80=D1=82=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Tue, 17 Dec 2024 18:37:15 +0200 Subject: [PATCH] Sanitize SharedInstallTestsProfileSpoofEnabledConfigured test Failed in https://download.eclipse.org/eclipse/downloads/drops4/I20241217-0630/testresults/html/org.eclipse.equinox.p2.tests_ep435I-unit-linux-x86_64-java23_linux.gtk.x86_64_23.html with really no message: ``` N/A junit.framework.AssertionFailedError at junit.framework.Assert.fail(Assert.java:55) at junit.framework.Assert.assertTrue(Assert.java:22) at junit.framework.Assert.assertFalse(Assert.java:39) at junit.framework.Assert.assertFalse(Assert.java:47) at junit.framework.TestCase.assertFalse(TestCase.java:216) at org.eclipse.equinox.p2.tests.reconciler.dropins.SharedInstallTestsProfileSpoofEnabledConfigured.testUserDropinsStartup(SharedInstallTestsProfileSpoofEnabledConfigured.java:215) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at junit.framework.TestCase.runTest(TestCase.java:177) at org.eclipse.equinox.p2.tests.AbstractProvisioningTest.runTest(AbstractProvisioningTest.java:968) at junit.framework.TestCase.runBare(TestCase.java:142) at junit.framework.TestResult$1.protect(TestResult.java:122) at junit.framework.TestResult.runProtected(TestResult.java:142) at junit.framework.TestResult.run(TestResult.java:125) at junit.framework.TestCase.run(TestCase.java:130) at junit.framework.TestSuite.runTest(TestSuite.java:241) at org.eclipse.equinox.p2.tests.reconciler.dropins.ReconcilerTestSuite.run(ReconcilerTestSuite.java:87) at junit.framework.TestSuite.runTest(TestSuite.java:241) at junit.framework.TestSuite.run(TestSuite.java:236) ``` This PR removes insane assert messages and some other changes to make code slightly easier on the eyes. --- .../META-INF/MANIFEST.MF | 2 +- .../p2/tests/reconciler/dropins/AllTests.java | 12 +++-- ...allTestsProfileSpoofEnabledConfigured.java | 49 +++++++------------ 3 files changed, 27 insertions(+), 36 deletions(-) diff --git a/bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF index 0be133d9be..20e4989a4d 100644 --- a/bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF @@ -23,7 +23,7 @@ Export-Package: org.eclipse.equinox.p2.tests;version="2.0.0", Require-Bundle: org.eclipse.equinox.frameworkadmin, org.eclipse.equinox.common, org.eclipse.core.tests.harness;bundle-version="3.4.0", - org.eclipse.core.runtime;bundle-version="3.29.0", + org.eclipse.core.runtime;bundle-version="3.30.0", org.eclipse.equinox.p2.publisher;bundle-version="1.0.0", org.eclipse.equinox.frameworkadmin.test;bundle-version="1.0.0", org.junit;bundle-version="4.8.0", diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/AllTests.java index 7604f70127..6842ea3023 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/AllTests.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/AllTests.java @@ -1,27 +1,29 @@ /******************************************************************************* * Copyright (c) 2008, 2013 IBM Corporation and others. * - * This program and the accompanying materials + * 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 * Red Hat, Inc. - Fragment support added. *******************************************************************************/ package org.eclipse.equinox.p2.tests.reconciler.dropins; -import junit.framework.*; +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; import org.eclipse.equinox.p2.tests.sharedinstall.AbstractSharedInstallTest; /** * To run the reconciler tests, you must perform some manual setup steps: * 1) Download the platform runtime binary zip (latest build or the one you want to test). * 2) Set the following system property to the file system path of the binary zip. For example: - * + * * -Dorg.eclipse.equinox.p2.reconciler.tests.platform.archive=c:/tmp/eclipse-platform-3.4-win32.zip */ public class AllTests extends TestCase { @@ -34,7 +36,7 @@ public static Test suite() { suite.addTest(SharedInstallTests.suite()); suite.addTest(SharedInstallTestsProfileSpoofEnabled.suite()); if (!AbstractSharedInstallTest.WINDOWS) { - suite.addTest(SharedInstallTestsProfileSpoofEnabledConfigured.suite()); + suite.addTestSuite(SharedInstallTestsProfileSpoofEnabledConfigured.class); } suite.addTest(Bug362692.suite()); return suite; diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/SharedInstallTestsProfileSpoofEnabledConfigured.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/SharedInstallTestsProfileSpoofEnabledConfigured.java index dcd61d1d5c..c5321e0c91 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/SharedInstallTestsProfileSpoofEnabledConfigured.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/SharedInstallTestsProfileSpoofEnabledConfigured.java @@ -19,8 +19,6 @@ import java.io.IOException; import java.io.InputStream; import java.util.Properties; -import junit.framework.Test; -import junit.framework.TestSuite; import org.eclipse.core.runtime.Platform; import org.eclipse.equinox.internal.p2.updatesite.Activator; import org.eclipse.equinox.p2.tests.sharedinstall.AbstractSharedInstallTest; @@ -29,15 +27,6 @@ public class SharedInstallTestsProfileSpoofEnabledConfigured extends SharedInsta private File extensions; - public static Test suite() { - TestSuite suite = new ReconcilerTestSuite(); - suite.setName(SharedInstallTestsProfileSpoofEnabledConfigured.class.getName()); - suite.addTest(new SharedInstallTestsProfileSpoofEnabledConfigured("testBasicStartup")); - suite.addTest(new SharedInstallTestsProfileSpoofEnabledConfigured("testReadOnlyDropinsStartup")); - suite.addTest(new SharedInstallTestsProfileSpoofEnabledConfigured("testUserDropinsStartup")); - return suite; - } - /* * Constructor for the class. */ @@ -98,18 +87,18 @@ public void testBasicStartup() throws IOException { try { File userBundlesInfo = new File(userBase, "configuration/org.eclipse.equinox.simpleconfigurator/bundles.info"); File userConfigIni = new File(userBase, "configuration/config.ini"); - assertFalse("0.1", userBundlesInfo.exists()); - assertFalse("0.2", userConfigIni.exists()); - reconcileReadOnly("0.21", extensions); - assertFalse("0.3", userBundlesInfo.exists()); - assertTrue("0.4", userConfigIni.exists()); + assertFalse(userBundlesInfo.exists()); + assertFalse(userConfigIni.exists()); + reconcileReadOnly("", extensions); + assertFalse(userBundlesInfo.exists()); + assertTrue(userConfigIni.exists()); Properties props = new Properties(); try (InputStream is = new BufferedInputStream(new FileInputStream(userConfigIni))) { props.load(is); } - assertTrue("0.5", props.containsKey("osgi.sharedConfiguration.area")); - assertTrue("0.6", props.size() == 1); + assertTrue(props.containsKey("osgi.sharedConfiguration.area")); + assertEquals(1, props.size()); } finally { cleanupReadOnlyInstall(); } @@ -117,7 +106,7 @@ public void testBasicStartup() throws IOException { @Override public void testReadOnlyDropinsStartup() throws IOException { - if (Platform.getOS().equals(Platform.OS_MACOSX)) + if (Platform.OS.isMac()) return; assertInitialized(); @@ -128,13 +117,13 @@ public void testReadOnlyDropinsStartup() throws IOException { try { File userBundlesInfo = new File(userBase, "configuration/org.eclipse.equinox.simpleconfigurator/bundles.info"); File userConfigIni = new File(userBase, "configuration/config.ini"); - assertFalse("0.1", userBundlesInfo.exists()); - assertFalse("0.2", userConfigIni.exists()); + assertFalse(userBundlesInfo.exists()); + assertFalse(userConfigIni.exists()); reconcileReadOnly("0.21", extensions); - assertTrue("0.3", userBundlesInfo.exists()); - assertTrue("0.4", userConfigIni.exists()); + assertTrue(userBundlesInfo.exists()); + assertTrue(userConfigIni.exists()); assertTrue(isInBundlesInfo(userBundlesInfo, "myBundle", null)); assertTrue(isInBundlesInfo(userBundlesInfo, "zzz", null)); @@ -142,7 +131,7 @@ public void testReadOnlyDropinsStartup() throws IOException { // remove the bundle from the dropins and reconcile setReadOnly(readOnlyBase, false); AbstractSharedInstallTest.removeReallyReadOnly(readOnlyBase); - assertTrue("0.7", readOnlyBase.canWrite()); + assertTrue(readOnlyBase.canWrite()); remove("1.0", "dropins", "myBundle_1.0.0.jar"); setReadOnly(readOnlyBase, true); AbstractSharedInstallTest.reallyReadOnly(readOnlyBase); @@ -164,7 +153,7 @@ public void testReadOnlyDropinsStartup() throws IOException { // new, up-to-date bundles.info setReadOnly(readOnlyBase, false); AbstractSharedInstallTest.removeReallyReadOnly(readOnlyBase); - assertTrue("0.7", readOnlyBase.canWrite()); + assertTrue(readOnlyBase.canWrite()); add("0.211", "dropins", jar); setReadOnly(readOnlyBase, true); AbstractSharedInstallTest.reallyReadOnly(readOnlyBase); @@ -183,7 +172,7 @@ public void testReadOnlyDropinsStartup() throws IOException { @Override public void testUserDropinsStartup() throws IOException { - if (Platform.getOS().equals(Platform.OS_MACOSX)) + if (Platform.OS.isMac()) return; assertInitialized(); @@ -198,13 +187,13 @@ public void testUserDropinsStartup() throws IOException { File userBundlesInfo = new File(userBase, "configuration/org.eclipse.equinox.simpleconfigurator/bundles.info"); File userConfigIni = new File(userBase, "configuration/config.ini"); - assertFalse("0.1", userBundlesInfo.exists()); - assertFalse("0.2", userConfigIni.exists()); + assertFalse(userBundlesInfo.exists()); + assertFalse(userConfigIni.exists()); reconcileReadOnly("0.21", extensions); - assertTrue("0.3", userBundlesInfo.exists()); - assertTrue("0.4", userConfigIni.exists()); + assertTrue(userBundlesInfo.exists()); + assertTrue(userConfigIni.exists()); assertTrue(isInBundlesInfo(userBundlesInfo, "myBundle", null)); assertTrue(isInBundlesInfo(userBundlesInfo, "zzz", null));