Permalink
Browse files

Implementing client...

  • Loading branch information...
1 parent 23f070e commit 59136b271a478ed463af3d7111cac1b55128e703 @kawasima committed Aug 3, 2012
View
@@ -1,3 +1,7 @@
+target
+.project
+.settings
+.classpath
*.class
# Package Files #
View
@@ -95,6 +95,11 @@
<artifactId>xstream</artifactId>
<version>1.4.2</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.2.1</version>
+ </dependency>
</dependencies>
<groupId>net.unit8.sastruts</groupId>
<artifactId>sastruts-easy-api</artifactId>
@@ -0,0 +1,17 @@
+package net.unit8.sastruts.easyapi.client;
+
+public class ClientContext {
+ private Object sendData;
+
+ public ClientContext(Object sendData) {
+
+ }
+
+ public ClientContext to(String name) {
+ return this;
+ }
+
+ public ClientContext from(String name) {
+ return this;
+ }
+}
@@ -0,0 +1,20 @@
+package net.unit8.sastruts.easyapi.client;
+
+import net.unit8.sastruts.easyapi.EasyApiException;
+
+import org.apache.http.client.HttpClient;
+import org.apache.http.impl.conn.PoolingClientConnectionManager;
+
+public class EasyApiClient {
+ private Object data;
+ private static PoolingClientConnectionManager manager;
+ HttpClient client;
+
+ public void post(Object data) {
+ this.data = data;
+ }
+
+ public void to() {
+
+ }
+}
@@ -0,0 +1,41 @@
+package net.unit8.sastruts.easyapi.client;
+
+public class EasyApiSetting {
+ /** Setting name */
+ private String name;
+ private String host;
+ private String path;
+ private int retryCount = 0;
+ private int retryInterval = 0;
+
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getHost() {
+ return host;
+ }
+ public void setHost(String host) {
+ this.host = host;
+ }
+ public String getPath() {
+ return path;
+ }
+ public void setPath(String path) {
+ this.path = path;
+ }
+ public int getRetryCount() {
+ return retryCount;
+ }
+ public void setRetryCount(int retryCount) {
+ this.retryCount = retryCount;
+ }
+ public int getRetryInterval() {
+ return retryInterval;
+ }
+ public void setRetryInterval(int retryInterval) {
+ this.retryInterval = retryInterval;
+ }
+}
@@ -0,0 +1,16 @@
+package net.unit8.sastruts.easyapi.client;
+
+import java.util.List;
+
+import org.seasar.framework.container.S2Container;
+import org.seasar.framework.container.factory.SingletonS2ContainerFactory;
+
+public class EasyApiSettingProvider {
+ boolean useMock = false;
+
+ public void register(String name) {
+ }
+ public void register(List<String> nameList) {
+
+ }
+}
@@ -0,0 +1,17 @@
+package net.unit8.sastruts.easyapi.client;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.seasar.framework.unit.Seasar2;
+import org.seasar.framework.unit.TestContext;
+
+@RunWith(Seasar2.class)
+public class EasyApiClientTest {
+ private TestContext ctx;
+ @Test
+ public void testPost() {
+ EasyApiClient client = ctx.getComponent(EasyApiClient.class);
+ muchMoneyDto = new MuchMoneyDto();
+ client.post(muchMoneyDto).to("CityBank");
+ }
+}
@@ -0,0 +1,5 @@
+package net.unit8.sastruts.easyapi.dto;
+
+public class MuchMoneyDto {
+ public int amount;
+}
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container 2.4//EN"
+ "http://www.seasar.org/dtd/components24.dtd">
+<components>
+ <component name="easyApiClient" class="net.unit8.sastruts.easyapi.client.MockEasyApiClient"/>
+ <component class="net.unit8.sastruts.easyapi.client.EsayApiSettingProvider">
+ <property name="useMock">#ENV == 'ut' || #ENV == 'ct'</property>
+ <initMethod name="register">
+ <arg>{"cityBank"}</arg>
+ </initMethod>
+ </component>
+ <component name="cityBank" class="net.unit8.sastruts.easyapi.client.EasyApiSetting">
+ <property name="host">"http://example.com"</property>
+ <property name="path">"/api/{id}"</property>
+ <component>
+</components>

0 comments on commit 59136b2

Please sign in to comment.