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.UDDI_090_SubscriptionListenerIntegrationBase.java

/**
 * find related businesses i.e. setup subscriptions for all related
 * businesses to joe's biz then setup PA between Joe and Mary
 *
 * @throws Exception//from   w ww.  j a v a 2s .com
 */
@Test
public void joePublisherUpdate_FIND_RELATED_BIZ() throws Exception {
    Assume.assumeTrue(TckPublisher.isEnabled());
    Assume.assumeNotNull(getHostame());
    Assume.assumeTrue(IsEnabled());
    logger.info("joePublisherUpdate_" + getTransport() + "_FIND_RELATED_BIZ");
    TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
    Holder<List<Subscription>> holder = null;
    try {
        reset();

        String before = TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe);

        tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);

        tckTModelMary.saveMaryPublisherTmodel(authInfoMary);

        BusinessEntity saveMaryPublisherBusiness = tckBusinessMary.saveMaryPublisherBusiness(authInfoMary);
        tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
        tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
        //Saving the Listener Service
        String bindingkey = tckSubscriptionListenerJoe.saveService(authInfoJoe,
                getXMLLocationOfServiceForDelivery(), getPort(), getHostame());

        //Saving the Subscription
        holder = new Holder<List<Subscription>>();
        holder.value = new ArrayList<Subscription>();
        Subscription sub = new Subscription();
        sub.setBindingKey(bindingkey);
        sub.setNotificationInterval(DatatypeFactory.newInstance().newDuration(5000));
        sub.setSubscriptionFilter(new SubscriptionFilter());
        sub.getSubscriptionFilter().setFindRelatedBusinesses(new FindRelatedBusinesses());
        sub.getSubscriptionFilter().getFindRelatedBusinesses().setBusinessKey(TckBusiness.MARY_BUSINESS_KEY);

        holder.value.add(sub);
        subscriptionJoe.saveSubscription(authInfoJoe, holder);
        logger.info("subscription saved for " + holder.value.get(0).getSubscriptionKey());
        //tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION3_XML);
        //Changing the service we subscribed to "JoePublisherService"
        Thread.sleep(1000);

        logger.info("saving Mary's publisher assertion********** ");
        AddPublisherAssertions pa = new AddPublisherAssertions();
        pa.setAuthInfo(authInfoMary);
        PublisherAssertion pas = new PublisherAssertion();
        pas.setToKey(TckBusiness.JOE_BUSINESS_KEY);
        pas.setFromKey(TckBusiness.MARY_BUSINESS_KEY);
        pas.setKeyedReference(new KeyedReference(UDDIConstants.RELATIONSHIPS, "parent", "parent-child"));
        pa.getPublisherAssertion().add(pas);

        publicationMary.addPublisherAssertions(pa);
        logger.info("saving Joe's publisher assertion********** ");
        pa = new AddPublisherAssertions();
        pa.setAuthInfo(authInfoJoe);
        pas = new PublisherAssertion();
        pas.setToKey(TckBusiness.JOE_BUSINESS_KEY);
        pas.setFromKey(TckBusiness.MARY_BUSINESS_KEY);
        pas.setKeyedReference(new KeyedReference(UDDIConstants.RELATIONSHIPS, "parent", "parent-child"));
        pa.getPublisherAssertion().add(pas);
        publicationJoe.addPublisherAssertions(pa);

        //expecting that Joe gets notified that joe's and mary's businesses are now "related"
        boolean found = verifyDelivery(TckBusiness.MARY_BUSINESS_KEY);
        DeletePublisherAssertions deletePublisherAssertions = new DeletePublisherAssertions();
        deletePublisherAssertions.setAuthInfo(authInfoMary);
        deletePublisherAssertions.getPublisherAssertion().add(pas);
        publicationMary.deletePublisherAssertions(deletePublisherAssertions);

        deletePublisherAssertions = new DeletePublisherAssertions();
        deletePublisherAssertions.setAuthInfo(authInfoJoe);
        deletePublisherAssertions.getPublisherAssertion().add(pas);
        // publicationJoe.deletePublisherAssertions(deletePublisherAssertions);

        if (!found) {
            logger.warn("Test failed, dumping business list");
            logger.warn("BEFORE " + before);
            logger.warn("After " + TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe));
            TckCommon.PrintMarker();
            Assert.fail("Notification does not contain the correct service.");
        }

    } catch (Exception e) {
        logger.error("No exceptions please.");
        TckCommon.PrintMarker();
        e.printStackTrace();

        Assert.fail(e.getMessage());
    } finally {
        //tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_KEY);
        DeleteSubscription ds = new DeleteSubscription();
        ds.setAuthInfo(authInfoJoe);
        ds.getSubscriptionKey().add(holder.value.get(0).getSubscriptionKey());
        subscriptionJoe.deleteSubscription(ds);
        tckBusinessMary.deleteMaryPublisherBusiness(authInfoMary);
        tckTModelMary.deleteMaryPublisherTmodel(authInfoMary);

        tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
        tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
        tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
        tckTModelJoe.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY,
                TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);

    }
}

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

