Example usage for javax.xml.ws Holder Holder

List of usage examples for javax.xml.ws Holder Holder

Introduction

In this page you can find the example usage for javax.xml.ws Holder Holder.

Prototype

public Holder() 

Source Link

Document

Creates a new holder with a null value.

Usage

From source file:org.apache.juddi.v3.tck.TckSubscriptionListener.java

public void saveSubscription(String authInfo, String subscriptionXML, String subscriptionKey,
        String bindingkey) {/*from   w  w  w.  j a  v  a2s . c  o  m*/
    try {
        logger.info("saving subscription " + subscriptionKey + " " + subscriptionXML + " " + bindingkey);
        Subscription subIn = (Subscription) EntityCreator.buildFromDoc(subscriptionXML, "org.uddi.sub_v3");
        List<Subscription> subscriptionList = new ArrayList<Subscription>();
        subscriptionList.add(subIn);
        Holder<List<Subscription>> subscriptionHolder = new Holder<List<Subscription>>();
        subscriptionHolder.value = subscriptionList;

        subscription.saveSubscription(authInfo, subscriptionHolder);

        Subscription subDirectOut = subscriptionHolder.value.get(0);
        Assert.assertEquals(subIn.getSubscriptionKey(), subDirectOut.getSubscriptionKey());

        List<Subscription> outSubscriptionList = subscription.getSubscriptions(authInfo);
        Assert.assertNotNull(outSubscriptionList);
        Subscription subOut = outSubscriptionList.get(0);

        Assert.assertEquals(subDirectOut.getExpiresAfter().getMonth(), subOut.getExpiresAfter().getMonth());
        Assert.assertEquals(subDirectOut.getExpiresAfter().getDay(), subOut.getExpiresAfter().getDay());
        Assert.assertEquals(subDirectOut.getExpiresAfter().getYear(), subOut.getExpiresAfter().getYear());

        //assertEquals(subIn.getSubscriptionFilter().getFindService().getName().get(0).getValue(), 
        //          subOut.getSubscriptionFilter().getFindService().getName().get(0).getValue());

    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        Assert.fail("No exception should be thrown");
    }
}

From source file:org.apache.juddi.v3.tck.UDDI_080_SubscriptionIntegrationTest.java

/**
 * Null expiration time, the server should set the expiration time
 *///  w  w  w.  j  a va 2s .  c o  m
@Test
public void JUDDI_606_1() {
    Assume.assumeTrue(TckPublisher.isEnabled());
    System.out.println("JUDDI_606_1");
    Assume.assumeTrue(TckPublisher.isSubscriptionEnabled());
    // Null expiration time

    Subscription sub = new Subscription();
    Holder<List<Subscription>> data = new Holder<List<Subscription>>();
    data.value = new ArrayList<Subscription>();
    sub.setBrief(true);
    sub.setExpiresAfter(null);
    sub.setMaxEntities(1);
    sub.setNotificationInterval(null);
    sub.setBindingKey(null);
    sub.setSubscriptionFilter(new SubscriptionFilter());
    sub.getSubscriptionFilter().setFindService(new FindService());
    sub.getSubscriptionFilter().getFindService().setFindQualifiers(new FindQualifiers());
    sub.getSubscriptionFilter().getFindService().getFindQualifiers().getFindQualifier()
            .add(UDDIConstants.APPROXIMATE_MATCH);
    sub.getSubscriptionFilter().getFindService().getName().add(new Name("%", null));
    data.value.add(sub);
    try {
        tckSubscriptionJoe.subscription.saveSubscription(authInfoJoe, data);
        Assert.assertNotNull(data.value.get(0).getExpiresAfter());
    } catch (Exception ex) {
        HandleException(ex);
        Assert.fail();
    }
}

From source file:org.apache.juddi.v3.tck.UDDI_080_SubscriptionIntegrationTest.java

/**
 * invalid expiration time/*from w ww  .j  a va  2 s  .  c o m*/
 *
 * @throws DatatypeConfigurationException
 */
