List of usage examples for javax.xml.ws Holder Holder
public Holder()
From source file:org.apache.cxf.systest.jaxrs.JAXRS20ClientServerBookTest.java
private void doTestPostBookAsyncHandler(String address) throws InterruptedException, ExecutionException { WebClient wc = createWebClientPost(address); final Holder<Book> holder = new Holder<Book>(); final InvocationCallback<Book> callback = new InvocationCallback<Book>() { public void completed(Book response) { holder.value = response;//ww w .j a v a 2 s .co m } public void failed(Throwable error) { } }; Future<Book> future = wc.post(new Book("async", 126L), callback); Book book = future.get(); assertSame(book, holder.value); assertEquals(124L, book.getId()); validatePostResponse(wc, true, false); }
From source file:org.apache.cxf.systest.jaxrs.JAXRS20ClientServerBookTest.java
private void doTestGetBookAsyncResponse(String address, boolean asyncInvoker) throws InterruptedException, ExecutionException { WebClient wc = createWebClient(address); wc.accept(MediaType.APPLICATION_XML_TYPE); final Holder<Response> holder = new Holder<Response>(); final InvocationCallback<Response> callback = new InvocationCallback<Response>() { public void completed(Response response) { holder.value = response;/* w w w . j a v a 2 s . c o m*/ } public void failed(Throwable error) { } }; Future<Response> future = asyncInvoker ? wc.async().get(callback) : wc.get(callback); Book book = future.get().readEntity(Book.class); assertEquals(124L, book.getId()); validateResponse(wc); }
From source file:org.apache.juddi.api.impl.API_099_LoadTest.java
/** * create 1000 subscriptions/*from w w w.j ava 2 s . c o m*/ * @throws Exception */ //@Ignore @Test public void joePublisher() throws Exception { //Assume.assumeTrue(TckPublisher.isLoadTest()); List<String> keys = new ArrayList<String>(); for (int i = 0; i < 1000; i++) { Holder<List<Subscription>> items = new Holder<List<Subscription>>(); items.value = new ArrayList<Subscription>(); Subscription s = new Subscription(); s.setSubscriptionFilter(new SubscriptionFilter()); s.getSubscriptionFilter().setFindBusiness(new FindBusiness()); s.getSubscriptionFilter().getFindBusiness().setFindQualifiers(new FindQualifiers()); s.getSubscriptionFilter().getFindBusiness().getFindQualifiers().getFindQualifier() .add(UDDIConstants.APPROXIMATE_MATCH); s.getSubscriptionFilter().getFindBusiness().getName().add(new Name(UDDIConstants.WILDCARD, null)); items.value.add(s); sub.saveSubscription(authInfoJoe, items); keys.add(items.value.get(0).getSubscriptionKey()); } List<Subscription> subscriptions = sub.getSubscriptions(authInfoJoe); DeleteSubscription ds = new DeleteSubscription(); ds.setAuthInfo(authInfoJoe); ds.getSubscriptionKey().addAll(keys); sub.deleteSubscription(ds); Assert.assertEquals(subscriptions.size(), keys.size()); }
From source file:org.apache.juddi.api.impl.API_099_LoadTests.java
@Test public void joePublisher() throws Exception { Assume.assumeTrue(TckPublisher.isLoadTest()); List<String> keys = new ArrayList<String>(); for (int i = 0; i < 1000; i++) { Holder<List<Subscription>> items = new Holder<List<Subscription>>(); items.value = new ArrayList<Subscription>(); Subscription s = new Subscription(); s.setSubscriptionFilter(new SubscriptionFilter()); s.getSubscriptionFilter().setFindBusiness(new FindBusiness()); s.getSubscriptionFilter().getFindBusiness().setFindQualifiers(new FindQualifiers()); s.getSubscriptionFilter().getFindBusiness().getFindQualifiers().getFindQualifier() .add(UDDIConstants.APPROXIMATE_MATCH); s.getSubscriptionFilter().getFindBusiness().getName().add(new Name(UDDIConstants.WILDCARD, null)); items.value.add(s);//ww w. j a v a 2 s . com sub.saveSubscription(authInfoJoe, items); keys.add(items.value.get(0).getSubscriptionKey()); } List<Subscription> subscriptions = sub.getSubscriptions(authInfoJoe); Assert.assertEquals(subscriptions.size(), keys.size()); }
From source file:org.apache.juddi.api.impl.API_170_CustodyTransferTest.java
@Test public void testTransfer() throws Exception { UDDIInquiryImpl inquire = new UDDIInquiryImpl(); //save sam's business tckBusiness.saveSamSyndicatorBusiness(authInfoSam); //save mary's business tckBusiness.saveMaryPublisherBusiness(authInfoMary); GetOperationalInfo goi = new GetOperationalInfo(); goi.getEntityKey().add(TckBusiness.SAM_BUSINESS_KEY); OperationalInfos operationalInfo = inquire.getOperationalInfo(goi); Assert.assertEquals(operationalInfo.getOperationalInfo().get(0).getAuthorizedName(), TckPublisher.getSamPublisherId()); //sam wants to transfer to mary, get a token UDDICustodyTransferImpl custody = new UDDICustodyTransferImpl(); KeyBag kb = new KeyBag(); kb.getKey().add(TckBusiness.SAM_BUSINESS_KEY); Holder<String> node = new Holder<String>(); Holder<XMLGregorianCalendar> expires = new Holder<XMLGregorianCalendar>(); Holder<byte[]> token = new Holder<byte[]>(); custody.getTransferToken(authInfoSam, kb, node, expires, token); //use mary's account to accept and transfer TransferEntities te = new TransferEntities(); te.setAuthInfo(authInfoMary);/*from w w w .jav a 2s . c om*/ te.setKeyBag(kb); te.setTransferToken(new TransferToken()); te.getTransferToken().setExpirationTime(expires.value); te.getTransferToken().setNodeID(node.value); te.getTransferToken().setOpaqueToken(token.value); custody.transferEntities(te); operationalInfo = inquire.getOperationalInfo(goi); Assert.assertEquals(operationalInfo.getOperationalInfo().get(0).getAuthorizedName(), TckPublisher.getMaryPublisherId()); tckBusiness.deleteBusiness(authInfoMary, TckBusiness.SAM_BUSINESS_XML, TckBusiness.SAM_BUSINESS_KEY); tckBusiness.deleteBusiness(authInfoMary, TckBusiness.MARY_BUSINESS_XML, TckBusiness.MARY_BUSINESS_KEY); }
From source file:org.apache.juddi.api.impl.UDDIv2PublishImpl.java
@Override public PublisherAssertions setPublisherAssertions(SetPublisherAssertions body) throws org.uddi.v2_service.DispositionReport { try {/*from w ww.j ava 2 s.c om*/ Holder<List<PublisherAssertion>> req = new Holder<List<PublisherAssertion>>(); req.value = MapUDDIv2Tov3.MapSetPublisherAssertions(body); publishService.setPublisherAssertions(body.getAuthInfo(), req); return MapUDDIv3Tov2.MapPublisherAssertions(req.value, getNodeID(), getUsername(body.getAuthInfo())); } catch (DispositionReportFaultMessage ex) { throw MapUDDIv3Tov2.MapException(ex, getNodeID()); } }
From source file:org.apache.juddi.samples.UddiCustodyTransfer.java
public void TransferBusiness(String fromUser, String fromUserAuthToken, String toUser, String toUserAuthToken, String BusinessKey) throws Exception { System.out.println("Transfering business key " + BusinessKey); DatatypeFactory df = DatatypeFactory.newInstance(); GregorianCalendar gcal = new GregorianCalendar(); gcal.setTimeInMillis(System.currentTimeMillis()); XMLGregorianCalendar xcal = df.newXMLGregorianCalendar(gcal); //Create a transfer token from fromUser to toUser KeyBag kb = new KeyBag(); kb.getKey().add(BusinessKey);/*from w w w .j a va 2s .c o m*/ Holder<String> nodeidOUT = new Holder<String>(); Holder<XMLGregorianCalendar> expiresOUT = new Holder<XMLGregorianCalendar>(); Holder<byte[]> tokenOUT = new Holder<byte[]>(); custodyTransferPortType.getTransferToken(fromUserAuthToken, kb, nodeidOUT, expiresOUT, tokenOUT); System.out.println("Transfer token obtained. Give this to user " + toUser); System.out.println("Expires " + expiresOUT.value.toXMLFormat()); System.out.println("Node " + nodeidOUT.value); System.out.println("Token " + org.apache.commons.codec.binary.Base64.encodeBase64String(tokenOUT.value)); if (toUser == null || toUser.length() == 0 || toUserAuthToken == null || toUserAuthToken.length() == 0) { System.out .println("The toUser parameters are either null or empty, I can't complete the transfer here"); return; } //The magic part happens here, the user ROOT needs to give the user UDDI the token information out of band //in practice, all values must match exactly //UDDI now accepts the transfer TransferEntities te = new TransferEntities(); te.setAuthInfo(toUserAuthToken); te.setKeyBag(kb); TransferToken tt = new TransferToken(); tt.setExpirationTime(expiresOUT.value); tt.setNodeID(nodeidOUT.value); tt.setOpaqueToken(tokenOUT.value); te.setTransferToken(tt); System.out.println("Excuting transfer..."); custodyTransferPortType.transferEntities(te); System.out.println("Complete! verifing ownership change..."); //confirm the transfer GetOperationalInfo go = new GetOperationalInfo(); go.setAuthInfo(fromUserAuthToken); go.getEntityKey().add(BusinessKey); OperationalInfos operationalInfo = uddiInquiryService.getOperationalInfo(go); boolean ok = false; boolean found = false; for (int i = 0; i < operationalInfo.getOperationalInfo().size(); i++) { if (operationalInfo.getOperationalInfo().get(i).getEntityKey().equalsIgnoreCase(BusinessKey)) { found = true; if (operationalInfo.getOperationalInfo().get(i).getAuthorizedName().equalsIgnoreCase(fromUser)) { System.out.println("Transfer unexpected failed"); } if (operationalInfo.getOperationalInfo().get(i).getAuthorizedName().equalsIgnoreCase(toUser)) { ok = true; } } } if (!found) { System.out.println("Could get the operational info the transfed business"); } System.out.println("Transfer " + (ok ? "success" : " failed")); }
From source file:org.apache.juddi.v3.client.config.UDDIClerk.java
/** * Register a Subscription to UDDI node passed in. Make sure you use a * clerk that has credentials for this node. Note, if registration * fails, no exception is thrown//w w w . j a va 2 s . co m * * @param subscription a UDDI subscription, remember only one filter * type is allowed by UDDI * @param node the UDDI node referenced from the config file * @return the potentially UDDI server modified subscription */ public Subscription register(Subscription subscription, Node node) { log.info("Registering subscription with key " + subscription.getSubscriptionKey()); Holder<List<Subscription>> holder = new Holder<List<Subscription>>(); try { List<Subscription> subscriptions = new ArrayList<Subscription>(); subscriptions.add(subscription); holder.value = subscriptions; getUDDINode().getTransport().getUDDISubscriptionService(node.getSubscriptionUrl()) .saveSubscription(getAuthToken(node.getSecurityUrl()), holder); if (log.isDebugEnabled()) { log.debug("Registering subscription " + subscription.getSubscriptionKey() + " completed."); } } catch (Exception e) { log.error( "Unable to register subscription " + subscription.getSubscriptionKey() + " ." + e.getMessage(), e); } catch (Throwable t) { log.error( "Unable to register subscriptionl " + subscription.getSubscriptionKey() + " ." + t.getMessage(), t); } subscription = holder.value.get(0); return subscription; }
From source file:org.apache.juddi.v3.tck.JUDDI_300_MultiNodeIntegrationTest.java
/** * transfer business from mary/node1 to sam/node2, then delete * * @throws Exception/*ww w .j ava 2 s .co m*/ */ @Test public void testMultiNodeBusinessCustodyTransfer() throws Exception { logger.info("testMultiNodeBusinessCustodyTransfer"); try { Assume.assumeTrue(TckPublisher.isReplicationEnabled() && TckPublisher.isCustodyTransferEnabled()); Assume.assumeTrue(TckPublisher.isJUDDI()); refreshTokens(); testSetupReplicationConfig(); getReplicationStatus(); //create mary's business, node1 BusinessEntity mary = new BusinessEntity(); mary.getName().add(new Name("Mary's biz on " + CFG_node1_MARY, null)); mary.setBusinessServices(new BusinessServices()); BusinessService bs = new BusinessService(); bs.getName().add(new Name("Mary's service", null)); bs.setBindingTemplates(new BindingTemplates()); BindingTemplate bt = new BindingTemplate(); bt.setAccessPoint(new AccessPoint("http://localhost/mary", "wsdlDeployment")); bs.getBindingTemplates().getBindingTemplate().add(bt); mary.getBusinessServices().getBusinessService().add(bs); SaveBusiness sb = new SaveBusiness(); sb.setAuthInfo(maryTokenNode1); sb.getBusinessEntity().add(mary); BusinessDetail saveBusiness = publishMary.saveBusiness(sb); Thread.sleep(5000); //sleep a bit and wait for replication to do it's thing GetOperationalInfo operationalInfo = new GetOperationalInfo(); operationalInfo.setAuthInfo(maryTokenNode1); operationalInfo.getEntityKey().add(saveBusiness.getBusinessEntity().get(0).getBusinessKey()); OperationalInfos beforeNode1 = inquiryMary.getOperationalInfo(operationalInfo); operationalInfo.setAuthInfo(samTokenNode2); OperationalInfos beforeNode2 = null; int timeout = TckPublisher.getSubscriptionTimeout(); while (timeout > 0) { logger.info("Waiting for the update..."); try { GetBusinessDetail gbd = new GetBusinessDetail(); gbd.setAuthInfo(samTokenNode2); gbd.getBusinessKey().add(saveBusiness.getBusinessEntity().get(0).getBusinessKey()); BusinessDetail businessDetail = inquirySamNode2.getBusinessDetail(gbd); if (businessDetail != null && !businessDetail.getBusinessEntity().isEmpty()) { logger.info( "Mary's business exists on Sams node, grabbing the operational info to confirm ownership..."); } beforeNode2 = inquirySamNode2.getOperationalInfo(operationalInfo); break; } catch (Exception ex) { logger.warn(ex.getMessage()); } timeout--; Thread.sleep(1000); } Assert.assertNotNull(beforeNode1); Assert.assertNotNull(beforeNode2); JAXB.marshal(beforeNode1, System.out); JAXB.marshal(beforeNode2, System.out); //confirm we're replicated correctly Assert.assertEquals(beforeNode1.getOperationalInfo().get(0).getAuthorizedName(), beforeNode2.getOperationalInfo().get(0).getAuthorizedName()); Assert.assertEquals(beforeNode1.getOperationalInfo().get(0).getEntityKey(), beforeNode2.getOperationalInfo().get(0).getEntityKey()); Assert.assertEquals(beforeNode1.getOperationalInfo().get(0).getEntityKey(), saveBusiness.getBusinessEntity().get(0).getBusinessKey()); Assert.assertEquals(beforeNode1.getOperationalInfo().get(0).getNodeID(), beforeNode2.getOperationalInfo().get(0).getNodeID()); //get a transfer token, node1 KeyBag kb = new KeyBag(); kb.getKey().add(saveBusiness.getBusinessEntity().get(0).getBusinessKey()); Holder<String> sourceNode = new Holder<String>(); Holder<XMLGregorianCalendar> expiration = new Holder<XMLGregorianCalendar>(); Holder<byte[]> token = new Holder<byte[]>(); custodyMary.getTransferToken(maryTokenNode1, kb, sourceNode, expiration, token); //sam accepts the transfer token, node 2 TransferEntities transferEntities = new TransferEntities(); transferEntities.setAuthInfo(samTokenNode2); transferEntities.setKeyBag(kb); transferEntities.setTransferToken(new TransferToken()); transferEntities.getTransferToken().setExpirationTime(expiration.value); transferEntities.getTransferToken().setNodeID(sourceNode.value); transferEntities.getTransferToken().setOpaqueToken(token.value); custodySam.transferEntities(transferEntities); //stuff happens //Thread.sleep(5000); //confirm the transfer timeout = TckPublisher.getSubscriptionTimeout(); OperationalInfos afterNode1 = null; OperationalInfos afterNode2 = null; while (timeout > 0) { logger.info("Waiting for the update..."); try { operationalInfo.setAuthInfo(maryTokenNode1); //operationalInfo.getEntityKey().add(saveBusiness.getBusinessEntity().get(0).getBusinessKey()); afterNode1 = inquiryMary.getOperationalInfo(operationalInfo); if (afterNode1.getOperationalInfo().get(0).getAuthorizedName() .equals(TckPublisher.getSamPublisherId())) { logger.info("Mary's biz on node 1 is now owned by Sam"); //node 1 is up to date operationalInfo.setAuthInfo(samTokenNode2); afterNode2 = inquirySamNode2.getOperationalInfo(operationalInfo); if (afterNode2.getOperationalInfo().get(0).getAuthorizedName() .equals(TckPublisher.getSamPublisherId())) { //node 2 is up to date logger.info("Mary's biz on node 2 is now owned by Sam"); break; } else { logger.info("Mary's biz on node 2 is still owned by Mary"); } } else { logger.info("Mary's biz on node 1 is still owned by Mary"); } } catch (Exception ex) { logger.warn(ex.getMessage()); } timeout--; Thread.sleep(1000); } //operationalInfo.setAuthInfo(maryTokenNode1); // operationalInfo.getEntityKey().add(saveBusiness.getBusinessEntity().get(0).getBusinessKey()); Assert.assertNotNull(afterNode1); Assert.assertNotNull(afterNode2); if (TckCommon.isDebug()) { JAXB.marshal(afterNode1, System.out); JAXB.marshal(afterNode2, System.out); } //confirm we're replicated correctly Assert.assertEquals(afterNode1.getOperationalInfo().get(0).getAuthorizedName(), afterNode2.getOperationalInfo().get(0).getAuthorizedName()); Assert.assertEquals(afterNode1.getOperationalInfo().get(0).getEntityKey(), afterNode2.getOperationalInfo().get(0).getEntityKey()); Assert.assertEquals(afterNode1.getOperationalInfo().get(0).getEntityKey(), saveBusiness.getBusinessEntity().get(0).getBusinessKey()); Assert.assertEquals(afterNode1.getOperationalInfo().get(0).getNodeID(), afterNode2.getOperationalInfo().get(0).getNodeID()); //confirm that the entity now belongs to sam Assert.assertEquals(afterNode1.getOperationalInfo().get(0).getAuthorizedName(), TckPublisher.getSamPublisherId()); Assert.assertNotEquals(beforeNode1.getOperationalInfo().get(0).getNodeID(), afterNode1.getOperationalInfo().get(0).getNodeID()); } finally { resetTmodels(); resetBusinesses(); } }
From source file:org.apache.juddi.v3.tck.TckSubscription.java
public void saveSubscription(String authInfo, String subscriptionXML, String subscriptionKey, String bindingkey) {//from w w w .j av a 2 s.c o m try { Subscription subIn = (Subscription) EntityCreator.buildFromDoc(subscriptionXML, "org.uddi.sub_v3"); List<Subscription> subscriptionList = new ArrayList<Subscription>(); subIn.setSubscriptionKey(subscriptionKey); // if (subIn.getBindingKey()!=null && subIn.getBindingKey().length()==0){ // subIn.setBindingKey(null); //} subIn.setBindingKey(bindingkey); subscriptionList.add(subIn); Holder<List<Subscription>> subscriptionHolder = new Holder<List<Subscription>>(); subscriptionHolder.value = subscriptionList; subscription.saveSubscription(authInfo, subscriptionHolder); Subscription subDirectOut = subscriptionHolder.value.get(0); assertEquals(subIn.getSubscriptionKey(), subDirectOut.getSubscriptionKey()); List<Subscription> outSubscriptionList = subscription.getSubscriptions(authInfo); Assert.assertNotNull(outSubscriptionList); Subscription subOut = outSubscriptionList.get(0); assertEquals(subIn.getSubscriptionKey(), subOut.getSubscriptionKey()); assertEquals(subDirectOut.getExpiresAfter().getMonth(), subOut.getExpiresAfter().getMonth()); assertEquals(subDirectOut.getExpiresAfter().getDay(), subOut.getExpiresAfter().getDay()); 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"); } }