Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: ignore deprecated java.security #520

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import org.osgi.service.startlevel.StartLevel;
import org.osgi.util.tracker.ServiceTracker;

@SuppressWarnings("deprecation")
@SuppressWarnings({ "deprecation", "removal" }) // AccessController
public class BundleInstaller {
private BundleContext context;
private String rootLocation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public void testAdapt_Module() throws Exception {
}

@Test
@SuppressWarnings({ "deprecation", "removal" }) // SecurityManager
public void testAdapt_ProtectionDomain() throws Exception {
Bundle bundle = installer.installBundle("test");
SecurityManager previousSM = System.getSecurityManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
import org.osgi.service.url.URLConstants;
import org.osgi.service.url.URLStreamHandlerService;

@SuppressWarnings({ "deprecation", "removal" }) // SecurityManager
public class SystemBundleTests extends AbstractBundleTests {

@Test
Expand Down Expand Up @@ -1981,7 +1982,6 @@ private void doTestJavaProfile(String javaSpecVersion, String expectedEEName, St
configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath());
Equinox equinox = new Equinox(configuration);
equinox.init();
@SuppressWarnings("deprecation")
String osgiEE = equinox.getBundleContext().getProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT);
// don't do anything; just put the framework back to the RESOLVED state
stop(equinox);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
import org.osgi.service.permissionadmin.PermissionAdmin;
import org.osgi.service.permissionadmin.PermissionInfo;

@SuppressWarnings("deprecation")
@SuppressWarnings({ "deprecation", "removal" }) // AccessControlContext
public class SecurityAdminUnitTests extends AbstractBundleTests {

private static final PermissionInfo[] SOCKET_INFOS = new PermissionInfo[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import org.osgi.service.permissionadmin.PermissionInfo;
import org.osgi.service.startlevel.StartLevel;

@SuppressWarnings({ "deprecation", "removal" }) // Policy
public class SecurityManagerTests extends AbstractBundleTests {
private static final PermissionInfo hostFragmentPermission = new PermissionInfo(BundlePermission.class.getName(),
"*", "host,fragment"); //$NON-NLS-1$ //$NON-NLS-2$
Expand All @@ -82,7 +83,7 @@ public class SecurityManagerTests extends AbstractBundleTests {

@Override
public void setUp() throws Exception {
assertNull("Cannot test with security manager set", System.getSecurityManager());
assertNull("Cannot test with security manager set", getSecurityManager());
previousPolicy = Policy.getPolicy();
final Permission allPermission = new AllPermission();
final PermissionCollection allPermissions = new PermissionCollection() {
Expand Down Expand Up @@ -140,7 +141,7 @@ public void refresh() {
@Override
public void tearDown() throws Exception {
super.tearDown();
if (System.getSecurityManager() != null)
if (getSecurityManager() != null)
System.setSecurityManager(null);
Policy.setPolicy(previousPolicy);
}
Expand All @@ -154,7 +155,7 @@ public void testEnableSecurityManager01() throws BundleException {
Equinox equinox = new Equinox(configuration);
equinox.init();

assertNotNull("SecurityManager is null", System.getSecurityManager()); //$NON-NLS-1$
assertNotNull("SecurityManager is null", getSecurityManager()); //$NON-NLS-1$
// should be in the STARTING state
assertEquals("Wrong state for SystemBundle", Bundle.STARTING, equinox.getState()); //$NON-NLS-1$
equinox.start();
Expand All @@ -163,7 +164,7 @@ public void testEnableSecurityManager01() throws BundleException {
// put the framework back to the RESOLVED state
stop(equinox);
assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState()); //$NON-NLS-1$
assertNull("SecurityManager is not null", System.getSecurityManager()); //$NON-NLS-1$
assertNull("SecurityManager is not null", getSecurityManager()); //$NON-NLS-1$
}

@Test
Expand All @@ -176,7 +177,7 @@ public void testEnableSecurityManager02() throws BundleException {
Equinox equinox = new Equinox(configuration);
equinox.init();

assertNotNull("SecurityManager is null", System.getSecurityManager()); //$NON-NLS-1$
assertNotNull("SecurityManager is null", getSecurityManager()); //$NON-NLS-1$
// should be in the STARTING state
assertEquals("Wrong state for SystemBundle", Bundle.STARTING, equinox.getState()); //$NON-NLS-1$

Expand Down Expand Up @@ -207,7 +208,7 @@ public void testEnableSecurityManager02() throws BundleException {
stop(equinox);
}
assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState()); //$NON-NLS-1$
assertNull("SecurityManager is not null", System.getSecurityManager()); //$NON-NLS-1$
assertNull("SecurityManager is not null", getSecurityManager()); //$NON-NLS-1$
}

@Test
Expand All @@ -219,7 +220,7 @@ public void testEnableSecurityManager03() throws BundleException {
Equinox equinox = new Equinox(configuration);
equinox.init();

assertNotNull("SecurityManager is null", System.getSecurityManager()); //$NON-NLS-1$
assertNotNull("SecurityManager is null", getSecurityManager()); //$NON-NLS-1$
// should be in the STARTING state
assertEquals("Wrong state for SystemBundle", Bundle.STARTING, equinox.getState()); //$NON-NLS-1$

Expand Down Expand Up @@ -273,7 +274,7 @@ public void testEnableSecurityManager03() throws BundleException {
stop(equinox);
}
assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState()); //$NON-NLS-1$
assertNull("SecurityManager is not null", System.getSecurityManager()); //$NON-NLS-1$
assertNull("SecurityManager is not null", getSecurityManager()); //$NON-NLS-1$
}

@Test
Expand All @@ -285,7 +286,7 @@ public void testEnableSecurityManager04() throws Exception {
Equinox equinox = new Equinox(configuration);
equinox.init();

assertNotNull("SecurityManager is null", System.getSecurityManager()); //$NON-NLS-1$
assertNotNull("SecurityManager is null", getSecurityManager()); //$NON-NLS-1$
// should be in the STARTING state
assertEquals("Wrong state for SystemBundle", Bundle.STARTING, equinox.getState()); //$NON-NLS-1$

Expand Down Expand Up @@ -345,7 +346,7 @@ public void testEnableSecurityManager04() throws Exception {
stop(equinox);
}
assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState()); //$NON-NLS-1$
assertNull("SecurityManager is not null", System.getSecurityManager()); //$NON-NLS-1$
assertNull("SecurityManager is not null", getSecurityManager()); //$NON-NLS-1$
}

@Test
Expand All @@ -357,7 +358,7 @@ public void testEnableSecurityManager05() throws BundleException {
Equinox equinox = new Equinox(configuration);
equinox.init();

assertNotNull("SecurityManager is null", System.getSecurityManager()); //$NON-NLS-1$
assertNotNull("SecurityManager is null", getSecurityManager()); //$NON-NLS-1$
// should be in the STARTING state
assertEquals("Wrong state for SystemBundle", Bundle.STARTING, equinox.getState()); //$NON-NLS-1$

Expand Down Expand Up @@ -386,7 +387,11 @@ public void testEnableSecurityManager05() throws BundleException {
stop(equinox);
}
assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState()); //$NON-NLS-1$
assertNull("SecurityManager is not null", System.getSecurityManager()); //$NON-NLS-1$
assertNull("SecurityManager is not null", getSecurityManager()); //$NON-NLS-1$
}

private SecurityManager getSecurityManager() {
return System.getSecurityManager();
}

@Test
Expand All @@ -398,7 +403,7 @@ public void testLocalization01() throws BundleException {
configuration.put(Constants.FRAMEWORK_SECURITY, Constants.FRAMEWORK_SECURITY_OSGI);
Equinox equinox = new Equinox(configuration);
equinox.init();
assertNotNull("SecurityManager is null", System.getSecurityManager()); //$NON-NLS-1$
assertNotNull("SecurityManager is null", getSecurityManager()); //$NON-NLS-1$
// should be in the STARTING state
assertEquals("Wrong state for SystemBundle", Bundle.STARTING, equinox.getState()); //$NON-NLS-1$

Expand Down Expand Up @@ -436,7 +441,7 @@ public void testLocalization01() throws BundleException {
stop(equinox);
}
assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState()); //$NON-NLS-1$
assertNull("SecurityManager is not null", System.getSecurityManager()); //$NON-NLS-1$
assertNull("SecurityManager is not null", getSecurityManager()); //$NON-NLS-1$
}

@Test
Expand All @@ -447,7 +452,7 @@ public void testBug254600() throws BundleException {
configuration.put(Constants.FRAMEWORK_SECURITY, Constants.FRAMEWORK_SECURITY_OSGI);
Equinox equinox = new Equinox(configuration);
equinox.init();
assertNotNull("SecurityManager is null", System.getSecurityManager()); //$NON-NLS-1$
assertNotNull("SecurityManager is null", getSecurityManager()); //$NON-NLS-1$
// should be in the STARTING state
assertEquals("Wrong state for SystemBundle", Bundle.STARTING, equinox.getState()); //$NON-NLS-1$
equinox.start();
Expand Down Expand Up @@ -482,7 +487,7 @@ public void testBug254600() throws BundleException {

stop(equinox);
assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState()); //$NON-NLS-1$
assertNull("SecurityManager is not null", System.getSecurityManager()); //$NON-NLS-1$
assertNull("SecurityManager is not null", getSecurityManager()); //$NON-NLS-1$
}

@Test
Expand All @@ -493,7 +498,7 @@ public void testBug287750() throws BundleException {
configuration.put(Constants.FRAMEWORK_SECURITY, Constants.FRAMEWORK_SECURITY_OSGI);
Equinox equinox = new Equinox(configuration);
equinox.init();
assertNotNull("SecurityManager is null", System.getSecurityManager()); //$NON-NLS-1$
assertNotNull("SecurityManager is null", getSecurityManager()); //$NON-NLS-1$
// should be in the STARTING state
assertEquals("Wrong state for SystemBundle", Bundle.STARTING, equinox.getState()); //$NON-NLS-1$
equinox.start();
Expand All @@ -517,7 +522,7 @@ public void testBug287750() throws BundleException {
assertEquals("Wrong startlevel", 10, sl.getStartLevel()); //$NON-NLS-1$
stop(equinox);
assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState()); //$NON-NLS-1$
assertNull("SecurityManager is not null", System.getSecurityManager()); //$NON-NLS-1$
assertNull("SecurityManager is not null", getSecurityManager()); //$NON-NLS-1$
}

@Test
Expand All @@ -528,7 +533,7 @@ public void testBug367614() throws BundleException {
configuration.put(Constants.FRAMEWORK_SECURITY, Constants.FRAMEWORK_SECURITY_OSGI);
Equinox equinox = new Equinox(configuration);
equinox.init();
assertNotNull("SecurityManager is null", System.getSecurityManager()); //$NON-NLS-1$
assertNotNull("SecurityManager is null", getSecurityManager()); //$NON-NLS-1$
// should be in the STARTING state
assertEquals("Wrong state for SystemBundle", Bundle.STARTING, equinox.getState()); //$NON-NLS-1$
equinox.start();
Expand Down Expand Up @@ -572,7 +577,7 @@ public void testBug367614() throws BundleException {
// put the framework back to the RESOLVED state
stop(equinox);
assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState()); //$NON-NLS-1$
assertNull("SecurityManager is not null", System.getSecurityManager()); //$NON-NLS-1$
assertNull("SecurityManager is not null", getSecurityManager()); //$NON-NLS-1$
}

@Test
Expand Down Expand Up @@ -636,7 +641,7 @@ public void end() {
// put the framework back to the RESOLVED state
stop(equinox);
assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState()); //$NON-NLS-1$
assertNull("SecurityManager is not null", System.getSecurityManager()); //$NON-NLS-1$
assertNull("SecurityManager is not null", getSecurityManager()); //$NON-NLS-1$
}

@Test
Expand Down Expand Up @@ -671,9 +676,9 @@ public void doJava12SecurityManagerSetting(String managerValue, boolean isSecuri
try {
equinox.init();
if (isSecurityManager) {
assertNotNull("SecurityManager is null", System.getSecurityManager()); //$NON-NLS-1$
assertNotNull("SecurityManager is null", getSecurityManager()); //$NON-NLS-1$
} else {
assertNull("SecurityManager is not null", System.getSecurityManager()); //$NON-NLS-1$
assertNull("SecurityManager is not null", getSecurityManager()); //$NON-NLS-1$
}
} catch (BundleException e) {
if (isSecurityManager && e.getCause() instanceof UnsupportedOperationException) {
Expand Down
Loading