X-Git-Url: http://jaekl.net/gitweb/?a=blobdiff_plain;f=test%2Fnet%2Fjaekl%2Fcfb%2Fstore%2FDbStoreTest.java;h=9c6c1175c0b56098d4544901201d87bb59936db4;hb=0e31a70d77e7f8ff71484a18e9d0ced52183686a;hp=5c66c225fd38107d7e866d826bf43be269a68616;hpb=a1378c84c773511e4ffe99fb419da67af188aff7;p=cfb.git diff --git a/test/net/jaekl/cfb/store/DbStoreTest.java b/test/net/jaekl/cfb/store/DbStoreTest.java index 5c66c22..9c6c117 100644 --- a/test/net/jaekl/cfb/store/DbStoreTest.java +++ b/test/net/jaekl/cfb/store/DbStoreTest.java @@ -23,6 +23,7 @@ import net.jaekl.cfb.db.driver.ConnectionMock; import net.jaekl.cfb.db.driver.DbDriverMock; import net.jaekl.cfb.util.Command; import net.jaekl.cfb.xml.BugCollection; +import net.jaekl.cfb.xml.LocalVariable; import net.jaekl.cfb.xml.MessagesXmlData; import org.junit.Before; @@ -274,4 +275,33 @@ public class DbStoreTest { assertEquals(StoreException.Type.INVALID_LOC_ID, exc.getType()); } } + + @Test + public void testGetVar_nullReturnsNull() throws SQLException, TypeMismatchException, StoreException { + LocalVariable var = m_store.getVar(null); + assertNull(var); + } + + @Test + public void testGetVar_invalidId() throws SQLException, TypeMismatchException { + try { + m_store.getVar(Long.valueOf(-3)); + fail("Should have thrown a StoreException"); + } + catch (StoreException exc) { + assertEquals(StoreException.Type.INVALID_VAR_ID, exc.getType()); + } + } + + @Test + public void testGetVarId_notFoundIsStored() throws SQLException, TypeMismatchException { + LocalVariable var = new LocalVariable(2345678901L, "VariableNameDoesNotYetExist", "VARIABLE_READ"); + + Long varId = m_store.getVarId(var); + assertNotNull(varId); + assertTrue(varId.longValue() > 0); + + Long secondVarId = m_store.getVarId(var); + assertEquals(varId, secondVarId); + } }