コード例 #1
0
  // unit test-driver
  public static void main(String[] args) {
    org.juddi.util.SysManager.startup();

    try {
      Connection connection = (new org.juddi.datastore.jdbc.HSQLDataStoreFactory()).getConnection();
      test(connection);
      connection.close();
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    org.juddi.util.SysManager.shutdown();
  }
コード例 #2
0
  // system test-driver
  public static void test(Connection connection) {
    Transaction txn = new Transaction();

    if (connection != null) {
      try {
        String businessKey = UUID.nextID();
        BusinessEntity business = new BusinessEntity();
        business.setBusinessKey(businessKey);
        business.setAuthorizedName("sviens");
        business.setOperator("WebServiceRegistry.com");

        String serviceKey = UUID.nextID();
        BusinessService service = new BusinessService();
        service.setBusinessKey(businessKey);
        service.setServiceKey(serviceKey);

        // begin a new transaction
        txn.begin(connection);

        String authorizedUserID = "sviens";

        // insert a new BusinessEntity
        BusinessEntityTable.insert(business, authorizedUserID, connection);

        // insert a new BusinessService
        BusinessServiceTable.insert(service, connection);

        // insert another new BusinessService
        service.setServiceKey(UUID.nextID());
        BusinessServiceTable.insert(service, connection);

        // insert one more new BusinessService
        service.setServiceKey(UUID.nextID());
        BusinessServiceTable.insert(service, connection);

        // select a BusinessService object
        service = BusinessServiceTable.select(serviceKey, connection);

        // delete a BusinessService object
        BusinessServiceTable.delete(serviceKey, connection);

        // select a BusinessService object
        service = BusinessServiceTable.select(serviceKey, connection);

        // select a Collection BusinessService objects by BusinessKey
        BusinessServiceTable.selectByBusinessKey(businessKey, connection);

        // delete a Collection BusinessService objects by BusinessKey
        BusinessServiceTable.deleteByBusinessKey(businessKey, connection);

        // select a Collection BusinessService objects by BusinessKey
        BusinessServiceTable.selectByBusinessKey(businessKey, connection);

        // commit the transaction
        txn.commit();
      } catch (Exception ex) {
        ex.printStackTrace();
        try {
          txn.rollback();
        } catch (java.sql.SQLException sqlex) {
          sqlex.printStackTrace();
        }
      }
    }
  }