/**
 * getBinding tests joe want's updates on mary's binding
 *
 * @throws Exception//from w w w  .java2s. co  m
 */
@Test
public void joePublisherUpdate_FIND_BINDING_BY_SERVICEKEY_AND_TMI() throws Exception {
    Assume.assumeTrue(TckPublisher.isEnabled());
    Assume.assumeNotNull(getHostame());
    Assume.assumeTrue(IsEnabled());
    logger.info("joePublisherUpdate_" + getTransport() + "_FIND_BINDING_BY_SERVICEKEY_AND_TMI");
    TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
    Holder<List<Subscription>> holder = null;
    try {
        reset();

        String before = TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe);

        tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
        tckTModelJoe.saveTModels(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);

        tckTModelMary.saveMaryPublisherTmodel(authInfoMary);
        BusinessEntity saveMaryPublisherBusiness = tckBusinessMary.saveMaryPublisherBusiness(authInfoMary);

        BusinessService bs = new BusinessService();
        bs.setBusinessKey(saveMaryPublisherBusiness.getBusinessKey());
        bs.setServiceKey(TckTModel.MARY_KEY_PREFIX + UUID.randomUUID().toString());
        bs.getName().add(new Name("Mary's service for " + getTransport(), null));

        bs.setBindingTemplates(new BindingTemplates());
        BindingTemplate bt = new BindingTemplate();
        bt.setAccessPoint(new AccessPoint("http://localhost", "endPoint"));
        bt.setBindingKey(TckTModel.MARY_KEY_PREFIX + UUID.randomUUID().toString());
        bt.setServiceKey(bs.getServiceKey());
        bt = UDDIClient.addSOAPtModels(bt);

        bs.getBindingTemplates().getBindingTemplate().add(bt);
        SaveService ss = new SaveService();
        ss.getBusinessService().add(bs);
        ss.setAuthInfo(authInfoMary);
        bs = publicationMary.saveService(ss).getBusinessService().get(0);

        tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
        tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
        //Saving the Listener Service
        String bindingkey = tckSubscriptionListenerJoe.saveService(authInfoJoe,
                getXMLLocationOfServiceForDelivery(), getPort(), getHostame());

        //Saving the Subscription
        holder = new Holder<List<Subscription>>();
        holder.value = new ArrayList<Subscription>();
        Subscription sub = new Subscription();
        sub.setBindingKey(bindingkey);
        sub.setNotificationInterval(DatatypeFactory.newInstance().newDuration(5000));
        sub.setSubscriptionFilter(new SubscriptionFilter());
        sub.getSubscriptionFilter().setFindBinding(new FindBinding());
        //FAIL sub.getSubscriptionFilter().getFindBinding().setServiceKey(bs.getServiceKey());
        sub.getSubscriptionFilter().getFindBinding().setTModelBag(new TModelBag());

        //At least one of either a tModelBag or a find_tModel argument SHOULD be supplied, unless a categoryBag based search is being used.
        sub.getSubscriptionFilter().getFindBinding().getTModelBag().getTModelKey()
                .add(WSDMQosConstants.METRIC_FAULT_COUNT_KEY);
        //joe wants updates to mary's binding

        holder.value.add(sub);
        subscriptionJoe.saveSubscription(authInfoJoe, holder);
        logger.info("subscription saved for " + holder.value.get(0).getSubscriptionKey());
        //tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION3_XML);
        //Changing the service we subscribed to "JoePublisherService"
        Thread.sleep(1000);
        logger.info("updating Mary's binding ********** ");
        String newcontent = updatePublisherBindingAddTMI(authInfoMary, bt, publicationMary);

        boolean found = verifyDelivery(newcontent);

        if (!found) {
            logger.warn("Test failed, dumping business list");
            logger.warn("BEFORE " + before);
            logger.warn("After " + TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe));
            TckCommon.PrintMarker();
            Assert.fail("Notification does not contain the correct service.");
        }

    } catch (Exception e) {
        logger.error("No exceptions please.");
        TckCommon.PrintMarker();
        e.printStackTrace();

        Assert.fail(e.getMessage());
    } finally {
        //tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_KEY);
        DeleteSubscription ds = new DeleteSubscription();
        ds.setAuthInfo(authInfoJoe);
        ds.getSubscriptionKey().add(holder.value.get(0).getSubscriptionKey());
        subscriptionJoe.deleteSubscription(ds);
        tckBusinessMary.deleteMaryPublisherBusiness(authInfoMary);
        tckTModelMary.deleteMaryPublisherTmodel(authInfoMary);

        tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
        tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
        tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
        tckTModelJoe.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY,
                TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);

    }
}

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

