Started writing tests
This commit is contained in:
parent
e2de94eb7b
commit
93e8c9a90e
3 changed files with 77 additions and 0 deletions
src/test/java/info/ebenoit/ebul/cmp
65
src/test/java/info/ebenoit/ebul/cmp/TestDependencyInfo.java
Normal file
65
src/test/java/info/ebenoit/ebul/cmp/TestDependencyInfo.java
Normal file
|
@ -0,0 +1,65 @@
|
|||
package info.ebenoit.ebul.cmp;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
||||
|
||||
/** Tests for {@link DependencyInfo} */
|
||||
public class TestDependencyInfo
|
||||
{
|
||||
|
||||
/** Test: name-based constructor throws {@link NullPointerException} if name is <code>null</code> */
|
||||
@Test( expected = NullPointerException.class )
|
||||
public void testNewWithNullName( )
|
||||
{
|
||||
new DependencyInfo( (String) null );
|
||||
}
|
||||
|
||||
|
||||
/** Test: class-based constructor throws {@link NullPointerException} if class is <code>null</code> */
|
||||
@Test( expected = NullPointerException.class )
|
||||
public void testNewWithNullClass( )
|
||||
{
|
||||
new DependencyInfo( (Class< ? >) null );
|
||||
}
|
||||
|
||||
|
||||
/** Test: class-based constructor throws {@link ComponentDefinitionException} if class is a primitive type */
|
||||
@Test( expected = ComponentDefinitionException.class )
|
||||
public void testNewWithPrimitiveType( )
|
||||
{
|
||||
new DependencyInfo( int.class );
|
||||
}
|
||||
|
||||
|
||||
/** Test: class-based constructor throws {@link ComponentDefinitionException} if class is an array type */
|
||||
@Test( expected = ComponentDefinitionException.class )
|
||||
public void testNewWithArrayType( )
|
||||
{
|
||||
new DependencyInfo( Object[].class );
|
||||
}
|
||||
|
||||
|
||||
/** Test: equals() method */
|
||||
@Test
|
||||
public void testEquals( )
|
||||
{
|
||||
DependencyInfo[] di = new DependencyInfo[] {
|
||||
new DependencyInfo( "test" ) , new DependencyInfo( "test" ) , new DependencyInfo( "test2" ) ,
|
||||
new DependencyInfo( String.class ) , new DependencyInfo( String.class ) ,
|
||||
new DependencyInfo( Object.class )
|
||||
};
|
||||
|
||||
assertTrue( di[ 0 ].equals( di[ 0 ] ) );
|
||||
assertTrue( di[ 0 ].equals( di[ 1 ] ) );
|
||||
assertFalse( di[ 0 ].equals( di[ 2 ] ) );
|
||||
assertFalse( di[ 0 ].equals( di[ 3 ] ) );
|
||||
|
||||
assertTrue( di[ 3 ].equals( di[ 3 ] ) );
|
||||
assertTrue( di[ 3 ].equals( di[ 4 ] ) );
|
||||
assertFalse( di[ 3 ].equals( di[ 5 ] ) );
|
||||
assertFalse( di[ 3 ].equals( di[ 0 ] ) );
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue