Package org.apache.cxf.ws.eventing

Examples of org.apache.cxf.ws.eventing.Subscribe


                if (!req.getParameter("expires-set").equals("false")) {
                    expires = req.getParameter("expires");
                }
            }

            Subscribe sub = createSubscribeMessage(req.getParameter("targeturl"),
                    req.getParameter("filter-set") == null ? req.getParameter("filter") : null,
                    expires);

            resp.getWriter().append("<h3>Subscription request</h3>");
            resp.getWriter().append(convertJAXBElementToStringAndEscapeHTML(sub));
View Full Code Here


    }

    public Subscribe createSubscribeMessage(String targetURL, String filter, String expires)
        throws DatatypeConfigurationException {
        Subscribe sub = new Subscribe();


        // expires
        if (expires != null) {
            sub.setExpires(new ExpirationType());
            sub.getExpires().setValue(expires);
        }

        // delivery
        EndpointReferenceType eventSink = new EndpointReferenceType();
        AttributedURIType eventSinkAddr = new AttributedURIType();
        eventSinkAddr.setValue(targetURL);
        eventSink.setAddress(eventSinkAddr);
        sub.setDelivery(new DeliveryType());
        sub.getDelivery().getContent().add(new ObjectFactory().createNotifyTo(eventSink));

        // filter
        if (filter != null && filter.length() > 0) {
            sub.setFilter(new FilterType());
            sub.getFilter().getContent().add(filter);
        }

        return sub;
    }
