Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Tiede2014-10-14 13:42:01 +0000
committerMarkus Tiede2014-10-15 07:18:20 +0000
commit105596d2fc402703a0486c7a1f3b53bff723759b (patch)
tree0a69aa41c07b625bbcfba8365deac4b71b4d448c /org.eclipse.jubula.client.api
parent1f379031535cd62728312aa797ff067627477bb0 (diff)
downloadorg.eclipse.jubula.core-105596d2fc402703a0486c7a1f3b53bff723759b.tar.gz
org.eclipse.jubula.core-105596d2fc402703a0486c7a1f3b53bff723759b.tar.xz
org.eclipse.jubula.core-105596d2fc402703a0486c7a1f3b53bff723759b.zip
Sprint task - provide API: implement connect to AUT via API - part 7: first event processing implemented.
Diffstat (limited to 'org.eclipse.jubula.client.api')
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/AUT.java5
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ActionException.java16
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/CheckException.java42
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ComponentNotFoundException.java16
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ConfigurationException.java16
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ExecutionException.java16
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/AUTImpl.java64
7 files changed, 164 insertions, 11 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 f070603da..3e265899e 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,6 +12,7 @@ package org.eclipse.jubula.client;
import java.util.Map;
+import org.eclipse.jubula.client.exceptions.ExecutionException;
import org.eclipse.jubula.communication.CAP;
import org.eclipse.jubula.tools.AUTIdentifier;
@@ -31,6 +32,8 @@ public interface AUT extends Remote {
/**
* @param cap
* the CAP to execute on the AUT
+ * @throws ExecutionException
+ * in case of remote execution problems
*/
- void execute(CAP cap);
+ void execute(CAP cap) throws ExecutionException;
} \ 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
new file mode 100644
index 000000000..6002f7213
--- /dev/null
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ActionException.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * 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;
+
+/** @author BREDEX GmbH */
+public class ActionException extends ExecutionException {
+
+}
diff --git a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/CheckException.java b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/CheckException.java
new file mode 100644
index 000000000..b2e34300e
--- /dev/null
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/CheckException.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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;
+
+/** @author BREDEX GmbH */
+public class CheckException extends ExecutionException {
+
+ /** the actualValue */
+ private String m_actualValue;
+
+ /**
+ * Constructor
+ *
+ * @param actualValue
+ * the actual value
+ */
+ public CheckException(String actualValue) {
+ setActualValue(actualValue);
+ }
+
+ /**
+ * @return the actualValue
+ */
+ public String getActualValue() {
+ return m_actualValue;
+ }
+
+ /**
+ * @param actualValue the actualValue to set
+ */
+ private void setActualValue(String actualValue) {
+ m_actualValue = actualValue;
+ }
+} \ No newline at end of file
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
new file mode 100644
index 000000000..9f88f0525
--- /dev/null
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ComponentNotFoundException.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * 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;
+
+/** @author BREDEX GmbH */
+public class ComponentNotFoundException extends ExecutionException {
+
+}
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
new file mode 100644
index 000000000..88a6c0093
--- /dev/null
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ConfigurationException.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * 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;
+
+/** @author BREDEX GmbH */
+public class ConfigurationException extends ExecutionException {
+
+}
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
new file mode 100644
index 000000000..b3b437b2c
--- /dev/null
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/exceptions/ExecutionException.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * 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;
+
+/** @author BREDEX GmbH */
+public abstract class ExecutionException extends RuntimeException {
+
+}
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 219ce8e98..66ade3a4f 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,16 +13,24 @@ package org.eclipse.jubula.client.internal.impl;
import java.util.Map;
import org.eclipse.jubula.client.AUT;
+import org.eclipse.jubula.client.exceptions.ActionException;
+import org.eclipse.jubula.client.exceptions.CheckException;
+import org.eclipse.jubula.client.exceptions.ComponentNotFoundException;
+import org.eclipse.jubula.client.exceptions.ConfigurationException;
+import org.eclipse.jubula.client.exceptions.ExecutionException;
import org.eclipse.jubula.client.internal.AUTConnection;
import org.eclipse.jubula.client.internal.BaseConnection.NotConnectedException;
+import org.eclipse.jubula.client.internal.Synchronizer;
import org.eclipse.jubula.communication.CAP;
import org.eclipse.jubula.communication.internal.message.CAPTestMessage;
import org.eclipse.jubula.communication.internal.message.CAPTestMessageFactory;
+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.tools.AUTIdentifier;
import org.eclipse.jubula.tools.internal.exception.Assert;
import org.eclipse.jubula.tools.internal.exception.CommunicationException;
+import org.eclipse.jubula.tools.internal.objects.event.TestErrorEvent;
import org.eclipse.jubula.tools.internal.registration.AutIdentifier;
import org.eclipse.jubula.tools.internal.xml.businessmodell.ComponentClass;
import org.slf4j.Logger;
@@ -32,13 +40,13 @@ import org.slf4j.LoggerFactory;
public class AUTImpl implements AUT {
/** the logger */
private static Logger log = LoggerFactory.getLogger(AUTAgentImpl.class);
-
+
/** the AUT identifier */
private AutIdentifier m_autID;
/** the instance */
private AUTConnection m_instance;
/** the typeMapping */
- private Map<ComponentClass, String> m_typeMapping;
+ private Map<ComponentClass, String> m_typeMapping;
/**
* Constructor
@@ -76,34 +84,70 @@ public class AUTImpl implements AUT {
/**
* @return the typeMapping
*/
- public Map<ComponentClass, String> getTypeMapping() {
+ public Map<ComponentClass, String> getTypeMapping() {
return m_typeMapping;
}
/**
- * @param typeMapping the typeMapping to set
+ * @param typeMapping
+ * the typeMapping to set
*/
public void setTypeMapping(Map<?, ?> typeMapping) {
m_typeMapping = (Map<ComponentClass, String>) typeMapping;
}
/** {@inheritDoc} */
- public void execute(CAP cap) {
+ public void execute(CAP cap) throws ExecutionException {
try {
// TODO MT: fixme
CAPTestMessage capTestMessage = CAPTestMessageFactory
- .getCAPTestMessage((MessageCap) cap,
- "com.bredexsw.guidancer.SwtToolkitPlugin"); //$NON-NLS-1$
-
+ .getCAPTestMessage((MessageCap)cap,
+ "com.bredexsw.guidancer.SwtToolkitPlugin"); //$NON-NLS-1$
+
m_instance.send(capTestMessage);
+
+ Object exchange = Synchronizer.instance().exchange(null);
+ if (exchange instanceof CAPTestResponseMessage) {
+ CAPTestResponseMessage response =
+ (CAPTestResponseMessage) exchange;
+ processResponse(response);
+ } else {
+ log.error("Unexpected response received: " //$NON-NLS-1$
+ + String.valueOf(exchange));
+ }
+
} catch (UnknownMessageException e) {
log.error(e.getLocalizedMessage(), e);
} catch (NotConnectedException e) {
log.error(e.getLocalizedMessage(), e);
- } catch (IllegalArgumentException e) {
- log.error(e.getLocalizedMessage(), e);
} catch (CommunicationException e) {
log.error(e.getLocalizedMessage(), e);
+ } catch (InterruptedException e) {
+ log.error(e.getLocalizedMessage(), e);
+ }
+ }
+
+ /**
+ * @param response
+ * the response to process
+ */
+ private void processResponse(CAPTestResponseMessage response)
+ throws ExecutionException {
+ if (response.hasTestErrorEvent()) {
+ final TestErrorEvent event = response.getTestErrorEvent();
+ final String eventId = event.getId();
+ if (TestErrorEvent.ID.ACTION_ERROR.equals(eventId)) {
+ throw new ActionException();
+ } else if (TestErrorEvent.ID.COMPONENT_NOT_FOUND.equals(eventId)) {
+ throw new ComponentNotFoundException();
+ } else if (TestErrorEvent.ID.CONFIGURATION_ERROR.equals(eventId)) {
+ throw new ConfigurationException();
+ } else if (TestErrorEvent.ID.VERIFY_FAILED.equals(eventId)) {
+ Object actualValue = event.getProps().get(
+ TestErrorEvent.Property.ACTUAL_VALUE_KEY);
+
+ throw new CheckException(String.valueOf(actualValue));
+ }
}
}
} \ No newline at end of file

Back to the top