1 22 package org.jboss.test.jaxr.scout.publish; 23 24 25 import org.jboss.test.jaxr.scout.JaxrBaseTestCase; 26 27 import javax.xml.registry.BulkResponse ; 28 import javax.xml.registry.JAXRException ; 29 import javax.xml.registry.JAXRResponse ; 30 import javax.xml.registry.infomodel.Key ; 31 import javax.xml.registry.infomodel.Organization ; 32 import java.util.ArrayList ; 33 import java.util.Collection ; 34 import java.util.Iterator ; 35 36 42 43 public class JaxrSaveOrganizationTestCase extends JaxrBaseTestCase 44 { 45 private Key orgKey = null; 46 47 public void testSaveOrg() throws JAXRException 48 { 49 String keyid = ""; 50 login(); 51 try 52 { 53 rs = connection.getRegistryService(); 54 55 blm = rs.getBusinessLifeCycleManager(); 56 Collection orgs = new ArrayList (); 57 Organization org = createOrganization("JBOSS"); 58 59 orgs.add(org); 60 BulkResponse br = blm.saveOrganizations(orgs); 61 if (br.getStatus() == JAXRResponse.STATUS_SUCCESS) 62 { 63 if ("true".equalsIgnoreCase(debugProp)) 64 System.out.println("Organization Saved"); 65 Collection coll = br.getCollection(); 66 Iterator iter = coll.iterator(); 67 while (iter.hasNext()) 68 { 69 Key key = (Key ) iter.next(); 70 keyid = key.getId(); 71 if ("true".equalsIgnoreCase(debugProp)) 72 System.out.println("Saved Key=" + key.getId()); 73 assertNotNull(keyid); 74 } } else 76 { 77 System.err.println("JAXRExceptions " + 78 "occurred during save:"); 79 Collection exceptions = br.getExceptions(); 80 Iterator iter = exceptions.iterator(); 81 while (iter.hasNext()) 82 { 83 Exception e = (Exception ) iter.next(); 84 System.err.println(e.toString()); 85 fail(e.toString()); 86 } 87 } 88 } catch (JAXRException e) 89 { 90 e.printStackTrace(); 91 fail(e.getMessage()); 92 } 93 checkBusinessExists("JBOSS"); 94 } 95 96 private void checkBusinessExists(String bizname) 97 { 98 String request = "<find_business generic='2.0' xmlns='urn:uddi-org:api_v2'>" + 99 "<name xml:lang='en'>" + bizname + "</name></find_business>"; 100 String response = null; 101 try 102 { 103 response = rs.makeRegistrySpecificRequest(request); 104 } catch (Exception e) 105 { 106 fail(e.getLocalizedMessage()); 107 } 108 if (response == null || "".equals(response)) 109 fail("Find Business failed"); 110 111 } 112 113 protected void tearDown() throws Exception 114 { 115 super.tearDown(); 116 if(this.orgKey != null) 117 this.deleteOrganization(orgKey); 118 } 119 } 120 | Popular Tags |