john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

AtmosDirectoryListingTest INCOMPLETE

//2012-03-20 johnpfeiffer
// needs mock objects to fully test the dependency of a remote atmos listing

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

import org.junit.Test;


public class AtmosDirectoryListingTest
{
    public static final String CLASSVERSION = "0.1";
    AtmosDirectoryListing dirlist = null;

    @Test public void testAtmosDirectoryListingNull()
    {
        try{
            dirlist = new AtmosDirectoryListing( null );
        }catch( NullPointerException npe )
        {       return;
        }
        fail("Expected NullPointerException");
    }
    @Test public void testAtmosDirectoryListingEmpty()
    {
        try{
            dirlist = new AtmosDirectoryListing( "" );
        }catch( IllegalArgumentException iae )
        {       return;
        }
        fail("Expected IllegalArgumentException");
    }

    @Test public void testCalculateTokens()
    {
        System.out.println( "test" );
        dirlist = new AtmosDirectoryListing( "/" );
        dirlist.calculateTokens( 1 );
        assertEquals( 1 , dirlist.getTokenCount() );

        dirlist.calculateTokens( 10000 );
        assertEquals( 1 , dirlist.getTokenCount() );

        dirlist.calculateTokens( 10001 );
        assertEquals( 2 , dirlist.getTokenCount() );

        dirlist.calculateTokens( 20001 );
        assertEquals( 3 , dirlist.getTokenCount() );


    }


    @Test public void testDisplayListingNegativeLimit()
    {
        dirlist = new AtmosDirectoryListing( "/" );

        try{
            dirlist.displayListing( null , -1 );
        }catch( IllegalArgumentException iae )
        {       return;
        }
        fail("Expected IllegalArgumentException");
    }
    @Test public void testDisplayListingNullParameter()
    {
        dirlist = new AtmosDirectoryListing( "/" );

        try{
            dirlist.displayListing( null , 1 );
        }catch( IllegalArgumentException iae )
        {       return;
        }
        fail("Expected IllegalArgumentException");
    }

    @Test public void testDisplayListing()
    {
        dirlist = new AtmosDirectoryListing( "/" );
        //dirlist.displayListing( , 1 );
    }

    @Test public void testGetVersion()
    {
        dirlist = new AtmosDirectoryListing( "/" );
        assertEquals( CLASSVERSION , dirlist.getVersion() );
    }

    @Test public void testToString()
    {

        dirlist = new AtmosDirectoryListing( "/" );

        String lineSeparator = System.getProperty( "line.separator" );
        StringBuilder result = new StringBuilder();
        result.append(  "AtmosDirectoryListing Object {" + lineSeparator );
        result.append( "version: " + dirlist.getVersion() + lineSeparator);
        result.append( "objectPath: /" + lineSeparator);
        result.append( "DirectoryEntry: / - null - null" + lineSeparator);
        result.append( "}" );

        assertEquals( result.toString() , dirlist.toString() );
    }
} //end class

  • « eclipse create a java library jar and add to new project
  • AtmosDirectoryListing INCOMPLETE »

Published

Mar 21, 2012

Category

java-classes

~183 words

Tags

  • atmos 11
  • atmosdirectorylistingtest 1
  • classes 92
  • incomplete 22
  • java 252