juddi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From svi...@apache.org
Subject cvs commit: ws-juddi/test/src/uddi4j/org/apache/juddi/uddi4j Configurator.java TestFindBusiness.java UDDITestBase.java Test_save_binding.java TestTModel.java PublisherManager.java TestSaveBusiness.java TestFindService.java TestAddPublisherAssertion.java TestAll.java TestDiscardAuthToken.java samples.prop Test_save_tModel.java
Date Sun, 16 Jan 2005 18:00:52 GMT
sviens      2005/01/16 10:00:52

  Added:       test/src/uddi4j/org/apache/juddi/uddi4j Configurator.java
                        TestFindBusiness.java UDDITestBase.java
                        Test_save_binding.java TestTModel.java
                        PublisherManager.java TestSaveBusiness.java
                        TestFindService.java TestAddPublisherAssertion.java
                        TestAll.java TestDiscardAuthToken.java samples.prop
                        Test_save_tModel.java
  Log:
  UDDI4j functionality and compatibility tests.
  
  Revision  Changes    Path
  1.1                  ws-juddi/test/src/uddi4j/org/apache/juddi/uddi4j/Configurator.java
  
  Index: Configurator.java
  ===================================================================
  /*
   * Copyright 2001-2004 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.uddi4j;
  
  /*
   * The source code contained herein is licensed under the IBM Public License
   * Version 1.0, which has been approved by the Open Source Initiative.
   * Copyright (C) 2001, International Business Machines Corporation
   * Copyright (C) 2001, Hewlett-Packard Company
   * All Rights Reserved.
   *
   */
  
  import java.util.Properties;
  
  import org.uddi4j.transport.TransportFactory;
  
  /**
   * Configures the environment for the UDDI4J samples.
   * <OL>
   * <LI>Reads samples property file.
   * <LI>Sets SOAP transport according to property file.
   * <LI>Configures SSL/JSSE provider
   * </OL>
   *
   * @author David Melgar (dmelgar@us.ibm.com)
   */
  
  public class Configurator {
  
     /**
      * Loads configuration file. File may require
      * modification before running samples.
      *
      * @return Loaded properties object
      */
     public static Properties load() {
  
       ClassLoader loader = Thread.currentThread().getContextClassLoader();
  
  //     java.io.InputStream is = loader.getResourceAsStream("samples.prop");
       java.io.InputStream is = loader.getResourceAsStream("org/apache/juddi/uddi4j/samples.prop");
  
        Properties config = new Properties();
        try {
           config.load(is);
        } catch (Exception e) {
           System.out.println("Error loading samples property file\n" + e.toString());
        }
  
        // Configure UDDI4J system properties. Normally set on commandline or elsewhere
        // SOAP transport being used
        if (System.getProperty(TransportFactory.PROPERTY_NAME)==null) {
           System.setProperty(TransportFactory.PROPERTY_NAME, config.getProperty("TransportClassName"));
        }
        // Logging
        if (System.getProperty("org.uddi4j.logEnabled")==null) {
           System.setProperty("org.uddi4j.logEnabled", config.getProperty("logEnabled"));
        }
  
        // Configure JSSE support
        try {
           System.setProperty("java.protocol.handler.pkgs", config.getProperty("handlerPackageName"));
  
           // Dynamically loads security provider based on properties. Typically configured in JRE
           java.security.Security.addProvider((java.security.Provider)
              Class.forName(config.getProperty("securityClassName")).newInstance());
        } catch (Exception e) {
           System.out.println("Error configuring JSSE provider. Make sure JSSE is in classpath.\n" + e);
        }
        return config;
     }
  }
  
  
  
  1.1                  ws-juddi/test/src/uddi4j/org/apache/juddi/uddi4j/TestFindBusiness.java
  
  Index: TestFindBusiness.java
  ===================================================================
  /*
   * Copyright 2001-2004 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.uddi4j;
  
  import java.util.Vector;
  
  import org.uddi4j.UDDIException;
  import org.uddi4j.datatype.Name;
  import org.uddi4j.datatype.business.BusinessEntity;
  import org.uddi4j.response.BusinessDetail;
  import org.uddi4j.response.BusinessInfo;
  import org.uddi4j.response.BusinessList;
  import org.uddi4j.transport.TransportException;
  import org.uddi4j.util.FindQualifier;
  import org.uddi4j.util.FindQualifiers;
  
  /**
   * Sample code that exercises the find_business API.
   * @author Andy Cutright (acutright@borland.com)
   * @author Chrissie Hynde, for variable name inspirations
   * <p> tests the following find qualifiers..
   * </p>
   * EM   CS
   * 0     0  ee matches [eE][eE]* UPPER(NAME LIKE) text.toUpperCase  < default case
   * 0     1  ee matches ee*       NAME LIKE
   * 1     0  ee matches [eE][eE]  UPPER(NAME =) text.toUpperCase
   * 1     1  ee matches ee        NAME =
   *
   */
  
  public class TestFindBusiness extends UDDITestBase
  {
    public void testSortByNameDesc() {
      BusinessDetail busDetail = null;
      try {
        BusinessEntity bEntity = new BusinessEntity();
        bEntity.setDefaultName(new Name("ABC"));
        Vector busVector = new Vector();
        busVector.add(bEntity);
  
        bEntity = new BusinessEntity();
        bEntity.setDefaultName(new Name("CDE"));
        busVector.add(bEntity);
  
        bEntity = new BusinessEntity();
        bEntity.setDefaultName(new Name("EFG"));
        busVector.add(bEntity);
  
        busDetail = proxy.save_business(token.getAuthInfoString(), busVector);
        assertTrue(querySortByNameDesc());
      }
      catch (UDDIException ex) {
        fail(ex.toString());
      }
      catch (TransportException ex){
        fail(ex.toString());
      }
      finally {
        cleanupBusinessDetail(busDetail);
      }
    }
  
    protected boolean querySortByNameDesc() {
      try {
        Vector names = new Vector();
        names.add(new Name("ABC"));
        names.add(new Name("CDE"));
        names.add(new Name("EFG"));
  
        FindQualifiers findQualifiers = new FindQualifiers();
        Vector qualifier = new Vector();
        qualifier.add(new FindQualifier("sortByNameDesc"));
        findQualifiers.setFindQualifierVector(qualifier);
  
        BusinessList businessList = null;
        businessList = proxy.find_business(names, null, null, null, null,
                                           findQualifiers, 5);
  
        Vector victor = businessList.getBusinessInfos().getBusinessInfoVector();
        if (victor.size() !=3 ) {
          return false;
        }
        BusinessInfo info = (BusinessInfo)victor.elementAt(0);
        if (! ((BusinessInfo)victor.elementAt(0)).getDefaultNameString().equals("EFG")) {
          return false;
        }
        if (! ((BusinessInfo)victor.elementAt(1)).getDefaultNameString().equals("CDE")) {
          return false;
        }
        if (! ((BusinessInfo)victor.elementAt(2)).getDefaultNameString().equals("ABC")) {
          return false;
        }
      }
      catch (UDDIException ex) {
        return false;
      }
      catch (TransportException ex) {
        return false;
      }
      return true;
    }
  
    public void testExactMatch() {
      BusinessDetail busDetail = null;
  
      try {
        BusinessEntity bEntity = new BusinessEntity();
        Name name = new Name("BadBoysGetSpanked");
        bEntity.setDefaultName(name);
        Vector busVector = new Vector();
        busVector.add(bEntity);
        busDetail = proxy.save_business(token.getAuthInfoString(), busVector);
  
        assertTrue(queryExactMatch());
      }
      catch (UDDIException ex) {
        fail(ex.toString());
      }
      catch(TransportException ex) {
        fail(ex.toString());
      }
      finally {
        cleanupBusinessDetail(busDetail);
      }
    }
  
    protected boolean queryExactMatch() {
  
      try {
        Vector names = new Vector();
        names.add(new Name("BadBoys"));
  
        FindQualifiers findQualifiers = new FindQualifiers();
        Vector qualifier = new Vector();
        qualifier.add(new FindQualifier("exactNameMatch"));
        findQualifiers.setFindQualifierVector(qualifier);
  
        BusinessList businessList = null;
  
        businessList = proxy.find_business(names, null, null, null, null,
                                           findQualifiers, 5);
  
        if (businessList.getBusinessInfos().getBusinessInfoVector().size() != 0) {
          return false;
        }
  
        names.clear();
        names.add(new Name("BadBoysGetSpanked"));
  
        businessList = proxy.find_business(names, null, null, null, null,
                                           findQualifiers, 5);
  
        if (businessList.getBusinessInfos().getBusinessInfoVector().size() != 1) {
          return false;
        }
  
        /**
         * exact match, case insensitive
         */
        names.clear();
        names.add(new Name("badboysgetspanked"));
  
        businessList = proxy.find_business(names, null, null, null, null,
                                           findQualifiers, 5);
  
        if (businessList.getBusinessInfos().getBusinessInfoVector().size() != 1) {
          return false;
        }
  
        /**
         * exact match, case sensitive, negative
         */
        findQualifiers = new FindQualifiers();
        qualifier = new Vector();
        qualifier.add(new FindQualifier("exactNameMatch"));
        qualifier.add(new FindQualifier("caseSensitiveMatch"));
        findQualifiers.setFindQualifierVector(qualifier);
  
        names.clear();
        names.add(new Name("badboysgetspanked"));
        businessList = proxy.find_business(names, null, null, null, null,
                                           findQualifiers, 5);
  
        if (businessList.getBusinessInfos().getBusinessInfoVector().size() != 0) {
          return false;
        }
  
        /**
         * exact match, case sensitive, positive
         */
        names.clear();
        names.add(new Name("BadBoysGetSpanked"));
        businessList = proxy.find_business(names, null, null, null, null,
                                           findQualifiers, 5);
  
        if (businessList.getBusinessInfos().getBusinessInfoVector().size() != 1) {
          return false;
        }
  
      }
      catch (UDDIException ex) {
        return false;
      }
      catch (TransportException ex) {
        return false;
      }
      return true;
    }
  
    public void testCaseSensitiveMatch() {
      BusinessDetail busDetail = null;
      try {
        // create the business CaseSensitive
        BusinessEntity bEntity = new BusinessEntity();
        Name name = new Name("casesensitive");
        bEntity.setDefaultName(name);
        Vector busVector = new Vector();
        busVector.add(bEntity);
  
        bEntity = new BusinessEntity();
        name = new Name("CaseSensitive");
        bEntity.setDefaultName(name);
        busVector.add(bEntity);
        busDetail = proxy.save_business(token.getAuthInfoString(),busVector);
  
        assertTrue(queryCaseSensitiveMatch());
      }
      catch (TransportException ex) {
        fail(ex.toString());
      }
      catch (UDDIException ex) {
        fail(ex.toString());
      }
      finally {
        cleanupBusinessDetail(busDetail);
      }
    }
  
    /**
     * tests
     * 0. default case (not sensitive and not exact)
     * 1. case sensitive, not exact
     */
    protected boolean queryCaseSensitiveMatch() throws TransportException, UDDIException {
      Vector names = new Vector();
      names.add(new Name("c"));
  
      FindQualifiers findQualifiers = new FindQualifiers();
      Vector qualifier = new Vector();
      qualifier.add(new FindQualifier("caseSensitiveMatch"));
      findQualifiers.setFindQualifierVector(qualifier);
  
      BusinessList businessList = proxy.find_business(names, null, null, null,null,findQualifiers,5);
  
      if (businessList.getBusinessInfos().getBusinessInfoVector().size() != 1) {
        return false;
      }
  
      names.clear();
      names.add(new Name("C"));
      businessList = proxy.find_business(names, null, null, null,null,findQualifiers,5);
  
      if (businessList.getBusinessInfos().getBusinessInfoVector().size() != 1) {
        return false;
      }
      businessList = proxy.find_business(names, null, null, null,null,null,5);
  
      if (businessList.getBusinessInfos().getBusinessInfoVector().size() != 2) {
        return false;
      }
      return true;
    }
  }
  
  
  
  1.1                  ws-juddi/test/src/uddi4j/org/apache/juddi/uddi4j/UDDITestBase.java
  
  Index: UDDITestBase.java
  ===================================================================
  /*
   * Copyright 2001-2004 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.uddi4j;
  
  import java.net.MalformedURLException;
  import java.util.Properties;
  import java.util.Vector;
  
  import junit.framework.TestCase;
  
  import org.uddi4j.UDDIException;
  import org.uddi4j.client.UDDIProxy;
  import org.uddi4j.datatype.business.BusinessEntity;
  import org.uddi4j.datatype.tmodel.TModel;
  import org.uddi4j.response.AuthToken;
  import org.uddi4j.response.BusinessDetail;
  import org.uddi4j.response.DispositionReport;
  import org.uddi4j.response.TModelDetail;
  import org.uddi4j.transport.TransportException;
  
  public class UDDITestBase extends TestCase {
    Properties config = null;
    UDDIProxy proxy = null;
    AuthToken token = null;
    AuthToken secondAuthToken = null;
    AuthToken thirdAuthToken = null;
    AuthToken fourthAuthToken = null;
    AuthToken expiredAuthToken = null;
    boolean _inited = false;
  
    {
      init();
    }
    protected void _cleanupBusinessDetail(BusinessDetail busDetail, String auth) {
      if (busDetail != null) {
        Vector victor = busDetail.getBusinessEntityVector();
        for (int index = 0; index < victor.size(); index++) {
          BusinessEntity bet = (BusinessEntity) victor.elementAt(index);
          try {
            proxy.delete_business(auth, bet.getBusinessKey());
          }
          catch (Exception ex) {
          }
        }
      }
    }
    protected void cleanupBusinessDetail(BusinessDetail busDetail, String auth) {
      _cleanupBusinessDetail(busDetail, auth);
    }
    protected void cleanupBusinessDetail(BusinessDetail busDetail) {
      _cleanupBusinessDetail(busDetail, token.getAuthInfoString());
    }
  
    protected void cleanupTModels(TModelDetail details) {
      Vector victor = details.getTModelVector();
      Vector roger = new Vector();
      for (int index = 0; index < victor.size(); index++) {
        roger.add( ((TModel)victor.elementAt(index)).getTModelKey() );
      }
        try {
          proxy.delete_tModel(token.getAuthInfoString(), roger);
        }
        catch (TransportException ex) {
          // don't care
        }
        catch (UDDIException ex) {
          // dont' care
        }
    }
    protected void init() {
      if (_inited) {
        return;
      }
      try {
        config = Configurator.load();
  
        // Construct a UDDIProxy object.
        proxy = new UDDIProxy();
  
        // Pass in userid and password registered at the UDDI site
        proxy.setInquiryURL(config.getProperty("inquiryURL"));
        proxy.setPublishURL(config.getProperty("publishURL"));
  
        PublisherManager.createPublisher("juddi2", "juddi2", config);
        PublisherManager.createPublisher("juddi3", "juddi3", config);
        PublisherManager.createPublisher("juddi4", "juddi4", config);
        PublisherManager.createPublisher("expired", "expired", config);
  
        // Pass in userid and password registered at the UDDI site
        token = proxy.get_authToken(config.getProperty("userid"),
                                    config.getProperty("password"));
        secondAuthToken = proxy.get_authToken(config.getProperty("userid2"),
                                    config.getProperty("password"));
        thirdAuthToken = proxy.get_authToken(config.getProperty("userid3"),
                                    config.getProperty("password"));
        fourthAuthToken = proxy.get_authToken(config.getProperty("userid4"),
                                    config.getProperty("password"));
  
      }
      catch (UDDIException ex) {
        fail(ex.toString());
      }
      catch (TransportException ex) {
        fail(ex.toString());
  
      }
      catch (MalformedURLException ex) {
        fail(ex.toString());
      }
      _inited = true;
    }
  
    protected AuthToken getSecondAuthToken() {
      return secondAuthToken;
    }
    protected AuthToken getThirdAuthToken() {
      return thirdAuthToken;
    }
    protected AuthToken getExpiredAuthToken() {
      if (expiredAuthToken == null) {
        try {
          expiredAuthToken = proxy.get_authToken(config.getProperty("expired"),
                                                 config.getProperty("password"));
          DispositionReport disp =
              proxy.discard_authToken(expiredAuthToken.getAuthInfoString());
          assertTrue(disp.success());
        }
        catch (TransportException ex) {
        }
        catch (UDDIException ex) {
        }
      }
      return expiredAuthToken;
    }
  }
  
  
  1.1                  ws-juddi/test/src/uddi4j/org/apache/juddi/uddi4j/Test_save_binding.java
  
  Index: Test_save_binding.java
  ===================================================================
  /*
   * Copyright 2001-2004 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.uddi4j;
  
  import java.util.Vector;
  
  import org.uddi4j.UDDIException;
  import org.uddi4j.datatype.Name;
  import org.uddi4j.datatype.binding.BindingTemplate;
  import org.uddi4j.datatype.business.BusinessEntity;
  import org.uddi4j.datatype.service.BusinessService;
  import org.uddi4j.response.AuthToken;
  import org.uddi4j.response.BusinessDetail;
  import org.uddi4j.response.ServiceDetail;
  import org.uddi4j.transport.TransportException;
  
  
  public class Test_save_binding extends UDDITestBase {
    protected boolean inited = false;
    protected BusinessService _businessService = null;
  
    public Test_save_binding() {
    }
  
    public void testCases() {
      if (! inited) {
        fail("initialization failed");
        return;
      }
      _simpleBinding();
    }
  
    public void setUp() {
      /**
       * create business && service
       */
  
      if (! PublisherManager.createPublisher("saveBindingPublisher","saveBindingPublisher", config)) {
        fail("Unable to create publisher");
        return;
      }
  
      AuthToken _bindingToken = null;
      try {
        _bindingToken = proxy.get_authToken("saveBindingPublisher", "password");
      }
      catch (TransportException ex1) {
        fail(ex1.toString());
      }
      catch (UDDIException ex1) {
        fail(ex1.toString());
      }
  
      BusinessEntity bEntity = new BusinessEntity();
  
      bEntity.setDefaultName(new Name("saveBindingBusiness"));
      Vector busVector = new Vector();
      busVector.add(bEntity);
  
      Vector victor = null;
      try {
        BusinessDetail busDetail = proxy.save_business(token.getAuthInfoString(),
            busVector);
        victor = busDetail.getBusinessEntityVector();
        assertEquals(victor.size(), 1);
      }
      catch (TransportException ex) {
        fail(ex.toString());
        return;
      }
      catch (UDDIException ex) {
        fail(ex.toString());
        return;
      }
  
      BusinessEntity returnedBusinessEntity = (BusinessEntity)victor.elementAt(0);
  
      BusinessService service = new BusinessService();
      service.setBusinessKey(returnedBusinessEntity.getBusinessKey());
      Name name = new Name("saveBindingService");
      service.setDefaultName(name);
  
      java.util.Vector servicesVector = new Vector();
      servicesVector.add(service);
      try {
        proxy.save_service(_bindingToken.getAuthInfoString(), servicesVector);
        ServiceDetail detail = proxy.save_service(token.getAuthInfoString(), servicesVector);
        servicesVector = detail.getBusinessServiceVector();
        assertEquals(servicesVector.size(), 1);
        _businessService = (BusinessService)servicesVector.elementAt(0);
        assertNotNull(_businessService);
      }
      catch (TransportException ex2) {
        fail(ex2.toString());
        return;
      }
      catch (UDDIException ex2) {
        fail(ex2.toString());
        return;
      }
  
      inited = true;
    }
  
    public void tearDown() {
  
    }
  
    protected void _simpleBinding() {
      BindingTemplate bindingTemplate = new BindingTemplate();
      bindingTemplate.setDefaultDescriptionString("SOAP Binding");
      bindingTemplate.setServiceKey(_businessService.getServiceKey());
      try {
  
        AuthToken _bindingToken = proxy.get_authToken("saveBindingPublisher", "password");
        Vector bindingVector = new Vector();
        bindingVector.addElement(bindingTemplate);
        proxy.save_binding(_bindingToken.getAuthInfoString(), bindingVector);
      }
      catch (TransportException ex) {
        fail(ex.toString());
      }
      catch (UDDIException ex) {
        fail(ex.toString());
      }
    }
  }
  
  
  
  1.1                  ws-juddi/test/src/uddi4j/org/apache/juddi/uddi4j/TestTModel.java
  
  Index: TestTModel.java
  ===================================================================
  /*
   * Copyright 2001-2004 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.uddi4j;
  
  import java.util.Vector;
  
  import org.uddi4j.UDDIException;
  import org.uddi4j.datatype.tmodel.TModel;
  import org.uddi4j.response.TModelDetail;
  import org.uddi4j.transport.TransportException;
  import org.uddi4j.util.FindQualifier;
  import org.uddi4j.util.FindQualifiers;
  import org.uddi4j.util.CategoryBag;
  import org.uddi4j.util.KeyedReference;
  
  public class TestTModel extends UDDITestBase {
  
    public void testCases() {
      _testNoNameQualifier();
      _testEmptyFindQualifier(); 
    }
    public void _testEmptyFindQualifier() {
      Vector tmods = new Vector();
      TModel tModel =  new TModel();
      tModel.setName("AnimalProtocol");
      TModelDetail tmodDetail = null;
  
      tmods.add(tModel);
      try {
        tmodDetail = proxy.save_tModel(token.getAuthInfoString(),tmods);
        assertTrue(_queryEmptyQualifiers()) ;
      }
      catch (TransportException ex) {
        fail(ex.toString());
      }
      catch (UDDIException ex) {
        fail(ex.toString());
      }
      finally {
        cleanupTModels(tmodDetail);
      }
   }
  
    public boolean _queryEmptyQualifiers() {
      FindQualifiers findQualifiers = new FindQualifiers();
      FindQualifier findQualifier = new FindQualifier();
      findQualifiers.add(findQualifier);
      try {
        proxy.find_tModel("AnimalProtocol", null, null, findQualifiers, 5);
      }
      catch (UDDIException ex) {
        return false;
      }
      catch (TransportException ex) {
        return false;
      }
      return true;
    }
    
    public boolean _testNoNameQualifier() {
      
      Vector tmods = new Vector();
      TModel tModel =  new TModel();
      tModel.setName("PuffyProtocol");
      TModelDetail tmodDetail = null;
  
      tmods.add(tModel);
      try {
        tmodDetail = proxy.save_tModel(token.getAuthInfoString(), tmods);
        assertTrue(_queryNoNameQualifiers());
      }
      catch (TransportException ex) {
        fail(ex.toString()); 
      } 
      catch (UDDIException ex) {
        fail(ex.toString()); 
      }
      finally {
        cleanupTModels(tmodDetail); 
      }
      return true;
    }
  
    public boolean _queryNoNameQualifiers() {
      CategoryBag catBag = new CategoryBag(); 
     KeyedReference kref = new KeyedReference("", "categorization", TModel.TYPES_TMODEL_KEY);
      catBag.add(kref);
      try {
        proxy.find_tModel("", catBag, null, null, 5);
      }
      catch (UDDIException ex) {
        return false;
      }
      catch (TransportException ex) {
        return false;
      }
      return true;
    }
  }
  
  
  
  1.1                  ws-juddi/test/src/uddi4j/org/apache/juddi/uddi4j/PublisherManager.java
  
  Index: PublisherManager.java
  ===================================================================
  /*
   * Copyright 2001-2004 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.uddi4j;
  
  
  import java.util.Vector;
  import java.util.Properties;
  
  import org.apache.juddi.proxy.RegistryProxy;
  import org.apache.juddi.datatype.publisher.Publisher;
  import org.apache.juddi.datatype.request.AuthInfo;
  import org.apache.juddi.datatype.response.AuthToken;
  import org.apache.juddi.datatype.response.PublisherDetail;
  import org.apache.juddi.IRegistry;
  
  /**
   * @author Steve Viens (sviens@users.sourceforge.net)
   * @author Andy Cutright (acutright@users.sourceforge.net)
   */
  public class PublisherManager
  {
    public PublisherManager() {
    }
  
    public static boolean createPublisher(String name, String identifier, Properties testprops) {
      Properties props = new Properties();
      props.setProperty(RegistryProxy.ADMIN_ENDPOINT_PROPERTY_NAME, testprops.getProperty("adminURL"));
      props.setProperty(RegistryProxy.INQUIRY_ENDPOINT_PROPERTY_NAME, testprops.getProperty("inquiryURL"));
      props.setProperty(RegistryProxy.PUBLISH_ENDPOINT_PROPERTY_NAME, testprops.getProperty("publishURL"));
      IRegistry proxy = new RegistryProxy(props);
  
      boolean ret = false;
  
      try
      {
        // execute a GetAuthToken request
        AuthToken token = proxy.getAuthToken("juddi", "password");
        AuthInfo authInfo = token.getAuthInfo();
  
        // create a publisher
        Publisher publisher = new Publisher(name, identifier);
  
        // put the Publisher object into a Vector
        Vector vector = new Vector(1);
        vector.add(publisher);
  
        // make the request
        PublisherDetail detail = proxy.savePublisher(authInfo, vector);
  
        Vector pubVector = detail.getPublisherVector();
        if (pubVector.size() == 1) {
          ret = true;
        }
  
        return ret;
      }
      catch(Exception ex)
      {
        ex.printStackTrace();
      }
      return ret;
    }
  
    public static String getExpiredAuthToken(String publisher, String password) {
      RegistryProxy proxy = new RegistryProxy();
      AuthToken token = null;
      AuthInfo authInfo = null;
      String ret = null;
      try {
        token = proxy.getAuthToken(publisher, password);
        authInfo = token.getAuthInfo();
        ret = authInfo.getValue();
        proxy.discardAuthToken(authInfo);
      }
      catch (Exception ex) {
        ex.printStackTrace();
      }
      return ret;
    }
  }
  
  
  
  
  1.1                  ws-juddi/test/src/uddi4j/org/apache/juddi/uddi4j/TestSaveBusiness.java
  
  Index: TestSaveBusiness.java
  ===================================================================
  /*
   * Copyright 2001-2004 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.uddi4j;
  
  import java.util.Vector;
  
  import org.uddi4j.UDDIException;
  import org.uddi4j.datatype.Name;
  import org.uddi4j.datatype.business.BusinessEntity;
  import org.uddi4j.response.BusinessDetail;
  import org.uddi4j.transport.TransportException;
  
  public class TestSaveBusiness extends UDDITestBase {
  
    public void testSaveMultipleBusiness() {
  
      BusinessDetail busDetail = null;
      try {
        BusinessEntity bEntity = new BusinessEntity();
        bEntity.setDefaultName(new Name("ABC"));
        Vector busVector = new Vector();
        busVector.add(bEntity);
  
        bEntity = new BusinessEntity();
        bEntity.setDefaultName(new Name("CDE"));
        busVector.add(bEntity);
  
        busDetail = proxy.save_business(token.getAuthInfoString(), busVector);
        Vector victor = busDetail.getBusinessEntityVector();
        assertEquals(victor.size(),2);
      }
      catch (UDDIException ex) {
        fail(ex.toString());
      }
      catch (TransportException ex) {
        fail(ex.toString());
      }
      finally {
        cleanupBusinessDetail(busDetail);
      }
    }
  
    /**
     * possible bug reported 5/22/03, by
     * Ralph M´┐Żller <ram77@gmx.de>, but can't reproduce
     * @return
     */
    public void testSaveBusinessMultipleNames() {
      BusinessDetail busDetail = null;
  
      try {
        BusinessEntity bEntity = new BusinessEntity();
        Vector names = new Vector();
        names.addElement(new Name("AuthInfo1"));
        names.addElement(new Name("AuthInfo2"));
        bEntity.setNameVector(names);
  
        Vector busVector = new Vector();
        busVector.add(bEntity);
  
        busDetail = proxy.save_business(token.getAuthInfoString(), busVector);
        Vector victor = busDetail.getBusinessEntityVector();
        assertEquals(victor.size(),1);
      }
      catch (UDDIException ex) {
        fail(ex.toString());
      }
      catch (TransportException ex) {
        fail(ex.toString());
      }
      finally {
        cleanupBusinessDetail(busDetail);
      }
    }
  }
  
  
  1.1                  ws-juddi/test/src/uddi4j/org/apache/juddi/uddi4j/TestFindService.java
  
  Index: TestFindService.java
  ===================================================================
  /*
   * Copyright 2001-2004 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.uddi4j;
  
  import java.util.Vector;
  
  import org.uddi4j.UDDIException;
  import org.uddi4j.datatype.Name;
  import org.uddi4j.datatype.OverviewDoc;
  import org.uddi4j.datatype.binding.AccessPoint;
  import org.uddi4j.datatype.binding.BindingTemplate;
  import org.uddi4j.datatype.binding.BindingTemplates;
  import org.uddi4j.datatype.binding.TModelInstanceDetails;
  import org.uddi4j.datatype.binding.TModelInstanceInfo;
  import org.uddi4j.datatype.business.BusinessEntity;
  import org.uddi4j.datatype.service.BusinessService;
  import org.uddi4j.datatype.tmodel.TModel;
  import org.uddi4j.response.BusinessDetail;
  import org.uddi4j.response.ServiceDetail;
  import org.uddi4j.response.ServiceList;
  import org.uddi4j.response.TModelDetail;
  import org.uddi4j.transport.TransportException;
  import org.uddi4j.util.CategoryBag;
  import org.uddi4j.util.IdentifierBag;
  import org.uddi4j.util.KeyedReference;
  
  
  
  public class TestFindService extends UDDITestBase
  {
    private static final String ANIMAL_PROTOCOL_NAME="animal_protocol";
    private static final String ANIMAL_BUSINESS = "animal_business";
    private static final String ANIMAL_BUSINESS_SERVICE = "animal_business_service";
    private static final String ANIMAL_WSDL_URL = "http://localhost:8080/animal_java/services/Animal?wsdl";
    private static final String ANIMAL_SERVICE_NAME = "Animal Service";
  
    protected TModelDetail _animalProtocol_tModelDetail = null;
    protected BusinessEntity _animalBusinessEntity = null;
    protected BusinessService _animalBusinessService = null;
    protected boolean initOK=false;
  
  
  
  
    private boolean _publish_animalProtocol() {
      boolean ret = false;
      TModel animal_tModel = new TModel();
      animal_tModel.setName(ANIMAL_PROTOCOL_NAME);
      animal_tModel.setDefaultDescriptionString("some description");
      OverviewDoc overviewdoc = new OverviewDoc();
      overviewdoc.setDefaultDescriptionString("animal protocol doc");
      overviewdoc.setOverviewURL("<url for animal doc>");
      java.util.Vector tModelVector = new Vector();
      tModelVector.add(animal_tModel);
      try
      {
        _animalProtocol_tModelDetail = proxy.save_tModel(token.getAuthInfoString(), tModelVector);
        ret = true;
      }
      catch (TransportException ex) {
        /**
          * @todo logging
         */
      }
      catch (UDDIException ex) {
        /**
          * @todo logging
         */
      }
      return ret;
    }
  
    private CategoryBag _createCategoryBag() {
      CategoryBag catBag = new CategoryBag();
      KeyedReference kr = new KeyedReference(TModel.NAICS_TMODEL_KEY, "<FAKE NAICS NUMBER>");
      catBag.add(kr);
      return catBag;
    }
  
    private IdentifierBag _createIdentifierBag() {
      IdentifierBag idBag = new IdentifierBag();
      KeyedReference kr = new KeyedReference(TModel.D_U_N_S_TMODEL_KEY , "<FAKE DUNS KEY>");
      idBag.add(kr);
      return idBag;
    }
  
    private boolean _publish_animalBusiness() {
      boolean ret = false;
      java.util.Vector entities = new Vector();
      BusinessEntity be = new BusinessEntity("", ANIMAL_BUSINESS);
      IdentifierBag idBag = _createIdentifierBag();
      be.setIdentifierBag(idBag);
      CategoryBag catBag = _createCategoryBag();
      be.setCategoryBag(catBag);
      entities.addElement(be);
      try {
        BusinessDetail businessDetail = proxy.save_business(token.getAuthInfoString(), entities);
        Vector businessEntities = businessDetail.getBusinessEntityVector();
        _animalBusinessEntity = (BusinessEntity)(businessEntities.elementAt(0));
        ret = true;
      }
      catch (TransportException ex) {
        /**
          * @todo logging
         */
      }
      catch (UDDIException ex) {
        /**
          * @todo logging
         */
      }
      return ret;
    }
  
    private AccessPoint _createAccessPoint(String url) {
     AccessPoint animalAccessPoint = new AccessPoint();
     animalAccessPoint.setURLType("http");
     animalAccessPoint.setText(url);
     return animalAccessPoint;
   }
  
    private boolean _publish_animalService(){
      boolean ret = false;
      BusinessService busService = new BusinessService();
      busService.setBusinessKey(_animalBusinessEntity.getBusinessKey());
      Name name = new Name(ANIMAL_BUSINESS_SERVICE);
      busService.setDefaultName(name);
      CategoryBag catBag = _createCategoryBag();
      busService.setCategoryBag(catBag);
      BindingTemplate bindingTemplate = new BindingTemplate();
      TModelInstanceDetails tModelInstanceDetails = new TModelInstanceDetails();
      TModelInstanceInfo tModelInstanceInfo = new TModelInstanceInfo();
      tModelInstanceInfo.setTModelKey(((TModel)_animalProtocol_tModelDetail.getTModelVector().elementAt(0)).getTModelKey());
      tModelInstanceInfo.setDefaultDescriptionString("Animal Protocol tModel Instance");
      tModelInstanceDetails.add(tModelInstanceInfo);
  
      tModelInstanceInfo = new TModelInstanceInfo();
      tModelInstanceInfo.setTModelKey(((TModel)_animalProtocol_tModelDetail.getTModelVector().elementAt(0)).getTModelKey());
  
      /**
       * This creates the unique, well-defined tModel representing the service's WSDL
       */
      TModelDetail tmodelDetail = null;
      try {
        tmodelDetail = _publishWSDL_tModel();
      }
      catch (TransportException ex) {
        /**
         * @todo cleanup ??
         */
        return  ret;
      }
      catch (UDDIException ex) {
        /**
         * @todo cleanup ??
         */
        return ret;
      }
      tModelInstanceInfo = new TModelInstanceInfo();
      tModelInstanceInfo.setTModelKey(((TModel)tmodelDetail.getTModelVector().elementAt(0)).getTModelKey());
      tModelInstanceInfo.setDefaultDescriptionString("Animal Service tModel instance");
      tModelInstanceDetails.add(tModelInstanceInfo);
  
      /**
       * Associate the set of tModels with the Service's BindingTemplate
       */
      bindingTemplate.setTModelInstanceDetails(tModelInstanceDetails);
  
      /**
       * The binding template needs an [ accessPoint | hostRedirector ]
       */
      AccessPoint animalAccessPoint = _createAccessPoint(ANIMAL_WSDL_URL.substring(0,ANIMAL_WSDL_URL.lastIndexOf("?")));
      bindingTemplate.setAccessPoint(animalAccessPoint);
      BindingTemplates bindingTemplates = new BindingTemplates();
  
      bindingTemplate.setDefaultDescriptionString("SOAP Binding");
      bindingTemplates.add(bindingTemplate);
  
      busService.setBindingTemplates(bindingTemplates);
  
      // save the service
      java.util.Vector servicesVector = new Vector();
      servicesVector.add(busService);
      try {
       ServiceDetail serviceDetail = proxy.save_service(token.getAuthInfoString(), servicesVector);
       // get the business service to get the key
       _animalBusinessService = (BusinessService) serviceDetail.getBusinessServiceVector().elementAt(0);
  
      }
      catch(TransportException ex) {
        return ret;
      }
      catch(UDDIException ex) {
        /**
         * @todo cleanup ??
         */
        return ret;
      }
  
      ret = true;
  
      return ret;
    }
  
    private TModelDetail _publishWSDL_tModel()
        throws TransportException, UDDIException
    {
      TModel animalWSDL_tModel = new TModel();
      /**
       * UDDI best practices recommend a specific format for the OverviewDocument
       * for this tModel.
       */
      OverviewDoc animalWSDL_overviewDoc = new OverviewDoc();
      animalWSDL_overviewDoc.setDefaultDescriptionString("WSDL source document");
      animalWSDL_overviewDoc.setOverviewURL(ANIMAL_WSDL_URL);
      animalWSDL_tModel.setOverviewDoc(animalWSDL_overviewDoc);
  
      KeyedReference kr = new KeyedReference("uuid-org:types","wsdlSpec");
      kr.setTModelKey(TModel.TYPES_TMODEL_KEY);
      CategoryBag catBag = new CategoryBag();
      catBag.add(kr);
      animalWSDL_tModel.setCategoryBag(catBag);
  
      animalWSDL_tModel.setName(ANIMAL_SERVICE_NAME);
      animalWSDL_tModel.setDefaultDescriptionString("WSDL description of Animal protocol interface");
      java.util.Vector tModelVector = new Vector();
      tModelVector.add(animalWSDL_tModel);
      TModelDetail animal_tModelDetail = proxy.save_tModel(token.getAuthInfoString(), tModelVector);
      return animal_tModelDetail;
    }
  
  
    public void setUp() {
      if (!_publish_animalProtocol()) {
        return;
      }
      if (!_publish_animalBusiness()) {
        return;
      }
      if (!_publish_animalService()) {
        return;
      }
      initOK = true;
    }
  
    public void tearDown() {
    }
  
    protected void _testGetServiceDetail() {
  //    _animalBusinessEntity.
      try {
        proxy.get_serviceDetail(_animalBusinessService.getServiceKey());
      }
      catch (UDDIException ex) {
        fail(ex.toString());
      }
      catch (TransportException ex) {
        fail(ex.toString());
      }
    }
  
    protected void _testFindService() {
      // creates the fake NACS #
      CategoryBag catBag = _createCategoryBag();
      try {
        ServiceList list = proxy.find_service("", null, catBag, null, null, 0);
      }
      catch(UDDIException ex) {
        fail(ex.toString());
      }
      catch(TransportException ex) {
        fail(ex.toString());
      }
    }
  
    protected void _testInit() {
      if (!initOK) {
        fail("intialization failed");
      }
    }
    public void testCases() {
      _testInit();
      _testGetServiceDetail();
      _testFindService();
    }
  
  }
  
  
  
  1.1                  ws-juddi/test/src/uddi4j/org/apache/juddi/uddi4j/TestAddPublisherAssertion.java
  
  Index: TestAddPublisherAssertion.java
  ===================================================================
  /*
   * Copyright 2001-2004 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.uddi4j;
  
  import java.util.Vector;
  
  import org.uddi4j.UDDIException;
  import org.uddi4j.datatype.Name;
  import org.uddi4j.datatype.assertion.PublisherAssertion;
  import org.uddi4j.datatype.business.BusinessEntity;
  import org.uddi4j.datatype.tmodel.TModel;
  import org.uddi4j.response.BusinessDetail;
  import org.uddi4j.response.DispositionReport;
  import org.uddi4j.response.ErrInfo;
  import org.uddi4j.response.Result;
  import org.uddi4j.transport.TransportException;
  import org.uddi4j.util.KeyedReference;
  
  public class TestAddPublisherAssertion extends UDDITestBase {
    protected BusinessDetail[] _details;
    private static final String TEST_KEY = "irrelevant-key";
    protected String _businessKeyZero = null;
    protected String _businessKeyOne = null;
    protected String _businessKeyTwo = null;
  
    public void setUp() {
      _details = new BusinessDetail[3];
  
      try {
        BusinessEntity bEntity = new BusinessEntity();
        bEntity.setDefaultName(new Name("ABC"));
        Vector busVector = new Vector();
        busVector.add(bEntity);
  
        _details[0] = proxy.save_business(token.getAuthInfoString(), busVector);
  
        bEntity = new BusinessEntity();
        bEntity.setDefaultName(new Name("CDE"));
        busVector = new Vector();
        busVector.add(bEntity);
  
        _details[1] = proxy.save_business(getSecondAuthToken().getAuthInfoString(), busVector);
  
        bEntity = new BusinessEntity();
        bEntity.setDefaultName(new Name("FGE"));
        busVector = new Vector();
        busVector.add(bEntity);
  
        _details[2] = proxy.save_business(getThirdAuthToken().getAuthInfoString(), busVector);
  
        Vector victor = _details[0].getBusinessEntityVector();
        assertNotNull(victor);
        _businessKeyZero = ((BusinessEntity)(victor.elementAt(0))).getBusinessKey();
        assertNotNull(_businessKeyZero);
  
        victor = _details[1].getBusinessEntityVector();
        assertNotNull(victor);
        _businessKeyOne = ((BusinessEntity)(victor.elementAt(0))).getBusinessKey();
        assertNotNull(_businessKeyOne);
  
        victor = _details[2].getBusinessEntityVector();
        assertNotNull(victor);
        _businessKeyTwo = ((BusinessEntity)(victor.elementAt(0))).getBusinessKey();
        assertNotNull(_businessKeyTwo);
      }
      catch (TransportException ex) {
        fail(ex.toString());
      }
      catch (UDDIException ex) {
        fail(ex.toString());
      }
    }
    public void testCases() {
      _createPeerToPeer();
      _createInvalidPeerToPeer();
      _userMismatch();
      _invalidToken();
    }
  
    private void _invalidToken() {
      PublisherAssertion pubAssert = new PublisherAssertion();
  
      pubAssert.setToKeyString(_businessKeyOne);
      pubAssert.setFromKeyString(_businessKeyZero);
      KeyedReference keyedRef = new KeyedReference(TModel.RELATIONSHIPS_TMODEL_KEY, TEST_KEY, "peer-peer");
      pubAssert.setKeyedReference(keyedRef);
  
      try {
        DispositionReport disp =
            proxy.add_publisherAssertions("NONSENSE", pubAssert);
        assertFalse(disp.success());
  
        Vector results = disp.getResultVector();
        Result result = (Result)results.elementAt(0);
        ErrInfo errInfo = result.getErrInfo();
        assertEquals(errInfo.getErrCode(),DispositionReport.E_authTokenRequired);
      }
      catch (TransportException ex) {
        fail(ex.toString());
      }
      catch (UDDIException ex) {
        DispositionReport disp = ex.getDispositionReport();
        assertFalse(disp.success());
  
        Vector results = disp.getResultVector();
        Result result = (Result)results.elementAt(0);
        ErrInfo errInfo = result.getErrInfo();
        assertEquals(errInfo.getErrCode(),DispositionReport.E_authTokenRequired);
      }
    }
    private void _userMismatch() {
      PublisherAssertion pubAssert = new PublisherAssertion();
  
      pubAssert.setToKeyString(_businessKeyOne);
      pubAssert.setFromKeyString(_businessKeyZero);
      KeyedReference keyedRef = new KeyedReference(TModel.RELATIONSHIPS_TMODEL_KEY, TEST_KEY, "peer-peer");
      pubAssert.setKeyedReference(keyedRef);
  
      try {
        DispositionReport disp =
            proxy.add_publisherAssertions(getThirdAuthToken().getAuthInfoString(), pubAssert);
        assertFalse(disp.success());
  
        Vector results = disp.getResultVector();
        Result result = (Result)results.elementAt(0);
        ErrInfo errInfo = result.getErrInfo();
        assertEquals(errInfo.getErrCode(),DispositionReport.E_userMismatch);
        //assertEquals(disp.getErrCode(),disp.E_userMismatch);
      }
      catch (TransportException ex) {
        fail(ex.toString());
      }
      catch (UDDIException ex) {
        DispositionReport disp = ex.getDispositionReport();
        assertFalse(disp.success());
  
        Vector results = disp.getResultVector();
        Result result = (Result)results.elementAt(0);
        ErrInfo errInfo = result.getErrInfo();
        assertEquals(errInfo.getErrCode(),DispositionReport.E_userMismatch);
        //assertEquals(disp.getErrCode(),disp.E_userMismatch);
      }
    }
  
    private void _createInvalidPeerToPeer() {
      PublisherAssertion pubAssert = new PublisherAssertion();
  
      pubAssert.setToKeyString("NONSENSE");
      pubAssert.setFromKeyString(_businessKeyZero);
      KeyedReference keyedRef = new KeyedReference(TModel.RELATIONSHIPS_TMODEL_KEY, TEST_KEY, "peer-peer");
      pubAssert.setKeyedReference(keyedRef);
  
      try {
        DispositionReport disp = proxy.add_publisherAssertions(token.
            getAuthInfoString(), pubAssert);
        assertFalse(disp.success());
  
        Vector results = disp.getResultVector();
        Result result = (Result)results.elementAt(0);
        ErrInfo errInfo = result.getErrInfo();
        assertEquals(errInfo.getErrCode(),DispositionReport.E_invalidKeyPassed);
        //assertEquals(disp.getErrCode(),disp.E_invalidKeyPassed);
      }
      catch (TransportException ex) {
        fail(ex.toString());
      }
      catch (UDDIException ex) {
        DispositionReport disp = ex.getDispositionReport();
        assertFalse(disp.success());
  
        Vector results = disp.getResultVector();
        Result result = (Result)results.elementAt(0);
        ErrInfo errInfo = result.getErrInfo();
        assertEquals(errInfo.getErrCode(),DispositionReport.E_invalidKeyPassed);
        //assertEquals(disp.getErrCode(),disp.E_invalidKeyPassed);
      }
    }
  
    private void _createPeerToPeer() {
      PublisherAssertion pubAssert = new PublisherAssertion();
  
      pubAssert.setToKeyString(_businessKeyOne);
      pubAssert.setFromKeyString(_businessKeyZero);
      KeyedReference keyedRef = new KeyedReference(TModel.RELATIONSHIPS_TMODEL_KEY, TEST_KEY, "peer-peer");
      pubAssert.setKeyedReference(keyedRef);
  
      try {
        DispositionReport disp = proxy.add_publisherAssertions(token.
            getAuthInfoString(), pubAssert);
        assertTrue(disp.success());
        disp = proxy.delete_publisherAssertions(token.getAuthInfoString(),pubAssert);
        assertTrue(disp.success());
      }
      catch (TransportException ex) {
        fail(ex.toString());
      }
      catch (UDDIException ex) {
        fail(ex.toString());
      }
      finally {
        try {
          // not sure this actually is legal..
          proxy.delete_publisherAssertions(token.getAuthInfoString(), pubAssert);
        }
        catch(Exception ex) {
          // don't care..
        }
      }
    }
  
    public void tearDown() {
      cleanupBusinessDetail(_details[0]);
      cleanupBusinessDetail(_details[1],getSecondAuthToken().getAuthInfoString());
      cleanupBusinessDetail(_details[2],getThirdAuthToken().getAuthInfoString());
    }
    private void _expiredToken() {
      PublisherAssertion pubAssert = new PublisherAssertion();
  
      pubAssert.setToKeyString(_businessKeyOne);
      pubAssert.setFromKeyString(_businessKeyZero);
      KeyedReference keyedRef = new KeyedReference(TModel.RELATIONSHIPS_TMODEL_KEY, TEST_KEY, "peer-peer");
      pubAssert.setKeyedReference(keyedRef);
  
      try {
         DispositionReport disp = proxy.add_publisherAssertions(fourthAuthToken.getAuthInfoString(), pubAssert);
         assertTrue(disp.success());
  
      }
      catch (TransportException ex) {
        fail(ex.toString());
      }
      catch (UDDIException ex) {
  
        DispositionReport disp = ex.getDispositionReport();
        assertFalse(disp.success());
  
        Vector results = disp.getResultVector();
        Result result = (Result)results.elementAt(0);
        ErrInfo errInfo = result.getErrInfo();
        assertEquals(errInfo.getErrCode(),DispositionReport.E_authTokenExpired);
        //assertEquals(disp.getErrCode(),disp.E_authTokenExpired);
      }
      finally {
        try {
  
        }
        catch(Exception ex) {
  
        }
      }
    }
  
    private void _emptyKeyNameAndKeyValue() {
        PublisherAssertion pubAssert = new PublisherAssertion();
  
        pubAssert.setToKeyString(_businessKeyOne);
        pubAssert.setFromKeyString(_businessKeyZero);
        KeyedReference keyedRef = new KeyedReference(TModel.RELATIONSHIPS_TMODEL_KEY, "", "");
        pubAssert.setKeyedReference(keyedRef);
  
  
        try {
           DispositionReport disp = proxy.add_publisherAssertions(token.getAuthInfoString(), pubAssert);
           assertTrue(disp.success());
        }
        catch (TransportException ex) {
          fail(ex.toString());
        }
        catch (UDDIException ex) {
  
        }
        finally {
          try {
            // not sure this actually is legal..
            proxy.delete_publisherAssertions(token.getAuthInfoString(), pubAssert);
          }
          catch(Exception ex) {
            // don't care..
          }
  
        }
  
  
      }
  
  
  
  }
  
  
  1.1                  ws-juddi/test/src/uddi4j/org/apache/juddi/uddi4j/TestAll.java
  
  Index: TestAll.java
  ===================================================================
  /*
   * Copyright 2001-2004 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.uddi4j;
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  
  /**
   * @author Steve Viens (sviens@users.sourceforge.net)
   */
  public class TestAll extends TestCase
  {
    public TestAll(String testName)
    {
        super(testName);
    }
  
    public static Test suite()
    {
      TestSuite suite = new TestSuite();
      suite.addTestSuite(TestDiscardAuthToken.class);
      suite.addTestSuite(TestFindBusiness.class);
      suite.addTestSuite(TestSaveBusiness.class);
      suite.addTestSuite(Test_save_tModel.class);
      suite.addTestSuite(TestAddPublisherAssertion.class);
      suite.addTestSuite(TestTModel.class);
      /*
      suite.addTestSuite(Test_save_binding.class);
          */
      return suite;
    }
  
    public static void main(String args[])
    {
        String[] testCaseName = { TestAll.class.getName() };
        junit.textui.TestRunner.main(testCaseName);
    }
  }
  
  
  
  1.1                  ws-juddi/test/src/uddi4j/org/apache/juddi/uddi4j/TestDiscardAuthToken.java
  
  Index: TestDiscardAuthToken.java
  ===================================================================
  /*
   * Copyright 2001-2004 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.uddi4j;
  
  import java.util.Vector;
  
  import org.uddi4j.UDDIException;
  import org.uddi4j.response.DispositionReport;
  import org.uddi4j.response.ErrInfo;
  import org.uddi4j.response.Result;
  import org.uddi4j.transport.TransportException;
  
  public class TestDiscardAuthToken extends UDDITestBase {
    private void _discardAuthToken(){
      try{
        DispositionReport disp =
        proxy.discard_authToken(fourthAuthToken.getAuthInfoString());
        assertTrue(disp.success());
     }
     catch(TransportException ex) {
        fail(ex.toString());
     }
     catch (UDDIException uddiEx) {
       fail(uddiEx.toString());
     }
    }
    private void _authTokenRequired(){
      try{
       DispositionReport disp =
       proxy.discard_authToken("");
       assertTrue(disp.success());
      }
      catch(TransportException ex) {
        fail(ex.toString());
      }
      catch (UDDIException uddiEx) {
       DispositionReport disp = uddiEx.getDispositionReport();
       assertFalse(disp.success());
  
       Vector results = disp.getResultVector();
       Result result = (Result)results.elementAt(0);
       ErrInfo errInfo = result.getErrInfo();
       assertEquals(errInfo.getErrCode(),DispositionReport.E_authTokenRequired);
     }
    }
  
    public void testCases() {
      _discardAuthToken();
      _authTokenRequired();
    }
  
  }
  
  
  1.1                  ws-juddi/test/src/uddi4j/org/apache/juddi/uddi4j/samples.prop
  
  Index: samples.prop
  ===================================================================
  # Property file used to set parameters for UDDI4J samples
  
  # -----------------------------------------------------------------------
  # inquiryURL: The URL for the inquiry API of the target UDDI registry
  # publishURL: URL for the publish API of the target UDDI registry
  # A list of UDDI URLs is on the UDDI4J website http://www.uddi4j.org/
  #
  # A typical entry would be of the form
  # inquiryURL=http://company.com/uddi_node
  # publishURL=https://company.com/uddi_publish_node
  # -----------------------------------------------------------------------
  # IBM UDDI test site
  inquiryURL=http://localhost:8080/juddi/inquiry
  publishURL=http://localhost:8080/juddi/publish
  adminURL=http://localhost:8080/juddi/admin
  
  # -----------------------------------------------------------------------
  # Userid to use when running the publish samples. Userid/passwords should
  # not generally be stored in clear text
  # -----------------------------------------------------------------------
  userid=juddi
  userid2=juddi2
  userid3=juddi3
  userid4=juddi4
  expired=expired
  password=password
  # -----------------------------------------------------------------------
  # Transport classname. Typically defined on commandline as
  # -Dorg.uddi4j.TransportClassName=xxx.
  # -----------------------------------------------------------------------
  TransportClassName=org.uddi4j.transport.ApacheSOAPTransport
  # TransportClassName=org.uddi4j.transport.ApacheAxisTransport
  # TransportClassName=org.uddi4j.transport.HPSOAPTransport
  
  # -----------------------------------------------------------------------
  # Debug log enabled or not. Typically defined on command line as
  # -Dorg.uddi4j.logEnabled=true
  # -----------------------------------------------------------------------
  #logEnabled=false
  logEnabled=true
  
  # -----------------------------------------------------------------------
  # Values used to determine the implementation of JSSE to use. Provided
  # for convenience, this is typically configured within the jdk
  # in JAVA_HOME\jre\lib\security
  # -----------------------------------------------------------------------
  # Sun JSSE implementation
  handlerPackageName=com.sun.net.ssl.internal.www.protocol
  securityClassName=com.sun.net.ssl.internal.ssl.Provider
  
  # IBM JSSE implementation
  # handlerPackageName=com.ibm.net.ssl.internal.www.protocol
  # securityClassName=com.ibm.jsse.JSSEProvider
  
  # -----------------------------------------------------------------------
  # UDDI names to use within samples. Samples may or maynot use these values,
  # Check the source for the sample
  # -----------------------------------------------------------------------
  businessName=Sample Business
  serviceName=Sample Service
  tmodelName=Sample TModel
  #sampleEntityName=RobertJohnson
  sampleEntityName=S
  assertionRelationship=peer-peer
  
  # -----------------------------------------------------------------------
  # Additional values can be added as needed as a convenient repository
  # for data relevant to the UDDI4J samples
  # -----------------------------------------------------------------------
  
  
  
  1.1                  ws-juddi/test/src/uddi4j/org/apache/juddi/uddi4j/Test_save_tModel.java
  
  Index: Test_save_tModel.java
  ===================================================================
  /*
   * Copyright 2001-2004 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.uddi4j;
  
  import java.util.Vector;
  
  import org.uddi4j.UDDIException;
  import org.uddi4j.datatype.tmodel.TModel;
  import org.uddi4j.response.DispositionReport;
  import org.uddi4j.response.ErrInfo;
  import org.uddi4j.response.Result;
  import org.uddi4j.response.TModelDetail;
  import org.uddi4j.transport.TransportException;
  import org.uddi4j.util.CategoryBag;
  import org.uddi4j.util.KeyedReference;
  
  public class Test_save_tModel extends UDDITestBase {
    TModelDetail _tModelDetail0 = null;
  
    public void testCases() {
      _testCreatetModel();
      _testCreatetModel_noName();
      _testAuthTokenExpired();
      _testAuthTokenRequired();
    }
  
    public void setUp() {
      PublisherManager.createPublisher("tModel_Publisher", "tModel_Publisher",config);
    }
  
    public void tearDown() {
      Vector victor = _tModelDetail0.getTModelVector();
      TModel tModel = (TModel)victor.elementAt(0);
      String UUID = tModel.getTModelKey();
      try {
        proxy.delete_tModel(token.getAuthInfoString(), UUID);
      }
      catch (TransportException ex) {
        // don't care ?? could invalidate further tests..
      }
      catch (UDDIException ex) {
        // don't care ?? could invalidate further tests..
      }
    }
  
    private Vector _buildValidTModelVector() {
        TModel tester = new TModel();
        KeyedReference kr = new KeyedReference();
        kr.setKeyName("testKeyName0");
        kr.setKeyValue("testKeyValue0");
        CategoryBag catBag = new CategoryBag();
        catBag.add(kr);
        tester.setCategoryBag(catBag);
        tester.setName("testKeyName0");
        Vector tModelVector = new Vector();
        tModelVector.add(tester);
        return tModelVector;
    }
  
    private void _testCreatetModel() {
      Vector tModelVector = _buildValidTModelVector();
      assertNotNull(tModelVector);
  
      try {
        _tModelDetail0 = proxy.save_tModel(token.getAuthInfoString(),
                                           tModelVector);
        assertNotNull(_tModelDetail0);
        tModelVector = _tModelDetail0.getTModelVector();
        assertNotNull(tModelVector);
        assertEquals(tModelVector.size(), 1);
      }
      catch (TransportException ex) {
        fail(ex.toString());
      }
      catch (UDDIException ex) {
        fail(ex.toString());
      }
    }
  
    private void _testCreatetModel_noName() {
      TModel tester = new TModel();
      KeyedReference kr = new KeyedReference();
      kr.setKeyName("testKeyName0");
      kr.setKeyValue("testKeyValue0");
      CategoryBag catBag = new CategoryBag();
      catBag.add(kr);
      tester.setCategoryBag(catBag);
      Vector tModelVector = new Vector();
      tModelVector.add(tester);
      try {
        _tModelDetail0 = proxy.save_tModel(token.getAuthInfoString(),
                                           tModelVector);
        Object _empty = null;
        assertNotNull(_empty);
      }
      catch (TransportException ex) {
        fail(ex.toString());
      }
      catch (UDDIException ex) {
        assertTrue(true);
      }
    }
  
    private void _testAuthTokenExpired() {
      getExpiredAuthToken();
      Vector tModelVector = _buildValidTModelVector();
      assertNotNull(tModelVector);
      try {
        String authInfo = PublisherManager.getExpiredAuthToken("tModel_Publisher", "password");
        proxy.save_tModel(authInfo,
                          tModelVector);
        assertNotNull(null);
      }
      catch (TransportException ex) {
        fail(ex.toString());
      }
      catch (UDDIException ex) {
        DispositionReport disp = ex.getDispositionReport();
        assertFalse(disp.success());
  
        Vector results = disp.getResultVector();
        Result result = (Result)results.elementAt(0);
        ErrInfo errInfo = result.getErrInfo();
        assertEquals(errInfo.getErrCode(),DispositionReport.E_authTokenExpired);
      }
    }
  
    private void _testAuthTokenRequired() {
      TModel tester = new TModel();
      KeyedReference kr = new KeyedReference();
      kr.setKeyName("testKeyName0");
      kr.setKeyValue("testKeyValue0");
      CategoryBag catBag = new CategoryBag();
      catBag.add(kr);
      tester.setCategoryBag(catBag);
      Vector tModelVector = new Vector();
      tModelVector.add(tester);
      try {
        _tModelDetail0 = proxy.save_tModel("JUNK",
                                           tModelVector);
        assertNotNull(null);
      }
      catch (TransportException ex) {
        fail(ex.toString());
      }
      catch (UDDIException ex) {
        DispositionReport disp = ex.getDispositionReport();
        assertFalse(disp.success());
  
        Vector results = disp.getResultVector();
        Result result = (Result)results.elementAt(0);
        ErrInfo errInfo = result.getErrInfo();
        assertEquals(errInfo.getErrCode(),DispositionReport.E_authTokenRequired);
      }
    }
  }
  
  
  

Mime
View raw message