You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tv...@apache.org on 2014/04/11 14:12:13 UTC
svn commit: r1586620 -
/commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/engine/SystemPropertyUsageUnitTest.java
Author: tv
Date: Fri Apr 11 12:12:13 2014
New Revision: 1586620
URL: http://svn.apache.org/r1586620
Log:
Cleanup after test
Modified:
commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/engine/SystemPropertyUsageUnitTest.java
Modified: commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/engine/SystemPropertyUsageUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/engine/SystemPropertyUsageUnitTest.java?rev=1586620&r1=1586619&r2=1586620&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/engine/SystemPropertyUsageUnitTest.java (original)
+++ commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/engine/SystemPropertyUsageUnitTest.java Fri Apr 11 12:12:13 2014
@@ -34,8 +34,27 @@ import org.apache.commons.jcs.utils.prop
public class SystemPropertyUsageUnitTest
extends TestCase
{
+ private static final String JCS_DEFAULT_CACHEATTRIBUTES_MAX_OBJECTS = "jcs.default.cacheattributes.MaxObjects";
+ private static final int testValue = 6789;
- /**
+ private CompositeCacheManager manager = null;
+
+ /**
+ * @see junit.framework.TestCase#tearDown()
+ */
+ @Override
+ protected void tearDown() throws Exception
+ {
+ if (manager != null)
+ {
+ manager.shutDown();
+ }
+
+ System.clearProperty(JCS_DEFAULT_CACHEATTRIBUTES_MAX_OBJECTS);
+ super.tearDown();
+ }
+
+ /**
* Verify that the system properties are used.
* @throws Exception
*
@@ -43,16 +62,15 @@ public class SystemPropertyUsageUnitTest
public void testSystemPropertyUsage()
throws Exception
{
- final int testValue = 6789;
-
- System.getProperties().setProperty( "jcs.default.cacheattributes.MaxObjects", String.valueOf(testValue) );
+ System.setProperty( JCS_DEFAULT_CACHEATTRIBUTES_MAX_OBJECTS, String.valueOf(testValue) );
JCS.setConfigFilename( "/TestSystemPropertyUsage.ccf" );
CacheAccess<String, String> jcs = JCS.getInstance( "someCacheNotInFile" );
- assertEquals( "System property value is not reflected", testValue, jcs.getCacheAttributes().getMaxObjects());
+ manager = CompositeCacheManager.getInstance();
+ assertEquals( "System property value is not reflected", testValue, jcs.getCacheAttributes().getMaxObjects());
}
/**
@@ -64,19 +82,18 @@ public class SystemPropertyUsageUnitTest
public void testSystemPropertyUsage_inactive()
throws Exception
{
- System.getProperties().setProperty( "jcs.default.cacheattributes.MaxObjects", "6789" );
+ System.setProperty( JCS_DEFAULT_CACHEATTRIBUTES_MAX_OBJECTS, String.valueOf(testValue) );
- CompositeCacheManager mgr = CompositeCacheManager.getUnconfiguredInstance();
+ manager = CompositeCacheManager.getUnconfiguredInstance();
Properties props = PropertyLoader.loadProperties( "TestSystemPropertyUsage.ccf" );
- mgr.configure( props, false );
+ manager.configure( props, false );
CacheAccess<String, String> jcs = JCS.getInstance( "someCacheNotInFile" );
- assertFalse( "System property value should not be reflected",
- jcs.getCacheAttributes().getMaxObjects() == Integer.parseInt( props
- .getProperty( "jcs.default.cacheattributes.MaxObjects" ) ) );
-
+ assertEquals( "System property value should not be reflected",
+ Integer.parseInt( props.getProperty( JCS_DEFAULT_CACHEATTRIBUTES_MAX_OBJECTS ) ),
+ jcs.getCacheAttributes().getMaxObjects());
}
}