/**
 * joe wants updates on all services with wsdm qos tmi. mary updates a
 * binding to trigger the call back//from w w  w . ja v  a2  s.c o  m
 *
 * @throws Exception
 */
@Test
public void joePublisherUpdate_FIND_BINDING_BY_CATBAG() throws Exception {
    Assume.assumeTrue(TckPublisher.isEnabled());
    Assume.assumeNotNull(getHostame());
    Assume.assumeTrue(IsEnabled());
    logger.info("joePublisherUpdate_" + getTransport() + "_FIND_BINDING_BY_CATBAG");
    TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
    Holder<List<Subscription>> holder = null;
    try {
        reset();

        String before = TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe);

        tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
        tckTModelJoe.saveTModels(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);

        tckTModelMary.saveMaryPublisherTmodel(authInfoMary);
        BusinessEntity saveMaryPublisherBusiness = tckBusinessMary.saveMaryPublisherBusiness(authInfoMary);

        BusinessService bs = new BusinessService();
        bs.setBusinessKey(saveMaryPublisherBusiness.getBusinessKey());
        bs.setServiceKey(TckTModel.MARY_KEY_PREFIX + UUID.randomUUID().toString());
        bs.getName().add(new Name("Mary's service for " + getTransport(), null));

        bs.setBindingTemplates(new BindingTemplates());
        BindingTemplate bt = new BindingTemplate();
        bt.setAccessPoint(new AccessPoint("http://localhost", "endPoint"));
        bt.setBindingKey(TckTModel.MARY_KEY_PREFIX + UUID.randomUUID().toString());
        bt.setServiceKey(bs.getServiceKey());
        bt = UDDIClient.addSOAPtModels(bt);

        bs.getBindingTemplates().getBindingTemplate().add(bt);
        SaveService ss = new SaveService();
        ss.getBusinessService().add(bs);
        ss.setAuthInfo(authInfoMary);
        bs = publicationMary.saveService(ss).getBusinessService().get(0);

        tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
        tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
        //Saving the Listener Service
        String bindingkey = tckSubscriptionListenerJoe.saveService(authInfoJoe,
                getXMLLocationOfServiceForDelivery(), getPort(), getHostame());

        //Saving the Subscription
        holder = new Holder<List<Subscription>>();
        holder.value = new ArrayList<Subscription>();
        Subscription sub = new Subscription();
        sub.setBindingKey(bindingkey);
        sub.setNotificationInterval(DatatypeFactory.newInstance().newDuration(5000));
        sub.setSubscriptionFilter(new SubscriptionFilter());
        sub.getSubscriptionFilter().setFindBinding(new FindBinding());

        //At least one of either a tModelBag or a find_tModel argument SHOULD be supplied, unless a categoryBag based search is being used.
        sub.getSubscriptionFilter().getFindBinding().setCategoryBag(new CategoryBag());
        sub.getSubscriptionFilter().getFindBinding().getCategoryBag().getKeyedReference()
                .add(new KeyedReference("uddi:uddi.org:categorization:types",
                        UDDIConstants.CategorizationTypes_Cacheable, "Cacheable"));

        holder.value.add(sub);
        subscriptionJoe.saveSubscription(authInfoJoe, holder);
        logger.info("subscription saved for " + holder.value.get(0).getSubscriptionKey());
        //tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION3_XML);
        //Changing the service we subscribed to "JoePublisherService"
        Thread.sleep(1000);
        if (TckCommon.isDebug()) {
            logger.info("dumping mary's binding before.... ");
            JAXB.marshal(bs, System.out);
        }
        logger.info("updating Mary's binding ********** ");
        // BindingDetail after=new BindingDetail();
        /*GetBindingDetail bindingDetail = new GetBindingDetail();
         bindingDetail.setAuthInfo(authInfoMary);
         bindingDetail.getBindingKey().add(bs.getBindingTemplates().getBindingTemplate().get(0).getBindingKey());*/
        BindingDetail bindingDetail1 = null;//inquiryMary.getBindingDetail(bindingDetail);
        bindingDetail1 = updatePublisherBindingAddCategory(authInfoMary, bt, publicationMary,
                new KeyedReference("uddi:uddi.org:categorization:types",
                        UDDIConstants.CategorizationTypes_Cacheable, "Cacheable"),
                bindingDetail1);

        if (TckCommon.isDebug()) {
            logger.info("dumping mary's binding after.... ");
            JAXB.marshal(bindingDetail1, System.out);
        }
        boolean found = verifyDelivery(UDDIConstants.CategorizationTypes_Cacheable);

        if (!found) {
            logger.warn("Test failed, dumping business list");
            logger.warn("BEFORE " + before);
            logger.warn("After " + TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe));
            TckCommon.PrintMarker();
            Assert.fail("Notification does not contain the correct service.");
        }

    } catch (Exception e) {
        logger.error("No exceptions please.");
        TckCommon.PrintMarker();
        e.printStackTrace();

        Assert.fail(e.getMessage());
    } finally {
        //tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_KEY);
        DeleteSubscription ds = new DeleteSubscription();
        ds.setAuthInfo(authInfoJoe);
        ds.getSubscriptionKey().add(holder.value.get(0).getSubscriptionKey());
        subscriptionJoe.deleteSubscription(ds);
        tckBusinessMary.deleteMaryPublisherBusiness(authInfoMary);
        tckTModelMary.deleteMaryPublisherTmodel(authInfoMary);

        tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
        tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
        tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
        tckTModelJoe.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY,
                TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);

    }
}

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

/**
 * getBusiness tests/*from w  ww.ja  va2  s  . com*/
 * joe want's updates on mary's business
 * @throws Exception 
 */
@Test
public void joePublisherUpdate_HTTP_GET_BUSINESS_DETAIL() throws Exception {
    Assume.assumeTrue(TckPublisher.isEnabled());
    logger.info("joePublisherUpdate_HTTP_GET_BUSINESS_DETAIL");
    TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
    Holder<List<Subscription>> holder = null;
    try {
        UDDISubscriptionListenerImpl.notifcationMap.clear();
        UDDISubscriptionListenerImpl.notificationCount = 0;
        String before = TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe);

        tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
        tckTModelJoe.saveTModels(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);

        tckTModelMary.saveMaryPublisherTmodel(authInfoMary);
        BusinessEntity saveMaryPublisherBusiness = tckBusinessMary.saveMaryPublisherBusiness(authInfoMary);

        tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
        tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
        //Saving the Listener Service
        tckSubscriptionListenerJoe.saveService(authInfoJoe, TckSubscriptionListener.LISTENER_HTTP_SERVICE_XML,
                httpPort, hostname);

        //Saving the Subscription
        holder = new Holder<List<Subscription>>();
        holder.value = new ArrayList<Subscription>();
        Subscription sub = new Subscription();
        sub.setBindingKey("uddi:uddi.joepublisher.com:bindinglistener");
        sub.setNotificationInterval(DatatypeFactory.newInstance().newDuration(5000));
        sub.setSubscriptionFilter(new SubscriptionFilter());
        sub.getSubscriptionFilter().setGetBusinessDetail(new GetBusinessDetail());
        sub.getSubscriptionFilter().getGetBusinessDetail().getBusinessKey().add(TckBusiness.MARY_BUSINESS_KEY);

        holder.value.add(sub);
        subscriptionJoe.saveSubscription(authInfoJoe, holder);
        //tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION3_XML);
        //Changing the service we subscribed to "JoePublisherService"
        Thread.sleep(1000);
        logger.info("updating Mary's business ********** ");
        updatePublisherBusiness(authInfoMary, saveMaryPublisherBusiness, publicationMary);

        logger.info("Waiting " + TckPublisher.getSubscriptionTimeout() + " seconds for delivery");
        //waiting up to 100 seconds for the listener to notice the change.
        for (int i = 0; i < TckPublisher.getSubscriptionTimeout(); i++) {
            Thread.sleep(1000);
            System.out.print(".");
            if (UDDISubscriptionListenerImpl.notificationCount > 0) {
                //    logger.info("Received Notification");
                //                                        break;
            }
        }

        if (UDDISubscriptionListenerImpl.notificationCount == 0) {
            logger.warn("Test failed, dumping business list");
            logger.warn("BEFORE " + before);
            logger.warn("After " + TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe));
            Assert.fail("No Notification was sent");
        }
        Iterator<String> it = UDDISubscriptionListenerImpl.notifcationMap.values().iterator();
        StringBuilder sb = new StringBuilder();
        boolean found = false;
        while (it.hasNext()) {
            String test = it.next();
            sb.append("Message: " + test + System.getProperty("line.separator"));
            if (test.contains("Updated Name")) {
                found = true;
                break;
            }
        }
        if (!found) {
            logger.warn("Test failed, dumping business list");
            logger.warn("BEFORE " + before);
            logger.warn("After " + TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe));
            Assert.fail(
                    "Notification does not contain the correct service. Messages received: " + sb.toString());
        }

    } catch (Exception e) {
        logger.error("No exceptions please.");
        e.printStackTrace();

        Assert.fail();
    } finally {
        //tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_KEY);
        DeleteSubscription ds = new DeleteSubscription();
        ds.setAuthInfo(authInfoJoe);
        ds.getSubscriptionKey().add(holder.value.get(0).getSubscriptionKey());
        subscriptionJoe.deleteSubscription(ds);
        tckBusinessMary.deleteMaryPublisherBusiness(authInfoMary);
        tckTModelMary.deleteMaryPublisherTmodel(authInfoMary);

        tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
        tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
        tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
        tckTModelJoe.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY,
                TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);

    }
}

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

/**
 * testing upper case subscription callbacks
 *
 * @throws Exception//from   ww w.ja v  a  2  s  .  c  om
 */
@Test
public void JIRA_597() throws Exception {
    Assume.assumeTrue(TckPublisher.isEnabled());
    System.out.println("JIRA_597");

    int port = 7000;
    String hostname = TckPublisher.getProperties().getProperty("bindaddress");
    if (hostname == null) {
        hostname = InetAddress.getLocalHost().getHostName();
    }

    TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
    UDDISubscriptionListenerImpl.notifcationMap.clear();
    UDDISubscriptionListenerImpl.notificationCount = 0;
    Endpoint ep = null;
    boolean ok = false;
    do {
        try {
            logger.info("Attempting to bring up endpoint at " + "http://" + hostname + ":" + port
                    + "/UDDI_CALLBACK");
            ep = Endpoint.publish("http://" + hostname + ":" + port + "/UDDI_CALLBACK", impl);
            ok = true;
        } catch (Exception ex) {
            logger.warn("Trouble starting endpoint: " + ex.getMessage());
            port++;
        }
    } while (!ok);
    SaveBusiness sb = new SaveBusiness();
    sb.setAuthInfo(authInfoJoe);
    BusinessEntity be = new BusinessEntity();
    be.getName().add(new Name());
    be.getName().get(0).setValue("Joe's callback business");
    be.setBusinessServices(new BusinessServices());
    BusinessService bs = new BusinessService();
    bs.getName().add(new Name());
    bs.getName().get(0).setValue("Joe's callback service");
    bs.setBindingTemplates(new BindingTemplates());
    BindingTemplate bt = new BindingTemplate();
    bt.setAccessPoint(new AccessPoint());
    bt.getAccessPoint().setValue("http://" + hostname + ":" + port + "/UDDI_CALLBACK");
    bt.getAccessPoint().setUseType("endPoint");
    //Added per Kurt
    TModelInstanceInfo instanceInfo = new TModelInstanceInfo();
    instanceInfo.setTModelKey("uddi:uddi.org:transport:http");
    bt.setTModelInstanceDetails(new TModelInstanceDetails());
    bt.getTModelInstanceDetails().getTModelInstanceInfo().add(instanceInfo);

    bs.getBindingTemplates().getBindingTemplate().add(bt);

    bs.getBindingTemplates().getBindingTemplate().add(bt);
    be.getBusinessServices().getBusinessService().add(bs);
    sb.getBusinessEntity().add(be);
    BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb);

    List<String> deleteme = new ArrayList<String>();
    deleteme.add(saveBusiness.getBusinessEntity().get(0).getBusinessKey());
    //ok Joe's callback is setup

    //Setup a business to subscribe to
    sb = new SaveBusiness();
    sb.setAuthInfo(authInfoSam);
    be = new BusinessEntity();
    be.getName().add(new Name());
    be.getName().get(0).setValue("Sam's business");
    sb.getBusinessEntity().add(be);
    BusinessDetail saveBusiness1 = publicationSam.saveBusiness(sb);

    //ok Joe now needs to subscribe for Sam's business
    Holder<List<Subscription>> list = new Holder<List<Subscription>>();
    list.value = new ArrayList<Subscription>();
    Subscription s = new Subscription();
    s.setBindingKey(saveBusiness.getBusinessEntity().get(0).getBusinessServices().getBusinessService().get(0)
            .getBindingTemplates().getBindingTemplate().get(0).getBindingKey());
    s.setSubscriptionFilter(new SubscriptionFilter());
    s.getSubscriptionFilter().setGetBusinessDetail(new GetBusinessDetail());
    s.getSubscriptionFilter().getGetBusinessDetail().getBusinessKey()
            .add(saveBusiness1.getBusinessEntity().get(0).getBusinessKey());
    DatatypeFactory df = DatatypeFactory.newInstance();
    GregorianCalendar gcal = new GregorianCalendar();
    gcal.setTimeInMillis(System.currentTimeMillis());
    gcal.add(Calendar.HOUR, 1);
    s.setExpiresAfter(df.newXMLGregorianCalendar(gcal));

    s.setNotificationInterval(df.newDuration(5000));
    list.value.add(s);
    subscriptionJoe.saveSubscription(authInfoJoe, list);

    //ok have sam change his business around.
    sb = new SaveBusiness();
    sb.setAuthInfo(authInfoSam);
    be = saveBusiness1.getBusinessEntity().get(0);
    be.getName().get(0).setLang("en");
    sb.getBusinessEntity().add(be);
    publicationSam.saveBusiness(sb);
    int maxwait = 30000;
    logger.info("waiting for callbacks");
    while (maxwait > 0) {
        if (UDDISubscriptionListenerImpl.notifcationMap.size() > 0) {
            break;
        }
        Thread.sleep(1000);
        maxwait = maxwait - 1000;
    }
    TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
    this.DeleteBusinesses(deleteme, authInfoJoe, publicationJoe);
    deleteme.clear();
    deleteme.add(saveBusiness1.getBusinessEntity().get(0).getBusinessKey());
    this.DeleteBusinesses(deleteme, authInfoSam, publicationSam);
    ep.stop();
    if (UDDISubscriptionListenerImpl.notifcationMap.isEmpty()) {
        Assert.fail("no callbacks were recieved.");
    }

}

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

/**
 * testing callbacks with undefined transport type with a uppercase path
 * this also tests the case of one user subscribing to a specific entity
 * via GetBusinessDetail subscription filter
 *
 * @throws Exception//from w  w w. j a  v  a 2  s.c o m
 */
@Test
public void JIRA_596() throws Exception {
    Assume.assumeTrue(TckPublisher.isEnabled());
    System.out.println("JIRA_596");
    int port = 9000;

    String hostname = TckPublisher.getProperties().getProperty("bindaddress");
    if (hostname == null) {
        hostname = InetAddress.getLocalHost().getHostName();
    }

    // String localhostname = "localhost";//java.net.InetAddress.getLocalHost().getHostName();
    TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
    //UDDISubscriptionListenerImpl impl = new UDDISubscriptionListenerImpl();
    UDDISubscriptionListenerImpl.notifcationMap.clear();
    UDDISubscriptionListenerImpl.notificationCount = 0;

    Endpoint ep = null;
    boolean ok = false;
    do {
        try {
            ep = Endpoint.publish("http://" + hostname + ":" + port + "/UDDI_CALLBACK", impl);
            ok = true;
        } catch (Exception ex) {
            port++;
        }
    } while (!ok);
    SaveBusiness sb = new SaveBusiness();
    sb.setAuthInfo(authInfoJoe);
    BusinessEntity be = new BusinessEntity();
    be.getName().add(new Name());
    be.getName().get(0).setValue("Joe's callback business");
    be.setBusinessServices(new BusinessServices());
    BusinessService bs = new BusinessService();
    bs.getName().add(new Name());
    bs.getName().get(0).setValue("Joe's callback service");
    bs.setBindingTemplates(new BindingTemplates());
    BindingTemplate bt = new BindingTemplate();
    bt.setAccessPoint(new AccessPoint());
    bt.getAccessPoint().setValue("http://" + hostname + ":" + port + "/UDDI_CALLBACK");
    bt.getAccessPoint().setUseType("endPoint");
    //obmitted as part of the jira test case
    /*TModelInstanceInfo instanceInfo = new TModelInstanceInfo();
         instanceInfo.setTModelKey("uddi:uddi.org:transport:http");
         bt.setTModelInstanceDetails(new TModelInstanceDetails());
         bt.getTModelInstanceDetails().getTModelInstanceInfo().add(instanceInfo);
         */
    bs.getBindingTemplates().getBindingTemplate().add(bt);
    be.getBusinessServices().getBusinessService().add(bs);
    sb.getBusinessEntity().add(be);
    logger.info("setting up joe's callback business");
    BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb);

    List<String> deleteme = new ArrayList<String>();
    deleteme.add(saveBusiness.getBusinessEntity().get(0).getBusinessKey());
    //ok Joe's callback is setup

    //Setup a business to subscribe to
    sb = new SaveBusiness();
    sb.setAuthInfo(authInfoSam);
    be = new BusinessEntity();
    be.getName().add(new Name());
    be.getName().get(0).setValue("Sam's business");
    sb.getBusinessEntity().add(be);
    logger.info("saving sam's business");
    BusinessDetail saveBusiness1 = publicationSam.saveBusiness(sb);

    //ok Joe now needs to subscribe for Sam's business
    Holder<List<Subscription>> list = new Holder<List<Subscription>>();
    list.value = new ArrayList<Subscription>();
    Subscription s = new Subscription();
    s.setBindingKey(saveBusiness.getBusinessEntity().get(0).getBusinessServices().getBusinessService().get(0)
            .getBindingTemplates().getBindingTemplate().get(0).getBindingKey());
    s.setSubscriptionFilter(new SubscriptionFilter());
    s.getSubscriptionFilter().setGetBusinessDetail(new GetBusinessDetail());
    s.getSubscriptionFilter().getGetBusinessDetail().getBusinessKey()
            .add(saveBusiness1.getBusinessEntity().get(0).getBusinessKey());
    DatatypeFactory df = DatatypeFactory.newInstance();
    GregorianCalendar gcal = new GregorianCalendar();
    gcal.setTimeInMillis(System.currentTimeMillis());
    gcal.add(Calendar.HOUR, 1);
    s.setExpiresAfter(df.newXMLGregorianCalendar(gcal));

    s.setNotificationInterval(df.newDuration(5000));
    list.value.add(s);
    logger.info("subscribing joe's to updates for sam's business");
    subscriptionJoe.saveSubscription(authInfoJoe, list);

    //ok have sam change his business around.
    sb = new SaveBusiness();
    sb.setAuthInfo(authInfoSam);
    be = saveBusiness1.getBusinessEntity().get(0);
    be.getName().get(0).setLang("en");
    sb.getBusinessEntity().add(be);
    logger.info("altering sam's business");
    publicationSam.saveBusiness(sb);
    logger.info("Waiting...");
    int maxwait = 30000;
    while (maxwait > 0) {
        if (UDDISubscriptionListenerImpl.notifcationMap.size() > 0) {
            break;
        }
        Thread.sleep(1000);
        maxwait = maxwait - 1000;
    }
    TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
    DeleteBusinesses(deleteme, authInfoJoe, publicationJoe);
    deleteme.clear();
    deleteme.add(saveBusiness1.getBusinessEntity().get(0).getBusinessKey());
    DeleteBusinesses(deleteme, authInfoSam, publicationSam);
    ep.stop();
    if (UDDISubscriptionListenerImpl.notifcationMap.isEmpty()) {
        logger.error("no callbacks were recieved");
        Assert.fail("no callbacks were recieved.");
    }
    logger.info("callback response was " + UDDISubscriptionListenerImpl.notifcationMap.get(0));
    logger.info("PASS");

}

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

