Java 类javax.naming.TimeLimitExceededException 实例源码

项目:AI    文件:Planner.java   
/**
 * Finds the path from the current state to a state where the goal is
 * fulfilled.
 * 
 * @param goal
 *            The goal to be fulfilled
 * @return a Plan of how to solve the current problem
 */
public Plan findSolution(CompositeGoal goal)
        throws TimeLimitExceededException {
    // TODO Auto-generated method stub
    Plan plan = new Plan();

    int column = 0;
    while (((JSONArray) world.get(column)).isEmpty())
        column++;

    plan.add("I pick up . . .");
    plan.add("pick " + column);
    plan.add(". . . and then I drop down");
    plan.add("drop " + column);

    return plan;
}
项目:cn1    文件:LdapUtilsTest.java   
public void test_getExceptionFromResult() {
    String message = "error message";
    LdapResult result = getLdapResult(0, message);
    NamingException ex = LdapUtils.getExceptionFromResult(result);
    assertNull(ex);

    // error code map to CommunicationException
    result = getLdapResult(2, message);
    ex = LdapUtils.getExceptionFromResult(result);
    assertTrue(ex instanceof CommunicationException);
    assertEquals("[LDAP: error code 2 - error message]", ex.getMessage());

    // error code not in map
    result = getLdapResult(100, message);
    ex = LdapUtils.getExceptionFromResult(result);
    assertTrue(ex instanceof NamingException);
    assertEquals("[LDAP: error code 100 - error message]", ex.getMessage());

    // empty error message
    result = getLdapResult(3, "");
    ex = LdapUtils.getExceptionFromResult(result);
    assertTrue(ex instanceof TimeLimitExceededException);
    assertEquals("[LDAP: error code 3]", ex.getMessage());
}
项目:freeVM    文件:LdapUtilsTest.java   
public void test_getExceptionFromResult() {
    String message = "error message";
    LdapResult result = getLdapResult(0, message);
    NamingException ex = LdapUtils.getExceptionFromResult(result);
    assertNull(ex);

    // error code map to CommunicationException
    result = getLdapResult(2, message);
    ex = LdapUtils.getExceptionFromResult(result);
    assertTrue(ex instanceof CommunicationException);
    assertEquals("[LDAP: error code 2 - error message]", ex.getMessage());

    // error code not in map
    result = getLdapResult(100, message);
    ex = LdapUtils.getExceptionFromResult(result);
    assertTrue(ex instanceof NamingException);
    assertEquals("[LDAP: error code 100 - error message]", ex.getMessage());

    // empty error message
    result = getLdapResult(3, "");
    ex = LdapUtils.getExceptionFromResult(result);
    assertTrue(ex instanceof TimeLimitExceededException);
    assertEquals("[LDAP: error code 3]", ex.getMessage());
}
项目:AI    文件:Shrdlite.java   
private static void parseAndplan() throws TimeLimitExceededException {
    List tstrs = new ArrayList();
    result.put("trees", tstrs);
    for (Term t : trees) {
        tstrs.add(t.toString());
    }

    if (trees.isEmpty()) {
        result.put("output", "Parse error!");

    } else {
        List<CompositeGoal> goals = new ArrayList<CompositeGoal>();
        Interpreter interpreter = new Interpreter(currentWorld);
        for (Term tree : trees) {
            try {
                goals.addAll(interpreter.interpret(tree));
            } catch (PlanningException e) {
                //TODO: message gets overwritten later
                result.put("output", e.getMessage());
            }
        }
        String goalString = goals.toString();
        result.put("goals", goalString);

        if (goals.isEmpty()) {
            result.put("output", "Interpretation error!");

        } else if (goals.size() > 1) {
            result.put("output", "Ambiguity error!");

        } else {
            Planner planner = new BreadthFirstPlanner(currentWorld);
            Plan plan = planner.findSolution(goals.get(0));
            result.put("plan", plan.getPlan());

            if (plan.getPlan().isEmpty()) {
                result.put("output", "Goal is alreay fulfilled!");
            } else {
                result.put("output", "Success!");
                currentWorld = plan.getWorld();
            }
        }
    }
}