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

JobToolTest.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 junit.framework.*;
00026 import java.util.logging.*;
00027 import net.threebit.utils.sosc.*;
00028 
00033 public class JobToolTest extends TestCase {
00034 
00035   String url = System.getProperty("net.threebit.utils.sosc.DbTool.jdbcURL");
00036   String className = System.getProperty("net.threebit.utils.sosc.DbTool.jdbcURLClassName");
00037   String userName = System.getProperty("net.threebit.utils.sosc.DbTool.jdbcURLUserName");
00038   String password = System.getProperty("net.threebit.utils.sosc.DbTool.jdbcURLPassword");
00039 
00040   private DbTool getDb() throws Exception {
00041     if (url == null) { throw new Exception("net.threebit.utils.sosc.DbTool.jdbcURL property has not been set"); }
00042     if (className == null) { throw new Exception("net.threebit.utils.sosc.DbTool.jdbcURLClassName property has not been set"); }
00043     if (userName == null) { throw new Exception("net.threebit.utils.sosc.DbTool.jdbcURLUserName property has not been set"); }
00044     if (password == null) { throw new Exception("net.threebit.utils.sosc.DbTool.jdbcURLPassword property has not been set"); }
00045     return new DbTool(className, url,userName,password);
00046   }
00047 
00048         public void test1() throws Exception {
00049                 DbTool db = getDb();
00050                 JobTool jt = JobTool.initialize( db );
00051                 db.update(" delete from " + jt.JOB_TABLE + ";");
00052                 db.update(" delete from " + jt.JOB_ARGUMENTS + ";");
00053 
00054                 Map args = new HashMap();
00055                 args.put("key1","val1");
00056                 args.put("key2","val2");
00057                 Job job = new TestJobClass();
00058                 job.addToJobQueue("myqueue","test job blah blah",args);
00059 
00060                 args = new HashMap();
00061                 args.put("ZXCVZXCV","234234234");
00062                 jt.runJob("myqueue",args);
00063 
00064                 // This guarantees that the queue is empty
00065                 job = jt.runJob("masdfasdlfkajsdflaksjdf",args);
00066         }
00067 
00068 }

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