1 16 package org.apache.juddi.datastore.jdbc; 17 18 import java.sql.Connection ; 19 import java.util.Vector ; 20 21 import org.apache.juddi.datatype.KeyedReference; 22 import org.apache.juddi.datatype.business.BusinessEntity; 23 import org.apache.juddi.datatype.service.BusinessService; 24 import org.apache.juddi.util.Config; 25 import org.apache.juddi.util.jdbc.Transaction; 26 import org.apache.juddi.uuidgen.UUIDGen; 27 import org.apache.juddi.uuidgen.UUIDGenFactory; 28 29 32 class TestServiceCategoryTable 33 { 34 public static void main(String [] args) 35 throws Exception 36 { 37 Config.setStringProperty("juddi.useConnectionPool","true"); 40 41 Connection conn = null; 42 try { 43 conn = Database.aquireConnection(); 44 test(conn); 45 } 46 finally { 47 if (conn != null) 48 conn.close(); 49 } 50 } 51 52 public static void test(Connection connection) throws Exception 53 { 54 Transaction txn = new Transaction(); 55 UUIDGen uuidgen = UUIDGenFactory.getUUIDGen(); 56 57 if (connection != null) 58 { 59 try 60 { 61 String businessKey = uuidgen.uuidgen(); 62 BusinessEntity business = new BusinessEntity(); 63 business.setBusinessKey(businessKey); 64 business.setAuthorizedName("sviens"); 65 business.setOperator("WebServiceRegistry.com"); 66 67 String serviceKey = uuidgen.uuidgen(); 68 BusinessService service = new BusinessService(); 69 service.setServiceKey(serviceKey); 70 service.setBusinessKey(businessKey); 71 72 Vector keyRefs = new Vector (); 73 keyRefs.add(new KeyedReference(uuidgen.uuidgen(), "blah, blah, blah")); 74 keyRefs.add( 75 new KeyedReference(uuidgen.uuidgen(), "Yadda, Yadda, Yadda")); 76 keyRefs.add( 77 new KeyedReference(uuidgen.uuidgen(), "WhoobWhoobWhoobWhoob")); 78 79 String authorizedUserID = "sviens"; 80 81 txn.begin(connection); 83 84 BusinessEntityTable.insert(business, authorizedUserID, connection); 86 87 BusinessServiceTable.insert(service, connection); 89 90 ServiceCategoryTable.insert(serviceKey, keyRefs, connection); 92 93 service.setServiceKey(uuidgen.uuidgen()); 95 BusinessServiceTable.insert(service, connection); 96 97 ServiceCategoryTable.insert( 99 service.getServiceKey(), 100 keyRefs, 101 connection); 102 103 keyRefs = ServiceCategoryTable.select(serviceKey, connection); 105 106 ServiceCategoryTable.delete(serviceKey, connection); 108 109 keyRefs = ServiceCategoryTable.select(serviceKey, connection); 111 112 txn.commit(); 114 } 115 catch (Exception ex) 116 { 117 try 118 { 119 txn.rollback(); 120 } 121 catch (java.sql.SQLException sqlex) 122 { 123 sqlex.printStackTrace(); 124 } 125 throw ex; 126 } 127 } 128 } 129 } 130 | Popular Tags |