package org.jboss.test.jaxr.read;
import org.jboss.test.jaxr.common.JaxrTestCase;
import javax.xml.registry.BulkResponse;
import javax.xml.registry.FindQualifier;
import javax.xml.registry.infomodel.Organization;
import javax.xml.registry.infomodel.Key;
import java.util.Collection;
import java.util.ArrayList;
import java.util.Iterator;
public class JaxrReadTestCase
extends JaxrTestCase {
public JaxrReadTestCase(String name) {
super(name);
}
public void testJaxrRead()
throws Exception {
if( connection == null ) connection = this.getConnection();
this.clearOrganizations("JBoss");
String key = this.createOrganization();
assertNotNull("Key Obtained from saving the Org is null?",key);
getOrgDetails( key );
}
protected void getOrgDetails( String orgid)
throws Exception {
String querystr = "JBoss";
if(bqm == null ) bqm = this.getBusinessQueryManager();
Collection findQualifiers = new ArrayList();
findQualifiers.add(FindQualifier.CASE_SENSITIVE_MATCH);
Collection namePatterns = new ArrayList();
namePatterns.add("%" + querystr + "%");
BulkResponse response =
bqm.findOrganizations(findQualifiers, namePatterns, null,
null, null, null);
Collection orgs = response.getCollection();
System.out.println("getOrgDetails:Found orgs="+orgs.size());
Iterator iter = orgs.iterator();
while( iter.hasNext()){
Organization org = (Organization)iter.next();
String key = org.getKey().getId();
System.out.println("Organization Key="+key);
assertNotNull("Org Key is null?",key);
}
}
}