Subject | Re: After UDF exception, the current connection stops working |
---|---|
Author | vmdd_tech |
Post date | 2004-01-08T17:27:34Z |
Roman,
Can you modify the test case to use:
String query = "SELECT id, substr(long_str,1,2) FROM test_table ORDER
BY id DESC";
Thanks,
Ben
--- In Firebird-Java@yahoogroups.com, "Roman Rokytskyy"
<rrokytskyy@a...> wrote:
Can you modify the test case to use:
String query = "SELECT id, substr(long_str,1,2) FROM test_table ORDER
BY id DESC";
Thanks,
Ben
--- In Firebird-Java@yahoogroups.com, "Roman Rokytskyy"
<rrokytskyy@a...> wrote:
> Hi,See CVS.
>
> > Your test case did not really cover what I reported. Below is
> > a modification of your test case. (I am sorry I don't know how
> > to write junit test case):
>
> Sorry, probably I understood you wrong.
>
> >
> >
> > Object tmp = rs.getObject (1); //This should
> > cause null pointer exception
>
> I modified test case, but it does not cause NullPointerException.
>case
> As to the writing test cases. Concept is very simple. JUnit test
> has to implement junit.framework.Test interface (usually peopleextend
> junit.framework.TestCase class, I assume you do the same). Each testto
> case has its setup method (protected void setUp()) where some stuff
> initialize test case is performed. Also it has a cleanup methodcase.
> (protected void tearDown()) that is called after test case execution
> to clean everything that was setup by the setUp() method. Then all
> public void methods that start with "test" are considered as a test
>two
> Example:
>
> public class MyTestCase extends junit.framework.TestCase {
> public MyTestCase(String name) {
> super(name);
> }
>
> private int testValue;
>
> protected void setUp() {
> testValue = 5;
> }
>
> protected void tearDown() {
> testValue = 0;
> }
>
> public void testArithmetic() throws Exception {
> int a = 2;
> int b = 3;
> int c = a + b;
> assertTrue("Value should be correct.", c == testValue);
> }
> }
>
> In order to execute test case you have to use "runner". There are
> runners: Swing-based and text-based. I prefer latter.executing
>
> public class RunMyTestCase {
> public void main(String[] args) throws Exception {
> junit.textui.TestRunner.run(MyTestCase.class);
> }
> }
>
> This code will create instance of MyTestCase class, it will call
> setUp() method, then testArithmetics() and then tearDown() method.
> Such sequence is kept for each method that starts with "test".
>
> If you want to create test cases for JayBird, you should extend
> org.firebirdsql.common.FBTestBase. Do not forget to override setUp()
> and tearDown() methods like this:
>
> protected void setUp() throws Exception {
> super.setUp();
> // your code to setup test case
> }
>
> protected void tearDown() throws Exception {
> // your cleanup code
> super.tearDown();
> }
>
> This guarantees you that you will have fresh database before
> your test case.
>
> Best regards,
> Roman Rokytskyy