Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Tiede2014-10-16 11:14:47 +0000
committerMarkus Tiede2014-10-16 11:24:50 +0000
commitbc1de4d876c1673bcf9afdbed3762b29f2972531 (patch)
tree51ebd1c79caffb1b991f69627035088bf92a723b /org.eclipse.jubula.client.api
parent9e7e73edeccf3d24773359e0e82681511b210af7 (diff)
downloadorg.eclipse.jubula.core-bc1de4d876c1673bcf9afdbed3762b29f2972531.tar.gz
org.eclipse.jubula.core-bc1de4d876c1673bcf9afdbed3762b29f2972531.tar.xz
org.eclipse.jubula.core-bc1de4d876c1673bcf9afdbed3762b29f2972531.zip
Sprint task - JavaAPI: feedback after discussion implemented.
Diffstat (limited to 'org.eclipse.jubula.client.api')
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/AUT.java23
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/AUTAgent.java11
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/Result.java30
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ActionException.java9
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/CheckFailedException.java10
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ComponentNotFoundException.java8
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ConfigurationException.java8
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ExecutionException.java24
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/AUTConnection.java10
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/AUTAgentImpl.java5
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/AUTImpl.java38
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/ResultImpl.java49
12 files changed, 182 insertions, 43 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 6f06eb6eb..f6f118db3 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
@@ -12,10 +12,11 @@ package org.eclipse.jubula.client;
import org.eclipse.jubula.client.exceptions.ExecutionException;
import org.eclipse.jubula.communication.CAP;
-import org.eclipse.jubula.toolkit.ToolkitInfo;
import org.eclipse.jubula.tools.AUTIdentifier;
-/** @author BREDEX GmbH */
+/**
+ * @author BREDEX GmbH
+ */
public interface AUT extends Remote {
/**
* @return the identifier of this AUT
@@ -23,16 +24,24 @@ public interface AUT extends Remote {
AUTIdentifier getIdentifier();
/**
- * @param information
- * the information about the AUTs toolkit
+ * @param cap
+ * the CAP to execute on the AUT
+ * @param <T>
+ * the payload type
+ * @param payload
+ * the payload for the execution
+ * @return the result of the execution
+ * @throws ExecutionException
+ * in case of remote execution problems
*/
- void setToolkitInformation(ToolkitInfo information);
-
+ <T> Result<T> execute(CAP cap, T payload) throws ExecutionException;
+
/**
* @param cap
* the CAP to execute on the AUT
+ * @return the result of the execution
* @throws ExecutionException
* in case of remote execution problems
*/
- void execute(CAP cap) throws ExecutionException;
+ Result execute(CAP cap) throws ExecutionException;
} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/AUTAgent.java b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/AUTAgent.java
index 22021011e..b0173758d 100644
--- a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/AUTAgent.java
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/AUTAgent.java
@@ -13,6 +13,7 @@ package org.eclipse.jubula.client;
import java.util.List;
import org.eclipse.jubula.client.launch.AUTConfiguration;
+import org.eclipse.jubula.toolkit.ToolkitInfo;
import org.eclipse.jubula.tools.AUTIdentifier;
/** @author BREDEX GmbH */
@@ -42,9 +43,11 @@ public interface AUTAgent extends Remote {
List<AUTIdentifier> getAllRegisteredAUTIdentifier() throws Exception;
/**
- * @param autID the autID to get an AUT for
- * @return an AUT
+ * @param autID
+ * the autID to get an AUT for
+ * @param information
+ * the information about the toolkit
+ * @return an AUT
*/
- AUT getAUT(AUTIdentifier autID);
-
+ AUT getAUT(AUTIdentifier autID, ToolkitInfo information);
} \ 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
new file mode 100644
index 000000000..2c82a706b
--- /dev/null
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/Result.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.jubula.communication.CAP;
+
+/**
+ * @author BREDEX GmbH
+ * @param <T>
+ * the payload type
+ */
+public interface Result<T> {
+ /**
+ * @return the payload
+ */
+ T getPayload();
+
+ /**
+ * @return the CAP
+ */
+ CAP getCAP();
+} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ActionException.java b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ActionException.java
index 14ddcef8e..5dbc28ac5 100644
--- a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ActionException.java
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ActionException.java
@@ -10,16 +10,19 @@
*******************************************************************************/
package org.eclipse.jubula.client.exceptions;
+import org.eclipse.jubula.client.Result;
+
/** @author BREDEX GmbH */
public class ActionException extends ExecutionException {
/**
* Constructor
- *
+ * @param result
+ * the result
* @param message
* the message
*/
- public ActionException(String message) {
- super(message);
+ public ActionException(Result result, String message) {
+ super(result, message);
}
}
diff --git a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/CheckFailedException.java b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/CheckFailedException.java
index 4d01f36ff..39441fcb1 100644
--- a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/CheckFailedException.java
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/CheckFailedException.java
@@ -10,22 +10,26 @@
*******************************************************************************/
package org.eclipse.jubula.client.exceptions;
+import org.eclipse.jubula.client.Result;
+
/** @author BREDEX GmbH */
public class CheckFailedException extends ExecutionException {
-
/** the actualValue */
private String m_actualValue;
/**
* Constructor
*
+ * @param result
+ * the result
* @param actualValue
* the actual value
* @param message
* the message
*/
- public CheckFailedException(String message, String actualValue) {
- super(message);
+ public CheckFailedException(Result result, String message,
+ String actualValue) {
+ super(result, message);
setActualValue(actualValue);
}
diff --git a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ComponentNotFoundException.java b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ComponentNotFoundException.java
index 866d35a1c..b68295d51 100644
--- a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ComponentNotFoundException.java
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ComponentNotFoundException.java
@@ -10,16 +10,20 @@
*******************************************************************************/
package org.eclipse.jubula.client.exceptions;
+import org.eclipse.jubula.client.Result;
+
/** @author BREDEX GmbH */
public class ComponentNotFoundException extends ExecutionException {
/**
* Constructor
*
+ * @param result
+ * the result
* @param message
* the message
*/
- public ComponentNotFoundException(String message) {
- super(message);
+ public ComponentNotFoundException(Result result, String message) {
+ super(result, message);
}
}
diff --git a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ConfigurationException.java b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ConfigurationException.java
index 4d35035cf..324f95d76 100644
--- a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ConfigurationException.java
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ConfigurationException.java
@@ -10,15 +10,19 @@
*******************************************************************************/
package org.eclipse.jubula.client.exceptions;
+import org.eclipse.jubula.client.Result;
+
/** @author BREDEX GmbH */
public class ConfigurationException extends ExecutionException {
/**
* Constructor
*
+ * @param result
+ * the result
* @param message
* the message
*/
- public ConfigurationException(String message) {
- super(message);
+ public ConfigurationException(Result result, String message) {
+ super(result, message);
}
} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ExecutionException.java b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ExecutionException.java
index 2e0c6f7bf..603c9f837 100644
--- a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ExecutionException.java
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ExecutionException.java
@@ -10,15 +10,37 @@
*******************************************************************************/
package org.eclipse.jubula.client.exceptions;
+import org.eclipse.jubula.client.Result;
+
/** @author BREDEX GmbH */
public abstract class ExecutionException extends RuntimeException {
+ /** the result */
+ private Result m_result;
+
/**
* Constructor
*
+ * @param result
+ * the result
* @param message
* the message
*/
- public ExecutionException(String message) {
+ public ExecutionException(Result result, String message) {
super(message);
+ setResult(result);
+ }
+
+ /**
+ * @return the result
+ */
+ public Result getResult() {
+ return m_result;
+ }
+
+ /**
+ * @param result the result to set
+ */
+ private void setResult(Result result) {
+ m_result = result;
}
} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/AUTConnection.java b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/AUTConnection.java
index 0163d1dc6..f66d8a246 100644
--- a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/AUTConnection.java
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/AUTConnection.java
@@ -122,16 +122,12 @@ public class AUTConnection extends BaseAUTConnection {
}
LOGGER.error("Connection to AUT could not be established."); //$NON-NLS-1$
} catch (CommunicationException e) {
- LOGGER.error(
- "Error occurred while establishing connection to AUT.", e); //$NON-NLS-1$
+ LOGGER.error("Error occurred while establishing connection to AUT.", e); //$NON-NLS-1$
} catch (JBVersionException e) {
- LOGGER
- .error(
- "Version error occurred while establishing connection to AUT.", e); //$NON-NLS-1$
+ LOGGER .error("Version error occurred while establishing connection to AUT.", e); //$NON-NLS-1$
}
} else {
- LOGGER
- .warn("Cannot establish new connection to AUT: Connection to AUT already exists."); //$NON-NLS-1$
+ LOGGER.warn("Cannot establish new connection to AUT: Connection to AUT already exists."); //$NON-NLS-1$
}
return false;
}
diff --git a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/AUTAgentImpl.java b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/AUTAgentImpl.java
index 4bf3608a0..0584597a7 100644
--- a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/AUTAgentImpl.java
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/AUTAgentImpl.java
@@ -24,6 +24,7 @@ import org.eclipse.jubula.communication.internal.Communicator;
import org.eclipse.jubula.communication.internal.message.GetRegisteredAutListMessage;
import org.eclipse.jubula.communication.internal.message.StartAUTServerMessage;
import org.eclipse.jubula.communication.internal.message.StopAUTServerMessage;
+import org.eclipse.jubula.toolkit.ToolkitInfo;
import org.eclipse.jubula.tools.AUTIdentifier;
import org.eclipse.jubula.tools.internal.constants.AUTStartResponse;
import org.eclipse.jubula.tools.internal.constants.AutConfigConstants;
@@ -147,7 +148,7 @@ public class AUTAgentImpl implements AUTAgent {
}
/** {@inheritDoc} */
- public AUT getAUT(AUTIdentifier autID) {
- return new AUTImpl((AutIdentifier) autID);
+ public AUT getAUT(AUTIdentifier autID, ToolkitInfo information) {
+ return new AUTImpl((AutIdentifier) autID, information);
}
} \ 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 424ab2488..92abf1491 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
@@ -13,6 +13,7 @@ package org.eclipse.jubula.client.internal.impl;
import java.util.Map;
import org.eclipse.jubula.client.AUT;
+import org.eclipse.jubula.client.Result;
import org.eclipse.jubula.client.exceptions.ActionException;
import org.eclipse.jubula.client.exceptions.CheckFailedException;
import org.eclipse.jubula.client.exceptions.ComponentNotFoundException;
@@ -27,6 +28,7 @@ import org.eclipse.jubula.communication.internal.message.CAPTestResponseMessage;
import org.eclipse.jubula.communication.internal.message.MessageCap;
import org.eclipse.jubula.communication.internal.message.UnknownMessageException;
import org.eclipse.jubula.toolkit.ToolkitInfo;
+import org.eclipse.jubula.toolkit.internal.AbstractToolkitInfo;
import org.eclipse.jubula.tools.AUTIdentifier;
import org.eclipse.jubula.tools.internal.exception.Assert;
import org.eclipse.jubula.tools.internal.exception.CommunicationException;
@@ -46,22 +48,24 @@ public class AUTImpl implements AUT {
/** the instance */
private AUTConnection m_instance;
/** the toolkit specific information */
- private ToolkitInfo m_information;
+ private AbstractToolkitInfo m_information;
/**
* Constructor
*
* @param autID
* the identifier to use for connection
+ * @param information
*/
- public AUTImpl(AutIdentifier autID) {
+ public AUTImpl(AutIdentifier autID, ToolkitInfo information) {
m_autID = autID;
+ setToolkitInformation((AbstractToolkitInfo)information);
}
/** {@inheritDoc} */
public void connect() throws Exception {
final Map<ComponentClass, String> typeMapping =
- (Map<ComponentClass, String>) getInformation().getTypeMapping();
+ getInformation().getTypeMapping();
Assert.verify(typeMapping != null);
m_instance = AUTConnection.getInstance();
m_instance.connectToAut(m_autID, typeMapping);
@@ -83,19 +87,25 @@ public class AUTImpl implements AUT {
}
/** {@inheritDoc} */
- public void setToolkitInformation(ToolkitInfo information) {
+ public void setToolkitInformation(AbstractToolkitInfo information) {
m_information = information;
}
/**
* @return the information
*/
- public ToolkitInfo getInformation() {
+ public AbstractToolkitInfo getInformation() {
return m_information;
}
+
+ /** {@inheritDoc} */
+ public Result execute(CAP cap) throws ExecutionException {
+ return execute(cap, null);
+ }
/** {@inheritDoc} */
- public void execute(CAP cap) throws ExecutionException {
+ public <T> Result<T> execute(CAP cap, T payload) throws ExecutionException {
+ final ResultImpl<T> result = new ResultImpl<T>(cap, payload);
try {
CAPTestMessage capTestMessage = CAPTestMessageFactory
.getCAPTestMessage((MessageCap)cap,
@@ -107,7 +117,7 @@ public class AUTImpl implements AUT {
if (exchange instanceof CAPTestResponseMessage) {
CAPTestResponseMessage response =
(CAPTestResponseMessage) exchange;
- processResponse(response);
+ processResponse(response, result);
} else {
log.error("Unexpected response received: " //$NON-NLS-1$
+ String.valueOf(exchange));
@@ -120,13 +130,17 @@ public class AUTImpl implements AUT {
} catch (InterruptedException e) {
log.error(e.getLocalizedMessage(), e);
}
+ return result;
}
/**
+ * @param result
+ * the result
* @param response
* the response to process
*/
- private void processResponse(CAPTestResponseMessage response)
+ private void processResponse(CAPTestResponseMessage response,
+ final Result result)
throws ExecutionException {
if (response.hasTestErrorEvent()) {
final TestErrorEvent event = response.getTestErrorEvent();
@@ -143,15 +157,15 @@ public class AUTImpl implements AUT {
description = I18n.getString(key, args);
}
if (TestErrorEvent.ID.ACTION_ERROR.equals(eventId)) {
- throw new ActionException(description);
+ throw new ActionException(result, description);
} else if (TestErrorEvent.ID.COMPONENT_NOT_FOUND.equals(eventId)) {
- throw new ComponentNotFoundException(description);
+ throw new ComponentNotFoundException(result, description);
} else if (TestErrorEvent.ID.CONFIGURATION_ERROR.equals(eventId)) {
- throw new ConfigurationException(description);
+ throw new ConfigurationException(result, description);
} else if (TestErrorEvent.ID.VERIFY_FAILED.equals(eventId)) {
Object actualValue = event.getProps().get(
TestErrorEvent.Property.ACTUAL_VALUE_KEY);
- throw new CheckFailedException(description,
+ throw new CheckFailedException(result, description,
String.valueOf(actualValue));
}
}
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
new file mode 100644
index 000000000..0f770e439
--- /dev/null
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/ResultImpl.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * 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.internal.impl;
+
+import org.eclipse.jubula.client.Result;
+import org.eclipse.jubula.communication.CAP;
+
+/**
+ * @author BREDEX GmbH
+ * @param <T>
+ * the payload type
+ */
+public class ResultImpl<T> implements Result<T> {
+ /** the payload */
+ private T m_payload;
+ /** the cap */
+ private CAP m_cap;
+
+ /**
+ * Constructor
+ *
+ * @param cap
+ * the CAP
+ * @param payload
+ * the payload to use
+ */
+ public ResultImpl(CAP cap, T payload) {
+ m_cap = cap;
+ m_payload = payload;
+ }
+
+ /** {@inheritDoc} */
+ public T getPayload() {
+ return m_payload;
+ }
+
+ /** {@inheritDoc} */
+ public CAP getCAP() {
+ return m_cap;
+ }
+} \ No newline at end of file

Back to the top