List of usage examples for javax.xml.datatype DatatypeFactory newInstance
public static DatatypeFactory newInstance() throws DatatypeConfigurationException
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 ww.j a v a 2 s. c om */ @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 .j a v a2 s. c om * * @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 ww w.j av a 2s . 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/* w w w . jav a2 s . com*/ */ @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 av a 2 s . c om*/ */ @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.ja v a2s. 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 InvalidTransferTokenEmptyNullAuthToken() { Assume.assumeTrue(TckPublisher.isEnabled()); String keyJoeBiz = null;// ww w. j a va2s . co m 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); } }
From source file:org.apache.juddi.v3.tck.UDDI_150_CustodyTransferIntegrationTest.java
/** * a valid transfer token issued, then modified out of band, this should * fail/*from w ww . j a v a2 s . co m*/ */ @Test public void InvalidTransferTokenModified() { Assume.assumeTrue(TckPublisher.isEnabled()); String keySamBiz = null; String keyJoeBiz = null; 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("InvalidTransferTokenModified 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(); myBusEntity = new BusinessEntity(); myBusName = new Name(); myBusName.setLang("en"); myBusName.setValue("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); 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); te.getKeyBag().getKey().add("uddi:uddi.joepublisher.com:" + UUID.randomUUID().toString()); TransferToken tt = new TransferToken(); tt.setExpirationTime(expiresOUT.value); tt.setNodeID(nodeidOUT.value); tt.setOpaqueToken(tokenOUT.value); te.setTransferToken(tt); custodyTransferPortTypeSam.transferEntities(te); Assert.fail(); } catch (Exception ex) { // HandleException(ex); logger.info("Expected exception: " + ex.getMessage()); } finally { TckCommon.DeleteBusiness(keyJoeBiz, authInfoJoe, publishJoe); TckCommon.DeleteBusiness(keySamBiz, authInfoSam, publishSam); } }
From source file:org.apache.juddi.validation.ValidateSubscription.java
private void validateSubscription(EntityManager em, org.uddi.sub_v3.Subscription subscription) throws DispositionReportFaultMessage { // A supplied subscription can't be null if (subscription == null) { throw new ValueNotAllowedException(new ErrorMessage("errors.subscription.NullInput")); }/*w w w . ja va 2 s .c om*/ if (df == null) { try { df = DatatypeFactory.newInstance(); } catch (DatatypeConfigurationException ex) { throw new FatalErrorException(new ErrorMessage("errors.DatatypeFactor")); } } boolean entityExists = false; String entityKey = subscription.getSubscriptionKey(); //no key specified, make a new one if (entityKey == null || entityKey.length() == 0) { KeyGenerator keyGen = KeyGeneratorFactory.getKeyGenerator(); entityKey = keyGen.generate(); subscription.setSubscriptionKey(entityKey); } else { //key specified, validate it // Per section 4.4: keys must be case-folded entityKey = entityKey.toLowerCase(); subscription.setSubscriptionKey(entityKey); Object obj = em.find(org.apache.juddi.model.Subscription.class, entityKey); if (obj != null) { entityExists = true; //revising a new item // Make sure publisher owns this entity. if (!publisher.getAuthorizedName() .equals(((org.apache.juddi.model.Subscription) obj).getAuthorizedName())) { throw new UserMismatchException( new ErrorMessage("errors.usermismatch.InvalidOwner", entityKey)); } } else { //new item // Inside this block, we have a key proposed by the publisher on a new entity // Validate key and then check to see that the proposed key is valid for this publisher ValidateUDDIKey.validateUDDIv3Key(entityKey); if (!publisher.isValidPublisherKey(em, entityKey)) { throw new KeyUnavailableException( new ErrorMessage("errors.keyunavailable.BadPartition", entityKey)); } } } if (!entityExists) { // Check to make sure key isn't used by another entity. if (!isUniqueKey(em, entityKey)) { throw new KeyUnavailableException(new ErrorMessage("errors.keyunavailable.KeyExists", entityKey)); } } //AO, if it's already expired, why even allow it? if (subscription.getExpiresAfter() != null) { long expiresat = subscription.getExpiresAfter().toGregorianCalendar().getTimeInMillis(); if (System.currentTimeMillis() > expiresat) { throw new ValueNotAllowedException(new ErrorMessage("errors.subscription.expired")); } } if (subscription.getMaxEntities() != null) { if (subscription.getMaxEntities().intValue() <= 0) { throw new ValueNotAllowedException(new ErrorMessage("errors.subscription.maxrecordstoosmall")); } } //maxEntities: This optional integer specifies the maximum number of entities in a notification returned to a subscription listener. //If not specified, the number of entities sent is not limited, unless by node policy. try { if (subscription.getMaxEntities() == null || subscription.getMaxEntities().intValue() > AppConfig .getConfiguration().getInt(Property.JUDDI_SUBSCRIPTION_MAXENTITIES, 1000)) { subscription.setMaxEntities( AppConfig.getConfiguration().getInt(Property.JUDDI_SUBSCRIPTION_MAXENTITIES, 1000)); } } catch (ConfigurationException x) { subscription.setMaxEntities(1000); } /* * notificationInterval: This optional argument is only required when asynchronous notifications are used. * It is of type xsd:duration and specifies how often change notifications are to be provided to a subscriber. * If the notificationInterval specified is not acceptable due to node policy, then the node adjusts the value to * match the next longer time period that is supported. The adjusted value is provided with the returns from this * API. Also see Section 5.5.1.1 Specifying Durations. */ if (subscription.getNotificationInterval() == null && subscription.getBindingKey() != null) { throw new ValueNotAllowedException( new ErrorMessage("errors.subscription.notificationintervalnotdefined")); } //validate that the binding key exists validateSubscriptionBindingkeyExists(em, subscription.getBindingKey()); validateSubscriptionFilter(subscription.getSubscriptionFilter(), entityExists); }
From source file:org.apache.juddi.webconsole.hub.UddiHub.java
private UddiHub() throws DatatypeConfigurationException { df = DatatypeFactory.newInstance(); }