Skip to content

Commit

Permalink
Fixs
Browse files Browse the repository at this point in the history
  • Loading branch information
chamerling committed Nov 16, 2012
1 parent b6ed689 commit 80d9e13
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 5 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@
import org.ow2.play.platform.api.APIException; import org.ow2.play.platform.api.APIException;
import org.ow2.play.platform.api.bean.Subscription; import org.ow2.play.platform.api.bean.Subscription;
import org.ow2.play.platform.api.bean.SubscriptionResult; import org.ow2.play.platform.api.bean.SubscriptionResult;
import org.ow2.play.platform.client.api.ClientException;
import org.ow2.play.service.registry.api.Constants; import org.ow2.play.service.registry.api.Constants;
import org.ow2.play.service.registry.api.Registry; import org.ow2.play.service.registry.api.Registry;
import org.ow2.play.service.registry.api.RegistryException; import org.ow2.play.service.registry.api.RegistryException;
import org.petalslink.dsb.cxf.CXFHelper; import org.petalslink.dsb.cxf.CXFHelper;


import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.eventbus.Subscribe;
import com.sun.istack.logging.Logger; import com.sun.istack.logging.Logger;


/** /**
Expand Down
4 changes: 3 additions & 1 deletion play-platform-apiwar/src/main/webapp/WEB-INF/beans.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
<property name="url" value="http://localhost:8080/registry/RegistryService"/> <property name="url" value="http://localhost:8080/registry/RegistryService"/>
</bean> </bean>


<bean id="api" class="org.ow2.play.platform.api.service.API"/> <bean id="api" class="org.ow2.play.platform.api.service.API">
<property name="registry" ref="serviceregistry"/>
</bean>


<bean id="api-subscriptionservice" class="org.ow2.play.platform.api.service.SubscriptionService"> <bean id="api-subscriptionservice" class="org.ow2.play.platform.api.service.SubscriptionService">
<property name="registry" ref="serviceregistry"/> <property name="registry" ref="serviceregistry"/>
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public interface PlatformClient {
/** /**
* *
* @return * @return
* @throws ClientException
*/ */
SubscriptionService getSubscriptionManager(); SubscriptionService getSubscriptionManager() throws ClientException;


} }
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -96,12 +96,19 @@ public void connect(String apiEndpoint, String authtoken)
* org.ow2.play.platform.client.api.PlatformClient#getSubscriptionManager() * org.ow2.play.platform.client.api.PlatformClient#getSubscriptionManager()
*/ */
@Override @Override
public synchronized SubscriptionService getSubscriptionManager() { public synchronized SubscriptionService getSubscriptionManager() throws ClientException {
checkConnected();
if (subscriptionManager == null) { if (subscriptionManager == null) {
subscriptionManager = new SubscriptionServiceImpl(); subscriptionManager = new SubscriptionServiceImpl();
} }
return subscriptionManager; return subscriptionManager;
} }

private void checkConnected() throws ClientException {
if (apiEndpoint == null) {
throw new ClientException("Please connect first");
}
}


class SubscriptionServiceImpl implements SubscriptionService { class SubscriptionServiceImpl implements SubscriptionService {


Expand Down
50 changes: 50 additions & 0 deletions play-platform-client-ws/src/test/java/org/ow2/play/AppTest.java
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,10 @@
package org.ow2.play; package org.ow2.play;


import org.ow2.play.platform.api.bean.Subscription;
import org.ow2.play.platform.api.bean.SubscriptionResult;
import org.ow2.play.platform.api.bean.Topic;
import org.ow2.play.platform.client.ws.PlatformClient;

import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestCase; import junit.framework.TestCase;
import junit.framework.TestSuite; import junit.framework.TestSuite;
Expand Down Expand Up @@ -35,4 +40,49 @@ public void testApp()
{ {
assertTrue( true ); assertTrue( true );
} }

public void testMe() throws Exception {
PlatformClient client = new PlatformClient();
client.connect("http://localhost:8080/play/api/v1/", null);

Subscription subscription = new Subscription();
subscription.subscriber = "http://localhost:3001/";
Topic topic = new Topic();
topic.name = "FacebookStatusFeed";
topic.ns = "http://streams.event-processing.org/ids/";
topic.prefix = "s";

subscription.topic = topic;
SubscriptionResult result = client.getSubscriptionManager().subscribe(subscription);
System.out.println("" + result.subscriptionID);
}

public void testUnsubscribe() throws Exception {
PlatformClient client = new PlatformClient();
client.connect("http://localhost:8080/play/api/v1/", null);

boolean result = client.getSubscriptionManager().unsubscribe("4d7ddc57-f426-454c-a738-625a7621a852");;
System.out.println(result);
}


public void testSubscribeThenUnsubscribe() throws Exception {
PlatformClient client = new PlatformClient();
client.connect("http://localhost:8080/play/api/v1/", null);

Subscription subscription = new Subscription();
subscription.subscriber = "http://localhost:3001/";
Topic topic = new Topic();
topic.name = "FacebookStatusFeed";
topic.ns = "http://streams.event-processing.org/ids/";
topic.prefix = "s";

subscription.topic = topic;
SubscriptionResult result = client.getSubscriptionManager().subscribe(subscription);
System.out.println("Got subscription : " + result.subscriptionID);

Thread.sleep(20000L);

client.getSubscriptionManager().unsubscribe(result.subscriptionID);
}
} }

0 comments on commit 80d9e13

Please sign in to comment.