Return-Path: Delivered-To: apmail-ws-scout-dev-archive@www.apache.org Received: (qmail 57693 invoked from network); 24 Dec 2004 03:23:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 24 Dec 2004 03:23:13 -0000 Received: (qmail 97553 invoked by uid 500); 24 Dec 2004 03:23:12 -0000 Delivered-To: apmail-ws-scout-dev-archive@ws.apache.org Received: (qmail 97532 invoked by uid 500); 24 Dec 2004 03:23:12 -0000 Mailing-List: contact scout-dev-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: scout-dev@ws.apache.org Delivered-To: mailing list scout-dev@ws.apache.org Received: (qmail 97518 invoked by uid 500); 24 Dec 2004 03:23:12 -0000 Delivered-To: apmail-ws-scout-cvs@ws.apache.org Received: (qmail 97515 invoked by uid 99); 24 Dec 2004 03:23:12 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Thu, 23 Dec 2004 19:23:11 -0800 Received: (qmail 57651 invoked by uid 65534); 24 Dec 2004 03:23:09 -0000 Date: 24 Dec 2004 03:23:09 -0000 Message-ID: <20041224032309.57648.qmail@minotaur.apache.org> From: anil@apache.org To: scout-cvs@ws.apache.org Subject: svn commit: r123268 - in webservices/scout/trunk/modules/scout/src/test/org/apache/ws/scout/registry: Delete Publish MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Author: anil Date: Thu Dec 23 19:23:08 2004 New Revision: 123268 URL: http://svn.apache.org/viewcvs?view=rev&rev=123268 Log: Addition of DeleteOrgTest. Added: webservices/scout/trunk/modules/scout/src/test/org/apache/ws/scout/registry/Delete/ webservices/scout/trunk/modules/scout/src/test/org/apache/ws/scout/registry/Delete/DeleteOrgTest.java Modified: webservices/scout/trunk/modules/scout/src/test/org/apache/ws/scout/registry/Publish/PublishConceptTest.java Added: webservices/scout/trunk/modules/scout/src/test/org/apache/ws/scout/registry/Delete/DeleteOrgTest.java Url: http://svn.apache.org/viewcvs/webservices/scout/trunk/modules/scout/src/test/org/apache/ws/scout/registry/Delete/DeleteOrgTest.java?view=auto&rev=123268 ============================================================================== --- (empty file) +++ webservices/scout/trunk/modules/scout/src/test/org/apache/ws/scout/registry/Delete/DeleteOrgTest.java Thu Dec 23 19:23:08 2004 @@ -0,0 +1,226 @@ +/** + * + * Copyright 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.ws.scout.registry.Delete; + +import junit.framework.TestCase; + +import javax.xml.registry.*; +import javax.xml.registry.infomodel.*; +import java.util.*; +import java.net.PasswordAuthentication; + +/** + * Tests Deleting Org in the UDDI Registry. + * Open source UDDI Browser + * can be used to check your results + * + * @author Anil Saldhana + * @since Dec 23, 2004 + */ +public class DeleteOrgTest extends TestCase +{ + private Connection connection = null; + //Tested on a local jboss instance + private String userid = "jboss"; + private String passwd = "jboss"; + private BusinessLifeCycleManager blm = null; + + public void setUp() + { + // Define connection configuration properties + // To query, you need only the query URL + Properties props = new Properties(); + props.setProperty("javax.xml.registry.queryManagerURL", + "http://localhost:8080/juddi/inquiry"); + props.setProperty("javax.xml.registry.lifeCycleManagerURL", + "http://localhost:8080/juddi/publish"); + props.setProperty("javax.xml.registry.factoryClass", + "org.apache.ws.scout.registry.ConnectionFactoryImpl"); + + try + { + // Create the connection, passing it the configuration properties + ConnectionFactory factory = ConnectionFactory.newInstance(); + factory.setProperties(props); + connection = factory.createConnection(); + } catch (JAXRException e) + { + e.printStackTrace(); + } + } + + public void tearDown() + { + try + { + if (connection != null) + connection.close(); + } catch (JAXRException e) + { + + } + } + + public void testDeleteOrg() + { + Key orgkey = null; + + login(); + try + { + RegistryService rs = connection.getRegistryService(); + + blm = rs.getBusinessLifeCycleManager(); + Collection orgs = new ArrayList(); + Organization org = createOrganization(); + + orgs.add(org); + BulkResponse br = blm.saveOrganizations(orgs); + orgkey = checkResult(br,"Saved"); + + //Delete Now + Collection col = new ArrayList(); + col.add(orgkey); + br = blm.deleteOrganizations(col); + checkResult(br,"deleted"); + } catch (JAXRException e) + { + e.printStackTrace(); + } + } + + private Key checkResult(BulkResponse br, String op) + throws JAXRException + { + Key orgkey = null; + if (br.getStatus() == JAXRResponse.STATUS_SUCCESS) + { + System.out.println("Organization "+op); + Collection coll = br.getCollection(); + Iterator iter = coll.iterator(); + while (iter.hasNext()) + { + Object obj = iter.next(); + System.out.println(obj.getClass().getName()); + Key key = (Key) obj; + orgkey = key; + System.out.println(op+" Key=" + key.getId()); + }//end while + } else + { + System.err.println("JAXRExceptions " + + "occurred during "+op+":"); + Collection exceptions = br.getExceptions(); + Iterator iter = exceptions.iterator(); + while (iter.hasNext()) + { + Exception e = (Exception) iter.next(); + System.err.println(e.toString()); + } + } + return orgkey; + } + + + /** + * Creates a Jaxr Organization with 1 or more services + * @return + * @throws JAXRException + */ + private Organization createOrganization() + throws JAXRException + { + Organization org = blm.createOrganization(getIString("USA")); + org.setDescription(getIString("Apache Software Foundation")); + Service service = blm.createService(getIString("Apache JAXR Service")); + service.setDescription(getIString("Services of UDDI Registry")); + User user = blm.createUser(); + org.setPrimaryContact(user); + PersonName personName = blm.createPersonName("Anil S"); + TelephoneNumber telephoneNumber = blm.createTelephoneNumber(); + telephoneNumber.setNumber("410-666-7777"); + telephoneNumber.setType(null); + PostalAddress address + = blm.createPostalAddress("1901", + "Munsey Drive", "Forest Hill", + "MD", "USA", "21050-2747", ""); + Collection postalAddresses = new ArrayList(); + postalAddresses.add(address); + Collection emailAddresses = new ArrayList(); + EmailAddress emailAddress = blm.createEmailAddress("anil@apache.org"); + emailAddresses.add(emailAddress); + + Collection numbers = new ArrayList(); + numbers.add(telephoneNumber); + user.setPersonName(personName); + user.setPostalAddresses(postalAddresses); + user.setEmailAddresses(emailAddresses); + user.setTelephoneNumbers(numbers); + + ClassificationScheme cScheme = getClassificationScheme("ntis-gov:naics", ""); + Key cKey = blm.createKey("uuid:C0B9FE13-324F-413D-5A5B-2004DB8E5CC2"); + cScheme.setKey(cKey); + Classification classification = blm.createClassification(cScheme, + "Computer Systems Design and Related Services", + "5415"); + org.addClassification(classification); + ClassificationScheme cScheme1 = getClassificationScheme("D-U-N-S", ""); + Key cKey1 = blm.createKey("uuid:3367C81E-FF1F-4D5A-B202-3EB13AD02423"); + cScheme1.setKey(cKey1); + ExternalIdentifier ei = + blm.createExternalIdentifier(cScheme1, "D-U-N-S number", + "08-146-6849"); + org.addExternalIdentifier(ei); + org.addService(service); + return org; + } + + + /** + * Does authentication with the uddi registry + */ + private void login() + { + PasswordAuthentication passwdAuth = new PasswordAuthentication(userid, + passwd.toCharArray()); + Set creds = new HashSet(); + creds.add(passwdAuth); + + try + { + connection.setCredentials(creds); + } catch (JAXRException e) + { + e.printStackTrace(); + } + } + + private InternationalString getIString(String str) + throws JAXRException + { + return blm.createInternationalString(str); + } + + private ClassificationScheme getClassificationScheme(String str1, String str2) + throws JAXRException + { + ClassificationScheme cs = blm.createClassificationScheme(getIString(str1), + getIString(str2)); + return cs; + } + +} Modified: webservices/scout/trunk/modules/scout/src/test/org/apache/ws/scout/registry/Publish/PublishConceptTest.java Url: http://svn.apache.org/viewcvs/webservices/scout/trunk/modules/scout/src/test/org/apache/ws/scout/registry/Publish/PublishConceptTest.java?view=diff&rev=123268&p1=webservices/scout/trunk/modules/scout/src/test/org/apache/ws/scout/registry/Publish/PublishConceptTest.java&r1=123267&p2=webservices/scout/trunk/modules/scout/src/test/org/apache/ws/scout/registry/Publish/PublishConceptTest.java&r2=123268 ============================================================================== --- webservices/scout/trunk/modules/scout/src/test/org/apache/ws/scout/registry/Publish/PublishConceptTest.java (original) +++ webservices/scout/trunk/modules/scout/src/test/org/apache/ws/scout/registry/Publish/PublishConceptTest.java Thu Dec 23 19:23:08 2004 @@ -34,6 +34,7 @@ public class PublishConceptTest extends TestCase { private Connection connection = null; + //Tested on a local jboss instance private String userid = "jboss"; private String passwd = "jboss"; private BusinessLifeCycleManager blm = null; --------------------------------------------------------------------- To unsubscribe, e-mail: scout-dev-unsubscribe@ws.apache.org For additional commands, e-mail: scout-dev-help@ws.apache.org