You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by ar...@apache.org on 2002/11/28 23:33:02 UTC

cvs commit: jakarta-ojb/src/test/org/apache/ojb/odmg ScrollableQueryResultsTest.java

arminw      2002/11/28 14:33:02

  Modified:    src/test/org/apache/ojb/broker
                        PerformanceJdbcReferenceTest.java
               src/test/org/apache/ojb/odmg ScrollableQueryResultsTest.java
  Log:
  update test cases
  
  Revision  Changes    Path
  1.5       +6 -6      jakarta-ojb/src/test/org/apache/ojb/broker/PerformanceJdbcReferenceTest.java
  
  Index: PerformanceJdbcReferenceTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/test/org/apache/ojb/broker/PerformanceJdbcReferenceTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PerformanceJdbcReferenceTest.java	29 Sep 2002 09:18:24 -0000	1.4
  +++ PerformanceJdbcReferenceTest.java	28 Nov 2002 22:33:02 -0000	1.5
  @@ -133,7 +133,7 @@
           // the repository.xml file.
           ClassDescriptor cld = broker.getClassDescriptor(PerformanceArticle.class);
           JdbcConnectionDescriptor jcd = cld.getConnectionDescriptor();
  -        ConnectionFactory cf = ConnectionFactoryFactory.getConnectionFactory(jcd);
  +        ConnectionFactory cf = ConnectionFactoryFactory.getInstance();
           Connection conn = cf.lookupConnection(jcd);
           return conn;
       }
  @@ -181,7 +181,7 @@
       protected void insertNewArticles() throws Exception
       {
       	clearTable();
  -    	
  +
           Connection conn = getConnection();
   
           // Use the OJB SqlGenerator to generate SQL Statements. All details about
  @@ -250,7 +250,7 @@
           ClassDescriptor cld = broker.getClassDescriptor(PerformanceArticle.class);
           String sql = SqlGeneratorFactory.getInstance().createSqlGenerator().getPreparedSelectByPkStatement(cld);
           logger.debug("select stmt: " + sql);
  -        
  +
   		String colId = cld.getFieldDescriptorByName("articleId").getColumnName();
   		String colName = cld.getFieldDescriptorByName("articleName").getColumnName();
   		String colSupplier = cld.getFieldDescriptorByName("supplierId").getColumnName();
  @@ -327,9 +327,9 @@
   		String colStock = cld.getFieldDescriptorByName("stock").getColumnName();
   		String colOrdered = cld.getFieldDescriptorByName("orderedUnits").getColumnName();
   		String colMin = cld.getFieldDescriptorByName("minimumStock").getColumnName();
  -        
  -        
  -        
  +
  +
  +
           int fetchCount = 0;
           long start = System.currentTimeMillis();
           try
  
  
  
  1.11      +46 -43    jakarta-ojb/src/test/org/apache/ojb/odmg/ScrollableQueryResultsTest.java
  
  Index: ScrollableQueryResultsTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/test/org/apache/ojb/odmg/ScrollableQueryResultsTest.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ScrollableQueryResultsTest.java	26 Oct 2002 16:24:10 -0000	1.10
  +++ ScrollableQueryResultsTest.java	28 Nov 2002 22:33:02 -0000	1.11
  @@ -323,6 +323,12 @@
        */
       public void testGetSomeC() throws Exception
       {
  +        // only perform this test in singlevm mode
  +        if (((PersistenceBrokerConfiguration) PersistenceBrokerFactory.getConfigurator().getConfigurationFor(null)).
  +                    isRunningInServerMode())
  +        {
  +            return;
  +        }
           Implementation odmg = OJB.getInstance();
           Database db = odmg.newDatabase();
           db.open(databaseName, Database.OPEN_READ_WRITE);
  @@ -341,50 +347,47 @@
               TransactionImpl tx = (TransactionImpl) odmg.newTransaction();
               tx.begin();
               PersistenceBroker broker = tx.getBroker();
  -            // only perform this test in singlevm mode
  -            if (broker instanceof PersistenceBrokerImpl)
  -            {
  -                Connection conn =
  -                        broker
  -                        .getConnectionManager()
  -                        .getConnection();
  -                /**
  -                 * only execute this test if scrolling is supported.
  -                 */
  -                if (!conn
  -                        .getMetaData()
  -                        .supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE))
  -                {
  -                    return;
  -                }
   
  -                EnhancedOQLQuery query = odmg.newOQLQuery();
  -                String sql =
  -                        "select somePersons from "
  -                        + org.apache.ojb.broker.Person.class.getName();
  -                query.create(sql, start, end);
  -
  -                ManageableCollection somePersons =
  -                        (ManageableCollection) query.execute();
  -                // Iterator over the restricted articles objects
  -                java.util.Iterator it = somePersons.ojbIterator();
  -                int count = 0;
  -                while (it.hasNext())
  -                {
  -                    it.next();
  -                    count++;
  -                }
  +            Connection conn =
  +                    broker
  +                    .getConnectionManager()
  +                    .getConnection();
  +            /**
  +             * only execute this test if scrolling is supported.
  +             */
  +            if (!conn
  +                    .getMetaData()
  +                    .supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE))
  +            {
                   tx.commit();
  -                // check that we got the right amount back.
  -                if (count != (CONTROL_SIZE - start +1)) /* +1 because the last row is inclusive */
  -                {
  -                    fail(
  -                            "count not right, found <"
  -                            + count
  -                            + "> should have got <"
  -                            + (CONTROL_SIZE - start + 1)
  -                            + "> This failure is expected if your driver doesn't support advanced JDBC operations.");
  -                }
  +                return;
  +            }
  +
  +            EnhancedOQLQuery query = odmg.newOQLQuery();
  +            String sql =
  +                    "select somePersons from "
  +                    + org.apache.ojb.broker.Person.class.getName();
  +            query.create(sql, start, end);
  +            ManageableCollection somePersons =
  +                    (ManageableCollection) query.execute();
  +            // Iterator over the restricted articles objects
  +            java.util.Iterator it = somePersons.ojbIterator();
  +            int count = 0;
  +            while (it.hasNext())
  +            {
  +                it.next();
  +                count++;
  +            }
  +            tx.commit();
  +            // check that we got the right amount back.
  +            if (count != (CONTROL_SIZE - start +1)) /* +1 because the last row is inclusive */
  +            {
  +                fail(
  +                        "count not right, found <"
  +                        + count
  +                        + "> should have got <"
  +                        + (CONTROL_SIZE - start + 1)
  +                        + "> This failure is expected if your driver doesn't support advanced JDBC operations.");
               }
           }
           finally