1 16 package org.apache.juddi.datastore.jdbc; 17 18 import java.sql.Connection ; 19 20 import org.apache.juddi.datatype.OverviewDoc; 21 import org.apache.juddi.datatype.tmodel.TModel; 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 TestTModelTable 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 OverviewDoc overviewDoc = new OverviewDoc(); 61 overviewDoc.setOverviewURL("http://www.sviens.com/jtruss.html"); 62 63 String tModelKey = uuidgen.uuidgen(); 64 TModel tModel = new TModel(); 65 tModel.setTModelKey(tModelKey); 66 tModel.setAuthorizedName("Steve Viens"); 67 tModel.setOperator("WebServiceRegistry.com"); 68 tModel.setName("Tuscany Web Service Company"); 69 tModel.setOverviewDoc(overviewDoc); 70 71 String publisherID = "sviens"; 72 73 txn.begin(connection); 75 76 TModelTable.insert(tModel,publisherID,connection); 78 79 tModel = TModelTable.select(tModelKey,connection); 81 82 TModelTable.selectByPublisherID(publisherID,connection); 84 85 TModelTable.verifyOwnership(tModelKey,"mviens",connection); 86 TModelTable.verifyOwnership(tModelKey,"sviens",connection); 87 88 TModelTable.delete(tModelKey,connection); 90 92 tModel = TModelTable.select(tModelKey,connection); 94 95 TModelTable.selectByPublisherID(publisherID,connection); 97 98 txn.commit(); 100 } 101 catch(Exception ex) 102 { 103 try { txn.rollback(); } 104 catch(java.sql.SQLException sqlex) { sqlex.printStackTrace(); } 105 throw ex; 106 } 107 } 108 } 109 } 110 | Popular Tags |