/**
 * tests a user to user transfer on the same node
 *
 * @throws Exception//  w  w w  . j av  a 2 s .c  o m
 */
@Test
public void ValidTransfer() throws Exception {
    Assume.assumeTrue(TckPublisher.isEnabled());
    System.out.println("ValidTransfer");
    DatatypeFactory df = DatatypeFactory.newInstance();
    GregorianCalendar gcal = new GregorianCalendar();
    gcal.setTimeInMillis(System.currentTimeMillis());
    XMLGregorianCalendar xcal = df.newXMLGregorianCalendar(gcal);

    BusinessEntity myBusEntity = new BusinessEntity();
    Name myBusName = new Name();
    myBusName.setLang("en");
    myBusName.setValue("ValidTransfer UDDI's Business" + " " + xcal.toString());
    myBusEntity.getName().add(myBusName);
    myBusEntity.setBusinessServices(new BusinessServices());
    myBusEntity.getBusinessServices().getBusinessService().add(CreateBusiness("UDDI"));
    SaveBusiness sb = new SaveBusiness();
    sb.getBusinessEntity().add(myBusEntity);
    sb.setAuthInfo(authInfoJoe);
    BusinessDetail bd = publishJoe.saveBusiness(sb);

    String keyJoeBiz = bd.getBusinessEntity().get(0).getBusinessKey();
    //String keyJoeBizSvc = bd.getBusinessEntity().get(0).getBusinessServices().getBusinessService().get(0).getServiceKey();

    myBusEntity = new BusinessEntity();
    myBusName = new Name();
    myBusName.setLang("en");
    myBusName.setValue("ValidTransfer Root's Business" + " " + xcal.toString());
    myBusEntity.getName().add(myBusName);
    myBusEntity.setBusinessServices(new BusinessServices());
    myBusEntity.getBusinessServices().getBusinessService().add(CreateBusiness("root"));
    sb = new SaveBusiness();
    sb.getBusinessEntity().add(myBusEntity);
    sb.setAuthInfo(authInfoSam);
    bd = publishSam.saveBusiness(sb);

    String keySamBiz = bd.getBusinessEntity().get(0).getBusinessKey();
    //String keySamBizSvc = bd.getBusinessEntity().get(0).getBusinessServices().getBusinessService().get(0).getServiceKey();

    //transfers from Joe to Sam
    KeyBag kb = new KeyBag();
    kb.getKey().add(keyJoeBiz);

    Holder<String> nodeidOUT = new Holder<String>();
    Holder<XMLGregorianCalendar> expiresOUT = new Holder<XMLGregorianCalendar>();
    Holder<byte[]> tokenOUT = new Holder<byte[]>();
    custodyTransferPortTypeJoe.getTransferToken(authInfoJoe, kb, nodeidOUT, expiresOUT, tokenOUT);

    //sam accepts
    TransferEntities te = new TransferEntities();
    te.setAuthInfo(authInfoSam);
    te.setKeyBag(kb);
    TransferToken tt = new TransferToken();
    tt.setExpirationTime(expiresOUT.value);
    tt.setNodeID(nodeidOUT.value);
    tt.setOpaqueToken(tokenOUT.value);
    te.setTransferToken(tt);

    custodyTransferPortTypeSam.transferEntities(te);

    //confirm the transfer
    GetOperationalInfo go = new GetOperationalInfo();
    go.setAuthInfo(authInfoSam);
    go.getEntityKey().add(keySamBiz);
    go.getEntityKey().add(keyJoeBiz);
    OperationalInfos operationalInfo = inquirySam.getOperationalInfo(go);

    for (int i = 0; i < operationalInfo.getOperationalInfo().size(); i++) {
        if (operationalInfo.getOperationalInfo().get(i).getEntityKey().equalsIgnoreCase(keyJoeBiz)) {
            Assert.assertEquals(operationalInfo.getOperationalInfo().get(i).getAuthorizedName(),
                    (TckPublisher.getSamPublisherId()));

        }
    }
    System.out.println("Business Entity transfered successfull");

    //note, we transfered ownership here so sam has to delete both of them
    TckCommon.DeleteBusiness(keyJoeBiz, authInfoSam, publishSam);
    TckCommon.DeleteBusiness(keySamBiz, authInfoSam, publishSam);

}

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