@Test
public void JUDDI_606_2() throws DatatypeConfigurationException {
    Assume.assumeTrue(TckPublisher.isEnabled());
    System.out.println("JUDDI_606_2");
    Assume.assumeTrue(TckPublisher.isSubscriptionEnabled());
    // invalid expiration time
    DatatypeFactory df = DatatypeFactory.newInstance();
    GregorianCalendar gcal = new GregorianCalendar();
    gcal.setTimeInMillis(System.currentTimeMillis());
    gcal.add(Calendar.DATE, -1);
    XMLGregorianCalendar newXMLGregorianCalendar = df.newXMLGregorianCalendar(gcal);

    Subscription sub = new Subscription();
    Holder<List<Subscription>> data = new Holder<List<Subscription>>();
    data.value = new ArrayList<Subscription>();
    sub.setBrief(true);
    sub.setExpiresAfter(newXMLGregorianCalendar);
    sub.setMaxEntities(1);
    sub.setNotificationInterval(null);
    sub.setBindingKey(null);
    sub.setSubscriptionFilter(new SubscriptionFilter());
    sub.getSubscriptionFilter().setFindService(new FindService());
    sub.getSubscriptionFilter().getFindService().setFindQualifiers(new FindQualifiers());
    sub.getSubscriptionFilter().getFindService().getFindQualifiers().getFindQualifier()
            .add(UDDIConstants.APPROXIMATE_MATCH);
    sub.getSubscriptionFilter().getFindService().getName().add(new Name("%", null));
    data.value.add(sub);
    try {
        tckSubscriptionJoe.subscription.saveSubscription(authInfoJoe, data);
        Assert.fail();
    } catch (Exception ex) {
        //HandleException(ex);
        logger.info("Expected exception: " + ex.getMessage());
    }
}

From source file:org.apache.juddi.v3.tck.UDDI_080_SubscriptionIntegrationTest.java

/**
 * confirm a subscription key is returned when not specified
 *///  w  w  w. java 2  s  .c  o m
@Test
public void JUDDI_606_3() {
    Assume.assumeTrue(TckPublisher.isEnabled());
    System.out.println("JUDDI_606_3");
    Assume.assumeTrue(TckPublisher.isSubscriptionEnabled());
    //

    Subscription sub = new Subscription();
    Holder<List<Subscription>> data = new Holder<List<Subscription>>();
    data.value = new ArrayList<Subscription>();
    sub.setBrief(true);
    sub.setExpiresAfter(null);
    sub.setMaxEntities(1);
    sub.setNotificationInterval(null);
    sub.setBindingKey(null);
    sub.setSubscriptionFilter(new SubscriptionFilter());
    sub.getSubscriptionFilter().setFindService(new FindService());
    sub.getSubscriptionFilter().getFindService().setFindQualifiers(new FindQualifiers());
    sub.getSubscriptionFilter().getFindService().getFindQualifiers().getFindQualifier()
            .add(UDDIConstants.APPROXIMATE_MATCH);
    sub.getSubscriptionFilter().getFindService().getName().add(new Name("%", null));
    data.value.add(sub);
    try {
        tckSubscriptionJoe.subscription.saveSubscription(authInfoJoe, data);
        Assert.assertNotNull(data.value.get(0).getSubscriptionKey());
        Assert.assertTrue(data.value.get(0).getSubscriptionKey().length() > 0);
    } catch (Exception ex) {
        HandleException(ex);
        Assert.fail();
    }
}

From source file:org.apache.juddi.v3.tck.UDDI_080_SubscriptionIntegrationTest.java

/**
 * null subscription filter//w ww .  j av a2 s .c  o  m
 */
@Test
public void JUDDI_606_4() {
    Assume.assumeTrue(TckPublisher.isEnabled());
    System.out.println("JUDDI_606_4");
    //
    Assume.assumeTrue(TckPublisher.isSubscriptionEnabled());

    Subscription sub = new Subscription();
    Holder<List<Subscription>> data = new Holder<List<Subscription>>();
    data.value = new ArrayList<Subscription>();
    sub.setBrief(true);
    sub.setExpiresAfter(null);
    sub.setMaxEntities(1);
    sub.setNotificationInterval(null);
    sub.setBindingKey(null);
    sub.setSubscriptionFilter(null);

    try {
        tckSubscriptionJoe.subscription.saveSubscription(authInfoJoe, data);
        Assert.fail();
    } catch (Exception ex) {
        //HandleException(ex);
        logger.info("Expected exception: " + ex.getMessage());
    }
}

From source file:org.apache.juddi.v3.tck.UDDI_080_SubscriptionIntegrationTest.java

/**
 * empty subscription filter// www.j  a va2 s  . c  o m
 */
