You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by tf...@apache.org on 2005/04/23 16:58:14 UTC

cvs commit: db-torque/src/rttest test-schema.xml

tfischer    2005/04/23 07:58:14

  Modified:    src/rttest/org/apache/torque DataTest.java
               src/rttest test-schema.xml
  Log:
  Added a test case which checks selecting from boolean columns.
  Tests TRQS221
  
  Revision  Changes    Path
  1.15      +42 -1     db-torque/src/rttest/org/apache/torque/DataTest.java
  
  Index: DataTest.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/rttest/org/apache/torque/DataTest.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- DataTest.java	26 Mar 2005 17:38:39 -0000	1.14
  +++ DataTest.java	23 Apr 2005 14:58:14 -0000	1.15
  @@ -110,11 +110,13 @@
               bc.setTestKey("t1");
               bc.setBintValue(true);
               bc.setBcharValue(true);
  +            bc.setBitValue(true);
               bc.save();
               bc = new BooleanCheck();
               bc.setTestKey("f1");
               bc.setBintValue(false);
               bc.setBcharValue(false);
  +            bc.setBitValue(false);
               bc.save();
           }
           catch (Exception ex)
  @@ -241,11 +243,15 @@
                       + bc.getBintValue(), bc.getBintValue());
               assertTrue("BOOLEANCHAR should be true but is: " 
                       + bc.getBcharValue(), bc.getBcharValue());
  +            assertTrue("BIT should be true but is: " 
  +                    + bc.getBitValue(), bc.getBitValue());
               bc = BooleanCheckPeer.retrieveByPK(new StringKey("f1"));
               assertFalse("BOOLEANINT should be false but is: " 
                       + bc.getBintValue(), bc.getBintValue());
               assertFalse("BOOLEANCHAR should be false but is: " 
                       + bc.getBcharValue(), bc.getBcharValue());
  +            assertFalse("BIT should be false but is: " 
  +                    + bc.getBitValue(), bc.getBitValue());
           }
           catch (Exception ex)
           {
  @@ -255,6 +261,41 @@
                       + " : " + ex.getMessage());
           }
       }
  +    
  +    /**
  +     * check whether we can select from boolean columns 
  +     * @throws Exception if the test fails
  +     */
  +    public void testBooleanSelects() throws Exception
  +    {
  +        Criteria criteria = new Criteria();
  +        criteria.add(BooleanCheckPeer.BCHAR_VALUE, new Boolean(true));
  +        criteria.add(BooleanCheckPeer.BINT_VALUE, new Boolean(true));
  +        criteria.add(BooleanCheckPeer.BIT_VALUE, new Boolean(true));
  +        List booleanCheckList = BooleanCheckPeer.doSelect(criteria);
  +        assertTrue("Should have read 1 dataset with both values true "
  +                + "but read " + booleanCheckList.size(), 
  +                booleanCheckList.size() == 1);
  +        BooleanCheck booleanCheck = (BooleanCheck) booleanCheckList.get(0);
  +        // use trim() for testkey because some databases will return the
  +        // testkey filled up with blanks, as it is defined as char(10)
  +        assertTrue("Primary key of data set should be t1 but is "
  +                + booleanCheck.getTestKey().trim(),
  +                "t1".equals(booleanCheck.getTestKey().trim()));
  +        
  +        criteria.clear();
  +        criteria.add(BooleanCheckPeer.BCHAR_VALUE, new Boolean(false));
  +        criteria.add(BooleanCheckPeer.BINT_VALUE, new Boolean(false));
  +        criteria.add(BooleanCheckPeer.BIT_VALUE, new Boolean(false));
  +        booleanCheckList = BooleanCheckPeer.doSelect(criteria);
  +        assertTrue("Should have read 1 dataset with both values false "
  +                + "but read " + booleanCheckList.size(), 
  +                booleanCheckList.size() == 1);
  +        booleanCheck = (BooleanCheck) booleanCheckList.get(0);
  +        assertTrue("Primary key of data set should be f1 but is "
  +                + booleanCheck.getTestKey().trim(),
  +                "f1".equals(booleanCheck.getTestKey().trim()));
  +    }
   
       /**
        * test whether delete works as expected
  
  
  
  1.19      +1 -0      db-torque/src/rttest/test-schema.xml
  
  Index: test-schema.xml
  ===================================================================
  RCS file: /home/cvs/db-torque/src/rttest/test-schema.xml,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- test-schema.xml	21 Jan 2004 23:05:58 -0000	1.18
  +++ test-schema.xml	23 Apr 2005 14:58:14 -0000	1.19
  @@ -152,6 +152,7 @@
       <column name="test_key" required="true" primaryKey="true" type="CHAR" size="10" />
       <column name="bint_value" required="true" type="BOOLEANINT" />
       <column name="bchar_value" required="true" type="BOOLEANCHAR" />
  +    <column name="bit_value" required="true" type="BIT" />
     </table>
   
     <!-- TRQS97 -->
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org