1 16 package org.apache.juddi.datastore.jdbc; 17 18 import java.sql.Connection ; 19 20 import org.apache.juddi.datatype.publisher.Publisher; 21 import org.apache.juddi.util.Config; 22 import org.apache.juddi.util.jdbc.Transaction; 23 import org.apache.juddi.uuidgen.UUIDGen; 24 import org.apache.juddi.uuidgen.UUIDGenFactory; 25 26 29 class TestAuthTokenTable 30 { 31 public static void main(String [] args) 32 throws Exception 33 { 34 Config.setStringProperty("juddi.useConnectionPool","true"); 37 38 Connection conn = null; 39 try { 40 conn = Database.aquireConnection(); 41 test(conn); 42 } 43 finally { 44 if (conn != null) 45 conn.close(); 46 } 47 } 48 49 public static void test(Connection connection) 50 throws Exception 51 { 52 Transaction txn = new Transaction(); 53 UUIDGen uuidgen = UUIDGenFactory.getUUIDGen(); 54 55 if (connection != null) 56 { 57 try 58 { 59 txn.begin(connection); 61 62 String authToken1 = "juddi:"+uuidgen.uuidgen(); 63 AuthTokenTable.insert(authToken1,new Publisher("sviens","Steve Viens"),connection); 64 AuthTokenTable.selectLastUsed(authToken1,connection); 65 66 String authToken2 = "juddi:"+uuidgen.uuidgen(); 67 AuthTokenTable.insert(authToken2,new Publisher("sviens","Steve Viens"),connection); 68 AuthTokenTable.selectLastUsed(authToken2,connection); 69 70 System.out.println("PublisherID: "+AuthTokenTable.selectPublisher(authToken1,connection)); 71 72 AuthTokenTable.delete(authToken1,connection); 73 74 Thread.sleep(3000); 75 76 AuthTokenTable.touch(authToken2,connection); 77 AuthTokenTable.touch(authToken2,connection); 78 AuthTokenTable.touch(authToken2,connection); 79 AuthTokenTable.selectLastUsed(authToken2,connection); 80 AuthTokenTable.touch(authToken2,connection); 81 AuthTokenTable.touch(authToken2,connection); 82 AuthTokenTable.touch(authToken2,connection); 83 AuthTokenTable.selectLastUsed(authToken2,connection); 84 AuthTokenTable.touch(authToken2,connection); 85 AuthTokenTable.touch(authToken2,connection); 86 AuthTokenTable.touch(authToken2,connection); 87 AuthTokenTable.selectLastUsed(authToken2,connection); 88 AuthTokenTable.touch(authToken2,connection); 89 AuthTokenTable.invalidate(authToken2,connection); 90 AuthTokenTable.selectLastUsed(authToken2,connection); 91 92 System.out.println("PublisherID: "+AuthTokenTable.selectPublisher(authToken1,connection)); 93 System.out.println("PublisherID: "+AuthTokenTable.selectPublisher(authToken2,connection)); 94 95 txn.commit(); 97 } 98 catch(Exception ex) 99 { 100 try { txn.rollback(); } 101 catch(java.sql.SQLException sqlex) { sqlex.printStackTrace(); } 102 throw ex; 103 } 104 } 105 } 106 } 107 | Popular Tags |