[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jakarta-commons-dev
Subject:    Re: [collections] Map.Entry and KeyValue
From:       "Neil O'Toole" <neilotoole () users ! sourceforge ! net>
Date:       2003-09-30 6:03:31
[Download RAW message or body]

Attached are tests for the (updated) classes in collections.pairs:

- TestAll.java
- TestMapEntry.java (abstract)
- TestDefaultMapEntry.java (extends TestMapEntry)
- TestDefaultKeyValue.java 

Stephen (because I have a feeling it'll be you you doing this ;)), you
will of course need to add an entry into o.a.c.collections.TestAll to
reference o.a.c.c.pairs.TestAll. 

Two other bits before we call it a night:

- AbstractMapEntry is missing the 'abstract' keyword on the class
declaration.

- Further to:

 >> the essence of which is "KeyValue" and not "Pair"

and the renaming of the interface type from "Pair" to "KeyValue", we
should probably consider renaming the package to "keyvalue" or such for
consistency. Thoughts?

Thanks,

- Neil
["TestAll.java" (text/plain)]

/*
 * $Header: /home/cvspublic/jakarta-commons/collections/src/test/org/apache/commons/collections/observed/TestAll.java,v \
                1.4 2003/09/28 21:50:37 scolebourne Exp $
 * ====================================================================
 *
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 2003 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution, if
 *    any, must include the following acknowledgement:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgement may appear in the software itself,
 *    if and wherever such third-party acknowledgements normally appear.
 *
 * 4. The names "The Jakarta Project", "Commons", and "Apache Software
 *    Foundation" must not be used to endorse or promote products derived
 *    from this software without prior written permission. For written
 *    permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache"
 *    nor may "Apache" appear in their names without prior written
 *    permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 *
 */
package org.apache.commons.collections.pairs;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
 * Entry point for key-value test cases.
 * 
 * @since Commons Collections 3.0
 * @version $Revision: 1.4 $ $Date: 2003/09/28 21:50:37 $
 * 
 * @author Neil O'Toole
 */
public class TestAll extends TestCase {
    
    public TestAll(String testName) {
        super(testName);
    }

    public static void main(String args[]) {
        String[] testCaseName = { TestAll.class.getName() };
        junit.textui.TestRunner.main(testCaseName);
    }
    
    public static Test suite() {
        TestSuite suite = new TestSuite();
        
        suite.addTest(TestDefaultKeyValue.suite());
        suite.addTest(TestDefaultMapEntry.suite());
        return suite;
    }
        
}


["TestMapEntry.java" (text/plain)]

/*
 * $Header: x:/apps/cvsnt/cvs_repository/main/notifyingcollections/src/test/org/apache/commons/collections/TestKeyValueRecord.java,v \
                1.1 2003/09/20 22:00:46 otoolen Exp $
 * ====================================================================
 *
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution, if
 *    any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "The Jakarta Project", "Commons", and "Apache Software
 *    Foundation" must not be used to endorse or promote products derived
 *    from this software without prior written permission. For written
 *    permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache"
 *    nor may "Apache" appear in their names without prior written
 *    permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 *
 */
package org.apache.commons.collections.pairs;

import java.util.HashMap;
import java.util.Map;

import junit.framework.TestCase;

/**
 * Abstract tests that can be extended to test any Map.Entry implementation.
 * Subclasses must implement {@link #makeMapEntry(Object, Object)} to return
 * a new Map.Entry of the type being tested. Subclasses must also implement
 * {@link #testConstructors()} to test the constructors of the Map.Entry
 * type being tested.
 * 
 * @author Neil O'Toole
 */
public abstract class TestMapEntry extends TestCase
{
	protected final String key = "name";
	protected final String value = "duke";


	public TestMapEntry(String testName)
	{
		super(testName);

	}

	/**
	 * Make an instance of Map.Entry with the default (null) key and value.
	 * This implementation simply calls {@link #makeMapEntry(Object, Object)}
	 * with null for key and value. Subclasses can override this method if desired.
	 */
	public Map.Entry makeMapEntry()
	{
		return makeMapEntry(null, null);
	}

	/**
	 * Make an instance of Map.Entry with the specified key and value.
	 * Subclasses should override this method to return a Map.Entry
	 * of the type being tested.
	 */
	public abstract Map.Entry makeMapEntry(Object key, Object value);

	

	public Map.Entry makeKnownMapEntry()
	{
		return makeKnownMapEntry(null, null);
	}

	/**
	 * Makes a Map.Entry of a type that's known to work correctly.
	 */
	public Map.Entry makeKnownMapEntry(Object key, Object value)
	{
		Map map = new HashMap(1);
		map.put(key, value);
		Map.Entry entry = (Map.Entry) map.entrySet().iterator().next();
		return entry;
	}


	public void testAccessorsAndMutators()
	{
		Map.Entry entry = makeMapEntry(key, value);
		
		
		assertTrue(entry.getKey() == key);
		
		entry.setValue(value);
		assertTrue(entry.getValue() == value);

		// check that null doesn't do anything funny
		entry = makeMapEntry(null, null);
		assertTrue(entry.getKey() == null);
		
		entry.setValue(null);
		assertTrue(entry.getValue() == null);		
	}
	
	/**
	 * Subclasses should override this method to test the
	 * desired behaviour of the class with respect to
	 * handling of self-references.
	 *
	 */
	
	public void testSelfReferenceHandling()
	{
		// test that #setValue does not permit
		//  the MapEntry to contain itself (and thus cause infinite recursion
		//  in #hashCode and #toString)

		Map.Entry entry = makeMapEntry();
		
		try
		{
			entry.setValue(entry);
			fail("Should throw an IllegalArgumentException");
		}
		catch(IllegalArgumentException iae)
		{
			// expected to happen...
			
			// check that the KVP's state has not changed
			assertTrue(entry.getKey() == null && entry.getValue() == null);
		}
	}
	
	
	/**
	 * Subclasses should provide tests for their constructors.
	 *
	 */
	public abstract void testConstructors();
	
	
	public void testEqualsAndHashCode()
	{
		// 1. test with object data
		Map.Entry e1 = makeMapEntry(key, value);
		Map.Entry e2 = makeKnownMapEntry(key, value);
		
		assertTrue(e1.equals(e1));
		assertTrue(e2.equals(e1));
		assertTrue(e1.equals(e2));
		assertTrue(e1.hashCode() == e2.hashCode());
		
		// 2. test with nulls
		e1 = makeMapEntry();
		e2 = makeKnownMapEntry();
		
		assertTrue(e1.equals(e1));
		assertTrue(e2.equals(e1));
		assertTrue(e1.equals(e2));
		assertTrue(e1.hashCode() == e2.hashCode());
	}
	
	public void testToString()
	{
		Map.Entry entry = makeMapEntry(key, value);
		assertTrue(entry.toString().equals("["+ entry.getKey() + "=" + entry.getValue() + \
"]"));  
		// test with nulls
		entry = makeMapEntry();
		assertTrue(entry.toString().equals("[" + entry.getKey() + "=" + entry.getValue() + \
"]"));  }
	

}


["TestDefaultMapEntry.java" (text/plain)]

/*
 * $Header: x:/apps/cvsnt/cvs_repository/main/notifyingcollections/src/test/org/apache/commons/collections/TestKeyValueRecord.java,v \
                1.1 2003/09/20 22:00:46 otoolen Exp $
 * ====================================================================
 *
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution, if
 *    any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "The Jakarta Project", "Commons", and "Apache Software
 *    Foundation" must not be used to endorse or promote products derived
 *    from this software without prior written permission. For written
 *    permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache"
 *    nor may "Apache" appear in their names without prior written
 *    permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 *
 */
package org.apache.commons.collections.pairs;

import java.util.Map;

import junit.framework.Test;
import junit.framework.TestSuite;

/**
 * 
 * @author Neil O'Toole
 */
public class TestDefaultMapEntry extends TestMapEntry
{


	public TestDefaultMapEntry(String testName)
	{
		super(testName);

	}

	public static void main(String[] args)
	{
		junit.textui.TestRunner.run(TestDefaultMapEntry.class);
	}

	public static Test suite()
	{
		return new TestSuite(TestDefaultMapEntry.class);
	}

	/**
	 * Make an instance of Map.Entry with the default (null) key and value.
	 * Subclasses should override this method to return a Map.Entry
	 * of the type being tested.
	 */
	public Map.Entry makeMapEntry()
	{
		return new DefaultMapEntry(null, null);
	}

	/**
	 * Make an instance of Map.Entry with the specified key and value.
	 * Subclasses should override this method to return a Map.Entry
	 * of the type being tested.
	 */
	public Map.Entry makeMapEntry(Object key, Object value)
	{
		return new DefaultMapEntry(key, value);
	}
	
	/**
	 * Subclasses should override this method.
	 *
	 */
	public void testConstructors()
	{
		// 1. test default constructor
		Map.Entry entry = new DefaultMapEntry();
		assertTrue(entry.getKey() == null && entry.getValue() == null);
		
			
		// 2. test key-value constructor
		entry = new DefaultMapEntry(key, value);
		assertTrue(entry.getKey() == key && entry.getValue() == value);
		
		
		// 3. test copy constructor
		Map.Entry entry2 = new DefaultMapEntry(entry);
		assertTrue(entry2.getKey() == key && entry2.getValue() == value);
		
		// test that the objects are independent
		entry.setValue(null);
		
		assertTrue(entry2.getValue() == value);		
	}
	

	public void testSelfReferenceHandling()
	{

		Map.Entry entry = makeMapEntry();
		
		try
		{
			entry.setValue(entry);
			assertTrue(entry.getValue() == entry);
			
		}
		catch(Exception e)
		{
			fail("This Map.Entry implementation supports value self-reference.");
		}
	}


}


["TestDefaultKeyValue.java" (text/plain)]

/*
 * $Header: x:/apps/cvsnt/cvs_repository/main/notifyingcollections/src/test/org/apache/commons/collections/TestKeyValueRecord.java,v \
                1.1 2003/09/20 22:00:46 otoolen Exp $
 * ====================================================================
 *
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution, if
 *    any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "The Jakarta Project", "Commons", and "Apache Software
 *    Foundation" must not be used to endorse or promote products derived
 *    from this software without prior written permission. For written
 *    permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache"
 *    nor may "Apache" appear in their names without prior written
 *    permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 *
 */
package org.apache.commons.collections.pairs;

import java.util.HashMap;
import java.util.Map;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
 * 
 * @author Neil O'Toole
 */
public class TestDefaultKeyValue extends TestCase
{
	private final String key = "name";
	private final String value = "duke";


	public TestDefaultKeyValue(String testName)
	{
		super(testName);

	}

	public static void main(String[] args)
	{
		junit.textui.TestRunner.run(TestDefaultKeyValue.class);
	}


	public static Test suite()
	{
		return new TestSuite(TestDefaultKeyValue.class);
	}


	/**
	 * Make an instance of DefaultKeyValue with the default (null) key and value.
	 * Subclasses should override this method to return a DefaultKeyValue
	 * of the type being tested.
	 */
	public DefaultKeyValue makeDefaultKeyValue()
	{
		return new DefaultKeyValue(null, null);
	}

	/**
	 * Make an instance of DefaultKeyValue with the specified key and value.
	 * Subclasses should override this method to return a DefaultKeyValue
	 * of the type being tested.
	 */
	public DefaultKeyValue makeDefaultKeyValue(Object key, Object value)
	{
		return new DefaultKeyValue(key, value);
	}


	public void testAccessorsAndMutators()
	{
		DefaultKeyValue kv = makeDefaultKeyValue();
		
		kv.setKey(key);
		assertTrue(kv.getKey() == key);
		
		kv.setValue(value);
		assertTrue(kv.getValue() == value);

		// check that null doesn't do anything funny
		kv.setKey(null);
		assertTrue(kv.getKey() == null);
		
		kv.setValue(null);
		assertTrue(kv.getValue() == null);
		
	}
	
	public void testSelfReferenceHandling()
	{
		// test that #setKey and #setValue do not permit
		//  the KVP to contain itself (and thus cause infinite recursion
		//  in #hashCode and #toString)
		
		DefaultKeyValue kv = makeDefaultKeyValue();
		
		try
		{
			kv.setKey(kv);
			fail("Should throw an IllegalArgumentException");
		}
		catch(IllegalArgumentException iae)
		{
			// expected to happen...
			
			// check that the KVP's state has not changed
			assertTrue(kv.getKey() == null && kv.getValue() == null);
		}
		
		try
		{
			kv.setValue(kv);
			fail("Should throw an IllegalArgumentException");
		}
		catch(IllegalArgumentException iae)
		{
			// expected to happen...
			
			// check that the KVP's state has not changed
			assertTrue(kv.getKey() == null && kv.getValue() == null);
		}
	}
	
	/**
	 * Subclasses should override this method to test their own constructors.
	 */
	public void testConstructors()
	{
		// 1. test default constructor
		DefaultKeyValue kv = new DefaultKeyValue();
		assertTrue(kv.getKey() == null && kv.getValue() == null);
		
			
		// 2. test key-value constructor
		kv = new DefaultKeyValue(key, value);
		assertTrue(kv.getKey() == key && kv.getValue() == value);
		
		
		// 3. test copy constructor
		DefaultKeyValue kv2 = new DefaultKeyValue(kv);
		assertTrue(kv2.getKey() == key && kv2.getValue() == value);
		
		// test that the KVPs are independent
		kv.setKey(null);
		kv.setValue(null);
		
		assertTrue(kv2.getKey() == key && kv2.getValue() == value);
		
		
		
		// 4. test Map.Entry constructor
		Map map = new HashMap();
		map.put(key, value);
		Map.Entry entry = (Map.Entry) map.entrySet().iterator().next();
		
		kv = new DefaultKeyValue(entry);
		assertTrue(kv.getKey() == key && kv.getValue() == value);
		
		// test that the KVP is independent of the Map.Entry
		entry.setValue(null);
		assertTrue(kv.getValue() == value);
			
	}
	
	public void testEqualsAndHashCode()
	{
		// 1. test with object data
		DefaultKeyValue kv =  makeDefaultKeyValue(key, value);
		DefaultKeyValue kv2 =  makeDefaultKeyValue(key, value);
		
		assertTrue(kv.equals(kv));
		assertTrue(kv.equals(kv2));
		assertTrue(kv.hashCode() == kv2.hashCode());
		
		// 2. test with nulls
		kv =  makeDefaultKeyValue(null, null);
		kv2 = makeDefaultKeyValue(null, null);
		
		assertTrue(kv.equals(kv));
		assertTrue(kv.equals(kv2));
		assertTrue(kv.hashCode() == kv2.hashCode());
	}
	
	public void testToString()
	{
		DefaultKeyValue kv = makeDefaultKeyValue(key, value);
		assertTrue(kv.toString().equals("[" + kv.getKey() + "=" + kv.getValue() + "]"));
		
		// test with nulls
		kv = makeDefaultKeyValue(null, null);
		assertTrue(kv.toString().equals("[" + kv.getKey() + "=" + kv.getValue() + "]"));
	}
	

	public void testToMapEntry()
	{
		DefaultKeyValue kv = makeDefaultKeyValue(key, value);
		
		Map map = new HashMap();
		map.put(kv.getKey(), kv.getValue());
		Map.Entry entry = (Map.Entry) map.entrySet().iterator().next();
		
		assertTrue(entry.equals(kv.toMapEntry()));
		assertTrue(entry.hashCode() == kv.hashCode());
	}

}



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic