Created
August 19, 2011 11:34
-
-
Save chamerling/1156619 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
*/ | |
package org.petalslink.notification.commons; | |
import java.util.UUID; | |
import javax.xml.namespace.QName; | |
import javax.xml.parsers.DocumentBuilderFactory; | |
import junit.framework.TestCase; | |
import org.petalslink.dsb.notification.commons.NotificationException; | |
import org.petalslink.dsb.notification.commons.NotificationHelper; | |
import org.w3c.dom.Document; | |
import com.ebmwebsourcing.easycommons.xml.XMLHelper; | |
import com.ebmwebsourcing.wsstar.basefaults.datatypes.impl.impl.WsrfbfModelFactoryImpl; | |
import com.ebmwebsourcing.wsstar.basenotification.datatypes.api.abstraction.Notify; | |
import com.ebmwebsourcing.wsstar.basenotification.datatypes.api.refinedabstraction.RefinedWsnbFactory; | |
import com.ebmwebsourcing.wsstar.basenotification.datatypes.api.utils.WsnbException; | |
import com.ebmwebsourcing.wsstar.basenotification.datatypes.impl.impl.WsnbModelFactoryImpl; | |
import com.ebmwebsourcing.wsstar.resource.datatypes.impl.impl.WsrfrModelFactoryImpl; | |
import com.ebmwebsourcing.wsstar.resourcelifetime.datatypes.impl.impl.WsrfrlModelFactoryImpl; | |
import com.ebmwebsourcing.wsstar.resourceproperties.datatypes.impl.impl.WsrfrpModelFactoryImpl; | |
import com.ebmwebsourcing.wsstar.topics.datatypes.impl.impl.WstopModelFactoryImpl; | |
import com.ebmwebsourcing.wsstar.wsnb.services.impl.util.Wsnb4ServUtils; | |
/** | |
* @author chamerling | |
* | |
*/ | |
public class NotificationHelperTest extends TestCase { | |
static { | |
Wsnb4ServUtils.initModelFactories(new WsrfbfModelFactoryImpl(), | |
new WsrfrModelFactoryImpl(), new WsrfrlModelFactoryImpl(), | |
new WsrfrpModelFactoryImpl(), new WstopModelFactoryImpl(), | |
new WsnbModelFactoryImpl()); | |
} | |
public void testAddPayload() { | |
String producerAddress = "http://localhost:9998/foo/Producer"; | |
String endpointAddress = "http://localhost:9998/foo/Endpoint"; | |
String uuid = UUID.randomUUID().toString(); | |
QName topicUsed = new QName("http://dsb.petalslink.org/notification", "Sample"); | |
String dialect = "dialect"; | |
Document notifPayload = null; | |
try { | |
notifPayload = DocumentBuilderFactory.newInstance().newDocumentBuilder() | |
.parse(NotificationHelperTest.class.getResourceAsStream("/notify.xml")); | |
} catch (Exception e) { | |
fail(e.getMessage()); | |
} | |
try { | |
Notify n = NotificationHelper.createNotification(producerAddress, endpointAddress, | |
uuid, topicUsed, dialect, notifPayload); | |
try { | |
final Document request = RefinedWsnbFactory.getInstance().getWsnbWriter().writeNotifyAsDOM(n); | |
System.out.println(XMLHelper.createStringFromDOMDocument(request)); | |
} catch (Exception e) { | |
// TODO Auto-generated catch block | |
e.printStackTrace(); | |
} | |
} catch (NotificationException e) { | |
fail(e.getMessage()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment