public void doAction(CommandContext commandContext) {
    try {
      TestSuite suite = new TestSuite();
      commandContext.setAttribute("testsuite", suite);

      TestContext testContext = new TestContext();
      suite.setContext(testContext);
      suite.getContext().setAttribute("android:context", Registry.getActiveInstance().getContext());

      testContext.setAttribute("service", "testServerBean");
      testContext.setAttribute("identifier", "IMEI:8675309");

      // This will cleanup any old configuration
      Context context = Registry.getActiveInstance().getContext();
      Database db = Database.getInstance(context);
      db.dropTable(Database.provisioning_table);
      db.createTable(Database.provisioning_table);

      // Activate the device
      ActivationUtil.activateDevice(suite);

      // Load the tests
      suite.load();

      suite.execute(commandContext);
    } catch (Exception e) {
      e.printStackTrace(System.out);
      throw new RuntimeException(e);
    }
  }
예제 #2
0
  // This does not execute on the UI thread. When this method is invoked, the UI thread is freed up,
  // so that its not frozen while the
  // information is being loaded from the Cloud
  public void doAction(CommandContext commandContext) {
    try {
      // Populate the Cloud Request
      Request request = new Request("/test/start/push");
      request.setAttribute("message", "Hello Push");
      request.setAttribute("app-id", Registry.getActiveInstance().getContext().getPackageName());

      Response response = new MobileService().invoke(request);
    } catch (Exception e) {
      // throw an AppException. If this happens, the doViewError will be invoked to alert the user
      // with an error message
      AppException appe = new AppException();
      appe.setMessage(e.getMessage());

      // Record this error in the Cloud Error Log
      ErrorHandler.getInstance().handle(appe);

      throw appe;
    }
  }
예제 #3
0
  public TestSuite() {
    this.tests = new Vector();
    this.errors = new Vector();

    try {
      // Load up cloud activation related configuration
      Properties properties = new Properties();
      properties.load(TestSuite.class.getResourceAsStream("/moblet-app/activation.properties"));

      this.cloudServer = properties.getProperty("cloud_server_ip");
      this.email = properties.getProperty("email");
      this.password = properties.getProperty("password");

      Context context = Registry.getActiveInstance().getContext();
      final Configuration conf = Configuration.getInstance(context);
      String registeredIp = conf.getServerIp();
      if (registeredIp != null && registeredIp.trim().length() > 0) {
        this.cloudServer = registeredIp;
      }
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }