You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by al...@apache.org on 2014/01/06 03:18:39 UTC
svn commit: r1555648 [13/13] - in /juddi/trunk: ./ docs/examples/auth/
juddi-client/src/main/java/org/apache/juddi/v3/client/config/
juddi-core-openjpa/ juddi-core/src/main/java/org/apache/juddi/api/impl/
juddi-core/src/main/java/org/apache/juddi/subsc...
Modified: juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_150_CustodyTransferIntegrationTest.java
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_150_CustodyTransferIntegrationTest.java?rev=1555648&r1=1555647&r2=1555648&view=diff
==============================================================================
--- juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_150_CustodyTransferIntegrationTest.java (original)
+++ juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_150_CustodyTransferIntegrationTest.java Mon Jan 6 02:18:37 2014
@@ -20,6 +20,7 @@ import javax.xml.datatype.DatatypeFactor
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.soap.SOAPFault;
+import javax.xml.ws.BindingProvider;
import javax.xml.ws.Holder;
import org.apache.commons.configuration.ConfigurationException;
@@ -27,9 +28,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.juddi.v3.client.config.UDDIClient;
import org.apache.juddi.v3.client.transport.Transport;
-import org.apache.juddi.v3.tck.TckPublisher;
-import org.apache.juddi.v3.tck.TckSecurity;
-import org.apache.juddi.v3.tck.TckTModel;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
@@ -63,343 +61,381 @@ import org.uddi.v3_service.UDDISecurityP
*/
public class UDDI_150_CustodyTransferIntegrationTest {
- private static Log logger = LogFactory.getLog(UDDI_150_CustodyTransferIntegrationTest.class);
- static UDDISecurityPortType security = null;
- static UDDIInquiryPortType inquiry = null;
- static UDDIPublicationPortType publish = null;
- static UDDICustodyTransferPortType custodyTransferPortType = null;
- static TckTModel tckTModel = null;
- protected static String authInfoJoe = null;
- protected static String authInfoSam = null;
- private static UDDIClient manager;
- static final String str256 = "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111";
- static final String str255 = "uddi:tmodelkey:categories:1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111";
- static final String strkey256 = "uddi:tmodelkey:categories:11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111";
- static final String strkey256_1 = "uddi:org.apache:omething.something.something.something.something.something.something.something.something.something.something.something.something.something.something.something.something.something.something.something.something.something.something.somethi.com";
- static final String str26 = "11111111111111111111111111";
- static final String str27 = "111111111111111111111111110";
- static final String str10 = "0123456789";
- static final String str11 = "01234567890";
- static final String str80 = "01234567890123456789012345678901234567890123456789012345678901234567890123456789";
- static final String str81 = "012345678901234567890123456789012345678901234567890123456789012345678901234567891";
- static final String TRANS = "The transaction has been rolled back";
- static final String str4096 = "12345670000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001234567000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000001234567000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000123456700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000123456700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012345670000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012345670000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001234567000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000XXXXXXXX";
- static final String str4097 = "12345670000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001234567000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000001234567000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000123456700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000123456700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012345670000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012345670000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001234567000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000XXXXXXXXZ";
- static final String str51 = "111111111111111111111111111111111111111111111111111";
- static final String str50 = "11111111111111111111111111111111111111111111111111";
- static final String MISSING_RESOURCE = "Can't find resource for bundle";
-
- @AfterClass
- public static void stopManager() throws ConfigurationException {
- manager.stop();
- }
-
- @BeforeClass
- public static void startManager() throws ConfigurationException {
- manager = new UDDIClient();
- manager.start();
-
- logger.debug("Getting auth tokens..");
- try {
- Transport transport = manager.getTransport();
- security = transport.getUDDISecurityService();
- authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
- authInfoSam = TckSecurity.getAuthToken(security, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
- Assert.assertNotNull(authInfoJoe);
- Assert.assertNotNull(authInfoSam);
-
- publish = transport.getUDDIPublishService();
- inquiry = transport.getUDDIInquiryService();
- custodyTransferPortType = transport.getUDDICustodyTransferService();
- tckTModel = new TckTModel(publish, inquiry);
-
-
- String authInfoUDDI = TckSecurity.getAuthToken(security, TckPublisher.getUDDIPublisherId(), TckPublisher.getUDDIPassword());
- tckTModel.saveUDDIPublisherTmodel(authInfoUDDI);
- tckTModel.saveTModels(authInfoUDDI, TckTModel.TMODELS_XML);
- tckTModel.saveJoePublisherTmodel(authInfoJoe);
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- Assert.fail("Could not obtain authInfo token.");
- }
- }
-
- static void HandleException(Exception ex) {
- System.err.println("Error caught of type " + ex.getClass().getCanonicalName());
- ex.printStackTrace();
- if (ex.getMessage() != null) {
- Assert.assertFalse(ex.getMessage().contains(TRANS));
- Assert.assertFalse(ex.getMessage().contains(MISSING_RESOURCE));
- }
- if (ex instanceof SOAPFault) {
- SOAPFault sf = (SOAPFault) ex;
- if (!sf.getTextContent().contains("org.apache.juddi.v3.error.ValueNotAllowedException")) {
- Assert.fail();
- }
- }
- }
-
- /**
- * tests a user to user transfer on the same node
- *
- * @throws Exception
- */
- @Test
- public void ValidTransfer() throws Exception {
- 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("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 = publish.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("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 = publish.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[]>();
- custodyTransferPortType.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);
-
- custodyTransferPortType.transferEntities(te);
-
- //confirm the transfer
- GetOperationalInfo go = new GetOperationalInfo();
- go.setAuthInfo(authInfoSam);
- go.getEntityKey().add(keySamBiz);
- go.getEntityKey().add(keyJoeBiz);
- OperationalInfos operationalInfo = inquiry.getOperationalInfo(go);
- boolean ok = false;
- 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");
-
-
- }
-
- private BusinessService CreateBusiness(String root) {
- BusinessService bs = new BusinessService();
- bs.getName().add(new Name());
- bs.getName().get(0).setValue(root + "'s callback endpoint");
- bs.setBindingTemplates(new BindingTemplates());
- BindingTemplate bt = new BindingTemplate();
- bt.setAccessPoint(new AccessPoint());
- bt.getAccessPoint().setValue("http://localhost:9999/" + root);
- bt.getAccessPoint().setUseType("endPoint");
- bs.getBindingTemplates().getBindingTemplate().add(bt);
- return bs;
- }
-
- @Test
- public void InvalidTransferTokenNullKeybag() {
- try {
- //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[]>();
- custodyTransferPortType.getTransferToken(authInfoJoe, kb, nodeidOUT, expiresOUT, tokenOUT);
- Assert.fail();
- } catch (Exception ex) {
- // HandleException(ex);
- }
-
- }
-
- @Test
- public void InvalidTransferTokenEmptyKeybag() {
- try {
- //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[]>();
- custodyTransferPortType.getTransferToken(authInfoJoe, kb, nodeidOUT, expiresOUT, tokenOUT);
-
- Assert.fail();
- } catch (Exception ex) {
- // HandleException(ex);
- }
-
- }
-
- @Test
- public void InvalidTransferTokenEmptyNullAuthToken() {
- 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("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 = publish.saveBusiness(sb);
-
- String 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[]>();
- custodyTransferPortType.getTransferToken(null, kb, nodeidOUT, expiresOUT, tokenOUT);
-
- Assert.fail();
- } catch (Exception ex) {
- // HandleException(ex);
- }
-
- }
-
- @Test
- public void InvalidTransferTokenModified() {
- 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("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 = publish.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("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 = publish.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[]>();
- custodyTransferPortType.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);
-
- custodyTransferPortType.transferEntities(te);
- Assert.fail();
- } catch (Exception ex) {
- // HandleException(ex);
- }
-
- }
-
- @Test
- public void InvalidTransferTokenServiceDoesntExist() throws Exception {
- try {
- //transfers from Joe to Sam
- KeyBag kb = new KeyBag();
- kb.getKey().add("uddi:uddi.joepublisher.com:" + UUID.randomUUID().toString());
-
- Holder<String> nodeidOUT = new Holder<String>();
- Holder<XMLGregorianCalendar> expiresOUT = new Holder<XMLGregorianCalendar>();
- Holder<byte[]> tokenOUT = new Holder<byte[]>();
- custodyTransferPortType.getTransferToken(authInfoJoe, kb, nodeidOUT, expiresOUT, tokenOUT);
- Assert.fail();
- } catch (Exception ex) {
- //HandleException(ex);
- }
- }
-
- @Test
- public void ExpiredTransferToken() {
- //TODO
- }
+ private static Log logger = LogFactory.getLog(UDDI_150_CustodyTransferIntegrationTest.class);
+ static UDDISecurityPortType security = null;
+ static UDDIInquiryPortType inquiryJoe = null;
+ static UDDIPublicationPortType publishJoe = null;
+ static UDDICustodyTransferPortType custodyTransferPortTypeJoe = null;
+ static TckTModel tckTModelJoe = null;
+ static UDDIInquiryPortType inquirySam = null;
+ static UDDIPublicationPortType publishSam = null;
+ static UDDICustodyTransferPortType custodyTransferPortTypeSam = null;
+ protected static String authInfoJoe = null;
+ protected static String authInfoSam = null;
+ private static UDDIClient manager;
+ static final String TRANS = "The transaction has been rolled back";
+ static final String MISSING_RESOURCE = "Can't find resource for bundle";
+
+ @AfterClass
+ public static void stopManager() throws ConfigurationException {
+ tckTModelJoe.deleteCreatedTModels(authInfoJoe);
+ manager.stop();
+ }
+
+ @BeforeClass
+ public static void startManager() throws ConfigurationException {
+ manager = new UDDIClient();
+ manager.start();
+
+ logger.debug("Getting auth tokens..");
+ try {
+ Transport transport = manager.getTransport();
+ security = transport.getUDDISecurityService();
+ authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
+ authInfoSam = TckSecurity.getAuthToken(security, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
+ //Assert.assertNotNull(authInfoJoe);
+ //Assert.assertNotNull(authInfoSam);
+
+
+ publishJoe = transport.getUDDIPublishService();
+ inquiryJoe = transport.getUDDIInquiryService();
+ custodyTransferPortTypeJoe = transport.getUDDICustodyTransferService();
+
+ if (!TckPublisher.isUDDIAuthMode()) {
+ TckSecurity.setCredentials((BindingProvider) publishJoe, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
+ TckSecurity.setCredentials((BindingProvider) inquiryJoe, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
+ TckSecurity.setCredentials((BindingProvider) custodyTransferPortTypeJoe, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
+ }
+
+ tckTModelJoe = new TckTModel(publishJoe, inquiryJoe);
+
+ transport = manager.getTransport();
+ publishSam = transport.getUDDIPublishService();
+ inquirySam = transport.getUDDIInquiryService();
+ custodyTransferPortTypeSam = transport.getUDDICustodyTransferService();
+ if (!TckPublisher.isUDDIAuthMode()) {
+ TckSecurity.setCredentials((BindingProvider) publishJoe, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
+ TckSecurity.setCredentials((BindingProvider) inquiryJoe, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
+ TckSecurity.setCredentials((BindingProvider) custodyTransferPortTypeJoe, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
+ }
+
+ transport = manager.getTransport();
+ UDDIPublicationPortType uddiPublishService = transport.getUDDIPublishService();
+ UDDIInquiryPortType uddiInquiryService = transport.getUDDIInquiryService();
+ if (!TckPublisher.isUDDIAuthMode()) {
+ TckSecurity.setCredentials((BindingProvider) publishJoe, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
+ TckSecurity.setCredentials((BindingProvider) inquiryJoe, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
+ TckSecurity.setCredentials((BindingProvider) custodyTransferPortTypeJoe, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
+ }
+
+ TckTModel tckTModelUDDI = new TckTModel(uddiPublishService, uddiInquiryService);
+ String authInfoUDDI = TckSecurity.getAuthToken(security, TckPublisher.getUDDIPublisherId(), TckPublisher.getUDDIPassword());
+ tckTModelUDDI.saveUDDIPublisherTmodel(authInfoUDDI);
+ tckTModelUDDI.saveTModels(authInfoUDDI, TckTModel.TMODELS_XML);
+
+ tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ Assert.fail("Could not obtain authInfo token.");
+ }
+ }
+
+ static void HandleException(Exception ex) {
+ System.err.println("Error caught of type " + ex.getClass().getCanonicalName());
+ ex.printStackTrace();
+ if (ex.getMessage() != null) {
+ Assert.assertFalse(ex.getMessage().contains(TRANS));
+ Assert.assertFalse(ex.getMessage().contains(MISSING_RESOURCE));
+ }
+ if (ex instanceof SOAPFault) {
+ SOAPFault sf = (SOAPFault) ex;
+ if (!sf.getTextContent().contains("org.apache.juddi.v3.error.ValueNotAllowedException")) {
+ Assert.fail();
+ }
+ }
+ }
+
+ /**
+ * tests a user to user transfer on the same node
+ *
+ * @throws Exception
+ */
+ @Test
+ public void ValidTransfer() throws Exception {
+ 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);
+
+
+ }
+
+ private BusinessService CreateBusiness(String root) {
+ BusinessService bs = new BusinessService();
+ bs.getName().add(new Name());
+ bs.getName().get(0).setValue(root + "'s callback endpoint");
+ bs.setBindingTemplates(new BindingTemplates());
+ BindingTemplate bt = new BindingTemplate();
+ bt.setAccessPoint(new AccessPoint());
+ bt.getAccessPoint().setValue("http://localhost:9999/" + root);
+ bt.getAccessPoint().setUseType("endPoint");
+ bs.getBindingTemplates().getBindingTemplate().add(bt);
+ return bs;
+ }
+
+ @Test
+ public void InvalidTransferTokenNullKeybag() {
+ try {
+ //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());
+ }
+
+ }
+
+ @Test
+ public void InvalidTransferTokenEmptyKeybag() {
+ try {
+ //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());
+ }
+
+ }
+
+ @Test
+ public void InvalidTransferTokenEmptyNullAuthToken() {
+ 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("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);
+
+ }
+
+ }
+
+ /**
+ * a valid transfer token issued, then modified out of band, this should
+ * fail
+ */
+ @Test
+ public void InvalidTransferTokenModified() {
+ 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);
+ }
+
+ }
+
+ @Test
+ public void InvalidTransferTokenServiceDoesntExist() throws Exception {
+ try {
+ //transfers from Joe to Sam
+ KeyBag kb = new KeyBag();
+ kb.getKey().add("uddi:uddi.joepublisher.com:" + UUID.randomUUID().toString());
+
+ 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) {
+ //HandleException(ex);
+ logger.info("Expected exception: " + ex.getMessage());
+ }
+ }
+
+ @Test
+ public void ExpiredTransferToken() {
+ //TODO
+ }
}
Added: juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_160_RESTIntergrationTest.java
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_160_RESTIntergrationTest.java?rev=1555648&view=auto
==============================================================================
--- juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_160_RESTIntergrationTest.java (added)
+++ juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_160_RESTIntergrationTest.java Mon Jan 6 02:18:37 2014
@@ -0,0 +1,256 @@
+/*
+ * Copyright 2013 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.juddi.v3.tck;
+
+import java.rmi.RemoteException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.xml.bind.JAXB;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.juddi.v3.client.UDDIConstants;
+import org.apache.juddi.v3.client.config.UDDIClient;
+import org.apache.juddi.v3.client.transport.Transport;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.uddi.api_v3.BindingTemplate;
+import org.uddi.api_v3.BusinessEntity;
+import org.uddi.api_v3.BusinessList;
+import org.uddi.api_v3.BusinessService;
+import org.uddi.api_v3.FindBusiness;
+import org.uddi.api_v3.FindQualifiers;
+import org.uddi.api_v3.FindService;
+import org.uddi.api_v3.FindTModel;
+import org.uddi.api_v3.GetServiceDetail;
+import org.uddi.api_v3.Name;
+import org.uddi.api_v3.ServiceDetail;
+import org.uddi.api_v3.ServiceList;
+import org.uddi.api_v3.TModel;
+import org.uddi.api_v3.TModelList;
+import org.uddi.v3_service.DispositionReportFaultMessage;
+import org.uddi.v3_service.UDDIInquiryPortType;
+
+/**
+ * Optional HTTP GET, REST style web services for UDDI
+ *
+ * @author Alex O'Ree
+ */
+public class UDDI_160_RESTIntergrationTest {
+
+ private static UDDIInquiryPortType inquiry = null;
+ private static Log logger = LogFactory.getLog(UDDI_160_RESTIntergrationTest.class);
+ private static String authInfo = null;
+ private static UDDIClient manager;
+
+ @BeforeClass
+ public static void startRegistry() throws ConfigurationException {
+
+ manager = new UDDIClient();
+ manager.start();
+
+ try {
+ Transport transport = manager.getTransport();
+ inquiry = transport.getUDDIInquiryService();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ Assert.fail("Could not obtain authInfo token.");
+ }
+ }
+
+ @AfterClass
+ public static void stopRegistry() throws ConfigurationException {
+ manager.stop();
+ }
+
+ /*@Test
+ public void InquiryREST_WADL_GET() throws Exception {
+ Assume.assumeTrue(TckPublisher.isInquiryRestEnabled());
+
+ String url = manager.getClientConfig().getHomeNode().getInquiry_REST_Url();
+ Assume.assumeNotNull(url);
+ HttpClient client = new DefaultHttpClient();
+ HttpGet httpGet = new HttpGet(url + "?_wadl");
+ HttpResponse response = client.execute(httpGet);
+ Assert.assertTrue(response.getStatusLine().getStatusCode() == 200);
+
+ }*/
+ @Test
+ public void InquiryREST_GET_Business() throws Exception {
+ Assume.assumeTrue(TckPublisher.isInquiryRestEnabled());
+ FindBusiness fb = new FindBusiness();
+ fb.setMaxRows(1);
+ fb.getName().add(new Name(UDDIConstants.WILDCARD, null));
+ fb.setFindQualifiers(new FindQualifiers());
+ fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
+ BusinessList findBusiness = inquiry.findBusiness(fb);
+ Assume.assumeTrue(findBusiness != null);
+ Assume.assumeTrue(findBusiness.getBusinessInfos() != null);
+ Assume.assumeTrue(!findBusiness.getBusinessInfos().getBusinessInfo().isEmpty());
+
+ String url = manager.getClientConfig().getHomeNode().getInquiry_REST_Url();
+
+ Assume.assumeNotNull(url);
+ HttpClient client = new DefaultHttpClient();
+ HttpGet httpGet = new HttpGet(url + "?businessKey=" + findBusiness.getBusinessInfos().getBusinessInfo().get(0).getBusinessKey());
+ logger.info("Fetching " + httpGet.getURI());
+ HttpResponse response = client.execute(httpGet);
+ Assert.assertTrue(response.getStatusLine().getStatusCode() == 200);
+ logger.info("Response content: " + response.getEntity().getContent());
+ BusinessEntity unmarshal = JAXB.unmarshal(response.getEntity().getContent(), BusinessEntity.class);
+ Assert.assertNotNull(unmarshal);
+ Assert.assertEquals(unmarshal.getBusinessKey(), findBusiness.getBusinessInfos().getBusinessInfo().get(0).getBusinessKey());
+
+
+ }
+
+ @Test
+ public void InquiryREST_GET_TModel() throws Exception {
+ Assume.assumeTrue(TckPublisher.isInquiryRestEnabled());
+ FindTModel fb = new FindTModel();
+ fb.setMaxRows(1);
+ fb.setName(new Name(UDDIConstants.WILDCARD, null));
+ fb.setFindQualifiers(new FindQualifiers());
+ fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
+ TModelList findTModel = inquiry.findTModel(fb);
+ Assume.assumeTrue(findTModel != null);
+ Assume.assumeTrue(findTModel.getTModelInfos() != null);
+ Assume.assumeTrue(!findTModel.getTModelInfos().getTModelInfo().isEmpty());
+
+ String url = manager.getClientConfig().getHomeNode().getInquiry_REST_Url();
+
+ Assume.assumeNotNull(url);
+
+ HttpClient client = new DefaultHttpClient();
+
+ HttpGet httpGet = new HttpGet(url + "?tModelKey=" + findTModel.getTModelInfos().getTModelInfo().get(0).getTModelKey());
+ logger.info("Fetching " + httpGet.getURI());
+ HttpResponse response = client.execute(httpGet);
+ Assert.assertTrue(response.getStatusLine().getStatusCode() == 200);
+ logger.info("Response content: " + response.getEntity().getContent());
+ TModel unmarshal = JAXB.unmarshal(response.getEntity().getContent(), TModel.class);
+ Assert.assertNotNull(unmarshal);
+ Assert.assertEquals(unmarshal.getTModelKey(), findTModel.getTModelInfos().getTModelInfo().get(0).getTModelKey());
+
+
+ }
+
+ @Test
+ public void InquiryREST_GET_Service() throws Exception {
+ Assume.assumeTrue(TckPublisher.isInquiryRestEnabled());
+ //find the first service via inquriy soap
+ FindService fb = new FindService();
+ fb.setMaxRows(1);
+ fb.getName().add(new Name(UDDIConstants.WILDCARD, null));
+ fb.setFindQualifiers(new FindQualifiers());
+ fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
+ ServiceList findService = inquiry.findService(fb);
+ Assume.assumeTrue(findService != null);
+ Assume.assumeTrue(findService.getServiceInfos() != null);
+ Assume.assumeTrue(!findService.getServiceInfos().getServiceInfo().isEmpty());
+
+ String url = manager.getClientConfig().getHomeNode().getInquiry_REST_Url();
+
+ Assume.assumeNotNull(url);
+
+ //get the results via inquiry rest
+ HttpClient client = new DefaultHttpClient();
+ HttpGet httpGet = new HttpGet(url + "?serviceKey=" + findService.getServiceInfos().getServiceInfo().get(0).getServiceKey());
+ logger.info("Fetching " + httpGet.getURI());
+ HttpResponse response = client.execute(httpGet);
+ Assert.assertTrue(response.getStatusLine().getStatusCode() == 200);
+ logger.info("Response content: " + response.getEntity().getContent());
+ BusinessService unmarshal = JAXB.unmarshal(response.getEntity().getContent(), BusinessService.class);
+ Assert.assertNotNull(unmarshal);
+ Assert.assertEquals(unmarshal.getServiceKey(), findService.getServiceInfos().getServiceInfo().get(0).getServiceKey());
+
+
+ }
+
+ private BindingTemplate getFirstBindingTemplate() {
+ try {
+ int fetch = 10;
+ int offset = 0;
+ FindService fb = new FindService();
+ fb.setMaxRows(fetch);
+ fb.setListHead(offset);
+ fb.getName().add(new Name(UDDIConstants.WILDCARD, null));
+ fb.setFindQualifiers(new FindQualifiers());
+ fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
+ ServiceList findService = inquiry.findService(fb);
+ int returnedcount = findService.getServiceInfos().getServiceInfo().size();
+ do {
+ for (int i = 0; i < findService.getServiceInfos().getServiceInfo().size(); i++) {
+ GetServiceDetail gsd = new GetServiceDetail();
+ gsd.getServiceKey().add(findService.getServiceInfos().getServiceInfo().get(i).getServiceKey());
+ ServiceDetail serviceDetail = inquiry.getServiceDetail(gsd);
+ if (serviceDetail.getBusinessService().get(0).getBindingTemplates() != null
+ && !serviceDetail.getBusinessService().get(0).getBindingTemplates().getBindingTemplate().isEmpty()) {
+ return serviceDetail.getBusinessService().get(0).getBindingTemplates().getBindingTemplate().get(0);
+ }
+
+ }
+ offset = fetch;
+ fetch = fetch + 10;
+ fb = new FindService();
+ fb.setMaxRows(fetch);
+ fb.setListHead(offset);
+ fb.getName().add(new Name(UDDIConstants.WILDCARD, null));
+ fb.setFindQualifiers(new FindQualifiers());
+ fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
+ findService = inquiry.findService(fb);
+ returnedcount = findService.getServiceInfos().getServiceInfo().size();
+
+ } while (returnedcount > 0);
+ } catch (DispositionReportFaultMessage ex) {
+ Logger.getLogger(UDDI_160_RESTIntergrationTest.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (RemoteException ex) {
+ Logger.getLogger(UDDI_160_RESTIntergrationTest.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ return null;
+ }
+
+ @Test
+ public void InquiryREST_GET_Binding() throws Exception {
+ Assume.assumeTrue(TckPublisher.isInquiryRestEnabled());
+
+ BindingTemplate bt = getFirstBindingTemplate();
+ Assume.assumeTrue(bt != null);
+
+ String url = manager.getClientConfig().getHomeNode().getInquiry_REST_Url();
+
+ Assume.assumeNotNull(url);
+ HttpClient client = new DefaultHttpClient();
+ HttpGet httpGet = new HttpGet(url + "?bindingKey=" + bt.getBindingKey());
+ logger.info("Fetching " + httpGet.getURI());
+ HttpResponse response = client.execute(httpGet);
+ Assert.assertTrue(response.getStatusLine().getStatusCode() == 200);
+ logger.info("Response content: " + response.getEntity().getContent());
+ BindingTemplate unmarshal = JAXB.unmarshal(response.getEntity().getContent(), BindingTemplate.class);
+ Assert.assertNotNull(unmarshal);
+ Assert.assertEquals(unmarshal.getServiceKey(), bt.getServiceKey());
+ Assert.assertEquals(unmarshal.getBindingKey(), bt.getBindingKey());
+
+
+ }
+}
Added: juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_170_ValueSetValidation.java
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_170_ValueSetValidation.java?rev=1555648&view=auto
==============================================================================
--- juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_170_ValueSetValidation.java (added)
+++ juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_170_ValueSetValidation.java Mon Jan 6 02:18:37 2014
@@ -0,0 +1,310 @@
+/*
+ * Copyright 2013 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.juddi.v3.tck;
+
+import java.net.InetAddress;
+import java.rmi.RemoteException;
+import java.util.Random;
+import java.util.UUID;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Endpoint;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.juddi.v3.client.UDDIConstants;
+import org.apache.juddi.v3.client.config.UDDIClient;
+import org.apache.juddi.v3.client.transport.Transport;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.uddi.api_v3.AccessPoint;
+import org.uddi.api_v3.BindingTemplate;
+import org.uddi.api_v3.BindingTemplates;
+import org.uddi.api_v3.BusinessDetail;
+import org.uddi.api_v3.BusinessEntity;
+import org.uddi.api_v3.BusinessService;
+import org.uddi.api_v3.BusinessServices;
+import org.uddi.api_v3.CategoryBag;
+import org.uddi.api_v3.DeleteBusiness;
+import org.uddi.api_v3.DeleteTModel;
+import org.uddi.api_v3.Description;
+import org.uddi.api_v3.DispositionReport;
+import org.uddi.api_v3.ErrInfo;
+import org.uddi.api_v3.KeyType;
+import org.uddi.api_v3.KeyedReference;
+import org.uddi.api_v3.Name;
+import org.uddi.api_v3.Result;
+import org.uddi.api_v3.SaveBusiness;
+import org.uddi.api_v3.SaveTModel;
+import org.uddi.api_v3.TModel;
+import org.uddi.v3_service.DispositionReportFaultMessage;
+import org.uddi.v3_service.UDDIInquiryPortType;
+import org.uddi.v3_service.UDDIPublicationPortType;
+import org.uddi.v3_service.UDDISecurityPortType;
+import org.uddi.v3_service.UDDIValueSetValidationPortType;
+import org.uddi.vs_v3.ValidateValues;
+
+/**
+ *
+ * @author Alex O'Ree
+ */
+@WebService(name = "UDDI_ValueSetValidation_PortType", targetNamespace = "urn:uddi-org:v3_service")
+public class UDDI_170_ValueSetValidation implements UDDIValueSetValidationPortType {
+
+ private static UDDIInquiryPortType inquiry = null;
+ private static UDDIPublicationPortType publication = null;
+ static UDDISecurityPortType security = null;
+ //static UDDIV vsvc = null;
+ private static Log logger = LogFactory.getLog(UDDI_170_ValueSetValidation.class);
+ private static String authInfoJoe = null;
+ private static UDDIClient manager;
+ private static boolean VALID = true;
+
+ @BeforeClass
+ public static void startRegistry() throws ConfigurationException {
+
+ manager = new UDDIClient();
+ manager.start();
+
+ try {
+ Transport transport = manager.getTransport();
+ inquiry = transport.getUDDIInquiryService();
+ publication = transport.getUDDIPublishService();
+ security = transport.getUDDISecurityService();
+ authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
+ if (!TckPublisher.isUDDIAuthMode()) {
+ TckSecurity.setCredentials((BindingProvider) inquiry, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
+ TckSecurity.setCredentials((BindingProvider) publication, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
+ }
+
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ Assert.fail("Could not obtain authInfo token.");
+ }
+ }
+
+ @AfterClass
+ public static void stopRegistry() throws ConfigurationException {
+ manager.stop();
+ }
+ final static String VSV_KEY = "uddi:juddi.apache.org:businesses-asf";
+ //final static String VSV_BT_KEY = "uddi:juddi.apache.org:servicebindings-valueset-cp";
+ final static String TMODEL = "validated.checked.tmodel";
+
+ /**
+ * this will confirm that the uddi registry will call out to me during a
+ * vsv validation
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testVSV() throws Exception {
+ Assume.assumeTrue(TckPublisher.isValueSetAPIEnabled());
+ System.out.println("testVSV");
+ BusinessEntity SaveBusiness = null;
+ BusinessEntity SaveVSVCallbackService = null;
+ try {
+ Reset();
+ VALID = true;
+ SaveVSVCallbackService = SaveVSVCallbackService();
+ SaveCheckedTModel(TckTModel.JOE_PUBLISHER_KEY_PREFIX + TMODEL, SaveVSVCallbackService.getBusinessServices().getBusinessService().get(0).getBindingTemplates().getBindingTemplate().get(0).getBindingKey());
+ logger.info("Saving a business using those values");
+ SaveBusiness = SaveBusiness(authInfoJoe, true, TckTModel.JOE_PUBLISHER_KEY_PREFIX + TMODEL);
+
+
+ } catch (Exception ex) {
+ logger.error(ex);
+ Assert.fail("unexpected failure " + ex.getMessage());
+ } finally {
+ if (SaveBusiness != null) {
+ DeleteBusiness(authInfoJoe, SaveBusiness.getBusinessKey());
+ }
+ if (SaveVSVCallbackService != null) {
+ DeleteBusiness(authInfoJoe, SaveVSVCallbackService.getBusinessKey());
+ }
+ DeleteCheckedTModel(TckTModel.JOE_PUBLISHER_KEY_PREFIX + TMODEL);
+ }
+ Assert.assertTrue(messagesReceived == 1);
+ }
+
+ @Test
+ public void testVSVInvalid() throws Exception {
+ Assume.assumeTrue(TckPublisher.isValueSetAPIEnabled());
+ System.out.println("testVSVInvalid");
+ BusinessEntity SaveBusiness = null;
+ BusinessEntity SaveVSVCallbackService = null;
+ try {
+ Reset();
+ VALID = false;
+ SaveVSVCallbackService = SaveVSVCallbackService();
+ SaveCheckedTModel(TckTModel.JOE_PUBLISHER_KEY_PREFIX + TMODEL, SaveVSVCallbackService.getBusinessServices().getBusinessService().get(0).getBindingTemplates().getBindingTemplate().get(0).getBindingKey());
+ logger.info("Saving a business using those values");
+ SaveBusiness = SaveBusiness(authInfoJoe, false, TckTModel.JOE_PUBLISHER_KEY_PREFIX + TMODEL);
+ Assert.assertTrue(messagesReceived == 1);
+ Assert.fail("unexpected success");
+ } catch (Exception ex) {
+ logger.info("Expected failure " + ex.getMessage());
+ } finally {
+ if (SaveBusiness != null) {
+ DeleteBusiness(authInfoJoe, SaveBusiness.getBusinessKey());
+ }
+ if (SaveVSVCallbackService != null) {
+ DeleteBusiness(authInfoJoe, SaveVSVCallbackService.getBusinessKey());
+ }
+ DeleteCheckedTModel(TckTModel.JOE_PUBLISHER_KEY_PREFIX + TMODEL);
+ }
+ }
+
+ private BusinessEntity SaveBusiness(String authInfoJoe, boolean isValid, String key) throws Exception {
+ SaveBusiness sb = new SaveBusiness();
+ sb.setAuthInfo(authInfoJoe);
+ BusinessEntity be = new BusinessEntity();
+ be.getName().add(new Name("VSV", null));
+ be.setCategoryBag(new CategoryBag());
+ if (isValid) {
+ be.getCategoryBag().getKeyedReference().add(new KeyedReference(key, "name", "abcdefg"));
+ } else {
+ be.getCategoryBag().getKeyedReference().add(new KeyedReference(key, "name", "qwerty"));
+ }
+ sb.getBusinessEntity().add(be);
+ BusinessDetail saveBusiness = publication.saveBusiness(sb);
+ return saveBusiness.getBusinessEntity().get(0);
+ }
+
+ private void SaveCheckedTModel(String key, String binding) throws Exception {
+ TModel tm = new TModel();
+ tm.setTModelKey(key);
+ tm.setCategoryBag(new CategoryBag());
+ tm.setName(new Name("My Custom validated key", "en"));
+ tm.getDescription().add(new Description("valid values include 'one', 'two', 'three'", "en"));
+ tm.getCategoryBag().getKeyedReference().add(
+ new KeyedReference(UDDIConstants.IS_VALIDATED_BY, UDDIConstants.IS_VALIDATED_BY_KEY_NAME, binding));
+ SaveTModel stm = new SaveTModel();
+ stm.setAuthInfo(authInfoJoe);
+ stm.getTModel().add(tm);
+ publication.saveTModel(stm);
+ }
+
+ @Override
+ @WebMethod(operationName = "validate_values", action = "validate_values")
+ @WebResult(name = "dispositionReport", targetNamespace = "urn:uddi-org:api_v3", partName = "body")
+ @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
+ public DispositionReport validateValues(
+ @WebParam(name = "validate_values", targetNamespace = "urn:uddi-org:vs_v3", partName = "body") ValidateValues body)
+ throws DispositionReportFaultMessage, RemoteException {
+ messagesReceived++;
+ if (VALID) {
+ DispositionReport dispositionReport = new DispositionReport();
+ dispositionReport.getResult().add(new Result());
+ return dispositionReport;
+ }
+ DispositionReport dispositionReport = new DispositionReport();
+ Result r = new Result();
+ r.setKeyType(KeyType.T_MODEL_KEY);
+ r.setErrno(20200);
+ r.setErrInfo(new ErrInfo());
+ r.getErrInfo().setErrCode("E_invalidValue");
+ r.getErrInfo().setValue("E_invalidValue");
+
+ dispositionReport.getResult().add(r);
+ throw new DispositionReportFaultMessage("error", dispositionReport);
+ }
+
+ private BusinessEntity SaveVSVCallbackService() throws Exception {
+ SaveBusiness sb = new SaveBusiness();
+ sb.setAuthInfo(authInfoJoe);
+ BusinessEntity be = new BusinessEntity();
+ be.getName().add(new Name("VSV business", null));
+ be.setBusinessServices(new BusinessServices());
+ BusinessService bs = new BusinessService();
+ bs.getName().add(new Name("VSV callout", null));
+ bs.setBindingTemplates(new BindingTemplates());
+ BindingTemplate bt = new BindingTemplate();
+ bt.setAccessPoint(new AccessPoint(url, "endPoint"));
+ bs.getBindingTemplates().getBindingTemplate().add(bt);
+ be.getBusinessServices().getBusinessService().add(bs);
+ sb.getBusinessEntity().add(be);
+
+ return publication.saveBusiness(sb).getBusinessEntity().get(0);
+ }
+
+ private void DeleteCheckedTModel(String string) throws Exception {
+ DeleteTModel db = new DeleteTModel();
+ db.setAuthInfo(authInfoJoe);
+ db.getTModelKey().add(string);
+ publication.deleteTModel(db);
+ }
+
+ private void DeleteBusiness(String authInfoJoe, String string) throws Exception {
+ DeleteBusiness db = new DeleteBusiness();
+ db.setAuthInfo(authInfoJoe);
+ db.getBusinessKey().add(string);
+ publication.deleteBusiness(db);
+ }
+ Endpoint ep = null;
+ String url = null;
+ int messagesReceived = 0;
+
+ private void Reset() throws Exception {
+ messagesReceived = 0;
+ if (ep == null || !ep.isPublished()) {
+ int httpPort = 9600 + new Random().nextInt(99);
+ String hostname = TckPublisher.getProperties().getProperty("bindaddress");
+ if (hostname == null) {
+ hostname = InetAddress.getLocalHost().getHostName();
+ }
+ url = "http://" + hostname + ":" + httpPort + "/" + UUID.randomUUID().toString();
+ logger.info("Firing up embedded endpoint at " + url);
+ do {
+ try {
+
+ ep = Endpoint.publish(url, this);
+ httpPort = 9600 + new Random().nextInt(99);
+ } catch (Exception ex) {
+ logger.warn(ex.getMessage());
+ }
+ } while (ep != null && !ep.isPublished());
+
+ }
+
+ }
+
+ /**
+ * value set caching service TODO
+ */
+ //@Test
+ public void testVSCUnknownItem() {
+ /*
+ *
+ * E_invalidKeyPassed: Signifies that the tModelKey passed did not match with
+ * the uddiKey of any known tModels. The details on the invalid key SHOULD be
+ * included in the dispositionReport element.
+ *
+ * E_noValuesAvailable: Signifies that no values could be returned.
+ */
+ //Assume.assumeTrue(TckPublisher.isValueSetAPIEnabled());
+ }
+ //TODO · E_invalidValue: Signifies that the chunkToken value supplied is either invalid or has expired.
+ //TODO maybe? · E_unsupported: Signifies that the Web service does not support this API.
+ //this may be untestable unless the endpoint exists but isn't implemented
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org
For additional commands, e-mail: commits-help@juddi.apache.org