Skip to content

Commit

Permalink
Re-enable ignored SecurityManager-related test
Browse files Browse the repository at this point in the history
Prior to this change, CallbacksSecurityTests#testContainerPrivileges was
@ignored because it caused the build to fail under Gradle. After some
analysis, the root cause was determined to be the fact that (a) a
restrictive SecurityManager is active during the running of this test,
and (b), Gradle intercepts System.out and routes it through its internal
LogBack-based logging system. LogBack requires a call to
Class#getClassLoader when handling logging statements, and the
SecurityManager disallows this call, thus raising the error that fails
the build.

This commit solves the problem by eliminating the System.out.println
call in question and removing the @ignore annotation from the test. The
console output was diagnostic in nature anyway, and not required for the
successful execution of the test's assertions.

Issue: SPR-10074
  • Loading branch information
cbeams committed Feb 26, 2013
1 parent 3a192a0 commit 58ab8b6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@

package org.springframework.beans.factory.support.security;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.lang.reflect.Method;
import java.net.URL;
import java.security.AccessControlContext;
Expand All @@ -39,8 +33,8 @@
import javax.security.auth.Subject;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.BeanCreationException;
Expand All @@ -60,6 +54,8 @@
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;

import static org.junit.Assert.*;

/**
* Security test case. Checks whether the container uses its privileges for its
* internal work but does not leak them when touching/calling user code.
Expand Down Expand Up @@ -456,9 +452,6 @@ public void testConstructor() throws Exception {
}

@Test
@Ignore("passes under Eclipse, but fails under Gradle with https://gist.github.com/1664133")
// TODO [SPR-10074] passes under Eclipse, but fails under Gradle with
// https://gist.github.com/1664133
public void testContainerPrivileges() throws Exception {
AccessControlContext acc = provider.getAccessControlContext();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.beans.factory.support.security.support;

/**
Expand All @@ -25,6 +26,5 @@ public ConstructorBean() {
}

public ConstructorBean(Object obj) {
System.out.println("Received object " + obj);
}
}

0 comments on commit 58ab8b6

Please sign in to comment.