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.Description; 22 import org.apache.juddi.datatype.binding.AccessPoint; 23 import org.apache.juddi.datatype.binding.BindingTemplate; 24 import org.apache.juddi.datatype.binding.TModelInstanceInfo; 25 import org.apache.juddi.datatype.business.BusinessEntity; 26 import org.apache.juddi.datatype.service.BusinessService; 27 import org.apache.juddi.util.Config; 28 import org.apache.juddi.util.jdbc.Transaction; 29 import org.apache.juddi.uuidgen.UUIDGen; 30 import org.apache.juddi.uuidgen.UUIDGenFactory; 31 32 35 class TestInstanceDetailsDescTable 36 { 37 public static void main(String [] args) 38 throws Exception 39 { 40 Config.setStringProperty("juddi.useConnectionPool","true"); 43 44 Connection conn = null; 45 try { 46 conn = Database.aquireConnection(); 47 test(conn); 48 } 49 finally { 50 if (conn != null) 51 conn.close(); 52 } 53 } 54 55 public static void test(Connection connection) throws Exception 56 { 57 Transaction txn = new Transaction(); 58 UUIDGen uuidgen = UUIDGenFactory.getUUIDGen(); 59 60 if (connection != null) 61 { 62 try 63 { 64 String businessKey = uuidgen.uuidgen(); 65 BusinessEntity business = new BusinessEntity(); 66 business.setBusinessKey(businessKey); 67 business.setAuthorizedName("sviens"); 68 business.setOperator("WebServiceRegistry.com"); 69 70 String serviceKey = uuidgen.uuidgen(); 71 BusinessService service = new BusinessService(); 72 service.setBusinessKey(businessKey); 73 service.setServiceKey(serviceKey); 74 75 String bindingKey = uuidgen.uuidgen(); 76 BindingTemplate binding = new BindingTemplate(); 77 binding.setServiceKey(serviceKey); 78 binding.setBindingKey(bindingKey); 79 binding.setAccessPoint( 80 new AccessPoint("http://www.juddi.org/bindingtemplate.html", "http")); 81 82 Vector infoList = new Vector (); 83 infoList.add(new TModelInstanceInfo(uuidgen.uuidgen())); 84 int infoID = 0; 85 86 Vector descList = new Vector (); 87 descList.add(new Description("blah, blah, blah", "en")); 88 descList.add(new Description("Yadda, Yadda, Yadda", "it")); 89 descList.add(new Description("WhoobWhoobWhoobWhoob", "cy")); 90 descList.add(new Description("Haachachachacha", "km")); 91 92 String authorizedUserID = "sviens"; 93 94 txn.begin(connection); 96 97 BusinessEntityTable.insert(business, authorizedUserID, connection); 99 100 BusinessServiceTable.insert(service, connection); 102 103 BindingTemplateTable.insert(binding, connection); 105 106 TModelInstanceInfoTable.insert(bindingKey, infoList, connection); 108 109 InstanceDetailsDescTable.insert( 111 bindingKey, 112 infoID, 113 descList, 114 connection); 115 116 descList = 118 InstanceDetailsDescTable.select(bindingKey, infoID, connection); 119 120 InstanceDetailsDescTable.delete(bindingKey, connection); 122 123 descList = 125 InstanceDetailsDescTable.select(bindingKey, infoID, connection); 126 127 txn.commit(); 129 } 130 catch (Exception ex) 131 { 132 try 133 { 134 txn.rollback(); 135 } 136 catch (java.sql.SQLException sqlex) 137 { 138 sqlex.printStackTrace(); 139 } 140 throw ex; 141 } 142 } 143 } 144 } 145 | Popular Tags |