1 17 package org.apache.servicemix.store.jdbc; 18 19 import java.sql.Connection ; 20 21 import javax.sql.DataSource ; 22 23 import junit.framework.TestCase; 24 25 import org.apache.servicemix.store.Store; 26 import org.apache.servicemix.store.StoreFactory; 27 import org.hsqldb.jdbc.jdbcDataSource; 28 29 public class JdbcStoreTest extends TestCase { 30 31 private DataSource dataSource; 32 private Connection connection; 33 private StoreFactory factory; 34 35 protected void setUp() throws Exception { 36 jdbcDataSource ds = new jdbcDataSource(); 37 ds.setDatabase("jdbc:hsqldb:mem:aname"); 38 ds.setUser("sa"); 39 dataSource = ds; 40 connection = dataSource.getConnection(); 41 JdbcStoreFactory f = new JdbcStoreFactory(); 42 f.setDataSource(dataSource); 43 factory = f; 44 } 45 46 protected void tearDown() throws Exception { 47 if (connection != null) { 48 connection.close(); 49 } 50 } 51 52 public void testStoreLoad() throws Exception { 53 Store store = factory.open("store"); 54 String id = store.store(new Integer (10)); 55 Integer i = (Integer ) store.load(id); 56 assertEquals(10, i.intValue()); 57 assertNull(store.load("a")); 58 } 59 } 60 | Popular Tags |