@Test
public void JUDDI_606_5() {
    Assume.assumeTrue(TckPublisher.isEnabled());
    System.out.println("JUDDI_606_5");
    //
    Assume.assumeTrue(TckPublisher.isSubscriptionEnabled());

    Subscription sub = new Subscription();
    Holder<List<Subscription>> data = new Holder<List<Subscription>>();
    data.value = new ArrayList<Subscription>();
    sub.setBrief(true);
    sub.setExpiresAfter(null);
    sub.setMaxEntities(1);
    sub.setNotificationInterval(null);
    sub.setBindingKey(null);
    sub.setSubscriptionFilter(new SubscriptionFilter());

    data.value.add(sub);
    try {
        tckSubscriptionJoe.subscription.saveSubscription(authInfoJoe, data);
        Assert.fail();
    } catch (Exception ex) {
        //HandleException(ex);
        logger.info("Expected exception: " + ex.getMessage());
    }
}

From source file:org.apache.juddi.v3.tck.UDDI_080_SubscriptionIntegrationTest.java

/**
 * negative max entities//from  w  w w . j  a  v  a 2s .com
 */
@Test
public void JUDDI_606_6() {
    Assume.assumeTrue(TckPublisher.isEnabled());
    System.out.println("JUDDI_606_6");
    //
    Assume.assumeTrue(TckPublisher.isSubscriptionEnabled());

    Subscription sub = new Subscription();
    Holder<List<Subscription>> data = new Holder<List<Subscription>>();
    data.value = new ArrayList<Subscription>();
    sub.setBrief(true);
    sub.setExpiresAfter(null);
    sub.setMaxEntities(-1);
    sub.setNotificationInterval(null);
    sub.setBindingKey(null);
    sub.setSubscriptionFilter(new SubscriptionFilter());
    sub.getSubscriptionFilter().setFindService(new FindService());
    sub.getSubscriptionFilter().getFindService().setFindQualifiers(new FindQualifiers());
    sub.getSubscriptionFilter().getFindService().getFindQualifiers().getFindQualifier()
            .add(UDDIConstants.APPROXIMATE_MATCH);
    sub.getSubscriptionFilter().getFindService().getName().add(new Name("%", null));
    data.value.add(sub);
    try {
        tckSubscriptionJoe.subscription.saveSubscription(authInfoJoe, data);
        Assert.assertTrue(data.value.get(0).getMaxEntities() > 0);
    } catch (Exception ex) {
        //HandleException(ex);
        //this is ok as well
        logger.info("Expected exception: " + ex.getMessage());
    }
}

From source file:org.apache.juddi.v3.tck.UDDI_080_SubscriptionIntegrationTest.java

/**
 * more filters that expected/*from www  .ja v  a2 s .  c  o m*/
 *
 * @throws DatatypeConfigurationException
 */
@Test
public void JUDDI_606_7() throws DatatypeConfigurationException {
    Assume.assumeTrue(TckPublisher.isEnabled());
    System.out.println("JUDDI_606_7");
    Assume.assumeTrue(TckPublisher.isSubscriptionEnabled());
    //
    DatatypeFactory df = DatatypeFactory.newInstance();
    try {

        Holder<List<Subscription>> data = new Holder<List<Subscription>>();
        data.value = new ArrayList<Subscription>();
        Subscription sub = new Subscription();
        sub.setBrief(false);
        sub.setExpiresAfter(null);
        sub.setMaxEntities(null);
        sub.setNotificationInterval(null);
        sub.setBindingKey(null);
        sub.setSubscriptionFilter(new SubscriptionFilter());
        sub.getSubscriptionFilter().setFindBusiness(new FindBusiness());
        sub.getSubscriptionFilter().getFindBusiness().setFindQualifiers(new FindQualifiers());
        sub.getSubscriptionFilter().getFindBusiness().getFindQualifiers().getFindQualifier()
                .add(UDDIConstants.APPROXIMATE_MATCH);
        sub.getSubscriptionFilter().getFindBusiness().getName().add(new Name("%", null));
        sub.getSubscriptionFilter().setFindService(new FindService());
        sub.getSubscriptionFilter().getFindService().setFindQualifiers(new FindQualifiers());
        sub.getSubscriptionFilter().getFindService().getFindQualifiers().getFindQualifier()
                .add(UDDIConstants.APPROXIMATE_MATCH);
        sub.getSubscriptionFilter().getFindService().getName().add(new Name("%", null));

        data.value.add(sub);

        tckSubscriptionJoe.subscription.saveSubscription(authInfoJoe, data);
        Assert.fail();
    } catch (Exception ex) {
        logger.info(ex.getMessage());

    }
}

From source file:org.apache.juddi.v3.tck.UDDI_080_SubscriptionIntegrationTest.java

/**
 * testing reset expiration. i.e. save, wait a second then resave it,
 * the expiration time should be further into the future
 *///from   w  w w . j  av a  2  s.  com
@Test
public void JUDDI_606_8() {
    Assume.assumeTrue(TckPublisher.isEnabled());
    System.out.println("JUDDI_606_8");
    Assume.assumeTrue(TckPublisher.isSubscriptionEnabled());
    //

    try {

        Holder<List<Subscription>> data = new Holder<List<Subscription>>();
        data.value = new ArrayList<Subscription>();
        Subscription sub = new Subscription();
        sub.setBrief(true);
        sub.setExpiresAfter(null);
        sub.setMaxEntities(null);
        sub.setNotificationInterval(null);
        sub.setBindingKey(null);
        sub.setSubscriptionFilter(new SubscriptionFilter());
        sub.getSubscriptionFilter().setFindService(new FindService());
        sub.getSubscriptionFilter().getFindService().setFindQualifiers(new FindQualifiers());
        sub.getSubscriptionFilter().getFindService().getFindQualifiers().getFindQualifier()
                .add(UDDIConstants.APPROXIMATE_MATCH);
        sub.getSubscriptionFilter().getFindService().getName().add(new Name("%", null));
        data.value.add(sub);

        tckSubscriptionJoe.subscription.saveSubscription(authInfoJoe, data);
        Assert.assertNotNull(data.value.get(0).getExpiresAfter());
        XMLGregorianCalendar xcal = data.value.get(0).getExpiresAfter();

        Thread.sleep(5000);
        data.value.get(0).setExpiresAfter(null);
        tckSubscriptionJoe.subscription.saveSubscription(authInfoJoe, data);
        Assert.assertNotNull(data.value.get(0).getExpiresAfter());
        Assert.assertNotSame(xcal, data.value.get(0).getExpiresAfter());
        long initial = xcal.toGregorianCalendar().getTimeInMillis();
        long finaltime = data.value.get(0).getExpiresAfter().toGregorianCalendar().getTimeInMillis();
        Assert.assertTrue(finaltime > initial);

    } catch (Exception ex) {
        HandleException(ex);
        Assert.fail();
    }
}

From source file:org.apache.juddi.v3.tck.UDDI_080_SubscriptionIntegrationTest.java

/**
 * asynch subscriptions , binding key doesn't exist
 *
 * @throws DatatypeConfigurationException
 *//*from  w  w  w .  ja  v  a 2s .co m*/
@Test
public void JUDDI_606_9() throws DatatypeConfigurationException {
    Assume.assumeTrue(TckPublisher.isEnabled());
    System.out.println("JUDDI_606_9");
    Assume.assumeTrue(TckPublisher.isSubscriptionEnabled());
    //

    DatatypeFactory df = DatatypeFactory.newInstance();

    try {

        Holder<List<Subscription>> data = new Holder<List<Subscription>>();
        data.value = new ArrayList<Subscription>();
        Subscription sub = new Subscription();
        sub.setBrief(true);
        sub.setExpiresAfter(null);
        sub.setMaxEntities(null);
        sub.setNotificationInterval(df.newDuration(5000));
        sub.setBindingKey("uddi:uddi.joepublisher.com:mykey");
        sub.setSubscriptionFilter(new SubscriptionFilter());
        sub.getSubscriptionFilter().setFindService(new FindService());
        sub.getSubscriptionFilter().getFindService().setFindQualifiers(new FindQualifiers());
        sub.getSubscriptionFilter().getFindService().getFindQualifiers().getFindQualifier()
                .add(UDDIConstants.APPROXIMATE_MATCH);
        sub.getSubscriptionFilter().getFindService().getName().add(new Name("%", null));
        data.value.add(sub);

        tckSubscriptionJoe.subscription.saveSubscription(authInfoJoe, data);
        Assert.fail();
    } catch (Exception ex) {
        logger.info("Expected exception: " + ex.getMessage());
    }
}