View Full Code Here

    @Test
    public void doTest() throws IOException {
        NotificatorService service = createNotificatorService();
        service.start();

        Subscribe subscribe = new Subscribe();

        EndpointReferenceType eventSinkERT = new EndpointReferenceType();
        AttributedURIType eventSinkAddr = new AttributedURIType();
        String eventSinkURL = TestUtil.generateRandomURLWithLocalTransport();
        eventSinkAddr.setValue(eventSinkURL);
        eventSinkERT.setAddress(eventSinkAddr);
        subscribe.setDelivery(new DeliveryType());
        subscribe.getDelivery().getContent().add(new ObjectFactory().createNotifyTo(eventSinkERT));

        JAXBElement<String> idqn
            = new JAXBElement<String>(new QName("http://www.example.org", "MyReferenceParameter"),
                String.class,
                "380");
        ReferenceParametersType myParams = new ReferenceParametersType();
        myParams.getAny().add(idqn);
        eventSinkERT.setReferenceParameters(myParams);

        EndpointReferenceType endToERT = new EndpointReferenceType();
        AttributedURIType endToAddr = new AttributedURIType();
        String endToURL = TestUtil.generateRandomURLWithLocalTransport();
        endToAddr.setValue(endToURL);
        endToERT.setAddress(endToAddr);
        subscribe.setEndTo(endToERT);

        SubscribeResponse response = eventSourceClient.subscribeOp(subscribe);
        Element referenceParams = (Element)response.getSubscriptionManager()
                .getReferenceParameters().getAny().get(0);
View Full Code Here

     * @throws IOException
     */
    @Test
    public void testExpirationGrantingWithoutBestEffort() throws IOException {
        // we specify a xs:duration
        Subscribe subscribe = new Subscribe();
        ExpirationType exp = new ExpirationType();
        exp.setValue(
                DurationAndDateUtil.convertToXMLString(DurationAndDateUtil.parseDurationOrTimestamp("PT0S")));
        subscribe.setExpires(exp);
        DeliveryType delivery = new DeliveryType();
        subscribe.setDelivery(delivery);

        subscribe.getDelivery().getContent().add(createDummyNotifyTo());

        SubscribeResponse resp = eventSourceClient.subscribeOp(subscribe);
        Assert.assertTrue(
                "Specification requires that EventSource return a xs:duration "
                        + "expirationType if a xs:duration was requested by client",
                DurationAndDateUtil.isDuration(resp.getGrantedExpires().getValue()));

        // we specify a xs:dateTime
        subscribe = new Subscribe();
        exp = new ExpirationType();
        XMLGregorianCalendar dateRequest =
                (XMLGregorianCalendar)DurationAndDateUtil.parseDurationOrTimestamp("2138-06-26T12:23:12.000-01:00");
        exp.setValue(DurationAndDateUtil.convertToXMLString(dateRequest));
        subscribe.setExpires(exp);
        delivery = new DeliveryType();
        subscribe.setDelivery(delivery);
        subscribe.getDelivery().getContent().add(createDummyNotifyTo());
        resp = eventSourceClient.subscribeOp(subscribe);
        Assert.assertTrue(
                "Specification requires that EventSource return a "
                        + "xs:dateTime expirationType if a xs:dateTime was requested by client",
                DurationAndDateUtil.isXMLGregorianCalendar(resp.getGrantedExpires().getValue()));
        XMLGregorianCalendar returned = DurationAndDateUtil.parseXMLGregorianCalendar(
                resp.getGrantedExpires().getValue());
        System.out.println("granted expiration: " + returned.normalize().toXMLFormat());
        System.out.println("requested expiration: " + dateRequest.normalize().toXMLFormat());
        Assert.assertTrue("Server should have returned exactly the same date as we requested",
                returned.equals(dateRequest));

        // we don't specify anything
        subscribe = new Subscribe();
        delivery = new DeliveryType();
        subscribe.setDelivery(delivery);
        subscribe.getDelivery().getContent().add(createDummyNotifyTo());
        resp = eventSourceClient.subscribeOp(subscribe);
        Assert.assertTrue(
                "Specification requires that EventSource return a xs:duration "
                        + "expirationType if no specific expirationType was requested by client",
                DurationAndDateUtil.isDuration(resp.getGrantedExpires().getValue()));
View Full Code Here

     * When BestEffort=true, the server doesn't have to grant exactly the date as we requested
     * @throws IOException
     */
    @Test
    public void testExpirationGrantingWithBestEffort() throws IOException {
        Subscribe subscribe = new Subscribe();
        ExpirationType exp = new ExpirationType();
        DeliveryType delivery = new DeliveryType();
        XMLGregorianCalendar dateRequest =
                (XMLGregorianCalendar)DurationAndDateUtil.parseDurationOrTimestamp("2138-06-26T12:23:12.000-01:00");
        exp.setValue(DurationAndDateUtil.convertToXMLString(dateRequest));
        exp.setBestEffort(true);
        subscribe.setExpires(exp);
        subscribe.setDelivery(delivery);
        subscribe.getDelivery().getContent().add(createDummyNotifyTo());
        SubscribeResponse resp = eventSourceClient.subscribeOp(subscribe);
        Assert.assertTrue(
                "Specification requires that EventSource return a "
                        + "xs:dateTime expirationType if a xs:dateTime was requested by client",
                DurationAndDateUtil.isXMLGregorianCalendar(resp.getGrantedExpires().getValue()));
View Full Code Here

    }

    @Test
    public void noDeliveryMechanismSpecified() throws IOException {
        // we specify a xs:duration
        Subscribe subscribe = new Subscribe();
        ExpirationType exp = new ExpirationType();
        exp.setValue(
                DurationAndDateUtil.convertToXMLString(DurationAndDateUtil.parseDurationOrTimestamp("PT0S")));
        subscribe.setExpires(exp);
        try {
            eventSourceClient.subscribeOp(subscribe);
        } catch (SOAPFaultException ex) {
            Assert.assertTrue(ex.getFault().getFaultCode().contains(NoDeliveryMechanismEstablished.LOCAL_PART));
            Assert.assertTrue(ex.getFault().getTextContent().contains(NoDeliveryMechanismEstablished.REASON));
View Full Code Here

        Assert.fail("Event source should have sent a NoDeliveryMechanismEstablished fault");
    }

    @Test
    public void cannotProcessFilter() throws IOException {
        Subscribe subscribe = new Subscribe();
        ExpirationType exp = new ExpirationType();
        DeliveryType delivery = new DeliveryType();
        XMLGregorianCalendar dateRequest =
                (XMLGregorianCalendar)DurationAndDateUtil.parseDurationOrTimestamp("2138-06-26T12:23:12.000-01:00");
        exp.setValue(DurationAndDateUtil.convertToXMLString(dateRequest));
        exp.setBestEffort(true);
        subscribe.setExpires(exp);
        subscribe.setDelivery(delivery);
        subscribe.getDelivery().getContent().add(createDummyNotifyTo());


        subscribe.setFilter(new FilterType());
        subscribe.getFilter().getContent()
                .add("@^5this-is-not-a-valid-xpath-expression!!!*-/");

        try {
            eventSourceClient.subscribeOp(subscribe);
        } catch (SOAPFaultException ex) {
View Full Code Here

    /**
     * Creates a subscription and then retrieves its status from the Subscription Manager.
     */
    @Test
    public void getStatus() throws Exception {
        Subscribe subscribe = new Subscribe();
        ExpirationType exp = new ExpirationType();
        exp.setValue(
                DurationAndDateUtil.convertToXMLString(DurationAndDateUtil.parseDurationOrTimestamp("PT0S")));
        subscribe.setExpires(exp);
        DeliveryType delivery = new DeliveryType();
        subscribe.setDelivery(delivery);
        subscribe.getDelivery().getContent().add(createDummyNotifyTo());
        SubscribeResponse resp = eventSourceClient.subscribeOp(subscribe);

        SubscriptionManagerEndpoint client = createSubscriptionManagerClient(
                resp.getSubscriptionManager().getReferenceParameters());
        GetStatusResponse response = client.getStatusOp(new GetStatus());
View Full Code Here

     * Tries to create a subscription, then cancel it, then obtain its status.
     * The last mentioned operation should fail.
     */
    @Test
    public void unsubscribeAndThenGetStatus() throws Exception {
        Subscribe subscribe = new Subscribe();
        ExpirationType exp = new ExpirationType();
        exp.setValue(
                DurationAndDateUtil.convertToXMLString(DurationAndDateUtil.parseDurationOrTimestamp("PT0S")));
        subscribe.setExpires(exp);
        DeliveryType delivery = new DeliveryType();
        subscribe.setDelivery(delivery);
        subscribe.getDelivery().getContent().add(createDummyNotifyTo());
        SubscribeResponse subscribeResponse = eventSourceClient.subscribeOp(subscribe);

        SubscriptionManagerEndpoint client = createSubscriptionManagerClient(
                subscribeResponse.getSubscriptionManager().getReferenceParameters());
        UnsubscribeResponse unsubscribeResponse = client.unsubscribeOp(new Unsubscribe());
View Full Code Here

     * Tests the Renew operation, while specifying an xs:dateTime in the renew request,
     * eg. the subscriber requests to set the subscription expiration to a specific date/time.
     */
    @Test
    public void renewWithDateTime() throws IOException {
        Subscribe subscribe = new Subscribe();
        ExpirationType exp = new ExpirationType();
        exp.setValue(DurationAndDateUtil
                .convertToXMLString(DurationAndDateUtil
                        .parseDurationOrTimestamp("2018-10-21T14:52:46.826+02:00")))// 5 minutes
        subscribe.setExpires(exp);
        DeliveryType delivery = new DeliveryType();
        subscribe.setDelivery(delivery);
        subscribe.getDelivery().getContent().add(createDummyNotifyTo());
        SubscribeResponse resp = eventSourceClient.subscribeOp(subscribe);

        SubscriptionManagerEndpoint client = createSubscriptionManagerClient(
                resp.getSubscriptionManager().getReferenceParameters());
        GetStatusResponse response = client.getStatusOp(new GetStatus());
View Full Code Here

TOP

Related Classes of org.apache.cxf.ws.eventing.Subscribe

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.