Exemplo n.º 1
0
 public static int getDB(String sql) {
   try {
     ASA db = new ASA();
     db.setProperty("host", "localhost");
     db.setProperty("login", "dba");
     db.setProperty("password", "sql");
     db.setProperty("port", "5500");
     db.setProperty("driverClass", "com.sybase.jdbc3.jdbc.SybDriver");
     List result = DBUtil.runSQLForResult((IDBResource) db, sql);
     System.out.println(result.size());
     return result.size();
   } catch (Exception e) {
     e.printStackTrace();
     throw new RuntimeException("Failed to get record data from DB");
   }
 }
Exemplo n.º 2
0
  public static void testMain(Object[] args) {

    objectmap map = new objectmap();

    axeInit("C:\\AXE_Projects\\TestHarnessAPI\\TestHarnessAPI.tpj", "debug");

    Dispatch.call(
        axe,
        "TestBegin",
        "Test4",
        "Try Database connect 1",
        "C:/AXE_Projects/TestHarnessAPI/data/Tests.xml",
        "Tests",
        "C:/AXE_Projects/TestHarnessAPI/results/debug/results.xml",
        "");
    try {
      //
      // C:/AXE_Projects/TestHarnessAPI/data/Tests.xml:SQLUser Test01
      Dispatch.call(
          axe,
          "SubtestBegin",
          "Test01",
          "",
          "C:/AXE_Projects/TestHarnessAPI/data/Tests.xml",
          "SQLUser");
      Dispatch.call(
          axe, "StepBegin", "[]SQLUser", "set", "select * from accounts where Id in (1,2)");
      Dispatch.put(axe, "ResultCode", 0);
      Dispatch.call(
          harness,
          "DbInitialiseQuery",
          Dispatch.call(axe, "GetRunCategoryOption", "connection", "MySqlLocal"),
          Dispatch.call(
              axe, "GetRunCategoryOptionProperty", "connection", "MySqlLocal", "provider"),
          "select * from accounts where Id in (1,2)",
          "System.Data.DataSet");
      axeStepEnd();

      Dispatch.call(axe, "StepBegin", "[]SQLUser", "Invoke", "");
      Dispatch.put(axe, "ResultCode", 0);
      Dispatch.call(harness, "DbInvoke");
      axeStepEnd();

      Dispatch.call(axe, "StepBegin", "Surname", "get", "");
      Dispatch.put(axe, "ResultCode", 0);
      Dispatch.put(axe, "Value", Dispatch.call(harness, "DbGetResultNodeText", "//Surname", false));
      axeStepEnd();

      Dispatch.call(axe, "StepBegin", "Surname", "val", "");
      Dispatch.put(axe, "ResultCode", 0);
      Dispatch.put(
          axe,
          "ResultCode",
          Dispatch.call(axe, "StepValidateEqual", "", Dispatch.get(axe, "Value")));
      axeStepEnd();
      Dispatch.call(axe, "StepBegin", "ReturnValue", "get", "");
      Dispatch.put(axe, "ResultCode", 0);
      Dispatch.put(axe, "Value", Dispatch.call(harness, "DbGetResult"));
      axeStepEnd();

      Dispatch.call(axe, "StepBegin", "ReturnValue", "val", "");
      Dispatch.put(axe, "ResultCode", 0);
      Dispatch.put(
          axe,
          "ResultCode",
          Dispatch.call(axe, "StepValidateEqual", "", Dispatch.get(axe, "Value")));
      axeStepEnd();
      Dispatch.call(axe, "StepBegin", "IdReturn", "get", "");
      Dispatch.put(axe, "ResultCode", 0);
      Dispatch.put(axe, "Value", Dispatch.call(harness, "DbGetResultNodeText", "//Id", false));
      axeStepEnd();

      Dispatch.call(axe, "StepBegin", "IdReturn", "val", "");
      Dispatch.put(axe, "ResultCode", 0);
      Dispatch.put(
          axe,
          "ResultCode",
          Dispatch.call(axe, "StepValidateEqual", "", Dispatch.get(axe, "Value")));
      axeStepEnd();
      axeSubtestEnd();
      //
      //
    } catch (Exception ex) {
      axeTestAbort(ex.getMessage());
      return;
    }
    Dispatch.call(axe, "TestEnd");
    unregisterAll();
  }