You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@esme.apache.org by dh...@apache.org on 2009/02/02 01:19:36 UTC
svn commit: r739891 - in /incubator/esme/trunk/esme-java-client: ./ src/
src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/esme/ src/main/java/org/apache/esme/api/
src/main/java/org/apache/esme/model/ src/ma...
Author: dhague
Date: Mon Feb 2 00:19:35 2009
New Revision: 739891
URL: http://svn.apache.org/viewvc?rev=739891&view=rev
Log:
First import - many methods still to do, get_msgs partially done
Added:
incubator/esme/trunk/esme-java-client/
incubator/esme/trunk/esme-java-client/.classpath
incubator/esme/trunk/esme-java-client/.project
incubator/esme/trunk/esme-java-client/pom.xml
incubator/esme/trunk/esme-java-client/src/
incubator/esme/trunk/esme-java-client/src/main/
incubator/esme/trunk/esme-java-client/src/main/java/
incubator/esme/trunk/esme-java-client/src/main/java/org/
incubator/esme/trunk/esme-java-client/src/main/java/org/apache/
incubator/esme/trunk/esme-java-client/src/main/java/org/apache/esme/
incubator/esme/trunk/esme-java-client/src/main/java/org/apache/esme/api/
incubator/esme/trunk/esme-java-client/src/main/java/org/apache/esme/api/EsmeException.java
incubator/esme/trunk/esme-java-client/src/main/java/org/apache/esme/api/EsmeRestApi.java
incubator/esme/trunk/esme-java-client/src/main/java/org/apache/esme/model/
incubator/esme/trunk/esme-java-client/src/main/java/org/apache/esme/model/Message.java
incubator/esme/trunk/esme-java-client/src/main/java/org/apache/esme/model/Status.java
incubator/esme/trunk/esme-java-client/src/main/resources/
incubator/esme/trunk/esme-java-client/src/test/
incubator/esme/trunk/esme-java-client/src/test/java/
incubator/esme/trunk/esme-java-client/src/test/java/org/
incubator/esme/trunk/esme-java-client/src/test/java/org/apache/
incubator/esme/trunk/esme-java-client/src/test/java/org/apache/esme/
incubator/esme/trunk/esme-java-client/src/test/java/org/apache/esme/api/
incubator/esme/trunk/esme-java-client/src/test/java/org/apache/esme/api/RestTest.java
incubator/esme/trunk/esme-java-client/src/test/java/org/apache/esme/api/TestProperties.java
incubator/esme/trunk/esme-java-client/src/test/resources/
incubator/esme/trunk/esme-java-client/src/test/resources/props/
incubator/esme/trunk/esme-java-client/src/test/resources/props/test.properties
incubator/esme/trunk/esme-java-client/target/
incubator/esme/trunk/esme-java-client/target/classes/
incubator/esme/trunk/esme-java-client/target/classes/org/
incubator/esme/trunk/esme-java-client/target/classes/org/apache/
incubator/esme/trunk/esme-java-client/target/classes/org/apache/esme/
incubator/esme/trunk/esme-java-client/target/classes/org/apache/esme/api/
incubator/esme/trunk/esme-java-client/target/classes/org/apache/esme/api/EsmeException.class (with props)
incubator/esme/trunk/esme-java-client/target/classes/org/apache/esme/api/EsmeRestApi.class (with props)
incubator/esme/trunk/esme-java-client/target/classes/org/apache/esme/api/Message.class (with props)
incubator/esme/trunk/esme-java-client/target/classes/org/apache/esme/model/
incubator/esme/trunk/esme-java-client/target/classes/org/apache/esme/model/Message.class (with props)
incubator/esme/trunk/esme-java-client/target/classes/org/apache/esme/model/Status.class (with props)
incubator/esme/trunk/esme-java-client/target/surefire-reports/
incubator/esme/trunk/esme-java-client/target/surefire-reports/TEST-org.apache.esme.api.RestTest.xml
incubator/esme/trunk/esme-java-client/target/surefire-reports/org.apache.esme.api.RestTest.txt
incubator/esme/trunk/esme-java-client/target/test-classes/
incubator/esme/trunk/esme-java-client/target/test-classes/org/
incubator/esme/trunk/esme-java-client/target/test-classes/org/apache/
incubator/esme/trunk/esme-java-client/target/test-classes/org/apache/esme/
incubator/esme/trunk/esme-java-client/target/test-classes/org/apache/esme/api/
incubator/esme/trunk/esme-java-client/target/test-classes/org/apache/esme/api/RestTest.class (with props)
incubator/esme/trunk/esme-java-client/target/test-classes/org/apache/esme/api/TestProperties.class (with props)
incubator/esme/trunk/esme-java-client/target/test-classes/props/
incubator/esme/trunk/esme-java-client/target/test-classes/props/test.properties
Added: incubator/esme/trunk/esme-java-client/.classpath
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/esme-java-client/.classpath?rev=739891&view=auto
==============================================================================
--- incubator/esme/trunk/esme-java-client/.classpath (added)
+++ incubator/esme/trunk/esme-java-client/.classpath Mon Feb 2 00:19:35 2009
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry including="**/*.java" kind="src" output="target/test-classes" path="src/test/java"/>
+ <classpathentry including="**/*.java" kind="src" path="src/main/java"/>
+ <classpathentry kind="con" path="org.devzuz.q.maven.jdt.core.mavenClasspathContainer"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Added: incubator/esme/trunk/esme-java-client/.project
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/esme-java-client/.project?rev=739891&view=auto
==============================================================================
--- incubator/esme/trunk/esme-java-client/.project (added)
+++ incubator/esme/trunk/esme-java-client/.project Mon Feb 2 00:19:35 2009
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>EsmeRestApi</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.devzuz.q.maven.jdt.core.mavenIncrementalBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.devzuz.q.maven.jdt.core.mavenNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: incubator/esme/trunk/esme-java-client/pom.xml
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/esme-java-client/pom.xml?rev=739891&view=auto
==============================================================================
--- incubator/esme/trunk/esme-java-client/pom.xml (added)
+++ incubator/esme/trunk/esme-java-client/pom.xml Mon Feb 2 00:19:35 2009
@@ -0,0 +1,56 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>us.esme</groupId>
+ <artifactId>esme-rest-api</artifactId>
+ <packaging>jar</packaging>
+ <version>0.1-SNAPSHOT</version>
+ <name>EsmeRestApi</name>
+ <url>http://maven.apache.org</url>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.1</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <verbose>true</verbose>
+ <fork>true</fork>
+ <executable>${JAVA_HOME}/bin/javac</executable>
+ <!--
+ define the JAVA_1_4_HOME property in .m2/settings.xml for portability, e.g.:
+ <settings>
+ [...]
+ <profiles>
+ [...]
+ <profile>
+ <id>compiler</id>
+ <properties>
+ <JAVA_1_4_HOME>C:\Program Files\Java\j2sdk1.4.2_09</JAVA_1_4_HOME>
+ </properties>
+ </profile>
+ </profiles>
+ [...]
+ <activeProfiles>
+ <activeProfile>compiler</activeProfile>
+ </activeProfiles>
+ </settings>
+ -->
+ <compilerVersion>1.4</compilerVersion>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: incubator/esme/trunk/esme-java-client/src/main/java/org/apache/esme/api/EsmeException.java
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/esme-java-client/src/main/java/org/apache/esme/api/EsmeException.java?rev=739891&view=auto
==============================================================================
--- incubator/esme/trunk/esme-java-client/src/main/java/org/apache/esme/api/EsmeException.java (added)
+++ incubator/esme/trunk/esme-java-client/src/main/java/org/apache/esme/api/EsmeException.java Mon Feb 2 00:19:35 2009
@@ -0,0 +1,23 @@
+package org.apache.esme.api;
+
+public class EsmeException extends RuntimeException {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -9145163776335704925L;
+
+ private int httpStatus;
+
+ public EsmeException(int httpStatus)
+ {
+ this.setHttpStatus(httpStatus);
+ }
+
+ private void setHttpStatus(int httpStatus) {
+ this.httpStatus = httpStatus;
+ }
+
+ public int getHttpStatus() {
+ return httpStatus;
+ }
+}
Added: incubator/esme/trunk/esme-java-client/src/main/java/org/apache/esme/api/EsmeRestApi.java
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/esme-java-client/src/main/java/org/apache/esme/api/EsmeRestApi.java?rev=739891&view=auto
==============================================================================
--- incubator/esme/trunk/esme-java-client/src/main/java/org/apache/esme/api/EsmeRestApi.java (added)
+++ incubator/esme/trunk/esme-java-client/src/main/java/org/apache/esme/api/EsmeRestApi.java Mon Feb 2 00:19:35 2009
@@ -0,0 +1,284 @@
+/*
+ * Created on 02-Oct-2008
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package org.apache.esme.api;
+
+import java.io.ByteArrayInputStream;
+import org.apache.esme.model.Message;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Properties;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import org.apache.commons.httpclient.HostConfiguration;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.NameValuePair;
+import org.apache.commons.httpclient.ProxyClient;
+import org.apache.commons.httpclient.ProxyHost;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.esme.model.Status;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * @author I056593
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class EsmeRestApi {
+
+ public static boolean debugMode = false;
+ private static Logger logger = Logger.getLogger("org.apache.esme.api");
+
+ private String apiUrl;
+ private String authToken;
+ private HttpClient client = new HttpClient();
+ //private HostConfiguration hostConfig = new HostConfiguration();
+
+ public void setProxy(String proxyHost, int proxyPort) {
+ //hostConfig.setProxy(proxyHost, proxyPort);
+ client.getHostConfiguration().setProxy(proxyHost, proxyPort);
+ }
+
+ public EsmeRestApi(String apiUrl) throws IOException {
+ this.apiUrl = apiUrl;
+ }
+
+ public void sendMsg(String message) {
+ Message msg = new Message();
+ msg.setText(message);
+ sendMsg(msg);
+ }
+
+ /**
+ * @return
+ */
+ public String getApiUrl() {
+ return apiUrl;
+ }
+
+ /**
+ * @param string
+ */
+ public void setApiUrl(String string) {
+ apiUrl = string;
+ }
+
+ /**
+ * @return
+ */
+ public String getAuthToken() {
+ return authToken;
+ }
+
+ /**
+ * @param string
+ */
+ public void setAuthToken(String string) {
+ authToken = string;
+ }
+
+ private Document executeHttp(HttpMethod method)
+ {
+ Document result = null;
+
+ try {
+ int statusCode = client.executeMethod(method);
+ if (statusCode != 200) {
+ logger.log(Level.SEVERE, "send_msg response code: " + statusCode);
+ throw new EsmeException(statusCode);
+ }
+ byte[] responseBody = method.getResponseBody();
+ logger.log(Level.INFO, "Got body, convert to BAIS");
+ // Parse the resulting XML into a DOM
+ ByteArrayInputStream statusStream = new ByteArrayInputStream(responseBody);
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db;
+ db = dbf.newDocumentBuilder();
+ logger.log(Level.INFO, "Parse & create Document");
+ result = db.parse(statusStream);
+ } catch (IOException e) {
+ logger.log(Level.SEVERE,"Fatal transport error or XML error",e);
+ } catch (SAXException e) {
+ logger.log(Level.SEVERE,"Fatal XML error",e);
+ } catch (ParserConfigurationException e) {
+ logger.log(Level.SEVERE,"Fatal XML error",e);
+ } finally {
+ return result;
+ }
+ }
+
+ public void login(String token)
+ {
+// POST /api/login
+// token=API_TOKEN
+//
+// <esme_api operation="login" success="true"/>
+
+ PostMethod method = new PostMethod(apiUrl + "/login");
+ NameValuePair[] data = { new NameValuePair("token", token) };
+ try {
+ Document document = executeHttp(method);
+ } finally {
+ // Release the connection.
+ method.releaseConnection();
+ }
+ }
+
+ public void logout()
+ {
+// GET /api/logout
+//
+// <esme_api operation="logout" success="true"/>
+
+ GetMethod method = new GetMethod(apiUrl + "/logout");
+ try {
+ Document document = executeHttp(method);
+ } finally {
+ // Release the connection.
+ method.releaseConnection();
+ }
+ }
+
+ public void sendMsg(Message message) {
+// POST /api/send_msg
+// message=messagebody
+// via=optional_name_of_client
+// tags=optional_comma_delimitted_tags
+// metadata=optional_XML_Element_data
+// replyto=optional_id_of_message
+
+// <esme_api operation="send_msg" success="true"/>
+
+ PostMethod method = new PostMethod(apiUrl + "/send_msg");
+ String tags="";
+ for (int i = 0; i < message.getTags().length; i++) {
+ if (i != 0) tags+=(",");
+ tags+=(message.getTags()[i]);
+ }
+ NameValuePair[] data = {
+ new NameValuePair("message", message.getText()),
+ new NameValuePair("via", message.getVia()),
+ new NameValuePair("tags", tags),
+ };
+ try {
+ Document document = executeHttp(method);
+ } finally {
+ // Release the connection.
+ method.releaseConnection();
+ }
+ }
+
+ public Status getStatus()
+ {
+// GET /api/status
+//
+// <esme_api operation="status" success="false"/> -> null
+
+// <esme_api operation="status" success="true"> -> Status object
+// <user nickname="..." id="1"/>
+// </esme_api>
+
+ GetMethod method = new GetMethod(apiUrl + "/status");
+ Status status = new Status();
+
+ try {
+ Document document = executeHttp(method);
+
+ logger.log(Level.INFO, "Get Success string");
+ String success = document.getDocumentElement().getAttribute("success");
+
+ logger.log(Level.INFO, "success = "+success);
+ if ("false".equals(success))
+ {
+ logger.severe("success=false when calling /status");
+ return null;
+ }
+ Element user = (Element) document.getElementsByTagName("user").item(0);
+
+ /*
+ * <user nickname="dhague"
+ * image="http://www.gravatar.com/avatar/c438262bd9c0caedbe3312c1ded261f6?s=80"
+ * id="1"
+ * whole_name="Darren Hague"/>
+ */
+ status.setId(user.getAttribute("id"));
+ status.setImage(user.getAttribute("image"));
+ status.setNickname(user.getAttribute("nickname"));
+ status.setWholeName(user.getAttribute("whole_name"));
+
+ } finally {
+ // Release the connection.
+ method.releaseConnection();
+ }
+
+ return status;
+ }
+
+ public List getMessages()
+ {
+// GET /api/get_msgs
+//
+// <esme_api operation="get_msgs" success="true">
+// <message id="1134" source="web" date="...">
+// <author image="..." name="..." id="9"/>
+// <body>
+// Woohoo - got through the rest of the slides quite quickly. I can go home now.
+// </body>
+// <tags/>
+// </message>
+// </esme_api>
+
+ // TODO
+ GetMethod method = new GetMethod(apiUrl + "/get_msgs");
+
+ List messageList = new ArrayList();
+
+ try {
+ Document document = executeHttp(method);
+
+ String success = document.getDocumentElement().getAttribute("success");
+ if ("false".equals(success))
+ {
+ logger.severe("success=false when calling /get_msgs");
+ return null;
+ }
+
+ NodeList messages = document.getElementsByTagName("message");
+
+ // *************************************************************
+ // Major TODO - complete the parsing and the setting of messages
+ // *************************************************************
+
+ } finally {
+ // Release the connection.
+ method.releaseConnection();
+ }
+
+ return messageList;
+ }
+}
+
Added: incubator/esme/trunk/esme-java-client/src/main/java/org/apache/esme/model/Message.java
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/esme-java-client/src/main/java/org/apache/esme/model/Message.java?rev=739891&view=auto
==============================================================================
--- incubator/esme/trunk/esme-java-client/src/main/java/org/apache/esme/model/Message.java (added)
+++ incubator/esme/trunk/esme-java-client/src/main/java/org/apache/esme/model/Message.java Mon Feb 2 00:19:35 2009
@@ -0,0 +1,61 @@
+/*
+ * Created on 05-Oct-2008
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package org.apache.esme.model;
+
+/**
+ * @author I056593
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class Message {
+ private String text = "";
+ private String[] tags = {};
+ private String via = "Java API";
+ /**
+ * @return
+ */
+ public String[] getTags() {
+ return tags;
+ }
+
+ /**
+ * @return
+ */
+ public String getText() {
+ return text;
+ }
+
+ /**
+ * @return
+ */
+ public String getVia() {
+ return via;
+ }
+
+ /**
+ * @param strings
+ */
+ public void setTags(String[] strings) {
+ tags = strings;
+ }
+
+ /**
+ * @param string
+ */
+ public void setText(String string) {
+ text = string;
+ }
+
+ /**
+ * @param string
+ */
+ public void setVia(String string) {
+ via = string;
+ }
+
+}
Added: incubator/esme/trunk/esme-java-client/src/main/java/org/apache/esme/model/Status.java
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/esme-java-client/src/main/java/org/apache/esme/model/Status.java?rev=739891&view=auto
==============================================================================
--- incubator/esme/trunk/esme-java-client/src/main/java/org/apache/esme/model/Status.java (added)
+++ incubator/esme/trunk/esme-java-client/src/main/java/org/apache/esme/model/Status.java Mon Feb 2 00:19:35 2009
@@ -0,0 +1,95 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.apache.esme.model;
+
+/**
+ *
+ * @author dhague
+ *
+ */
+public class Status {
+
+ private String id;
+ private String image;
+ private String nickname;
+ private String wholeName;
+
+ public String toString()
+ {
+ return "id="+id+", nickname="+nickname+", wholeName="+wholeName+", image="+image;
+ }
+
+ /**
+ * Get the value of wholeName
+ *
+ * @return the value of wholeName
+ */
+ public String getWholeName() {
+ return wholeName;
+ }
+
+ /**
+ * Set the value of wholeName
+ *
+ * @param wholeName new value of wholeName
+ */
+ public void setWholeName(String wholeName) {
+ this.wholeName = wholeName;
+ }
+
+ /**
+ * Get the value of id
+ *
+ * @return the value of id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Set the value of id
+ *
+ * @param id new value of id
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * Get the value of image
+ *
+ * @return the value of image
+ */
+ public String getImage() {
+ return image;
+ }
+
+ /**
+ * Set the value of image
+ *
+ * @param image new value of image
+ */
+ public void setImage(String image) {
+ this.image = image;
+ }
+
+ /**
+ * Get the value of nickname
+ *
+ * @return the value of nickname
+ */
+ public String getNickname() {
+ return nickname;
+ }
+
+ /**
+ * Set the value of nickname
+ *
+ * @param nickname new value of nickname
+ */
+ public void setNickname(String nickname) {
+ this.nickname = nickname;
+ }
+}
Added: incubator/esme/trunk/esme-java-client/src/test/java/org/apache/esme/api/RestTest.java
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/esme-java-client/src/test/java/org/apache/esme/api/RestTest.java?rev=739891&view=auto
==============================================================================
--- incubator/esme/trunk/esme-java-client/src/test/java/org/apache/esme/api/RestTest.java (added)
+++ incubator/esme/trunk/esme-java-client/src/test/java/org/apache/esme/api/RestTest.java Mon Feb 2 00:19:35 2009
@@ -0,0 +1,52 @@
+package org.apache.esme.api;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.apache.esme.api.EsmeRestApi;
+import junit.framework.TestCase;
+import org.apache.esme.model.Status;
+
+public class RestTest extends TestCase {
+
+ private static Logger logger = Logger.getLogger("org.apache.esme.api");
+
+ private static String token = TestProperties.getProperty("esme-token");
+
+ public void testStatus() throws Exception
+ {
+ EsmeRestApi.debugMode = true;
+
+ logger.log(Level.INFO, "Testing message status");
+
+ EsmeRestApi esme = new EsmeRestApi("http://localhost:8080/api");
+ Status status = esme.getStatus();
+ logger.log(Level.INFO, "API status is "+status);
+ }
+
+ public void testSendMsg() throws Exception
+ {
+// EsmeRestApi esme = new EsmeRestApi("http://api.esme.us/esme/api");
+// esme.setProxy("proxy",8080);
+// esme.login("JHUWLD5YQ1EY3UWTSOIQMNCHNQO4EYED");
+// Message msg = new Message();
+// msg.setText("Hello World, from Java, via SAP proxy server");
+// msg.setTags(new String[]{"Java Api","proxy"});
+// esme.sendMsg(msg);
+// esme.logout();
+
+ EsmeRestApi.debugMode = true;
+
+ logger.log(Level.INFO, "Testing message sending");
+
+ EsmeRestApi esme = new EsmeRestApi("http://localhost:8080/api");
+ esme.login(token);
+
+ Status status = esme.getStatus();
+ logger.log(Level.INFO, "API status is "+status);
+
+ esme.sendMsg("Hello World, from Java - the status was "+status);
+
+ esme.logout();
+ }
+
+}
Added: incubator/esme/trunk/esme-java-client/src/test/java/org/apache/esme/api/TestProperties.java
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/esme-java-client/src/test/java/org/apache/esme/api/TestProperties.java?rev=739891&view=auto
==============================================================================
--- incubator/esme/trunk/esme-java-client/src/test/java/org/apache/esme/api/TestProperties.java (added)
+++ incubator/esme/trunk/esme-java-client/src/test/java/org/apache/esme/api/TestProperties.java Mon Feb 2 00:19:35 2009
@@ -0,0 +1,36 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.apache.esme.api;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Properties;
+
+/**
+ *
+ * @author dhague
+ */
+class TestProperties {
+ static Properties properties = null;
+
+ static public String getProperty(String propName)
+ {
+ if (properties == null)
+ {
+ properties = new Properties() ;
+ URL url = ClassLoader.getSystemResource("props/test.properties");
+ try {
+ properties.load(new FileInputStream(new File(url.getFile())));
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+ return properties.getProperty(propName);
+ }
+}
+
Added: incubator/esme/trunk/esme-java-client/src/test/resources/props/test.properties
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/esme-java-client/src/test/resources/props/test.properties?rev=739891&view=auto
==============================================================================
--- incubator/esme/trunk/esme-java-client/src/test/resources/props/test.properties (added)
+++ incubator/esme/trunk/esme-java-client/src/test/resources/props/test.properties Mon Feb 2 00:19:35 2009
@@ -0,0 +1,2 @@
+esme-token=XNVNYBSLXIASO2T4IVO0N0ZN4MGZPJOI
+
Added: incubator/esme/trunk/esme-java-client/target/classes/org/apache/esme/api/EsmeException.class
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/esme-java-client/target/classes/org/apache/esme/api/EsmeException.class?rev=739891&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/esme/trunk/esme-java-client/target/classes/org/apache/esme/api/EsmeException.class
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/esme/trunk/esme-java-client/target/classes/org/apache/esme/api/EsmeRestApi.class
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/esme-java-client/target/classes/org/apache/esme/api/EsmeRestApi.class?rev=739891&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/esme/trunk/esme-java-client/target/classes/org/apache/esme/api/EsmeRestApi.class
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/esme/trunk/esme-java-client/target/classes/org/apache/esme/api/Message.class
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/esme-java-client/target/classes/org/apache/esme/api/Message.class?rev=739891&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/esme/trunk/esme-java-client/target/classes/org/apache/esme/api/Message.class
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/esme/trunk/esme-java-client/target/classes/org/apache/esme/model/Message.class
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/esme-java-client/target/classes/org/apache/esme/model/Message.class?rev=739891&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/esme/trunk/esme-java-client/target/classes/org/apache/esme/model/Message.class
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/esme/trunk/esme-java-client/target/classes/org/apache/esme/model/Status.class
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/esme-java-client/target/classes/org/apache/esme/model/Status.class?rev=739891&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/esme/trunk/esme-java-client/target/classes/org/apache/esme/model/Status.class
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/esme/trunk/esme-java-client/target/surefire-reports/TEST-org.apache.esme.api.RestTest.xml
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/esme-java-client/target/surefire-reports/TEST-org.apache.esme.api.RestTest.xml?rev=739891&view=auto
==============================================================================
--- incubator/esme/trunk/esme-java-client/target/surefire-reports/TEST-org.apache.esme.api.RestTest.xml (added)
+++ incubator/esme/trunk/esme-java-client/target/surefire-reports/TEST-org.apache.esme.api.RestTest.xml Mon Feb 2 00:19:35 2009
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<testsuite failures="0" time="0.364" errors="0" skipped="0" tests="2" name="org.apache.esme.api.RestTest">
+ <properties>
+ <property name="java.vendor" value="Sun Microsystems Inc."/>
+ <property name="env.SESSION_MANAGER" value="local/ono-sendai:/tmp/.ICE-unix/6104"/>
+ <property name="env.LESSOPEN" value="| /usr/bin/lesspipe %s"/>
+ <property name="localRepository" value="/home/dhague/.m2/repository"/>
+ <property name="sun.java.launcher" value="SUN_STANDARD"/>
+ <property name="sun.management.compiler" value="HotSpot Client Compiler"/>
+ <property name="os.name" value="Linux"/>
+ <property name="sun.boot.class.path" value="/usr/lib/jvm/java-6-sun-1.6.0.10/jre/lib/resources.jar:/usr/lib/jvm/java-6-sun-1.6.0.10/jre/lib/rt.jar:/usr/lib/jvm/java-6-sun-1.6.0.10/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-6-sun-1.6.0.10/jre/lib/jsse.jar:/usr/lib/jvm/java-6-sun-1.6.0.10/jre/lib/jce.jar:/usr/lib/jvm/java-6-sun-1.6.0.10/jre/lib/charsets.jar:/usr/lib/jvm/java-6-sun-1.6.0.10/jre/classes"/>
+ <property name="env.PWD" value="/home/dhague/esme-java-client"/>
+ <property name="env.XDG_SESSION_COOKIE" value="c81c9df1cf967ad8d0f9894c49163875-1233493979.836712-973510856"/>
+ <property name="sun.desktop" value="gnome"/>
+ <property name="env.LANG" value="en_GB.UTF-8"/>
+ <property name="java.vm.specification.vendor" value="Sun Microsystems Inc."/>
+ <property name="java.runtime.version" value="1.6.0_10-b33"/>
+ <property name="env.DISPLAY" value=":0.0"/>
+ <property name="user.name" value="dhague"/>
+ <property name="env._" value="/usr/bin/mvn"/>
+ <property name="env.USER" value="dhague"/>
+ <property name="env.HISTCONTROL" value="ignoreboth"/>
+ <property name="env.SHELL" value="/bin/bash"/>
+ <property name="env.DESKTOP_SESSION" value="default"/>
+ <property name="env.XDG_DATA_DIRS" value="/usr/local/share/:/usr/share/:/usr/share/gdm/"/>
+ <property name="env.NLSPATH" value="/usr/dt/lib/nls/msg/%L/%N.cat"/>
+ <property name="env.PATH" value="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/netbeans-6.5rc2/bin"/>
+ <property name="user.language" value="en"/>
+ <property name="sun.boot.library.path" value="/usr/lib/jvm/java-6-sun-1.6.0.10/jre/lib/i386"/>
+ <property name="classworlds.conf" value="/usr/share/maven2/bin/m2.conf"/>
+ <property name="java.version" value="1.6.0_10"/>
+ <property name="user.timezone" value="GB-Eire"/>
+ <property name="env.DBUS_SESSION_BUS_ADDRESS" value="unix:abstract=/tmp/dbus-1UVfSfCaQS,guid=e804a684bf970a84be8226b349859fdd"/>
+ <property name="sun.arch.data.model" value="32"/>
+ <property name="java.endorsed.dirs" value="/usr/lib/jvm/java-6-sun-1.6.0.10/jre/lib/endorsed"/>
+ <property name="env.JDK_HOME" value="/usr/lib/jvm/java-6-sun"/>
+ <property name="sun.cpu.isalist" value=""/>
+ <property name="sun.jnu.encoding" value="UTF-8"/>
+ <property name="file.encoding.pkg" value="sun.io"/>
+ <property name="env.SHLVL" value="1"/>
+ <property name="file.separator" value="/"/>
+ <property name="java.specification.name" value="Java Platform API Specification"/>
+ <property name="env.GNOME_DESKTOP_SESSION_ID" value="this-is-deprecated"/>
+ <property name="java.class.version" value="50.0"/>
+ <property name="env.GDMSESSION" value="default"/>
+ <property name="user.country" value="GB"/>
+ <property name="env.GNOME_KEYRING_PID" value="6093"/>
+ <property name="java.home" value="/usr/lib/jvm/java-6-sun-1.6.0.10/jre"/>
+ <property name="java.vm.info" value="mixed mode, sharing"/>
+ <property name="env.LOGNAME" value="dhague"/>
+ <property name="os.version" value="2.6.27-11-generic"/>
+ <property name="path.separator" value=":"/>
+ <property name="java.vm.version" value="11.0-b15"/>
+ <property name="env.JAVA_HOME" value="/usr/lib/jvm/java-6-sun"/>
+ <property name="java.awt.printerjob" value="sun.print.PSPrinterJob"/>
+ <property name="env.TERM" value="xterm"/>
+ <property name="env.WINDOWPATH" value="7"/>
+ <property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
+ <property name="env.LIBGL_DRIVERS_PATH" value="/usr/lib/dri"/>
+ <property name="env.GDM_LANG" value="en_GB.UTF-8"/>
+ <property name="user.home" value="/home/dhague"/>
+ <property name="env.OLDPWD" value="/home/dhague"/>
+ <property name="java.specification.vendor" value="Sun Microsystems Inc."/>
+ <property name="env.WINDOWID" value="69214819"/>
+ <property name="java.library.path" value="/usr/lib/jvm/java-6-sun-1.6.0.10/jre/lib/i386/client:/usr/lib/jvm/java-6-sun-1.6.0.10/jre/lib/i386:/usr/lib/jvm/java-6-sun-1.6.0.10/jre/../lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib"/>
+ <property name="java.vendor.url" value="http://java.sun.com/"/>
+ <property name="env.GDM_XSERVER_LOCATION" value="local"/>
+ <property name="java.vm.vendor" value="Sun Microsystems Inc."/>
+ <property name="maven.home" value="/usr/share/maven2"/>
+ <property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/>
+ <property name="java.class.path" value="/usr/share/maven2/boot/classworlds.jar"/>
+ <property name="env.XFILESEARCHPATH" value="/usr/dt/app-defaults/%L/Dt"/>
+ <property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
+ <property name="java.vm.specification.version" value="1.0"/>
+ <property name="sun.os.patch.level" value="unknown"/>
+ <property name="sun.cpu.endian" value="little"/>
+ <property name="env.GTK_RC_FILES" value="/etc/gtk/gtkrc:/home/dhague/.gtkrc-1.2-gnome2"/>
+ <property name="env.HOME" value="/home/dhague"/>
+ <property name="surefire.test.class.path" value="/home/dhague/esme-java-client/target/test-classes:/home/dhague/esme-java-client/target/classes:/home/dhague/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar:/home/dhague/.m2/repository/commons-httpclient/commons-httpclient/3.1/commons-httpclient-3.1.jar:/home/dhague/.m2/repository/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar:/home/dhague/.m2/repository/commons-codec/commons-codec/1.2/commons-codec-1.2.jar:"/>
+ <property name="java.io.tmpdir" value="/tmp"/>
+ <property name="env.LD_LIBRARY_PATH" value="/usr/lib/jvm/java-6-sun-1.6.0.10/jre/lib/i386/client:/usr/lib/jvm/java-6-sun-1.6.0.10/jre/lib/i386:/usr/lib/jvm/java-6-sun-1.6.0.10/jre/../lib/i386"/>
+ <property name="env.LS_COLORS" value="no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.svgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.aac=00;36:*.au=00;36:*.
flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:"/>
+ <property name="java.vendor.url.bug" value="http://java.sun.com/cgi-bin/bugreport.cgi"/>
+ <property name="env.SSH_AUTH_SOCK" value="/tmp/keyring-bznilT/ssh"/>
+ <property name="java.awt.graphicsenv" value="sun.awt.X11GraphicsEnvironment"/>
+ <property name="os.arch" value="i386"/>
+ <property name="java.ext.dirs" value="/usr/lib/jvm/java-6-sun-1.6.0.10/jre/lib/ext:/usr/java/packages/lib/ext"/>
+ <property name="user.dir" value="/home/dhague/esme-java-client"/>
+ <property name="env.XAUTHORITY" value="/home/dhague/.Xauthority"/>
+ <property name="line.separator" value="
+"/>
+ <property name="java.vm.name" value="Java HotSpot(TM) Client VM"/>
+ <property name="env.COLORTERM" value="gnome-terminal"/>
+ <property name="basedir" value="/home/dhague/esme-java-client"/>
+ <property name="env.ORBIT_SOCKETDIR" value="/tmp/orbit-dhague"/>
+ <property name="env.USERNAME" value="dhague"/>
+ <property name="file.encoding" value="UTF-8"/>
+ <property name="env.GNOME_KEYRING_SOCKET" value="/tmp/keyring-bznilT/socket"/>
+ <property name="env.GPG_AGENT_INFO" value="/tmp/seahorse-b8faS0/S.gpg-agent:6177:1"/>
+ <property name="java.specification.version" value="1.6"/>
+ <property name="env.LESSCLOSE" value="/usr/bin/lesspipe %s %s"/>
+ </properties>
+ <testcase time="0.25" classname="org.apache.esme.api.RestTest" name="testStatus"/>
+ <testcase time="0.09" classname="org.apache.esme.api.RestTest" name="testSendMsg"/>
+</testsuite>
\ No newline at end of file
Added: incubator/esme/trunk/esme-java-client/target/surefire-reports/org.apache.esme.api.RestTest.txt
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/esme-java-client/target/surefire-reports/org.apache.esme.api.RestTest.txt?rev=739891&view=auto
==============================================================================
--- incubator/esme/trunk/esme-java-client/target/surefire-reports/org.apache.esme.api.RestTest.txt (added)
+++ incubator/esme/trunk/esme-java-client/target/surefire-reports/org.apache.esme.api.RestTest.txt Mon Feb 2 00:19:35 2009
@@ -0,0 +1,4 @@
+-------------------------------------------------------------------------------
+Test set: org.apache.esme.api.RestTest
+-------------------------------------------------------------------------------
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.381 sec
Added: incubator/esme/trunk/esme-java-client/target/test-classes/org/apache/esme/api/RestTest.class
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/esme-java-client/target/test-classes/org/apache/esme/api/RestTest.class?rev=739891&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/esme/trunk/esme-java-client/target/test-classes/org/apache/esme/api/RestTest.class
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/esme/trunk/esme-java-client/target/test-classes/org/apache/esme/api/TestProperties.class
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/esme-java-client/target/test-classes/org/apache/esme/api/TestProperties.class?rev=739891&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/esme/trunk/esme-java-client/target/test-classes/org/apache/esme/api/TestProperties.class
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/esme/trunk/esme-java-client/target/test-classes/props/test.properties
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/esme-java-client/target/test-classes/props/test.properties?rev=739891&view=auto
==============================================================================
--- incubator/esme/trunk/esme-java-client/target/test-classes/props/test.properties (added)
+++ incubator/esme/trunk/esme-java-client/target/test-classes/props/test.properties Mon Feb 2 00:19:35 2009
@@ -0,0 +1,2 @@
+esme-token=XNVNYBSLXIASO2T4IVO0N0ZN4MGZPJOI
+