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