@Test
public void InvalidTransferTokenNullKeybag() {
    Assume.assumeTrue(TckPublisher.isEnabled());
    try {//ww w  .ja v a2s.c o  m
        //transfers from Joe to Sam
        KeyBag kb = null;

        Holder<String> nodeidOUT = new Holder<String>();
        Holder<XMLGregorianCalendar> expiresOUT = new Holder<XMLGregorianCalendar>();
        Holder<byte[]> tokenOUT = new Holder<byte[]>();
        custodyTransferPortTypeJoe.getTransferToken(authInfoJoe, kb, nodeidOUT, expiresOUT, tokenOUT);
        Assert.fail();
    } catch (Exception ex) {
        logger.info("Expected exception: " + ex.getMessage());
    }

}

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

@Test
public void InvalidTransferTokenEmptyKeybag() {
    Assume.assumeTrue(TckPublisher.isEnabled());
    try {// w w w .  j  a v  a 2s  .c o  m
        //transfers from Joe to Sam
        KeyBag kb = new KeyBag();
        //kb.getKey().add(keyJoeBiz);

        Holder<String> nodeidOUT = new Holder<String>();
        Holder<XMLGregorianCalendar> expiresOUT = new Holder<XMLGregorianCalendar>();
        Holder<byte[]> tokenOUT = new Holder<byte[]>();
        custodyTransferPortTypeJoe.getTransferToken(authInfoJoe, kb, nodeidOUT, expiresOUT, tokenOUT);

        Assert.fail();
    } catch (Exception ex) {
        logger.info("Expected exception: " + ex.getMessage());
    }

}

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

@Test
public void InvalidTransferTokenEmptyNullAuthToken() {
    Assume.assumeTrue(TckPublisher.isEnabled());
    String keyJoeBiz = null;//from w ww  .  java 2  s  .com
    try {
        DatatypeFactory df = DatatypeFactory.newInstance();
        GregorianCalendar gcal = new GregorianCalendar();
        gcal.setTimeInMillis(System.currentTimeMillis());
        XMLGregorianCalendar xcal = df.newXMLGregorianCalendar(gcal);

        BusinessEntity myBusEntity = new BusinessEntity();
        Name myBusName = new Name();
        myBusName.setLang("en");
        myBusName.setValue("InvalidTransferTokenEmptyNullAuthToken UDDI's Business" + " " + xcal.toString());
        myBusEntity.getName().add(myBusName);
        myBusEntity.setBusinessServices(new BusinessServices());
        myBusEntity.getBusinessServices().getBusinessService().add(CreateBusiness("UDDI"));
        SaveBusiness sb = new SaveBusiness();
        sb.getBusinessEntity().add(myBusEntity);
        sb.setAuthInfo(authInfoJoe);
        BusinessDetail bd = publishJoe.saveBusiness(sb);

        keyJoeBiz = bd.getBusinessEntity().get(0).getBusinessKey();

        //transfers from Joe to Sam
        KeyBag kb = new KeyBag();
        kb.getKey().add(keyJoeBiz);

        Holder<String> nodeidOUT = new Holder<String>();
        Holder<XMLGregorianCalendar> expiresOUT = new Holder<XMLGregorianCalendar>();
        Holder<byte[]> tokenOUT = new Holder<byte[]>();
        custodyTransferPortTypeJoe.getTransferToken(null, kb, nodeidOUT, expiresOUT, tokenOUT);

        Assert.fail();
    } catch (Exception ex) {
        logger.info("Expected exception: " + ex.getMessage());

    } finally {
        TckCommon.DeleteBusiness(keyJoeBiz, authInfoJoe, publishJoe);

    }

}