Skip to content

Commit

Permalink
Sanitize SharedInstallTestsProfileSpoofEnabledConfigured test
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
akurtakov committed Dec 17, 2024
1 parent 371f140 commit 761ff93
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 36 deletions.
2 changes: 1 addition & 1 deletion bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
*/
Expand Down Expand Up @@ -98,26 +87,26 @@ 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();
}
}

@Override
public void testReadOnlyDropinsStartup() throws IOException {
if (Platform.getOS().equals(Platform.OS_MACOSX))
if (Platform.OS.isMac())
return;

assertInitialized();
Expand All @@ -128,21 +117,21 @@ 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));

// 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);
Expand All @@ -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);
Expand All @@ -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();
Expand All @@ -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));
Expand Down

0 comments on commit 761ff93

Please sign in to comment.