Package org.apache.avalon.excalibur.datasource.ids

Examples of org.apache.avalon.excalibur.datasource.ids.IdGenerator


    {
        getLogger().info( "testBigDecimalRequestIdsSize10" );

        if( isBigDecimalImplemented() )
        {
            IdGenerator idGenerator =
                (IdGenerator)m_idGeneratorSelector.select( "ids-testBigDecimalRequestIdsSize10" );
            try
            {
                int testCount = 100;
                BigDecimal initial = new BigDecimal( Long.MAX_VALUE + "00" );

                // Initialize the counter in the database.
                initializeNextBigDecimalId( "test", initial );

                for( int i = 0; i < testCount; i++ )
                {
                    BigDecimal id = idGenerator.getNextBigDecimalId();
                    assertEquals( "The returned id was not what was expected.",
                                  initial.add( new BigDecimal( i ) ), id );
                }

                assertEquals( "The next_id column in the database did not have the expected value.",
View Full Code Here


    public void testMaxByteIds() throws Exception
    {
        getLogger().info( "testMaxByteIds" );

        IdGenerator idGenerator = (IdGenerator)m_idGeneratorSelector.select( "ids-testMaxByteIds" );
        try
        {
            int testCount = 100;
            long max = Byte.MAX_VALUE;
            long initial = max - testCount;

            // Initialize the counter in the database.
            initializeNextLongId( "test", initial );

            for( int i = 0; i <= testCount; i++ )
            {
                byte id = idGenerator.getNextByteId();
                assertEquals( "The returned id was not what was expected.", i + initial, id );
            }

            // Next one should throw an exception
            try
            {
                byte id = idGenerator.getNextByteId();
                fail( "Should not have gotten an id: " + id );
            }
            catch( IdException e )
            {
                // Good.  Got the exception.
View Full Code Here

    public void testMaxShortIds() throws Exception
    {
        getLogger().info( "testMaxShortIds" );

        IdGenerator idGenerator = (IdGenerator)m_idGeneratorSelector.select( "ids-testMaxShortIds" );
        try
        {
            int testCount = 100;
            long max = Short.MAX_VALUE;
            long initial = max - testCount;

            // Initialize the counter in the database.
            initializeNextLongId( "test", initial );

            for( int i = 0; i <= testCount; i++ )
            {
                short id = idGenerator.getNextShortId();
                assertEquals( "The returned id was not what was expected.", i + initial, id );
            }

            // Next one should throw an exception
            try
            {
                short id = idGenerator.getNextShortId();
                fail( "Should not have gotten an id: " + id );
            }
            catch( IdException e )
            {
                // Good.  Got the exception.
View Full Code Here

    public void testMaxIntegerIds() throws Exception
    {
        getLogger().info( "testMaxIntegerIds" );

        IdGenerator idGenerator = (IdGenerator)m_idGeneratorSelector.select( "ids-testMaxIntegerIds" );
        try
        {
            int testCount = 100;
            long max = Integer.MAX_VALUE;
            long initial = max - testCount;

            // Initialize the counter in the database.
            initializeNextLongId( "test", initial );

            for( int i = 0; i <= testCount; i++ )
            {
                int id = idGenerator.getNextIntegerId();
                assertEquals( "The returned id was not what was expected.", i + initial, id );
            }

            // Next one should throw an exception
            try
            {
                int id = idGenerator.getNextIntegerId();
                fail( "Should not have gotten an id: " + id );
            }
            catch( IdException e )
            {
                // Good.  Got the exception.
View Full Code Here

    public void testMaxLongIds() throws Exception
    {
        getLogger().info( "testMaxLongIds" );

        IdGenerator idGenerator = (IdGenerator)m_idGeneratorSelector.select( "ids-testMaxLongIds" );
        try
        {
            int testCount = 100;
            long max = Long.MAX_VALUE;
            long initial = max - testCount;

            // Initialize the counter in the database.
            initializeNextLongId( "test", initial );

            for( int i = 0; i <= testCount; i++ )
            {
                long id = idGenerator.getNextLongId();
                assertEquals( "The returned id was not what was expected.", i + initial, id );
            }

            // Next one should throw an exception
            try
            {
                long id = idGenerator.getNextLongId();
                fail( "Should not have gotten an id: " + id );
            }
            catch( IdException e )
            {
                // Good.  Got the exception.
View Full Code Here

     *-------------------------------------------------------------*/
    public void testSimpleRequestIdsSize1() throws Exception
    {
        getLogEnabledLogger().info( "testSimpleRequestIdsSize1" );

        IdGenerator idGenerator =
            (IdGenerator)m_idGeneratorSelector.select( "ids-testSimpleRequestIdsSize1" );
        try
        {
            long firstId = 1;
            int idCount = ID_COUNT;
View Full Code Here

    public void testSimpleRequestIdsSize10() throws Exception
    {
        getLogEnabledLogger().info( "testSimpleRequestIdsSize10" );

        IdGenerator idGenerator =
            (IdGenerator)m_idGeneratorSelector.select( "ids-testSimpleRequestIdsSize10" );
        try
        {
            long firstId = 1;
            int idCount = ID_COUNT;
View Full Code Here

    public void testSimpleRequestIdsSize100() throws Exception
    {
        getLogEnabledLogger().info( "testSimpleRequestIdsSize100" );

        IdGenerator idGenerator =
            (IdGenerator)m_idGeneratorSelector.select( "ids-testSimpleRequestIdsSize100" );
        try
        {
            long firstId = 1;
            int idCount = ID_COUNT;
View Full Code Here

    {
        getLogEnabledLogger().info( "testBigDecimalRequestIdsSize10" );

        if( isBigDecimalImplemented() )
        {
            IdGenerator idGenerator =
                (IdGenerator)m_idGeneratorSelector.select( "ids-testBigDecimalRequestIdsSize10" );
            try
            {
                long firstId = 1;
                int idCount = ID_COUNT;
View Full Code Here

TOP

Related Classes of org.apache.avalon.excalibur.datasource.ids.IdGenerator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.