Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

BatchToolTest.java

Go to the documentation of this file.
00001 package net.threebit.utils.sosc.test;
00002 
00003 /*
00004         Copyright 2003 Shawn Deleurme
00005         Copyright 2003 Kevin O'Donnell
00006 
00007         This program is free software; you can redistribute it and/or modify
00008         it under the terms of the GNU General Public License as published by
00009         the Free Software Foundation; either version 2 of the License, or
00010         (at your option) any later version.
00011 
00012         This program is distributed in the hope that it will be useful,
00013         but WITHOUT ANY WARRANTY; without even the implied warranty of
00014         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015         GNU General Public License for more details.
00016 
00017         You should have received a copy of the GNU General Public License
00018         along with this program; if not, write to the Free Software
00019         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 */
00021 
00022 import java.io.*;
00023 import java.sql.*;
00024 import java.util.*;
00025 import javax.xml.transform.stream.*;
00026 import javax.xml.transform.*;
00027 import junit.framework.*;
00028 import net.threebit.utils.sosc.*;
00029 import java.util.logging.*;
00030 
00035 public class BatchToolTest extends TestCase {
00036 
00037         String url = System.getProperty("net.threebit.utils.sosc.DbTool.jdbcURL");
00038         String className = System.getProperty("net.threebit.utils.sosc.DbTool.jdbcURLClassName");
00039         String userName = System.getProperty("net.threebit.utils.sosc.DbTool.jdbcURLUserName");
00040         String password = System.getProperty("net.threebit.utils.sosc.DbTool.jdbcURLPassword");
00041 
00042         private BatchTool getBt() throws Exception {
00043                 if (url == null) { throw new Exception("net.threebit.utils.sosc.DbTool.jdbcURL property has not been set"); }
00044                 if (className == null) { throw new Exception("net.threebit.utils.sosc.DbTool.jdbcURLClassName property has not been set"); }
00045                 if (userName == null) { throw new Exception("net.threebit.utils.sosc.DbTool.jdbcURLUserName property has not been set"); }
00046                 if (password == null) { throw new Exception("net.threebit.utils.sosc.DbTool.jdbcURLPassword property has not been set"); }
00047                 BatchTool bt = new BatchTool("BatchToolTest", className, url, userName, password);
00048                 try { bt.dropSchema("mssql"); bt.createSchema("mssql"); } catch (Exception e) { }
00049                 return bt;
00050         }
00051 
00052         public void test1() throws Exception {
00053                 BatchTool bt = getBt();
00054                 int i = bt.createProfile("test1");
00055                 int j = bt.createProfile("test2");
00056 
00057                 assertTrue(i != 0);
00058                 assertTrue(j != 0);
00059                 assertTrue(j == (i+1));
00060 
00061                 assertTrue(i == bt.getProfileId("test1"));
00062                 assertTrue(j == bt.getProfileId("test2"));
00063 
00064                 int b1 = bt.createBatch("test1");
00065                 int b2 = bt.createBatch("test1");
00066                 assertTrue(b2 == (b1+1));
00067 
00068                 bt.addIntContents("select " + b1 + ",9000");
00069                 assertTrue(bt.rowCount( bt.getBatchContents(b1)) == 1);
00070 
00071                 bt.addIntContents("select " + b1 + ",9001");
00072                 assertTrue(bt.rowCount( bt.getBatchContents(b1)) == 2);
00073 
00074                 b2 = bt.createBatch("test1");
00075                 bt.addIntContents (b2, bt.query("select 2001 as content, 'val1' as key1, 'val2' as key2"));
00076 
00077         }
00078 
00079 }

Generated on Mon Jul 14 17:19:19 2003 for SOSC by doxygen1.2.15