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

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


     *-------------------------------------------------------------*/
    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

     *-------------------------------------------------------------*/
    public void testNonExistingTableName() throws Exception
    {
        getLogger().info( "testNonExistingTableName" );

        IdGenerator idGenerator =
            (IdGenerator)m_idGeneratorSelector.select( "ids-testNonExistingTableName" );
        try
        {
            try
            {
                idGenerator.getNextIntegerId();
                fail( "Should not have gotten an id" );
            }
            catch( IdException e )
            {
                // Got the expected error.
View Full Code Here

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

        IdGenerator idGenerator =
            (IdGenerator)m_idGeneratorSelector.select( "ids-testSimpleRequestIdsSize1" );
        try
        {
            int testCount = 100;

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

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

            assertEquals( "The next_id column in the database did not have the expected value.",
                          testCount + 1, peekNextLongId( "test" ) );
View Full Code Here

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

        IdGenerator idGenerator =
            (IdGenerator)m_idGeneratorSelector.select( "ids-testSimpleRequestIdsSize10" );
        try
        {
            int testCount = 100;

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

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

            assertEquals( "The next_id column in the database did not have the expected value.",
                          testCount + 1, peekNextLongId( "test" ) );
View Full Code Here

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

        IdGenerator idGenerator =
            (IdGenerator)m_idGeneratorSelector.select( "ids-testSimpleRequestIdsSize100" );
        try
        {
            int testCount = 100;

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

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

            assertEquals( "The next_id column in the database did not have the expected value.",
                          testCount + 1, peekNextLongId( "test" ) );
View Full Code Here

    {
        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

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.