1 16 package org.apache.juddi.datastore.jdbc; 17 18 import java.sql.Connection ; 19 20 import org.apache.juddi.datatype.business.BusinessEntity; 21 import org.apache.juddi.datatype.service.BusinessService; 22 import org.apache.juddi.util.Config; 23 import org.apache.juddi.util.jdbc.Transaction; 24 import org.apache.juddi.uuidgen.UUIDGen; 25 import org.apache.juddi.uuidgen.UUIDGenFactory; 26 27 30 class TestBusinessServiceTable 31 { 32 public static void main(String [] args) 33 throws Exception 34 { 35 Config.setStringProperty("juddi.useConnectionPool","true"); 38 39 Connection conn = null; 40 try { 41 conn = Database.aquireConnection(); 42 test(conn); 43 } 44 finally { 45 if (conn != null) 46 conn.close(); 47 } 48 } 49 50 public static void test(Connection connection) 51 throws Exception 52 { 53 Transaction txn = new Transaction(); 54 UUIDGen uuidgen = UUIDGenFactory.getUUIDGen(); 55 56 if (connection != null) 57 { 58 try 59 { 60 String businessKey = uuidgen.uuidgen(); 61 BusinessEntity business = new BusinessEntity(); 62 business.setBusinessKey(businessKey); 63 business.setAuthorizedName("sviens"); 64 business.setOperator("WebServiceRegistry.com"); 65 66 String serviceKey = uuidgen.uuidgen(); 67 BusinessService service = new BusinessService(); 68 service.setBusinessKey(businessKey); 69 service.setServiceKey(serviceKey); 70 71 txn.begin(connection); 73 74 String authorizedUserID = "sviens"; 75 76 BusinessEntityTable.insert(business,authorizedUserID,connection); 78 79 BusinessServiceTable.insert(service,connection); 81 82 service.setServiceKey(uuidgen.uuidgen()); 84 BusinessServiceTable.insert(service,connection); 85 86 service.setServiceKey(uuidgen.uuidgen()); 88 BusinessServiceTable.insert(service,connection); 89 90 service = BusinessServiceTable.select(serviceKey,connection); 92 93 BusinessServiceTable.delete(serviceKey,connection); 95 96 service = BusinessServiceTable.select(serviceKey,connection); 98 99 BusinessServiceTable.selectByBusinessKey(businessKey,connection); 101 102 BusinessServiceTable.deleteByBusinessKey(businessKey,connection); 104 105 BusinessServiceTable.selectByBusinessKey(businessKey,connection); 107 108 txn.commit(); 110 } 111 catch(Exception ex) 112 { 113 try { txn.rollback(); } 114 catch(java.sql.SQLException sqlex) { sqlex.printStackTrace(); } 115 throw ex; 116 } 117 } 118 } 119 } 120 | Popular Tags |