KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > jaxr > scout > query > JaxrBusinessQueryTestCase


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.query;
23
24 /** Tests Jaxr capability to do business queries
25  * @author <mailto:Anil.Saldhana@jboss.org>Anil Saldhana
26  * @since Dec 29, 2004
27  */

28
29 import java.util.ArrayList JavaDoc;
30 import java.util.Collection JavaDoc;
31 import java.util.Iterator JavaDoc;
32
33 import org.jboss.test.jaxr.scout.JaxrBaseTestCase;
34
35 import javax.xml.registry.BulkResponse JavaDoc;
36 import javax.xml.registry.JAXRException JavaDoc;
37 import javax.xml.registry.JAXRResponse JavaDoc;
38 import javax.xml.registry.infomodel.Key JavaDoc;
39 import javax.xml.registry.infomodel.Organization JavaDoc;
40
41 public class JaxrBusinessQueryTestCase extends JaxrBaseTestCase
42 {
43     protected String JavaDoc querystr = "JBOSS";
44     
45     private Key JavaDoc orgKey = null;
46     
47     protected void setUp() throws Exception JavaDoc
48     {
49        super.setUp();
50        String JavaDoc keyid = "";
51        login();
52        try
53        {
54            getJAXREssentials();
55            Collection JavaDoc orgs = new ArrayList JavaDoc();
56            Organization JavaDoc org = createOrganization("JBOSS");
57
58            orgs.add(org);
59            BulkResponse JavaDoc br = blm.saveOrganizations(orgs);
60            if (br.getStatus() == JAXRResponse.STATUS_SUCCESS)
61            {
62                Collection JavaDoc coll = br.getCollection();
63                Iterator JavaDoc iter = coll.iterator();
64                while (iter.hasNext())
65                {
66                    Key JavaDoc key = (Key JavaDoc) iter.next();
67                    keyid = key.getId();
68                    assertNotNull(keyid);
69                    orgKey = key;
70                }//end while
71
} else
72            {
73                Collection JavaDoc exceptions = br.getExceptions();
74                Iterator JavaDoc iter = exceptions.iterator();
75                while (iter.hasNext())
76                {
77                    Exception JavaDoc e = (Exception JavaDoc) iter.next();
78                    fail(e.toString());
79                }
80            }
81        } catch (JAXRException JavaDoc e)
82        {
83           e.printStackTrace();
84           fail(e.getMessage());
85        }
86     }
87     
88     protected void tearDown() throws Exception JavaDoc
89     {
90        if(orgKey != null)
91          this.deleteOrganization(this.orgKey);
92        super.tearDown();
93     }
94
95     public void testBusinessQuery() throws JAXRException JavaDoc
96     {
97         searchBusiness(querystr);
98     }
99 }
100
Popular Tags