KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > jaxr > scout > publish > JaxrDeleteOrganizationTestCase


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * 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 JavaDoc;
27 import javax.xml.registry.JAXRException JavaDoc;
28 import javax.xml.registry.JAXRResponse JavaDoc;
29 import javax.xml.registry.infomodel.Key JavaDoc;
30 import javax.xml.registry.infomodel.Organization JavaDoc;
31 import java.util.ArrayList JavaDoc;
32 import java.util.Collection JavaDoc;
33 import java.util.Iterator JavaDoc;
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
45     public String JavaDoc saveOrg(String JavaDoc orgname)
46     {
47         String JavaDoc keyid = "";
48         login();
49         try
50         {
51             getJAXREssentials();
52             Collection JavaDoc orgs = new ArrayList JavaDoc();
53             Organization JavaDoc org = createOrganization("JBOSS");
54
55             orgs.add(org);
56             BulkResponse JavaDoc br = blm.saveOrganizations(orgs);
57             if (br.getStatus() == JAXRResponse.STATUS_SUCCESS)
58             {
59                 if ("true".equalsIgnoreCase(debugProp))
60                     System.out.println("Organization Saved");
61                 Collection JavaDoc coll = br.getCollection();
62                 Iterator JavaDoc iter = coll.iterator();
63                 while (iter.hasNext())
64                 {
65                     Key JavaDoc key = (Key JavaDoc) iter.next();
66                     keyid = key.getId();
67                     if ("true".equalsIgnoreCase(debugProp))
68                         System.out.println("Saved Key=" + key.getId());
69                     assertNotNull(keyid);
70                 }//end while
71
} else
72             {
73                 System.err.println("JAXRExceptions " +
74                         "occurred during save:");
75                 Collection JavaDoc exceptions = br.getExceptions();
76                 Iterator JavaDoc iter = exceptions.iterator();
77                 while (iter.hasNext())
78                 {
79                     Exception JavaDoc e = (Exception JavaDoc) iter.next();
80                     System.err.println(e.toString());
81                     fail(e.toString());
82                 }
83             }
84         } catch (JAXRException JavaDoc e)
85         {
86             e.printStackTrace();
87             fail(e.getMessage());
88         }
89         return keyid;
90     }
91
92     public void testDeleteOrgs() throws Exception JavaDoc
93     {
94         String JavaDoc keyid = this.saveOrg("DELETEORG");
95         assertNotNull(keyid);
96         Key JavaDoc key = blm.createKey(keyid);
97         this.deleteOrganization(key);
98     }
99 }
100
Popular Tags