Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Tiede2014-10-13 14:40:03 +0000
committerMarkus Tiede2014-10-15 07:18:20 +0000
commita058672a193feb5072a84317dc093877d4c4cff5 (patch)
tree63518b8c61c052d42329c874b39e04e1b732ee4d /org.eclipse.jubula.client.api
parent690b517897137710452fb0894fd4d536dbad826b (diff)
downloadorg.eclipse.jubula.core-a058672a193feb5072a84317dc093877d4c4cff5.tar.gz
org.eclipse.jubula.core-a058672a193feb5072a84317dc093877d4c4cff5.tar.xz
org.eclipse.jubula.core-a058672a193feb5072a84317dc093877d4c4cff5.zip
Sprint task - provide API: implement connect to AUT via API - part 3: minor refactoring + basic support to transfer the mapping of supported technical components.
Diffstat (limited to 'org.eclipse.jubula.client.api')
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/AUT.java11
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/AUTConnection.java115
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/AUTImpl.java26
3 files changed, 100 insertions, 52 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 cb1d182c0..20542d517 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
@@ -10,13 +10,20 @@
*******************************************************************************/
package org.eclipse.jubula.client;
+import java.util.Map;
+
import org.eclipse.jubula.tools.internal.registration.AutIdentifier;
/** @author BREDEX GmbH */
public interface AUT extends Remote {
-
/**
* @return the identifier of this AUT
*/
- AutIdentifier getID();
+ AutIdentifier getIdentifier();
+
+ /**
+ * @param typeMapping
+ * the type mapping to set
+ */
+ void setTypeMapping(Map<?, ?> typeMapping);
} \ 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 8a3901f4a..b7c61fad1 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
@@ -10,13 +10,18 @@
*******************************************************************************/
package org.eclipse.jubula.client.internal;
+import java.util.Map;
+
import org.eclipse.jubula.client.internal.exceptions.ConnectionException;
import org.eclipse.jubula.communication.internal.message.ConnectToAutMessage;
+import org.eclipse.jubula.communication.internal.message.SendAUTListOfSupportedComponentsMessage;
import org.eclipse.jubula.tools.internal.constants.EnvConstants;
import org.eclipse.jubula.tools.internal.exception.CommunicationException;
import org.eclipse.jubula.tools.internal.exception.JBVersionException;
import org.eclipse.jubula.tools.internal.registration.AutIdentifier;
import org.eclipse.jubula.tools.internal.utils.TimeUtil;
+import org.eclipse.jubula.tools.internal.xml.businessmodell.ComponentClass;
+import org.eclipse.jubula.tools.internal.xml.businessprocess.ProfileBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -81,13 +86,17 @@ public class AUTConnection extends BaseAUTConnection {
}
/**
- * Establishes a connection to the Running AUT with the given ID.
+ * Establishes a connection to the Running AUT with the given ID.
*
- * @param autId The ID of the Running AUT to connect to.
- * @return <code>true</code> if a connection to the AUT could be
+ * @param autId
+ * The ID of the Running AUT to connect to.
+ * @param typeMapping
+ * the type mapping to use
+ * @return <code>true</code> if a connection to the AUT could be
* established. Otherwise <code>false</code>.
*/
- public boolean connectToAut(AutIdentifier autId) {
+ public boolean connectToAut(AutIdentifier autId,
+ Map<ComponentClass, String> typeMapping) {
if (!isConnected()) {
try {
LOGGER.info("Establishing connection to AUT..."); //$NON-NLS-1$
@@ -95,10 +104,9 @@ public class AUTConnection extends BaseAUTConnection {
final AutAgentConnection autAgent = AutAgentConnection
.getInstance();
autAgent.getCommunicator().send(
- new ConnectToAutMessage(
- EnvConstants.LOCALHOST_FQDN,
+ new ConnectToAutMessage(EnvConstants.LOCALHOST_FQDN,
getCommunicator().getLocalPort(), autId));
-
+
long startTime = System.currentTimeMillis();
while (!isConnected()
&& autAgent.isConnected()
@@ -109,55 +117,66 @@ public class AUTConnection extends BaseAUTConnection {
if (isConnected()) {
setConnectedAutId(autId);
LOGGER.info("Connection to AUT established."); //$NON-NLS-1$
-// AUTStartedCommand response = new AUTStartedCommand();
-// response.setStateMessage(new AUTStateMessage(
-// AUTStateMessage.RUNNING));
-// setup(response);
+ setup(typeMapping);
return true;
}
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("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;
}
-// /**
-// * setup the connection between API and AUT
-// *
-// * @param command
-// * the command to execute on callback
-// * @throws NotConnectedException
-// * if there is no connection to an AUT.
-// * @throws ConnectionException
-// * if no connection to an AUT could be initialized.
-// * @throws CommunicationException
-// * if an error occurs while communicating with the AUT.
-// */
-// public void setup(AUTStartedCommand command)
-// throws NotConnectedException, ConnectionException,
-// CommunicationException {
-// sendKeyboardLayoutToAUT();
-// sendResourceBundlesToAUT();
-// getAllComponentsFromAUT(command);
-// }
-//
-// /**
-// * send the resource bundles to the AUT
-// */
-// private void sendResourceBundlesToAUT() {
-// System.err.println("sendResourceBundlesToAUT()");
-// }
-//
-// /**
-// * send the keyboard layout to the AUT
-// */
-// private void sendKeyboardLayoutToAUT() {
-// System.err.println("sendKeyboardLayoutToAUT()");
-// }
+ /**
+ * setup the connection between API and AUT
+ *
+ * @param technicalTypeMapping
+ * the technical type mapping to use
+ * @throws NotConnectedException
+ * if there is no connection to an AUT.
+ * @throws ConnectionException
+ * if no connection to an AUT could be initialized.
+ * @throws CommunicationException
+ * if an error occurs while communicating with the AUT.
+ */
+ public void setup(Map<ComponentClass, String> technicalTypeMapping)
+ throws NotConnectedException, ConnectionException,
+ CommunicationException {
+ sendKeyboardLayoutToAUT();
+ sendComponentSupportToAUT(technicalTypeMapping);
+ }
+
+ /**
+ * send the list of supported components to the AUT
+ *
+ * @param technicalTypeMapping
+ * the technicalTypeMapping to use
+ */
+ private void sendComponentSupportToAUT(
+ Map<ComponentClass, String> technicalTypeMapping)
+ throws CommunicationException {
+ SendAUTListOfSupportedComponentsMessage message =
+ new SendAUTListOfSupportedComponentsMessage();
+
+ message.setTechTypeToTesterClassMapping(technicalTypeMapping);
+ message.setProfile(ProfileBuilder.getDefaultProfile());
+
+ send(message);
+ }
+
+ /**
+ * send the keyboard layout to the AUT
+ */
+ private void sendKeyboardLayoutToAUT() {
+ System.err.println("sendKeyboardLayoutToAUT()"); //$NON-NLS-1$
+ }
} \ 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 a1d5a1fed..1ffaa74d4 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
@@ -10,9 +10,13 @@
*******************************************************************************/
package org.eclipse.jubula.client.internal.impl;
+import java.util.Map;
+
import org.eclipse.jubula.client.AUT;
import org.eclipse.jubula.client.internal.AUTConnection;
+import org.eclipse.jubula.tools.internal.exception.Assert;
import org.eclipse.jubula.tools.internal.registration.AutIdentifier;
+import org.eclipse.jubula.tools.internal.xml.businessmodell.ComponentClass;
/** @author BREDEX GmbH */
public class AUTImpl implements AUT {
@@ -20,6 +24,8 @@ public class AUTImpl implements AUT {
private AutIdentifier m_autID;
/** the instance */
private AUTConnection m_instance;
+ /** the typeMapping */
+ private Map<ComponentClass, String> m_typeMapping;
/**
* Constructor
@@ -33,8 +39,10 @@ public class AUTImpl implements AUT {
/** {@inheritDoc} */
public void connect() throws Exception {
+ final Map<ComponentClass, String> typeMapping = getTypeMapping();
+ Assert.verify(typeMapping != null);
m_instance = AUTConnection.getInstance();
- m_instance.connectToAut(m_autID);
+ m_instance.connectToAut(m_autID, typeMapping);
}
/** {@inheritDoc} */
@@ -49,7 +57,21 @@ public class AUTImpl implements AUT {
/** {@inheritDoc} */
- public AutIdentifier getID() {
+ public AutIdentifier getIdentifier() {
return m_autID;
}
+
+ /**
+ * @return the typeMapping
+ */
+ public Map<ComponentClass, String> getTypeMapping() {
+ return m_typeMapping;
+ }
+
+ /**
+ * @param typeMapping the typeMapping to set
+ */
+ public void setTypeMapping(Map<?, ?> typeMapping) {
+ m_typeMapping = (Map<ComponentClass, String>) typeMapping;
+ }
} \ No newline at end of file

Back to the top