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.DiscoveryURL; 22 import org.apache.juddi.datatype.business.BusinessEntity; 23 import org.apache.juddi.util.Config; 24 import org.apache.juddi.util.jdbc.Transaction; 25 import org.apache.juddi.uuidgen.UUIDGen; 26 import org.apache.juddi.uuidgen.UUIDGenFactory; 27 28 31 class TestDiscoveryURLTable 32 { 33 public static void main(String [] args) 34 throws Exception 35 { 36 Config.setStringProperty("juddi.useConnectionPool","true"); 39 40 Connection conn = null; 41 try { 42 conn = Database.aquireConnection(); 43 test(conn); 44 } 45 finally { 46 if (conn != null) 47 conn.close(); 48 } 49 } 50 51 public static void test(Connection connection) 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 Vector urlList = new Vector (); 67 urlList.add( 68 new DiscoveryURL("businessEntity", "http://www.steveviens.com/abc")); 69 urlList.add( 70 new DiscoveryURL("businessEntity", "http://www.steveviens.com/def")); 71 urlList.add( 72 new DiscoveryURL( 73 "businessEntityExt", 74 "http://www.steveviens.com/ghi")); 75 urlList.add( 76 new DiscoveryURL( 77 "businessEntityExt", 78 "http://www.steveviens.com/jkl")); 79 80 String authorizedUserID = "sviens"; 81 82 txn.begin(connection); 84 85 BusinessEntityTable.insert(business, authorizedUserID, connection); 87 88 DiscoveryURLTable.insert(businessKey, urlList, connection); 90 91 urlList = DiscoveryURLTable.select(businessKey, connection); 93 94 DiscoveryURLTable.delete(businessKey, connection); 96 97 urlList = DiscoveryURLTable.select(businessKey, connection); 99 100 txn.commit(); 102 } 103 catch (Exception ex) 104 { 105 try 106 { 107 txn.rollback(); 108 } 109 catch (java.sql.SQLException sqlex) 110 { 111 sqlex.printStackTrace(); 112 } 113 throw ex; 114 } 115 } 116 } 117 } 118 | Popular Tags |