Hi,

Okay I managed to reproduce it through a simple test, but I didn't
find away of catching the warning messaged and then failing the unit
test.

So the only way I know it failed is because I log warning messaged
from H2.

Thanks

br
Flemming

package com.performancetest.h2;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.util.Arrays;

import junit.framework.TestCase;

public class TestH2CachePerformance extends TestCase {
    private static final int NO_OF_RECORDS = 100000;

    static String URL = "jdbc:h2:/tmp/
testcache;CACHE_TYPE=SOFT_LRU;DB_CLOSE_DELAY=0;CACHE_SIZE=2500;TRACE_LEVEL_FILE=4";
 //
$NON-NLS-1$
    private Connection connection;

    protected void setUp() throws Exception {
        connection = DriverManager.getConnection(URL, "sa", ""); //
$NON-NLS-1$ //$NON-NLS-2$
        connection.setAutoCommit(false);

        Statement createStatement = connection.createStatement();
        try {
            createStatement.execute("drop table
TestH2CachePerformance;"); //$NON-NLS-1$
        } catch (Exception e) {
            // Expect it in case of the table does not exits
        }
        createStatement
        .execute("create table TestH2CachePerformance (\"id\" INT,
\"FirstName\" CHAR(255),\"LastName\" CHAR(255));"); //$NON-NLS-1$
        createStatement.close();
        connection.commit();
    }

    public void testCache() throws Exception {
        Statement insertStatement = connection.createStatement();
        char[] firstCol = new char[255];
        char[] secondCol = new char[255];
        Arrays.fill(firstCol, 'A');
        Arrays.fill(secondCol, 'B');

        for (int i = 0; i < NO_OF_RECORDS; i++) {
            insertStatement.addBatch("INSERT INTO
TestH2CachePerformance VALUES ("+i+", '"+new String(firstCol)
+"','"+new String(secondCol)+"');"); //$NON-NLS-1$ //$NON-NLS-2$ //
$NON-NLS-3$ //$NON-NLS-4$
        }

        int[] executeBatch = insertStatement.executeBatch();
        insertStatement.close();
        connection.commit();
    }

    protected void tearDown() throws Exception {
        connection.close();
    }

On Dec 12, 9:33 am, Thomas Mueller <[email protected]>
wrote:
> Hi,
>
> > I think it will be fairly easy to set-up a test case that reproduce
> > the error. I will get back when it's ready.
>
> A test case would be great!
>
> > Do you have any idea why I didn't see this in 1.1.110?
>
> No.
>
> Regards,
> Thomas

--

You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.


Reply via email to