test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/Actions.java in calabash-android-0.2.15 vs test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/Actions.java in calabash-android-0.2.16
- old
+ new
@@ -41,12 +41,11 @@
if (element.startsWith("sh.calaba.instrumentationbackend.actions.")) {
addAction(element);
}
}
} catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ throw new RuntimeException(e);
}
}
@SuppressWarnings("rawtypes")
private void addAction(String className) throws Exception {
@@ -55,25 +54,25 @@
put((Action) action.newInstance());
}
}
@SuppressWarnings("rawtypes")
- private boolean isAction(Class action) {
- for (Class i : action.getInterfaces()) {
- if (i.equals(Action.class)) {
- return true;
- }
- }
- return false;
+ private boolean isAction(Class actionCandidate) {
+ boolean isImplementation = !actionCandidate.isInterface();
+ return isImplementation && Action.class.isAssignableFrom(actionCandidate);
}
private void put(Action action) {
if (getActions().containsKey(action.key())) {
Action duplicate = getActions().get(action.key());
throw new RuntimeException("Found duplicate action key:'" + action.key() + "'. [" + duplicate.getClass().getName() + "," + action.getClass().getName() + "]");
}
- InstrumentationBackend.log("Added:'" + action.getClass().getSimpleName() + "', with key:'" + action.key() + "'");
- getActions().put(action.key(), action);
+ if (action.key() == null) {
+ System.out.println("Skipping " + action.getClass() + ". Key is null.");
+ } else {
+ InstrumentationBackend.log("Added:'" + action.getClass().getSimpleName() + "', with key:'" + action.key() + "'");
+ getActions().put(action.key(), action);
+ }
}
public Action lookup(String key) {
Action action = getActions().get(key);
if (action == null) {