Author: asmuts
Date: Tue Oct 4 17:40:02 2005
New Revision: 294958
URL: http://svn.apache.org/viewcvs?rev=294958&view=rev
Log:
added more tests and logging for sortedprefarray. Found no bugs.
Modified:
jakarta/jcs/trunk/auxiliary-builds/jdk14/ (props changed)
jakarta/jcs/trunk/src/java/org/apache/jcs/utils/struct/SortedPreferentialArray.java
jakarta/jcs/trunk/src/test-conf/log4j.properties
jakarta/jcs/trunk/src/test/org/apache/jcs/utils/struct/TestSortedPrefArray.java
Propchange: jakarta/jcs/trunk/auxiliary-builds/jdk14/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Oct 4 17:40:02 2005
@@ -0,0 +1,3 @@
+
+junit1*.properties
+target
Modified:
jakarta/jcs/trunk/src/java/org/apache/jcs/utils/struct/SortedPreferentialArray.java
URL:
http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/utils/struct/SortedPreferentialArray.java?rev=294958&r1=294957&r2=294958&view=diff
==============================================================================
---
jakarta/jcs/trunk/src/java/org/apache/jcs/utils/struct/SortedPreferentialArray.java
(original)
+++
jakarta/jcs/trunk/src/java/org/apache/jcs/utils/struct/SortedPreferentialArray.java
Tue Oct 4 17:40:02 2005
@@ -294,7 +294,7 @@
}
catch ( Exception e )
{
- log.error( e );
+ log.error( "Problem removing from array.", e );
}
if ( log.isDebugEnabled() )
@@ -574,6 +574,7 @@
/**
* Debugging method to return a human readable display of array data.
+ * @return
*/
protected String dumpArray()
{
Modified: jakarta/jcs/trunk/src/test-conf/log4j.properties
URL:
http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test-conf/log4j.properties?rev=294958&r1=294957&r2=294958&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test-conf/log4j.properties (original)
+++ jakarta/jcs/trunk/src/test-conf/log4j.properties Tue Oct 4 17:40:02 2005
@@ -7,6 +7,7 @@
log4j.category.org.apache.jcs.auxiliary.disk=INFO
log4j.category.org.apache.jcs.auxiliary.remote=INFO
log4j.category.org.apache.jcs.auxiliary.lateral=INFO
+log4j.category.org.apache.jcs.utils.struct=DEBUG
log4j.category.org.apache.jcs.utils.threadpool=INFO
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
Modified:
jakarta/jcs/trunk/src/test/org/apache/jcs/utils/struct/TestSortedPrefArray.java
URL:
http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/utils/struct/TestSortedPrefArray.java?rev=294958&r1=294957&r2=294958&view=diff
==============================================================================
---
jakarta/jcs/trunk/src/test/org/apache/jcs/utils/struct/TestSortedPrefArray.java
(original)
+++
jakarta/jcs/trunk/src/test/org/apache/jcs/utils/struct/TestSortedPrefArray.java
Tue Oct 4 17:40:02 2005
@@ -226,6 +226,7 @@
int maxSize = 25;
SortedPreferentialArray array = new SortedPreferentialArray( maxSize );
array.setPreferLarge( true );
+
try
{
String taken = (String) array.takeNearestLargerOrEqual( null );
@@ -237,5 +238,85 @@
}
}
+
+ /**
+ * Verify that we don't get an npe when taking from an array of only one
+ *
+ * @throws Exception
+ */
+ public void testSingleItemTake()
+ throws Exception
+ {
+ int maxSize = 25;
+ SortedPreferentialArray array = new SortedPreferentialArray( maxSize );
+ array.setPreferLarge( true );
+
+ array.add( "10" );
+ System.out.println( array.dumpArray() );
+
+ try
+ {
+ String taken = (String) array.takeNearestLargerOrEqual( "09" );
+ System.out.println( taken );
+ assertNotNull( "taken should not be null, since nothing was in the
array", taken );
+ }
+ catch ( NullPointerException e )
+ {
+ fail( "Got a null pointer trying to take with a null" );
+ }
+
+ }
+
+ /**
+ * Verify that we don't get an npe when taking from an array of only one
+ *
+ * @throws Exception
+ */
+ public void testSingleItemTakeLarger()
+ throws Exception
+ {
+
+ int maxSize = 25;
+ SortedPreferentialArray array = new SortedPreferentialArray( maxSize );
+ array.setPreferLarge( true );
+
+ array.add( "10" );
+
+ try
+ {
+ String taken = (String) array.takeNearestLargerOrEqual( "11" );
+ assertNull( "taken should be null, since nothing smaller was in
the array", taken );
+ }
+ catch ( NullPointerException e )
+ {
+ fail( "Got a null pointer trying to take with a null" );
+ }
+
+ }
+
+ /**
+ * Verify that we don't get an npe when taking from an array of none
+ *
+ * @throws Exception
+ */
+ public void testSingleItemTakeLargerEmpty()
+ throws Exception
+ {
+
+ int maxSize = 25;
+ SortedPreferentialArray array = new SortedPreferentialArray( maxSize );
+ array.setPreferLarge( true );
+
+ try
+ {
+ String taken = (String) array.takeNearestLargerOrEqual( "11" );
+ assertNull( "taken should be null, since nothing was in the
array", taken );
+ }
+ catch ( NullPointerException e )
+ {
+ fail( "Got a null pointer trying to take with a null" );
+ }
+
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]