01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22: package org.jboss.test.jaxr.scout.publish;
23:
24: import org.jboss.test.jaxr.scout.JaxrBaseTestCase;
25:
26: import javax.xml.registry.BulkResponse;
27: import javax.xml.registry.JAXRException;
28: import javax.xml.registry.JAXRResponse;
29: import javax.xml.registry.infomodel.Key;
30: import javax.xml.registry.infomodel.Organization;
31: import java.util.ArrayList;
32: import java.util.Collection;
33: import java.util.Iterator;
34:
35: /**
36: * Checks Deletion of Organization
37: *
38: * @author <mailto:Anil.Saldhana@jboss.org>Anil Saldhana
39: * @since Jan 3, 2005
40: */
41:
42: public class JaxrDeleteOrganizationTestCase extends JaxrBaseTestCase {
43:
44: public String saveOrg(String orgname) {
45: String keyid = "";
46: login();
47: try {
48: getJAXREssentials();
49: Collection orgs = new ArrayList();
50: Organization org = createOrganization("JBOSS");
51:
52: orgs.add(org);
53: BulkResponse br = blm.saveOrganizations(orgs);
54: if (br.getStatus() == JAXRResponse.STATUS_SUCCESS) {
55: if ("true".equalsIgnoreCase(debugProp))
56: System.out.println("Organization Saved");
57: Collection coll = br.getCollection();
58: Iterator iter = coll.iterator();
59: while (iter.hasNext()) {
60: Key key = (Key) iter.next();
61: keyid = key.getId();
62: if ("true".equalsIgnoreCase(debugProp))
63: System.out.println("Saved Key=" + key.getId());
64: assertNotNull(keyid);
65: }//end while
66: } else {
67: System.err.println("JAXRExceptions "
68: + "occurred during save:");
69: Collection exceptions = br.getExceptions();
70: Iterator iter = exceptions.iterator();
71: while (iter.hasNext()) {
72: Exception e = (Exception) iter.next();
73: System.err.println(e.toString());
74: fail(e.toString());
75: }
76: }
77: } catch (JAXRException e) {
78: e.printStackTrace();
79: fail(e.getMessage());
80: }
81: return keyid;
82: }
83:
84: public void testDeleteOrgs() throws Exception {
85: String keyid = this .saveOrg("DELETEORG");
86: assertNotNull(keyid);
87: Key key = blm.createKey(keyid);
88: this.deleteOrganization(key);
89: }
90: }
|