You are viewing a plain text version of this content. The canonical link for it is here.
Posted to savan-dev@ws.apache.org by he...@apache.org on 2007/05/28 11:01:01 UTC
svn commit: r542163 - in /webservices/savan/trunk/java/modules:
core/src/main/java/org/apache/savan/atom/
core/src/main/java/org/apache/savan/messagereceiver/
core/src/test/java/org/apache/axis2/savan/atom/ mar/
Author: hemapani
Date: Mon May 28 02:01:00 2007
New Revision: 542163
URL: http://svn.apache.org/viewvc?view=rev&rev=542163
Log:
add initial version of test cases
Added:
webservices/savan/trunk/java/modules/core/src/main/java/org/apache/savan/messagereceiver/PublishingMessageReceiver.java
webservices/savan/trunk/java/modules/core/src/test/java/org/apache/axis2/savan/atom/
webservices/savan/trunk/java/modules/core/src/test/java/org/apache/axis2/savan/atom/AtomTest.java
webservices/savan/trunk/java/modules/core/src/test/java/org/apache/axis2/savan/atom/PublisherService.java
webservices/savan/trunk/java/modules/core/src/test/java/org/apache/axis2/savan/atom/UtilServer.java
webservices/savan/trunk/java/modules/core/src/test/java/org/apache/axis2/savan/atom/UtilServerBasedTestCase.java
webservices/savan/trunk/java/modules/core/src/test/java/org/apache/axis2/savan/atom/publisher.services.xml
Modified:
webservices/savan/trunk/java/modules/core/src/main/java/org/apache/savan/atom/AtomMessageReceiver.java
webservices/savan/trunk/java/modules/core/src/main/java/org/apache/savan/atom/AtomSubscriptionProcessor.java
webservices/savan/trunk/java/modules/core/src/main/java/org/apache/savan/atom/AtomUtilFactory.java
webservices/savan/trunk/java/modules/mar/module.xml
Modified: webservices/savan/trunk/java/modules/core/src/main/java/org/apache/savan/atom/AtomMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/java/modules/core/src/main/java/org/apache/savan/atom/AtomMessageReceiver.java?view=diff&rev=542163&r1=542162&r2=542163
==============================================================================
--- webservices/savan/trunk/java/modules/core/src/main/java/org/apache/savan/atom/AtomMessageReceiver.java (original)
+++ webservices/savan/trunk/java/modules/core/src/main/java/org/apache/savan/atom/AtomMessageReceiver.java Mon May 28 02:01:00 2007
@@ -3,6 +3,8 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.net.URI;
+import java.net.URISyntaxException;
import javax.servlet.http.HttpServletRequest;
import javax.xml.stream.XMLStreamException;
@@ -22,7 +24,6 @@
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.engine.AxisEngine;
-import org.apache.axis2.engine.AxisError;
import org.apache.axis2.engine.MessageReceiver;
import org.apache.axis2.i18n.Messages;
import org.apache.axis2.transport.http.HTTPConstants;
@@ -49,10 +50,32 @@
OMElement feedID = bodyContent.getFirstElement();
String pathWRTRepository = "atom/"+feedID.getText();
-
+
File atomFile = messageCtx.getConfigurationContext().getRealPath(pathWRTRepository);
+ if(pathWRTRepository.equals("atom/all.atom") && !atomFile.exists()){
+ AtomSubscriber atomSubscriber = new AtomSubscriber();
+ atomSubscriber.setId(new URI("All"));
+ atomSubscriber.setAtomFile(atomFile);
+ atomSubscriber.setAuthor("DefaultUser");
+ atomSubscriber.setTitle("default Feed");
+
+ String serviceAddress = messageCtx.getTo().getAddress();
+ int cutIndex = serviceAddress.indexOf("services");
+ if(cutIndex > 0){
+ serviceAddress = serviceAddress.substring(0,cutIndex-1);
+ }
+ atomSubscriber.setFeedUrl(serviceAddress+"/services/"+messageCtx.getServiceContext().getAxisService().getName() +"/atom?feed=all.atom");
+
+
+ SubscriberStore store = CommonUtil.getSubscriberStore(messageCtx.getAxisService());
+ if (store == null)
+ throw new AxisFault ("Cant find the Savan subscriber store");
+ store.store(atomSubscriber);
+ }
+
+
if(!atomFile.exists()){
- throw new AxisFault("no feed exisits for "+feedID.getText());
+ throw new AxisFault("no feed exisits for "+feedID.getText() + " no file found "+ atomFile.getAbsolutePath());
}
FileInputStream atomIn = new FileInputStream(atomFile);
@@ -96,12 +119,20 @@
}
} catch (SOAPProcessingException e) {
+ e.printStackTrace();
throw new AxisFault(e);
+
} catch (OMException e) {
+ e.printStackTrace();
throw new AxisFault(e);
} catch (FileNotFoundException e) {
+ e.printStackTrace();
throw new AxisFault(e);
} catch (XMLStreamException e) {
+ e.printStackTrace();
+ throw new AxisFault(e);
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
throw new AxisFault(e);
}
}
Modified: webservices/savan/trunk/java/modules/core/src/main/java/org/apache/savan/atom/AtomSubscriptionProcessor.java
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/java/modules/core/src/main/java/org/apache/savan/atom/AtomSubscriptionProcessor.java?view=diff&rev=542163&r1=542162&r2=542163
==============================================================================
--- webservices/savan/trunk/java/modules/core/src/main/java/org/apache/savan/atom/AtomSubscriptionProcessor.java (original)
+++ webservices/savan/trunk/java/modules/core/src/main/java/org/apache/savan/atom/AtomSubscriptionProcessor.java Mon May 28 02:01:00 2007
@@ -38,6 +38,7 @@
import org.apache.savan.configuration.Protocol;
import org.apache.savan.filters.Filter;
import org.apache.savan.filters.XPathBasedFilter;
+import org.apache.savan.storage.SubscriberStore;
import org.apache.savan.subscribers.Subscriber;
import org.apache.savan.subscription.ExpirationBean;
import org.apache.savan.subscription.SubscriptionProcessor;
@@ -120,7 +121,7 @@
String id = UUIDGenerator.getUUID();
smc.setProperty(AtomConstants.TransferedProperties.SUBSCRIBER_UUID,id);
atomSubscriber.setId(new URI(id));
- String atomFeedPath = id.replaceAll(":", "_")+ ".atom";
+ String atomFeedPath = id2Path(id);
atomSubscriber.setAtomFile(new File(realAtomPath,atomFeedPath));
atomSubscriber.setFeedUrl(serviceAddress+"/services/"+smc.getMessageContext().getServiceContext().getAxisService().getName() +"/atom?feed="+ atomFeedPath);
@@ -150,10 +151,8 @@
}
atomSubscriber.setFilter(filter);
}
- //TODO -Srinath
atomSubscriber.setAuthor(createFeed.getAuthor());
atomSubscriber.setTitle(createFeed.getTitle());
-
smc.setProperty(AtomConstants.Properties.feedUrl, atomSubscriber.getFeedUrl());
return atomSubscriber;
} catch (AxisFault e) {
@@ -250,5 +249,19 @@
return findValue(AtomConstants.ATOM_NAMESPACE,AtomConstants.IDEDNTIFIER_ELEMENT, envelope.getHeader(), false);
}
+
+ public void unsubscribe(SavanMessageContext endSubscriptionMessage) throws SavanException {
+ String subscriberID = getSubscriberID (endSubscriptionMessage);
+ File feedPath = endSubscriptionMessage.getConfigurationContext().getRealPath("atom/"+id2Path(subscriberID));
+ if(feedPath.exists()){
+ feedPath.delete();
+ }
+ super.unsubscribe(endSubscriptionMessage);
+ }
+
+ private String id2Path(String id){
+ return id.replaceAll(":", "_")+ ".atom";
+ }
+
}
Modified: webservices/savan/trunk/java/modules/core/src/main/java/org/apache/savan/atom/AtomUtilFactory.java
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/java/modules/core/src/main/java/org/apache/savan/atom/AtomUtilFactory.java?view=diff&rev=542163&r1=542162&r2=542163
==============================================================================
--- webservices/savan/trunk/java/modules/core/src/main/java/org/apache/savan/atom/AtomUtilFactory.java (original)
+++ webservices/savan/trunk/java/modules/core/src/main/java/org/apache/savan/atom/AtomUtilFactory.java Mon May 28 02:01:00 2007
@@ -26,6 +26,12 @@
import org.apache.savan.util.UtilFactory;
public class AtomUtilFactory implements UtilFactory {
+
+ public AtomUtilFactory(){
+
+ }
+
+
/**
* this is a way to map different actions to different types of operations
Added: webservices/savan/trunk/java/modules/core/src/main/java/org/apache/savan/messagereceiver/PublishingMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/java/modules/core/src/main/java/org/apache/savan/messagereceiver/PublishingMessageReceiver.java?view=auto&rev=542163
==============================================================================
--- webservices/savan/trunk/java/modules/core/src/main/java/org/apache/savan/messagereceiver/PublishingMessageReceiver.java (added)
+++ webservices/savan/trunk/java/modules/core/src/main/java/org/apache/savan/messagereceiver/PublishingMessageReceiver.java Mon May 28 02:01:00 2007
@@ -0,0 +1,17 @@
+package org.apache.savan.messagereceiver;
+
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.engine.MessageReceiver;
+import org.apache.savan.publication.client.PublicationClient;
+
+public class PublishingMessageReceiver implements MessageReceiver{
+ public void receive(MessageContext messageCtx) throws AxisFault {
+ SOAPEnvelope requestEnvelope = messageCtx.getEnvelope();
+ ServiceContext serviceContext = messageCtx.getServiceContext();
+ PublicationClient client = new PublicationClient(serviceContext.getConfigurationContext());
+ client.sendPublication(requestEnvelope.getBody().getFirstElement(),serviceContext.getAxisService(),null);
+ }
+}
Added: webservices/savan/trunk/java/modules/core/src/test/java/org/apache/axis2/savan/atom/AtomTest.java
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/java/modules/core/src/test/java/org/apache/axis2/savan/atom/AtomTest.java?view=auto&rev=542163
==============================================================================
--- webservices/savan/trunk/java/modules/core/src/test/java/org/apache/axis2/savan/atom/AtomTest.java (added)
+++ webservices/savan/trunk/java/modules/core/src/test/java/org/apache/axis2/savan/atom/AtomTest.java Mon May 28 02:01:00 2007
@@ -0,0 +1,298 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis2.savan.atom;
+
+//todo
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.savan.atom.AtomEventingClient;
+import org.apache.savan.eventing.EventingConstants;
+import org.apache.savan.eventing.client.EventingClient;
+import org.apache.savan.eventing.client.EventingClientBean;
+import org.apache.savan.eventing.client.SubscriptionStatus;
+
+import com.wso2.eventing.atom.CreateFeedResponseDocument.CreateFeedResponse;
+
+public class AtomTest extends UtilServerBasedTestCase {
+
+ private static final Log log = LogFactory.getLog(AtomTest.class);
+ protected QName transportName = new QName("http://localhost/my",
+ "NullTransport");
+ private final int MIN_OPTION = 1;
+ private final int MAX_OPTION = 9;
+
+ private final String SUBSCRIBER_1_ID = "subscriber1";
+ private final String SUBSCRIBER_2_ID = "subscriber2";
+
+ private final String AXIS2_REPO = "target/repository/";
+
+ private ServiceClient serviceClient = null;
+ private Options options = null;
+ private EventingClient eventingClient = null;
+
+ private String toAddressPart = "/axis2/services/PublisherService";
+ private String listner1AddressPart = "/axis2/services/ListnerService1";
+ private String listner2AddressPart = "/axis2/services/ListnerService2";
+
+ private final String applicationNamespaceName = "http://tempuri.org/";
+ private final String dummyMethod = "dummyMethod";
+
+ private static String repo = null;
+ private static int port = 5556;
+ private static String serverIP = "127.0.0.1";
+
+ protected AxisConfiguration engineRegistry;
+ protected MessageContext mc;
+ protected ServiceContext serviceContext;
+ protected AxisService service;
+ private QName serviceName = new QName("PublisherService");
+
+ protected boolean finish = false;
+
+ public AtomTest() {
+ super(AtomTest.class.getName());
+ }
+
+ public AtomTest(String testName) {
+ super(testName);
+ }
+
+
+
+ protected void setUp() throws Exception {
+ UtilServer.start(AXIS2_REPO);
+// service = Utils.createSimpleService(serviceName,
+// PublisherService.class.getName(),
+// new QName("dummyMethod"));
+// service.addModuleref("savan");
+//
+// UtilServer.deployService(service);
+
+// AxisService service1 = Utils.createSimpleService(new QName("ListnerService1"),
+// SavenTest.class.getName(),
+// new QName("publish"));
+// UtilServer.deployService(service1);
+
+ }
+
+ protected void tearDown() throws Exception {
+ //UtilServer.unDeployService(serviceName);
+ UtilServer.unDeployClientService();
+ }
+
+
+ public void testAtomSubcription()throws Exception{
+ //Thread.sleep(1000*60*100);
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_REPO,AXIS2_REPO+"/conf/axis2.xml");
+ serviceClient = new ServiceClient (configContext,null); //TODO give a repo
+
+ options = new Options ();
+ serviceClient.setOptions(options);
+ serviceClient.engageModule(new QName ("addressing"));
+
+ eventingClient = new EventingClient (serviceClient);
+
+ String toAddress = "http://" + serverIP + ":" + port + toAddressPart;
+
+ //String toAddress = "http://" + serverIP + ":" + port + "/axis2/services/RMSampleService";
+ options.setTo(new EndpointReference (toAddress));
+
+
+ AtomEventingClient atomEventingClient = new AtomEventingClient(serviceClient);
+ CreateFeedResponse createFeedResponse = atomEventingClient.createFeed("test Title","Srinath Perera");
+
+ options.setAction("http://wso2.com/eventing/dummyMethod");
+ serviceClient.fireAndForget(getDummyMethodRequestElement ());
+
+ options.setAction(EventingConstants.Actions.Publish);
+ serviceClient.fireAndForget(getDummyMethodRequestElement ());
+
+ //Thread.sleep(1000*10*1000);
+
+ int i = 0;
+ while(i<1){
+ System.out.println(createFeedResponse.getFeedUrl());
+ URL url = new URL(createFeedResponse.getFeedUrl());
+ System.out.println(readFromStream(url.openStream()));
+ Thread.sleep(1000*10);
+ i++;
+ }
+//
+ atomEventingClient.deleteFeed();
+
+
+ }
+
+
+
+// public void testEvents() throws Exception{
+// initClient ();
+// performAction (1);
+// }
+
+
+ public void publish(OMElement param) throws Exception {
+ System.out.println("\n");
+ System.out.println("'1' got a new publication...");
+ System.out.println(param);
+ System.out.println("\n");
+ }
+
+
+ private void initClient () throws AxisFault {
+
+// String CLIENT_REPO = null;
+// String AXIS2_XML = null;
+//
+// if (repo!=null) {
+// CLIENT_REPO = repo;
+// AXIS2_XML = repo + File.separator + "axis2.xml";
+// } else {
+//// throw new AxisFault ("Please specify the client repository as a program argument.Use '-h' for help.");
+// }
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_REPO,AXIS2_REPO+"/conf/axis2.xml");
+ serviceClient = new ServiceClient (configContext,null); //TODO give a repo
+
+ options = new Options ();
+ serviceClient.setOptions(options);
+ serviceClient.engageModule(new QName ("addressing"));
+
+ eventingClient = new EventingClient (serviceClient);
+
+ String toAddress = "http://" + serverIP + ":" + port + toAddressPart;
+
+ //String toAddress = "http://" + serverIP + ":" + port + "/axis2/services/RMSampleService";
+ options.setTo(new EndpointReference (toAddress));
+ }
+
+ private void performAction (int action) throws Exception {
+
+ switch (action) {
+ case 1:
+ doSubscribe(SUBSCRIBER_1_ID);
+ break;
+ case 2:
+ doSubscribe(SUBSCRIBER_2_ID);
+ break;
+ case 3:
+ doSubscribe(SUBSCRIBER_1_ID);
+ doSubscribe(SUBSCRIBER_2_ID);
+ break;
+ case 4:
+ doUnsubscribe(SUBSCRIBER_1_ID);
+ break;
+ case 5:
+ doUnsubscribe(SUBSCRIBER_2_ID);
+ break;
+ case 6:
+ doUnsubscribe(SUBSCRIBER_1_ID);
+ doUnsubscribe(SUBSCRIBER_2_ID);
+ break;
+ case 7:
+ doGetStatus(SUBSCRIBER_1_ID);
+ break;
+ case 8:
+ doGetStatus(SUBSCRIBER_2_ID);
+ break;
+ case 9:
+ System.exit(0);
+ break;
+ default:
+ break;
+ }
+ }
+
+ private void doSubscribe (String ID) throws Exception {
+ EventingClientBean bean = new EventingClientBean ();
+
+ String subscribingAddress = null;
+ if (SUBSCRIBER_1_ID.equals(ID)) {
+ subscribingAddress = "http://" + serverIP + ":" + port + listner1AddressPart;
+ } else if (SUBSCRIBER_2_ID.equals(ID)) {
+ subscribingAddress = "http://" + serverIP + ":" + port + listner2AddressPart;
+ }
+
+ bean.setDeliveryEPR(new EndpointReference (subscribingAddress));
+
+ //uncomment following to set an expiration time of 10 minutes.
+// Date date = new Date ();
+// date.setMinutes(date.getMinutes()+10);
+// bean.setExpirationTime(date);
+
+ eventingClient.subscribe(bean,ID);
+ Thread.sleep(1000); //TODO remove if not sequired
+ }
+
+ private void doUnsubscribe (String ID) throws Exception {
+ eventingClient.unsubscribe(ID);
+ Thread.sleep(1000); //TODO remove if not sequired
+ }
+
+ private void doGetStatus (String ID) throws Exception {
+ SubscriptionStatus status = eventingClient.getSubscriptionStatus(ID);
+ Thread.sleep(1000); //TODO remove if not sequired
+
+ String statusValue = status.getExpirationValue();
+ System.out.println("Status of the subscriber '" + ID +"' is" + statusValue);
+ }
+
+ private OMElement getDummyMethodRequestElement() {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+ return fac.createOMElement(dummyMethod, namespace);
+ }
+
+ public static String readFromStream(InputStream in) throws Exception{
+ try {
+ StringBuffer wsdlStr = new StringBuffer();
+
+ int read;
+
+ byte[] buf = new byte[1024];
+ while((read = in.read(buf)) > 0){
+ wsdlStr.append(new String(buf,0,read));
+ }
+ in.close();
+ return wsdlStr.toString();
+ } catch (IOException e) {
+ throw new Exception(e);
+ }
+ }
+
+}
Added: webservices/savan/trunk/java/modules/core/src/test/java/org/apache/axis2/savan/atom/PublisherService.java
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/java/modules/core/src/test/java/org/apache/axis2/savan/atom/PublisherService.java?view=auto&rev=542163
==============================================================================
--- webservices/savan/trunk/java/modules/core/src/test/java/org/apache/axis2/savan/atom/PublisherService.java (added)
+++ webservices/savan/trunk/java/modules/core/src/test/java/org/apache/axis2/savan/atom/PublisherService.java Mon May 28 02:01:00 2007
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis2.savan.atom;
+
+import java.net.URI;
+import java.util.Random;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.savan.publication.client.PublicationClient;
+import org.apache.savan.storage.SubscriberStore;
+import org.apache.savan.util.CommonUtil;
+
+public class PublisherService {
+
+ ServiceContext serviceContext = null;
+ private String eventName = "testTopic";
+
+ public void init(ServiceContext serviceContext) throws AxisFault {
+ try {
+ System.out.println("Eventing Service INIT called");
+ this.serviceContext = serviceContext;
+
+ PublisherThread thread = new PublisherThread ();
+ thread.start();
+ Thread.sleep(10000);
+ } catch (InterruptedException e) {
+ throw new AxisFault(e);
+ }
+ }
+
+ public void dummyMethod(OMElement param) throws Exception {
+ System.out.println("Eventing Service dummy method called");
+ }
+
+ private class PublisherThread extends Thread {
+
+ String Publication = "Publication";
+ String publicationNamespaceValue = "http://tempuri/publication/";
+ Random r = new Random ();
+
+ public void run () {
+ try {
+ while (true) {
+
+
+
+ //publishing
+ System.out.println("Publishing next publication...");
+
+ SubscriberStore store = CommonUtil.getSubscriberStore(serviceContext.getAxisService());
+ if (store==null)
+ throw new Exception ("Cant find the Savan subscriber store");
+
+ OMElement envelope = getNextPublicationEvent ();
+ PublicationClient client = new PublicationClient(serviceContext.getConfigurationContext());
+ client.sendPublication(envelope,serviceContext.getAxisService(),null);
+ Thread.sleep(10000);
+ }
+
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ private int eventID = 0;
+
+ public OMElement getNextPublicationEvent () {
+ SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+ OMNamespace namespace = factory.createOMNamespace(publicationNamespaceValue,"ns1");
+ OMElement publicationElement = factory.createOMElement(Publication,namespace);
+
+ factory.createOMElement("foo",namespace,publicationElement).setText("Event "+eventID);
+
+ OMElement publishMethod = factory.createOMElement("publish",namespace);
+ publishMethod.addChild(publicationElement);
+
+ return publishMethod;
+ }
+ }
+}
Added: webservices/savan/trunk/java/modules/core/src/test/java/org/apache/axis2/savan/atom/UtilServer.java
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/java/modules/core/src/test/java/org/apache/axis2/savan/atom/UtilServer.java?view=auto&rev=542163
==============================================================================
--- webservices/savan/trunk/java/modules/core/src/test/java/org/apache/axis2/savan/atom/UtilServer.java (added)
+++ webservices/savan/trunk/java/modules/core/src/test/java/org/apache/axis2/savan/atom/UtilServer.java Mon May 28 02:01:00 2007
@@ -0,0 +1,191 @@
+package org.apache.axis2.savan.atom;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.context.ServiceGroupContext;
+import org.apache.axis2.deployment.DeploymentConstants;
+import org.apache.axis2.deployment.DeploymentEngine;
+import org.apache.axis2.deployment.DeploymentException;
+import org.apache.axis2.deployment.repository.util.ArchiveReader;
+import org.apache.axis2.deployment.util.Utils;
+import org.apache.axis2.description.AxisModule;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisServiceGroup;
+import org.apache.axis2.description.Flow;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.ListenerManager;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+
+/**
+ *
+ */
+public class UtilServer {
+ private static int count = 0;
+
+ private static SimpleHTTPServer receiver;
+
+ public static final int TESTING_PORT = 5555;
+
+ public static synchronized void deployService(AxisService service)
+ throws AxisFault {
+ receiver.getConfigurationContext().getAxisConfiguration().addService(
+ service);
+ }
+
+ public static synchronized void unDeployService(QName service)
+ throws AxisFault {
+ receiver.getConfigurationContext().getAxisConfiguration()
+ .removeService(service.getLocalPart());
+ }
+
+ public static synchronized void unDeployClientService() throws AxisFault {
+ if (receiver.getConfigurationContext().getAxisConfiguration() != null) {
+ receiver.getConfigurationContext().getAxisConfiguration()
+ .removeService("AnonymousService");
+ }
+ }
+
+ public static synchronized void start() throws Exception {
+ start(org.apache.axis2.Constants.TESTING_REPOSITORY);
+ }
+
+ public static synchronized void start(String repository) throws Exception {
+ if (count == 0) {
+ ConfigurationContext er = getNewConfigurationContext(repository);
+ // er.getAxisConfiguration().addModule(new DeploymentEngine().)
+
+ receiver = new SimpleHTTPServer(er, TESTING_PORT);
+
+ receiver.start();
+ System.out
+ .print("Server started on port " + TESTING_PORT + ".....");
+
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException e1) {
+ throw new AxisFault("Thread interupted", e1);
+ }
+
+ }
+ count++;
+ }
+
+
+
+ public static ConfigurationContext getNewConfigurationContext(
+ String repository) throws Exception {
+ File file = new File(repository);
+ if (!file.exists()) {
+ throw new Exception("repository directory "
+ + file.getAbsolutePath() + " does not exists");
+ }
+ return ConfigurationContextFactory
+ .createConfigurationContextFromFileSystem(file
+ .getAbsolutePath(), file.getAbsolutePath()+"/conf/axis2.xml");
+ }
+
+ public static synchronized void stop() throws AxisFault {
+ if (count == 1) {
+ receiver.stop();
+ while (receiver.isRunning()) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e1) {
+ }
+ }
+ count = 0;
+ System.out.print("Server stopped .....");
+ } else {
+ count--;
+ }
+ ListenerManager listenerManager = receiver.getConfigurationContext()
+ .getListenerManager();
+ if (listenerManager != null) {
+ listenerManager.stop();
+ }
+ }
+
+ public static ConfigurationContext getConfigurationContext() {
+ return receiver.getConfigurationContext();
+ }
+
+ static class AddressingFilter implements FilenameFilter {
+ public boolean accept(File dir, String name) {
+ return name.startsWith("addressing") && name.endsWith(".mar");
+ }
+ }
+
+ private static File getAddressingMARFile() {
+ File dir = new File(org.apache.axis2.Constants.TESTING_REPOSITORY);
+ File[] files = dir.listFiles(new AddressingFilter());
+ TestCase.assertTrue(files.length == 1);
+ File file = files[0];
+ TestCase.assertTrue(file.exists());
+ return file;
+ }
+
+ public static ServiceContext createAdressedEnabledClientSide(
+ AxisService service) throws AxisFault {
+ File file = getAddressingMARFile();
+ TestCase.assertTrue(file.exists());
+
+ ConfigurationContext configContext = ConfigurationContextFactory
+ .createConfigurationContextFromFileSystem(
+ "target/test-resources/integrationRepo", null);
+ AxisModule axisModule = DeploymentEngine.buildModule(file,
+ configContext.getAxisConfiguration());
+ configContext.getAxisConfiguration().addModule(axisModule);
+
+ configContext.getAxisConfiguration().addService(service);
+
+ return new ServiceGroupContext(configContext,
+ (AxisServiceGroup) service.getParent())
+ .getServiceContext(service);
+ }
+
+ public static ConfigurationContext createClientConfigurationContext()
+ throws AxisFault {
+ File file = getAddressingMARFile();
+ TestCase.assertTrue(file.exists());
+
+ ConfigurationContext configContext = ConfigurationContextFactory
+ .createConfigurationContextFromFileSystem(
+ "target/test-resources/integrationRepo", null);
+ AxisModule axisModule = DeploymentEngine.buildModule(file,
+ configContext.getAxisConfiguration());
+ configContext.getAxisConfiguration().addModule(axisModule);
+ configContext.getAxisConfiguration().engageModule(
+ new QName("addressing"));
+ return configContext;
+ }
+
+ public static ServiceContext createAdressedEnabledClientSide(
+ AxisService service, String clientHome) throws AxisFault {
+ File file = getAddressingMARFile();
+ TestCase.assertTrue(file.exists());
+
+ ConfigurationContext configContext = ConfigurationContextFactory
+ .createConfigurationContextFromFileSystem(clientHome, null);
+ AxisModule axisModule = DeploymentEngine.buildModule(file,
+ configContext.getAxisConfiguration());
+
+ configContext.getAxisConfiguration().addModule(axisModule);
+ // sysContext.getAxisConfiguration().engageModule(moduleDesc.getName());
+
+ configContext.getAxisConfiguration().addService(service);
+
+ return new ServiceGroupContext(configContext,
+ (AxisServiceGroup) service.getParent())
+ .getServiceContext(service);
+ }
+
+}
Added: webservices/savan/trunk/java/modules/core/src/test/java/org/apache/axis2/savan/atom/UtilServerBasedTestCase.java
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/java/modules/core/src/test/java/org/apache/axis2/savan/atom/UtilServerBasedTestCase.java?view=auto&rev=542163
==============================================================================
--- webservices/savan/trunk/java/modules/core/src/test/java/org/apache/axis2/savan/atom/UtilServerBasedTestCase.java (added)
+++ webservices/savan/trunk/java/modules/core/src/test/java/org/apache/axis2/savan/atom/UtilServerBasedTestCase.java Mon May 28 02:01:00 2007
@@ -0,0 +1,68 @@
+/*
+* Copyright 2004-2006 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.axis2.savan.atom;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestCase;
+
+public class UtilServerBasedTestCase extends TestCase {
+
+ public UtilServerBasedTestCase() {
+ super(UtilServerBasedTestCase.class.getName());
+ }
+
+ public UtilServerBasedTestCase(java.lang.String string) {
+ super(string);
+ }
+
+ protected static Test getTestSetup(Test test) {
+ return new TestSetup(test) {
+ public void setUp() throws Exception {
+ UtilServer.start();
+ }
+
+ public void tearDown() throws Exception {
+ UtilServer.stop();
+ }
+ };
+ }
+
+ protected static Test getTestSetup2(Test test, final String param) {
+ return new TestSetup(test) {
+ public void setUp() throws Exception {
+ UtilServer.start(param);
+ }
+
+ public void tearDown() throws Exception {
+ UtilServer.stop();
+ }
+ };
+ }
+
+ protected static Test getTestSetup3(Test test, final String param1, final String param2) {
+ return new TestSetup(test) {
+ public void setUp() throws Exception {
+ UtilServer.start(param1);
+ }
+
+ public void tearDown() throws Exception {
+ UtilServer.stop();
+ }
+ };
+ }
+}
Added: webservices/savan/trunk/java/modules/core/src/test/java/org/apache/axis2/savan/atom/publisher.services.xml
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/java/modules/core/src/test/java/org/apache/axis2/savan/atom/publisher.services.xml?view=auto&rev=542163
==============================================================================
--- webservices/savan/trunk/java/modules/core/src/test/java/org/apache/axis2/savan/atom/publisher.services.xml (added)
+++ webservices/savan/trunk/java/modules/core/src/test/java/org/apache/axis2/savan/atom/publisher.services.xml Mon May 28 02:01:00 2007
@@ -0,0 +1,33 @@
+<!--
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ -->
+<service name="PublisherService">
+
+ <parameter name="ServiceClass" locked="xsd:false">org.apache.axis2.savan.atom.PublisherService</parameter>
+
+ <description>
+ The Publisher Service of the Axis2 Eventing sample.
+ </description>
+
+ <module ref="savan" />
+
+ <operation name="dummyMethod" mep="http://www.w3.org/2004/08/wsdl/in-only">
+ <messageReceiver class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver" />
+ <actionMapping>http://wso2.com/eventing/dummyMethod</actionMapping>
+ </operation>
+
+</service>
\ No newline at end of file
Modified: webservices/savan/trunk/java/modules/mar/module.xml
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/java/modules/mar/module.xml?view=diff&rev=542163&r1=542162&r2=542163
==============================================================================
--- webservices/savan/trunk/java/modules/mar/module.xml (original)
+++ webservices/savan/trunk/java/modules/mar/module.xml Mon May 28 02:01:00 2007
@@ -6,7 +6,6 @@
<actionMapping>http://schemas.xmlsoap.org/ws/2004/08/eventing/Renew</actionMapping>
<actionMapping>http://schemas.xmlsoap.org/ws/2004/08/eventing/GetStatus</actionMapping>
<actionMapping>http://schemas.xmlsoap.org/ws/2004/08/eventing/Unsubscribe</actionMapping>
- <actionMapping>http://wso2.com/ws/2007/05/eventing/Publish</actionMapping>
<actionMapping>http://wso2.com/eventing/Subscribe</actionMapping>
<actionMapping>http://wso2.com/eventing/Renew</actionMapping>
<actionMapping>http://wso2.com/eventing/Unsubscribe</actionMapping>
@@ -16,5 +15,10 @@
<operation name="atom" mep="http://www.w3.org/2004/08/wsdl/in-out">
<messageReceiver class="org.apache.savan.atom.AtomMessageReceiver"/>
</operation>
+
+ <operation name="publish" mep="http://www.w3.org/2004/08/wsdl/in-out">
+ <messageReceiver class="org.apache.savan.messagereceiver.PublishingMessageReceiver"/>
+ <actionMapping>http://wso2.com/ws/2007/05/eventing/Publish</actionMapping>
+ </operation>
</module>