You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by sv...@apache.org on 2003/11/11 13:59:20 UTC
cvs commit: ws-juddi/src/uddi4j/org/apache/juddi/uddi4j Configurator.java PublisherManager.java TestAddPublisherAssertion.java TestAll.java TestDiscardAuthToken.java TestFindBusiness.java TestSaveBusiness.java TestTModel.java Test_save_binding.java Test_save_tModel.java UDDITestBase.java samples.prop
sviens 2003/11/11 04:59:20
Added: src/uddi4j/org/apache/juddi/uddi4j Configurator.java
PublisherManager.java
TestAddPublisherAssertion.java TestAll.java
TestDiscardAuthToken.java TestFindBusiness.java
TestSaveBusiness.java TestTModel.java
Test_save_binding.java Test_save_tModel.java
UDDITestBase.java samples.prop
Log:
Moved from jUDDI CVS at SourceForge
Revision Changes Path
1.1 ws-juddi/src/uddi4j/org/apache/juddi/uddi4j/Configurator.java
Index: Configurator.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "jUDDI" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
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/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/src/uddi4j/org/apache/juddi/uddi4j/PublisherManager.java
Index: PublisherManager.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "jUDDI" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.juddi.uddi4j;
import java.util.Vector;
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;
/**
* @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) {
RegistryProxy proxy = new RegistryProxy();
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/src/uddi4j/org/apache/juddi/uddi4j/TestAddPublisherAssertion.java
Index: TestAddPublisherAssertion.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "jUDDI" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
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/src/uddi4j/org/apache/juddi/uddi4j/TestAll.java
Index: TestAll.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "jUDDI" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
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(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/src/uddi4j/org/apache/juddi/uddi4j/TestDiscardAuthToken.java
Index: TestDiscardAuthToken.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "jUDDI" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
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/src/uddi4j/org/apache/juddi/uddi4j/TestFindBusiness.java
Index: TestFindBusiness.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "jUDDI" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
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/src/uddi4j/org/apache/juddi/uddi4j/TestSaveBusiness.java
Index: TestSaveBusiness.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "jUDDI" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
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 <ra...@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/src/uddi4j/org/apache/juddi/uddi4j/TestTModel.java
Index: TestTModel.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "jUDDI" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
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;
public class TestTModel extends UDDITestBase {
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;
}
}
1.1 ws-juddi/src/uddi4j/org/apache/juddi/uddi4j/Test_save_binding.java
Index: Test_save_binding.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "jUDDI" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
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")) {
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/src/uddi4j/org/apache/juddi/uddi4j/Test_save_tModel.java
Index: Test_save_tModel.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "jUDDI" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
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");
}
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);
}
}
}
1.1 ws-juddi/src/uddi4j/org/apache/juddi/uddi4j/UDDITestBase.java
Index: UDDITestBase.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "jUDDI" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
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");
PublisherManager.createPublisher("juddi3", "juddi3");
PublisherManager.createPublisher("juddi4", "juddi4");
PublisherManager.createPublisher("expired", "expired");
// 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/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
# -----------------------------------------------------------------------
# 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
# -----------------------------------------------------------------------