Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Tiede2014-11-06 14:15:00 +0000
committerMarkus Tiede2014-11-06 14:16:46 +0000
commitec590818c3dc539fa9257f81fcf30b93fa5ade81 (patch)
treeb889f9efa27eb5e26da195d0f9bafb8b4111ef5f /org.eclipse.jubula.client.api
parent7b5cba480a47f6972f7b0bab13a0bc0bcafb699e (diff)
downloadorg.eclipse.jubula.core-ec590818c3dc539fa9257f81fcf30b93fa5ade81.tar.gz
org.eclipse.jubula.core-ec590818c3dc539fa9257f81fcf30b93fa5ade81.tar.xz
org.eclipse.jubula.core-ec590818c3dc539fa9257f81fcf30b93fa5ade81.zip
Sprint task - add exception handling for remote communication problems - part 2: configurable execution event handling.
Diffstat (limited to 'org.eclipse.jubula.client.api')
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/AUT.java14
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/Result.java7
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ExecutionExceptionHandler.java25
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/AUTImpl.java30
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/ResultImpl.java16
5 files changed, 83 insertions, 9 deletions
diff --git a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/AUT.java b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/AUT.java
index 928fb8a9b..3bd6638f3 100644
--- a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/AUT.java
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/AUT.java
@@ -13,6 +13,7 @@ package org.eclipse.jubula.client;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jubula.client.exceptions.CommunicationException;
+import org.eclipse.jubula.client.exceptions.ExecutionExceptionHandler;
import org.eclipse.jubula.client.exceptions.ExecutionException;
import org.eclipse.jubula.communication.CAP;
import org.eclipse.jubula.tools.AUTIdentifier;
@@ -25,11 +26,9 @@ import org.eclipse.jubula.tools.AUTIdentifier;
public interface AUT extends Remote {
/**
* @return the AUTIdentifier of this AUT
- * @throws CommunicationException
- * in case of communication problems with the remote side
*/
@NonNull
- AUTIdentifier getIdentifier() throws CommunicationException;
+ AUTIdentifier getIdentifier();
/**
* @param cap
@@ -40,11 +39,18 @@ public interface AUT extends Remote {
* the additional payload for the execution
* @return the result of the execution
* @throws ExecutionException
- * in case of remote execution problems
+ * in case of remote execution problems; behavior may vary if
+ * ExecutionExceptionHandler are being used
* @throws CommunicationException
* in case of communication problems with the remote side
*/
@NonNull
<T> Result<T> execute(@NonNull CAP cap, @Nullable T payload)
throws ExecutionException, CommunicationException;
+
+ /**
+ * @param handler
+ * the exception handler for this AUT; may be <code>null</code>.
+ */
+ void setHandler(@Nullable ExecutionExceptionHandler handler);
} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/Result.java b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/Result.java
index 2b3fafeae..a17d92660 100644
--- a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/Result.java
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/Result.java
@@ -12,6 +12,7 @@ package org.eclipse.jubula.client;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.jubula.client.exceptions.ExecutionException;
import org.eclipse.jubula.communication.CAP;
/**
@@ -31,6 +32,12 @@ public interface Result<T> {
T getPayload();
/**
+ * @return the execution problem
+ */
+ @Nullable
+ ExecutionException getException();
+
+ /**
* @return the CAP
*/
@NonNull
diff --git a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ExecutionExceptionHandler.java b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ExecutionExceptionHandler.java
new file mode 100644
index 000000000..021254c2b
--- /dev/null
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ExecutionExceptionHandler.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2014 BREDEX GmbH.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.exceptions;
+
+import org.eclipse.jdt.annotation.NonNull;
+
+/** @author BREDEX GmbH */
+public interface ExecutionExceptionHandler {
+
+ /**
+ * @param ee
+ * the execution exception to handle
+ * @throws ExecutionException
+ * in case of e.g. no handling
+ */
+ void handle(@NonNull ExecutionException ee) throws ExecutionException;
+} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/AUTImpl.java b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/AUTImpl.java
index df855fe6f..b7c15ba56 100644
--- a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/AUTImpl.java
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/AUTImpl.java
@@ -23,6 +23,7 @@ import org.eclipse.jubula.client.exceptions.CheckFailedException;
import org.eclipse.jubula.client.exceptions.CommunicationException;
import org.eclipse.jubula.client.exceptions.ComponentNotFoundException;
import org.eclipse.jubula.client.exceptions.ConfigurationException;
+import org.eclipse.jubula.client.exceptions.ExecutionExceptionHandler;
import org.eclipse.jubula.client.exceptions.ExecutionException;
import org.eclipse.jubula.client.internal.AUTConnection;
import org.eclipse.jubula.client.internal.BaseConnection.NotConnectedException;
@@ -54,6 +55,8 @@ public class AUTImpl implements AUT {
private AUTConnection m_instance;
/** the toolkit specific information */
private AbstractToolkitInfo m_information;
+ /** the exception handler */
+ private ExecutionExceptionHandler m_handler;
/**
* Constructor
@@ -173,8 +176,9 @@ public class AUTImpl implements AUT {
* the response to process
*/
private void processResponse(CAPTestResponseMessage response,
- @NonNull final Result result)
+ @NonNull final ResultImpl result)
throws ExecutionException {
+ ExecutionException exception = null;
if (response.hasTestErrorEvent()) {
final TestErrorEvent event = response.getTestErrorEvent();
final String eventId = event.getId();
@@ -190,11 +194,11 @@ public class AUTImpl implements AUT {
description = I18n.getString(key, args);
}
if (TestErrorEvent.ID.ACTION_ERROR.equals(eventId)) {
- throw new ActionException(result, description);
+ exception = new ActionException(result, description);
} else if (TestErrorEvent.ID.COMPONENT_NOT_FOUND.equals(eventId)) {
- throw new ComponentNotFoundException(result, description);
+ exception = new ComponentNotFoundException(result, description);
} else if (TestErrorEvent.ID.CONFIGURATION_ERROR.equals(eventId)) {
- throw new ConfigurationException(result, description);
+ exception = new ConfigurationException(result, description);
} else if (TestErrorEvent.ID.VERIFY_FAILED.equals(eventId)) {
Object actualValueObject = event.getProps().get(
TestErrorEvent.Property.ACTUAL_VALUE_KEY);
@@ -202,9 +206,25 @@ public class AUTImpl implements AUT {
if (actualValueObject instanceof String) {
actualValue = (String)actualValueObject;
}
- throw new CheckFailedException(
+ exception = new CheckFailedException(
result, description, actualValue);
}
}
+
+ result.setException(exception);
+
+ if (exception != null) {
+ if (m_handler != null) {
+ m_handler.handle(exception);
+ } else {
+ throw exception;
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void setHandler(
+ @Nullable ExecutionExceptionHandler handler) {
+ m_handler = handler;
}
} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/ResultImpl.java b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/ResultImpl.java
index 2c62bbb92..e223bc3aa 100644
--- a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/ResultImpl.java
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/ResultImpl.java
@@ -14,6 +14,7 @@ import org.apache.commons.lang.Validate;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jubula.client.Result;
+import org.eclipse.jubula.client.exceptions.ExecutionException;
import org.eclipse.jubula.communication.CAP;
/**
@@ -29,6 +30,8 @@ public class ResultImpl<T> implements Result<T> {
private CAP m_cap;
/** the result flag */
private boolean m_isOK = false;
+ /** the exception */
+ private ExecutionException m_exception;
/**
* Constructor
@@ -69,4 +72,17 @@ public class ResultImpl<T> implements Result<T> {
void setOK(boolean isOK) {
m_isOK = isOK;
}
+
+ /** {@inheritDoc} */
+ @Nullable
+ public ExecutionException getException() {
+ return m_exception;
+ }
+
+ /**
+ * @param exception the exception to set
+ */
+ void setException(ExecutionException exception) {
+ m_exception = exception;
+ }
} \ No newline at end of file

Back to the top