jicarilla-sandbox/platform/container/impl/src/test/org/jicarilla/container/test/selectors InstanceofSelectorTestCase.java,NONE,1.1 ClassSelectorTestCase.java,1.5,1.6 HintedClassSelectorTestCase.java,1.5,1.6

[email protected]
Newsgroups gmane.comp.java.jicarilla.cvs
Message-ID <[email protected]>
Update of /cvsroot/jicarilla/jicarilla-sandbox/platform/container/impl/src/test/org/jicarilla/container/test/selectors
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12008/platform/container/impl/src/test/org/jicarilla/container/test/selectors

Modified Files:
	ClassSelectorTestCase.java HintedClassSelectorTestCase.java 
Added Files:
	InstanceofSelectorTestCase.java 
Log Message:
minor api improvements + tests

--- NEW FILE: InstanceofSelectorTestCase.java ---
/* ====================================================================
The Jicarilla Software License

Copyright (c) 2003 Leo Simons.
All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
==================================================================== */
package org.jicarilla.container.test.selectors;

import org.jicarilla.container.selectors.InstanceofSelector;
import org.jicarilla.container.selectors.ClassSelector;
import org.jicarilla.container.tck.components.type3.rich.HomerImpl;
import org.jicarilla.container.tck.components.interfaces.Homer;
import org.jicarilla.container.tck.components.interfaces.HotdogBuyer;
import org.jicarilla.framework.TrueSelector;

import junit.framework.TestCase;

/**
 *
 *
 * @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
 * @version $Id: InstanceofSelectorTestCase.java,v 1.1 2004/03/09 23:59:59 lsimons Exp $
 */
public class InstanceofSelectorTestCase extends TestCase
{
    public void testEverything()
    {
        InstanceofSelector selector = new InstanceofSelector( HomerImpl.class );

        assertFalse( selector.select(null) );
        assertFalse( selector.select(this) );

        assertFalse( selector.select(Homer.class) );
        assertFalse( selector.select(HomerImpl.class) );
        assertFalse( selector.select(HotdogBuyer.class) );

        assertFalse( selector.select(Homer.class.getName()) );
        assertFalse( selector.select(HomerImpl.class.getName()) );
        assertFalse( selector.select(HotdogBuyer.class.getName()) );

        assertTrue( selector.select( new HomerImpl() ) );
    }
    public void testExceptions()
    {
        Throwable t = null;
        try
        {
            new InstanceofSelector( null );
        }
        catch( AssertionError th )
        {
            t = th;
        }
        assertNotNull( t );
    }

    public void testGetCriterion()
    {
        InstanceofSelector selector = new InstanceofSelector( this.getClass() );
        assertEquals( this.getClass(), selector.getCriterion() );
    }

    InstanceofSelector selector = new InstanceofSelector( InstanceofSelector.class );
    InstanceofSelector selector2 = new InstanceofSelector( InstanceofSelector.class );
    InstanceofSelector selector3 = new InstanceofSelector( this.getClass() );
    InstanceofSelector selector4 = new InstanceofSelector( this.getClass() );

    TrueSelector ts = new TrueSelector();

    public void testEquals()
    {
        assertTrue( selector.equals( selector ) );
        assertTrue( selector.equals( selector2 ) );
        assertFalse( selector.equals( selector3 ) );
        assertFalse( selector.equals( selector4 ) );
        assertFalse( selector.equals( null ) );
        assertFalse( selector.equals( this ) );
        assertFalse( selector.equals( ts ) );

        assertFalse( selector3.equals( selector ) );
        assertFalse( selector3.equals( selector2 ) );
        assertTrue( selector3.equals( selector3 ) );
        assertTrue( selector3.equals( selector4 ) );
        assertFalse( selector3.equals( null ) );
        assertFalse( selector3.equals( this ) );
        assertFalse( selector3.equals( ts ) );
    }
    public void testHashCode()
    {
        assertEquals(
                selector.hashCode(),
                selector.hashCode()
        );
        assertEquals(
                selector.hashCode(),
                selector2.hashCode()
        );
        assertEquals(
                selector3.hashCode(),
                selector3.hashCode()
        );
        assertEquals(
                selector4.hashCode(),
                selector4.hashCode()
        );

        assertFalse( selector.hashCode() == selector3.hashCode() );
        assertFalse( selector.hashCode() == selector4.hashCode() );
        assertFalse( selector.hashCode() == -1 );
        assertFalse( selector.hashCode() == this.hashCode() );
        assertFalse( selector.hashCode() == ts.hashCode() );

        assertFalse( selector3.hashCode() == selector.hashCode() );
        assertFalse( selector3.hashCode() == selector2.hashCode() );
        assertFalse( selector3.hashCode() == -1 );
        assertFalse( selector3.hashCode() == this.hashCode() );
        assertFalse( selector3.hashCode() == ts.hashCode() );
    }
}

Index: ClassSelectorTestCase.java
===================================================================
RCS file: /cvsroot/jicarilla/jicarilla-sandbox/platform/container/impl/src/test/org/jicarilla/container/test/selectors/ClassSelectorTestCase.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- ClassSelectorTestCase.java	18 Jan 2004 15:52:34 -0000	1.5
+++ ClassSelectorTestCase.java	9 Mar 2004 23:59:59 -0000	1.6
@@ -132,5 +132,4 @@
         assertFalse( selector3.hashCode() == this.hashCode() );
         assertFalse( selector3.hashCode() == ts.hashCode() );
     }
-
 }

Index: HintedClassSelectorTestCase.java
===================================================================
RCS file: /cvsroot/jicarilla/jicarilla-sandbox/platform/container/impl/src/test/org/jicarilla/container/test/selectors/HintedClassSelectorTestCase.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- HintedClassSelectorTestCase.java	18 Jan 2004 15:52:34 -0000	1.5
+++ HintedClassSelectorTestCase.java	9 Mar 2004 23:59:59 -0000	1.6
@@ -82,14 +82,14 @@
 
     public void testGetCriterion()
     {
-        ClassSelector selector = new ClassSelector( this.getClass() );
+        HintedClassSelector selector = new HintedClassSelector( this.getClass() );
         assertEquals( this.getClass(), selector.getCriterion() );
     }
 
-    ClassSelector selector = new ClassSelector( ClassSelector.class );
-    ClassSelector selector2 = new ClassSelector( ClassSelector.class );
-    ClassSelector selector3 = new ClassSelector( this.getClass() );
-    ClassSelector selector4 = new ClassSelector( this.getClass() );
+    HintedClassSelector selector = new HintedClassSelector( ClassSelector.class );
+    HintedClassSelector selector2 = new HintedClassSelector( ClassSelector.class );
+    HintedClassSelector selector3 = new HintedClassSelector( this.getClass() );
+    HintedClassSelector selector4 = new HintedClassSelector( this.getClass() );
 
     TrueSelector ts = new TrueSelector();
 



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.