You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by ks...@apache.org on 2013/04/13 22:02:28 UTC

svn commit: r1467686 [1/2] - in /juddi/trunk: juddi-core/src/main/java/org/apache/juddi/api/impl/ juddi-core/src/main/java/org/apache/juddi/query/ juddi-core/src/test/java/org/apache/juddi/api/impl/ uddi-tck-base/src/main/resources/uddi_data/tompublish...

Author: kstam
Date: Sat Apr 13 20:02:27 2013
New Revision: 1467686

URL: http://svn.apache.org/r1467686
Log:
JUDDI-545 rewriting the way combinedCategories queries are implemented. For Businesses is now also looks at the categoryBags on the Bindings.

Added:
    juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_110_FindBusinessTest.java
    juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_120_CombineCategoryBagsFindServiceTest.java
    juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_130_CombineCategoryBagsFindBusinessTest.java
    juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business5.xml
    juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi545-business.xml
    juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_110_FindBusinessIntegrationTest.java
      - copied, changed from r1464796, juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_110_FindServicesIntegrationTest.java
Removed:
    juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_110_FindServicesIntegrationTest.java
Modified:
    juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/InquiryHelper.java
    juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindBusinessByCombinedCategoryQuery.java
    juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindEntityByCombinedCategoryQuery.java
    juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindServiceByCategoryQuery.java
    juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindServiceByCombinedCategoryQuery.java
    juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_040_BusinessServiceTest.java
    juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business1.xml
    juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_120_CombineCategoryBagsFindServiceIntegrationTest.java
    juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_130_CombineCategoryBagsFindBusinessIntegrationTest.java

Modified: juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/InquiryHelper.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/InquiryHelper.java?rev=1467686&r1=1467685&r2=1467686&view=diff
==============================================================================
--- juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/InquiryHelper.java (original)
+++ juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/InquiryHelper.java Sat Apr 13 20:02:27 2013
@@ -287,7 +287,7 @@ public class InquiryHelper {
 		doFindTModelEmbeddedSearch(em, body.getFindQualifiers(), body.getFindTModel(), body.getTModelBag());
 		
 		keysFound = FindServiceByTModelKeyQuery.select(em, findQualifiers, body.getTModelBag(), body.getBusinessKey(), keysFound);
-                if (findQualifiers.isCombineCategoryBags()) {
+        if (findQualifiers.isCombineCategoryBags()) {
 		    keysFound = FindServiceByCombinedCategoryQuery.select(em, findQualifiers, body.getCategoryBag(), body.getBusinessKey(), keysFound);
 		} else {
 			keysFound = FindServiceByCategoryQuery.select(em, findQualifiers, body.getCategoryBag(), body.getBusinessKey(), keysFound);

Modified: juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindBusinessByCombinedCategoryQuery.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindBusinessByCombinedCategoryQuery.java?rev=1467686&r1=1467685&r2=1467686&view=diff
==============================================================================
--- juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindBusinessByCombinedCategoryQuery.java (original)
+++ juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindBusinessByCombinedCategoryQuery.java Sat Apr 13 20:02:27 2013
@@ -49,8 +49,12 @@ import org.uddi.api_v3.CategoryBag;
  */
 public class FindBusinessByCombinedCategoryQuery {
         
-        private static final String ENTITY_NAME_CHILD = "BusinessCategoryBag";
-        private static final String ENTITY_NAME_CHILD2  = "ServiceCategoryBag";
+        private static final String ENTITY_NAME_CHILD  = "BusinessCategoryBag";
+        private static final String ENTITY_FIELD2      = "businessService." + BusinessEntityQuery.ENTITY_FIELD;
+        private static final String ENTITY_NAME_CHILD2 = "ServiceCategoryBag";
+        private static final String ENTITY_FIELD3      = "bindingTemplate.businessService." + BusinessEntityQuery.ENTITY_FIELD;
+        private static final String ENTITY_NAME_CHILD3 = "BindingCategoryBag";
+        
 
         private static FindEntityByCombinedCategoryQuery findQuery;
         
@@ -60,7 +64,10 @@ public class FindBusinessByCombinedCateg
                             BusinessEntityQuery.KEY_NAME, 
                             BusinessEntityQuery.ENTITY_FIELD, 
                             ENTITY_NAME_CHILD,
-                            ENTITY_NAME_CHILD2);
+                            ENTITY_FIELD2,
+                            ENTITY_NAME_CHILD2,
+                            ENTITY_FIELD3,
+                            ENTITY_NAME_CHILD3);
         }
         
         public static List<?> select(EntityManager em, FindQualifiers fq, CategoryBag categoryBag, List<?> keysIn) {

Modified: juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindEntityByCombinedCategoryQuery.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindEntityByCombinedCategoryQuery.java?rev=1467686&r1=1467685&r2=1467686&view=diff
==============================================================================
--- juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindEntityByCombinedCategoryQuery.java (original)
+++ juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindEntityByCombinedCategoryQuery.java Sat Apr 13 20:02:27 2013
@@ -18,18 +18,18 @@
 package org.apache.juddi.query;
 
 import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import javax.persistence.EntityManager;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.juddi.config.Constants;
 import org.apache.juddi.query.util.DynamicQuery;
 import org.apache.juddi.query.util.FindQualifiers;
-import org.apache.juddi.query.util.KeyedRefTModelComparator;
 import org.uddi.api_v3.CategoryBag;
 import org.uddi.api_v3.KeyedReference;
 
@@ -77,27 +77,31 @@ public class FindEntityByCombinedCategor
 	
 	@SuppressWarnings("unused")
 	private static Log log = LogFactory.getLog(FindEntityByCombinedCategoryQuery.class);
-
-	private static final String ENTITY_KEYEDREFERENCE = "KeyedReference";
-	private static final String ALIAS_KEYEDREFERENCE = buildAlias(ENTITY_KEYEDREFERENCE);
-	private static final String FIELD_CATEGORYBAG = "categoryBag";
-	
-	private String joinClause;
-	private String currentAlias;
 	
+	protected String entityField2;
 	protected String entityNameChild2;
 	protected String entityAliasChild2;
+	
+	protected String entityField3;
+	protected String entityNameChild3;
+	protected String entityAliasChild3;
 
 	public FindEntityByCombinedCategoryQuery(String entityName, String entityAlias, String keyName, String entityField, String entityNameChild) {
 		super(entityName, entityAlias, keyName, entityField, entityNameChild);
 	}
 	
 	public FindEntityByCombinedCategoryQuery(String entityName, String entityAlias, String keyName, String entityField, String entityNameChild,
-			String entityNameChild2) {
+			String entityField2, String entityNameChild2, String entityField3, String entityNameChild3) {
 		super(entityName, entityAlias, keyName, entityField, entityNameChild);
 		
 		this.entityNameChild2 = entityNameChild2;
 		this.entityAliasChild2 = buildAlias(entityNameChild2);
+		this.entityField2 = entityField2;
+		if (entityNameChild3!=null) {
+			this.entityField3 = entityField3;
+			this.entityNameChild3 = entityNameChild3;
+			this.entityAliasChild3 = buildAlias(entityNameChild3);
+		}
 		
 		selectSQL = "";
 	}
@@ -109,284 +113,115 @@ public class FindEntityByCombinedCategor
 	public String getEntityAliasChild2() {
 		return entityAliasChild2;
 	}
+	
+	public String getEntityNameChild3() {
+		return entityNameChild3;
+	}
+	
+	public String getEntityAliasChild3() {
+		return entityAliasChild3;
+	}
 		
 	public List<?> select(EntityManager em, FindQualifiers fq, CategoryBag categoryBag, List<?> keysIn, DynamicQuery.Parameter... restrictions) {
-	        StringBuffer queryOne = new StringBuffer(200);
-                StringBuffer queryTwo = new StringBuffer(200);
-	    
-                // If keysIn is not null and empty, then search is over.
+	        
+        // If keysIn is not null and empty, then search is over.
 		if ((keysIn != null) && (keysIn.size() == 0))
 			return keysIn;
 		
 		if (categoryBag == null)
 			return keysIn;
 		
-		List<KeyedReference> categories = categoryBag.getKeyedReference();
-		if (categories == null || categories.size() == 0)
+		List<KeyedReference> keyRefsInCategories = categoryBag.getKeyedReference();
+		if (keyRefsInCategories == null || keyRefsInCategories.size() == 0)
 			return keysIn;
 		
-		queryOne.append("select " + entityAlias + "." + keyName + ", " + entityAliasChild + ".id "
-	                    + "from " + entityName + " " + entityAlias + ", " + entityNameChild + " " + entityAliasChild + " ");
-		
-		ArrayList<List> aggregatedResultsOne = new ArrayList<List>();
-                ArrayList<List> aggregatedResultsTwo = new ArrayList<List>();
-
-		for (KeyedReference elem : categories) {
-		    List<KeyedReference> keyedRefs = new ArrayList<KeyedReference>(0);
-
-		    if (elem instanceof KeyedReference)
-			keyedRefs.add((KeyedReference)elem);
-	            DynamicQuery dynamicQry = new DynamicQuery(queryOne.toString());
-	            currentAlias = entityAliasChild;
-	            joinClause = entityAlias + "." + keyName + " = "
-	                + entityAliasChild + "." + entityField + "." + keyName + " ";
-	            appendConditions(dynamicQry, fq, keyedRefs);
-	            if (restrictions != null && restrictions.length > 0)
-	                dynamicQry.AND().pad().appendGroupedAnd(restrictions);
-
-	            if (keyedRefs.size() != 0) {
-	                List list = getQueryResult(em, dynamicQry, keysIn, entityAlias + "." + keyName);
-	                aggregatedResultsOne.addAll(list);
-	            }
-		}		
-
-	        queryTwo.append("select  " + entityAlias + "." + keyName + ", " + entityAliasChild2 + ".id "
-	                + "from " + entityName + " " + entityAlias + ", " + entityNameChild + " " + entityAliasChild + ", "
-	                + entityNameChild2 + " " + entityAliasChild2 + " ");
-
-                for (KeyedReference elem : categories) {
-                    List<KeyedReference> keyedRefs = new ArrayList<KeyedReference>(0);
-
-                    if (elem instanceof KeyedReference)
-                        keyedRefs.add((KeyedReference)elem);
-                    DynamicQuery dynamicQry = new DynamicQuery(queryTwo.toString());
-                    currentAlias = entityAliasChild2;
-                    
-                    if (BusinessEntityQuery.ENTITY_NAME.equals(entityName)) {
-                        joinClause = entityAlias + ".entityKey" + " = "
-                        + entityAliasChild + "." + entityField + ".entityKey" + " and "
-                        + entityAliasChild + "." + entityField + ".entityKey" + " = "
-                        + entityAliasChild2 + ".businessService.businessEntity.entityKey";
-                    } else {
-                        joinClause = entityAlias + ".entityKey" + " = "
-                            + entityAliasChild + "." + entityField + ".entityKey" + " and "
-                            + entityAliasChild + "." + entityField + ".entityKey" + " = "
-                            + entityAliasChild2 + ".bindingTemplate.businessService.entityKey";
-                    }
-
-                    appendConditions(dynamicQry, fq, keyedRefs);
-                    if (restrictions != null && restrictions.length > 0)
-                        dynamicQry.AND().pad().appendGroupedAnd(restrictions);
-
-                    if (keyedRefs.size() != 0) {
-                        List list = getQueryResult(em, dynamicQry, keysIn, entityAlias + "." + keyName);
-                        aggregatedResultsTwo.addAll(list);
-                    }
-                }               
-
-                ArrayList results = new ArrayList();
-                if (BusinessServiceQuery.ENTITY_NAME.equals(entityName)) {
-                    ArrayList idsOne = new ArrayList();
-                    ArrayList idsTwo = new ArrayList();
-                    
-                    for (Iterator i = aggregatedResultsOne.iterator(); i.hasNext();) {
-                        Object[] l = (Object[]) i.next();
-                        String id = (String) l[0];
-                        idsOne.add(id);
-                    }
-                    for (Iterator i = aggregatedResultsTwo.iterator(); i.hasNext();) {
-                        Object[] l = (Object[]) i.next();
-                        String id = (String) l[0];
-                        idsTwo.add(id);
-                    }
-                    
-                    results.addAll(idsOne);
-                    results.retainAll(idsTwo);
-                } else if (BusinessEntityQuery.ENTITY_NAME.equals(entityName)) {
-                    ArrayList idsOne = new ArrayList();
-                    ArrayList idsTwo = new ArrayList();
-
-                    for (Iterator i = aggregatedResultsOne.iterator(); i.hasNext();) {
-                        Object[] l = (Object[]) i.next();
-                        String id = (String) l[0];
-                        idsOne.add(id);                        
-                    }
-                    for (Iterator i = aggregatedResultsTwo.iterator(); i.hasNext();) {
-                        Object[] l = (Object[]) i.next();
-                        String id = (String) l[0];
-                        idsTwo.add(id);
-                    }
-                    
-                    results.addAll(idsOne);
-                    results.retainAll(idsTwo);                    
-                }
-                		
-		return results;
-	}
-	
-	
-	/*
-	 * Appends the conditions to the query based on the keyedReference list.  With the default or when "orAllKeys" is passed, the keyedReferences are autonomous and are
-	 * all AND'd or OR'd respectively.  However, "orLikeKeys" requires special treatment.  The goal is to create the conditions in this format:
-	 * 
-	 * (likeKey1 = X or likeKey1 = Y) and (likeKey2 = A or likeKey2 = B or likeKey2 = C) 
-	 * 
-	 * ie. the "like" KeyedReferences are OR'd and the groups of "like" KeyedReferences are AND'd with each other.
-	 */
-	public void appendConditions(DynamicQuery qry, FindQualifiers fq, List<KeyedReference> keyedRefs) {
-		
-		// Append the necessary tables (two will always be added connecting the entity to its category table and then the category table to the keyed references).
-		appendJoinTables(qry, fq, keyedRefs);
-		qry.AND().pad().openParen().pad();
-		
-		String predicate = DynamicQuery.PREDICATE_EQUALS;
-		if (fq.isApproximateMatch()) {
-			predicate = DynamicQuery.PREDICATE_LIKE;
+		Map<KeyedReference,Set<String>> map  = new HashMap<KeyedReference,Set<String>>();
+		//1. First match at the top level (i.e. categoryBag on business)
+		findEntityByCategoryQuery(map, em, fq, categoryBag, entityField, entityNameChild, keysIn, restrictions);
+		//2. Now match at the second level (i.e. categoryBag on services for businesses)
+		findEntityByCategoryQuery(map, em, fq, categoryBag, entityField2, entityNameChild2, keysIn, restrictions);
+		//3. Now match at the third level (i.e. categoryBag on binding for businesses)
+		//   This does only apply to businesses (not for services)
+		if (entityNameChild3!=null) {
+			findEntityByCategoryQuery(map, em, fq, categoryBag, entityField3, entityNameChild3, keysIn, restrictions);
 		}
 		
-		// Sorting the collection by tModel Key
-		Collections.sort(keyedRefs, new KeyedRefTModelComparator());
-
-		String prevTModelKey = null;
-		int count = 0;
-		int tblCount = -1;
-		for(KeyedReference keyedRef : keyedRefs) {
-			String tmodelKey = keyedRef.getTModelKey();
-			String keyValue = keyedRef.getKeyValue();
-			String keyName = keyedRef.getKeyName();
-			
-			if (fq.isApproximateMatch()) {
-				// JUDDI-235: wildcards are provided by user (only commenting in case a new interpretation arises)
-				//keyValue = keyValue.endsWith(DynamicQuery.WILDCARD)?keyValue:keyValue + DynamicQuery.WILDCARD;
-				//keyName = keyName.endsWith(DynamicQuery.WILDCARD)?keyName:keyName + DynamicQuery.WILDCARD;
-			}
-
-			// Either opening up (and AND'ing) a new "group" of like keys or simply appending an "or".  If this is not "orLikeKeys", then just need to increment
-			// the table count.
-			if (fq.isOrLikeKeys()) {
-				if (count == 0) {
-					qry.openParen().pad();
-					tblCount++;
+		//Now build the results taking into account AND/OR/LIKE
+		Set<String> resultingEntityKeys = new HashSet<String>();
+		if (fq.isOrAllKeys()) {
+			//in this case get ALL businessKeys
+			for (KeyedReference keyRef: map.keySet()) {
+				resultingEntityKeys.addAll(map.get(keyRef));
+			}
+		} else if (fq.isOrLikeKeys()) {
+			// any keyedReference filters that come from the same namespace (e.g. have the same tModelKey value) 
+			// are OR’d together rather than AND’d
+			// 1. OR if we have keys with similar namespaces (keyValue)
+			Map<String,Set<String>> likeMap  = new HashMap<String,Set<String>>();
+			for (KeyedReference keyRef: map.keySet()) {
+				String keyValue = keyRef.getKeyValue();
+				if (likeMap.containsKey(keyValue)) {
+					likeMap.get(keyValue).addAll(map.get(keyRef));
+				} else {
+					likeMap.put(keyValue, map.get(keyRef));
 				}
-				else {
-					if (!tmodelKey.equals(prevTModelKey)) {
-						qry.closeParen().pad().AND().pad().openParen().pad();
-						tblCount++;
-					}
-					else
-						qry.OR().pad();
-				}
-			}
-			else
-				tblCount++;
-			
-			String keyValueTerm = (fq.isOrAllKeys()?ALIAS_KEYEDREFERENCE + "0":ALIAS_KEYEDREFERENCE + tblCount) + ".keyValue";
-			String keyNameTerm = (fq.isOrAllKeys()?ALIAS_KEYEDREFERENCE + "0":ALIAS_KEYEDREFERENCE + tblCount) + ".keyName";
-			String tmodelKeyTerm = (fq.isOrAllKeys()?ALIAS_KEYEDREFERENCE + "0":ALIAS_KEYEDREFERENCE + tblCount) + ".tmodelKeyRef";
-			if (fq.isCaseInsensitiveMatch()) {
-				keyValueTerm = "upper(" + keyValueTerm + ")";
-				keyValue = keyValue.toUpperCase();
-				
-				keyNameTerm = "upper(" + keyNameTerm + ")";
-				keyName = keyName.toUpperCase();
-			}
-			
-			
-			// According to specification, if the "general keyword" tmodel is used, then the keyName must be part of the query.
-			if (Constants.GENERAL_KEYWORD_TMODEL.equalsIgnoreCase(tmodelKey)) {
-				qry.appendGroupedAnd(new DynamicQuery.Parameter(tmodelKeyTerm, tmodelKey, DynamicQuery.PREDICATE_EQUALS),
-									 new DynamicQuery.Parameter(keyValueTerm, keyValue, predicate),
-									 new DynamicQuery.Parameter(keyNameTerm, keyName, predicate));
 			}
-			else {
-				qry.appendGroupedAnd(new DynamicQuery.Parameter(tmodelKeyTerm, tmodelKey, DynamicQuery.PREDICATE_EQUALS),
-									 new DynamicQuery.Parameter(keyValueTerm, keyValue, predicate));
-				
+			// 2. Now AND the likeMap
+			boolean firstTime = true;
+			for (String keyValue: likeMap.keySet()) {
+				if (firstTime) {
+					resultingEntityKeys = map.get(keyValue);
+					firstTime = false;
+				} else {
+					resultingEntityKeys.retainAll(map.get(keyValue));
+				}
 			}
-			
-			if (count + 1 < keyedRefs.size()) {
-				if (fq.isOrAllKeys())
-					qry.OR().pad();
-				else if (fq.isOrLikeKeys()) {
+		} else {
+			// AND keys by default, in this case each entity (business or service)
+			// needs to have ALL keys
+			boolean firstTime = true;
+			for (KeyedReference keyRef: map.keySet()) {
+				if (firstTime) {
+					resultingEntityKeys = map.get(keyRef);
+					firstTime = false;
+				} else {
+					resultingEntityKeys.retainAll(map.get(keyRef));
 				}
-				else
-					qry.AND().pad();
 			}
-			
-			// The "orLikeKeys" will always leave an unclosed parenthesis.  This will close it.
-			if (fq.isOrLikeKeys() && (count + 1 == keyedRefs.size()))
-				qry.closeParen().pad();
-
-			prevTModelKey = tmodelKey;
-			count++;
 		}
-		qry.closeParen().pad();
-		
+		return new ArrayList<String>(resultingEntityKeys);
 	}
-
-	
-	
-	/*
-	 * Appends the necessary join table for the child entity and additional tables for when keys are AND'd.  When "orLikeKeys" is used, 
-	 * we only need an extra table for each distinct tmodelKey.
+	/**
+	 * Finding the entities (businesses or services) that have a matching keyedReference in their
+	 * categoryBag.
+	 * 
+	 * @param map - result map of keyedReference and matching businesses
+	 * @param em
+	 * @param fq
+	 * @param categoryBag
+	 * @param entityField
+	 * @param entityNameChild
+	 * @param keysIn
+	 * @param restrictions
 	 */
-	public void appendJoinTables(DynamicQuery qry, FindQualifiers fq, List<KeyedReference> keyedRefs) {
-		
-		if (keyedRefs != null && keyedRefs.size() > 0) {
-			// Sorting the collection by tModel Key
-			Collections.sort(keyedRefs, new KeyedRefTModelComparator());
-
-			StringBuffer thetaJoins = new StringBuffer(200);
-			int tblCount = 0;
-			int count = 0;
-			String curTModelKey = null;
-			String prevTModelKey = null;
-			for(KeyedReference kr : keyedRefs) {
-				curTModelKey = kr.getTModelKey();
-				if (count != 0) {
-					if (!fq.isOrAllKeys()) {
-						if (fq.isOrLikeKeys() && curTModelKey.equals(prevTModelKey)) {
-							// Do nothing
-						}
-						else {
-							tblCount++;
-							qry.comma().pad().append(ENTITY_KEYEDREFERENCE + " " + ALIAS_KEYEDREFERENCE + tblCount).pad();
-							thetaJoins.append(ALIAS_KEYEDREFERENCE + (tblCount - 1) + "." + FIELD_CATEGORYBAG + ".id = " + ALIAS_KEYEDREFERENCE + tblCount + "." + FIELD_CATEGORYBAG + ".id ");
-					//		thetaJoins.append(DynamicQuery.OPERATOR_AND + " ");
-						}
-					}
-
-				}
-				else {
-					qry.comma().pad().append(ENTITY_KEYEDREFERENCE + " " + ALIAS_KEYEDREFERENCE + tblCount).pad();
-					//thetaJoins.append(" ( ");
-                                        thetaJoins.append(DynamicQuery.OPERATOR_AND + " ");
-					thetaJoins.append(currentAlias + ".id = " + ALIAS_KEYEDREFERENCE + tblCount + "." + FIELD_CATEGORYBAG + ".id ");
-					//thetaJoins.append(DynamicQuery.OPERATOR_OR + " ");
-					//thetaJoins.append(entityAliasChild2 + ".id = " + ALIAS_KEYEDREFERENCE + tblCount + "." + FIELD_CATEGORYBAG + ".id ");
-					///thetaJoins.append(" ) ");
-					thetaJoins.append(DynamicQuery.OPERATOR_AND + " ");
-					
-				}
-				prevTModelKey = curTModelKey;
-				count++;
+	private void findEntityByCategoryQuery(Map<KeyedReference,Set<String>> map, EntityManager em, 
+			FindQualifiers fq, CategoryBag categoryBag, String entityField, String entityNameChild, 
+			List<?> keysIn, DynamicQuery.Parameter... restrictions) 
+	{
+		FindEntityByCategoryQuery findEntityByCategoryQuery2 = new FindEntityByCategoryQuery(
+				entityName, entityAlias, keyName, entityField, entityNameChild);
+		for (KeyedReference keyedReference : categoryBag.getKeyedReference()) {
+			CategoryBag categoryBagWithOneKey = new CategoryBag();
+			categoryBagWithOneKey.getKeyedReference().add(keyedReference);
+			List<?> entityKeys =  findEntityByCategoryQuery2.select(
+					em, fq, categoryBagWithOneKey, keysIn, restrictions);
+			@SuppressWarnings({ "unchecked", "rawtypes" })
+			Set<String> keySet = new HashSet(entityKeys);
+			if (map.containsKey(keyedReference)) {
+				map.get(keyedReference).addAll(keySet);
+			} else {
+				map.put(keyedReference, keySet);
 			}
-			
-			qry.WHERE().pad().openParen().pad();
-			
-                        qry.append(joinClause).pad();
-
-			
-			// Appending the middling entity-specific category table condition
-			//qry.append(entityAlias + "." + keyName + " = " + entityAliasChild + "." + entityField + "." + KEY_NAME).pad();
-//			qry.AND().pad();
-
-			String thetaJoinsStr = thetaJoins.toString();
-			if (thetaJoinsStr.endsWith(DynamicQuery.OPERATOR_AND + " "))
-				thetaJoinsStr = thetaJoinsStr.substring(0, thetaJoinsStr.length() - (DynamicQuery.OPERATOR_AND + " ").length());
-			qry.append(thetaJoinsStr);
-
-			qry.closeParen().pad();
 		}
 	}
 	

Modified: juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindServiceByCategoryQuery.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindServiceByCategoryQuery.java?rev=1467686&r1=1467685&r2=1467686&view=diff
==============================================================================
--- juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindServiceByCategoryQuery.java (original)
+++ juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindServiceByCategoryQuery.java Sat Apr 13 20:02:27 2013
@@ -52,7 +52,8 @@ public class FindServiceByCategoryQuery 
 	
 	public static List<?> select(EntityManager em, FindQualifiers fq, CategoryBag categoryBag, String parentKey, List<?> keysIn) {
 		if (parentKey != null && parentKey.length() > 0) {
-			DynamicQuery.Parameter param = new DynamicQuery.Parameter(BusinessServiceQuery.ENTITY_ALIAS + "." + BusinessServiceQuery.KEY_NAME_PARENT, parentKey, DynamicQuery.PREDICATE_EQUALS); 
+			DynamicQuery.Parameter param = new DynamicQuery.Parameter(BusinessServiceQuery.ENTITY_ALIAS + "." 
+					+ BusinessServiceQuery.KEY_NAME_PARENT, parentKey, DynamicQuery.PREDICATE_EQUALS); 
 			return findQuery.select(em, fq, categoryBag, keysIn, param);
 		}
 		else

Modified: juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindServiceByCombinedCategoryQuery.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindServiceByCombinedCategoryQuery.java?rev=1467686&r1=1467685&r2=1467686&view=diff
==============================================================================
--- juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindServiceByCombinedCategoryQuery.java (original)
+++ juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindServiceByCombinedCategoryQuery.java Sat Apr 13 20:02:27 2013
@@ -38,12 +38,16 @@ import org.uddi.api_v3.CategoryBag;
  * and bindingTemplate elements were combined.  Searching for a category will yield a positive match on a registered 
  * business if any of the categoryBag elements contained within the full businessEntity element (including the 
  * categoryBag elements within contained or referenced businessService elements or bindingTemplate elements) 
- * contains the filter criteria.  In the case of find_service, this qualifier makes the categoryBag entries 
+ * contains the filter criteria. 
+ * 
+ * In the case of find_service, this qualifier makes the categoryBag entries 
  * for the full businessService element behave as though all categoryBag elements found at the businessService level 
  * and in all contained or referenced elements in the bindingTemplate elements were combined.  Searching for a category 
  * will yield a positive match on a registered service if any of the categoryBag elements contained within the 
  * full businessService element (including the categoryBag elements within contained or referenced bindingTemplate 
- * elements) contains the filter criteria. This find qualifier does not cause the keyedReferences in categoryBags 
+ * elements) contains the filter criteria. 
+ * 
+ * This find qualifier does not cause the keyedReferences in categoryBags 
  * to be combined with the keyedReferences in keyedReferenceGroups in categoryBags when performing the comparison.  
  * The keyedReferences are combined with each other, and the keyedReferenceGroups are combined with each other."
  * 
@@ -54,17 +58,21 @@ import org.uddi.api_v3.CategoryBag;
 public class FindServiceByCombinedCategoryQuery {
 	
 	private static final String ENTITY_NAME_CHILD  = "ServiceCategoryBag";
+	private static final String ENTITY_FIELD2      = "bindingTemplate." + BusinessServiceQuery.ENTITY_FIELD;
 	private static final String ENTITY_NAME_CHILD2 = "BindingCategoryBag";
 	
 	private static FindEntityByCombinedCategoryQuery findQuery;
 	
 	static {
 		findQuery = new FindEntityByCombinedCategoryQuery(BusinessServiceQuery.ENTITY_NAME, 
-				BusinessServiceQuery.ENTITY_ALIAS, 
-				BusinessServiceQuery.KEY_NAME, 
-				BusinessServiceQuery.ENTITY_FIELD, 
-				ENTITY_NAME_CHILD,
-				ENTITY_NAME_CHILD2);
+														  BusinessServiceQuery.ENTITY_ALIAS, 
+														  BusinessServiceQuery.KEY_NAME, 
+														  BusinessServiceQuery.ENTITY_FIELD, 
+														  ENTITY_NAME_CHILD,
+														  ENTITY_FIELD2,
+														  ENTITY_NAME_CHILD2,
+														  null,
+														  null);
 	}
 	
 	public static List<?> select(EntityManager em, FindQualifiers fq, CategoryBag categoryBag, String parentKey, List<?> keysIn) {
@@ -75,15 +83,4 @@ public class FindServiceByCombinedCatego
 		else
 			return findQuery.select(em, fq, categoryBag, keysIn);
 	}
-	
-//	select service.entity_key, scb.id from juddiv3.j3_business_service service 
-//	join juddiv3.j3_service_category_bag scb on service.entity_key = scb.entity_key, 
-//	juddiv3.j3_keyed_reference kr0, juddiv3.j3_keyed_reference kr1 
-//	where (kr0.category_bag_id=scb.id and kr0.tmodel_key_ref='uddi:uddi.joepublisher.com:tmodel01' and kr0.key_value='value-z') or (kr1.category_bag_id=scb.id and
-//	kr1.tmodel_key_ref='uddi:uddi.joepublisher.com:tmodel02' and kr1.key_value='value-x') group by  service.entity_key, scb.id UNION
-//	select service.entity_key, bcb.id from juddiv3.j3_business_service service join juddiv3.j3_binding_template bt on service.entity_key = bt.service_key join
-//	juddiv3.j3_binding_category_bag bcb on bt.entity_key = bcb.entity_key,
-//	juddiv3.j3_keyed_reference kr0, juddiv3.j3_keyed_reference kr1 
-//	where (kr0.category_bag_id=bcb.id and kr0.tmodel_key_ref='uddi:uddi.joepublisher.com:tmodel01' and kr0.key_value='value-z') or (kr1.category_bag_id=bcb.id and
-//	kr1.tmodel_key_ref='uddi:uddi.joepublisher.com:tmodel02' and kr1.key_value='value-x') group by  service.entity_key, bcb.id ;
 }

Modified: juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_040_BusinessServiceTest.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_040_BusinessServiceTest.java?rev=1467686&r1=1467685&r2=1467686&view=diff
==============================================================================
--- juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_040_BusinessServiceTest.java (original)
+++ juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_040_BusinessServiceTest.java Sat Apr 13 20:02:27 2013
@@ -52,7 +52,6 @@ public class API_040_BusinessServiceTest
 	private static TckTModel tckTModel               = new TckTModel(new UDDIPublicationImpl(), new UDDIInquiryImpl());
 	private static TckBusiness tckBusiness           = new TckBusiness(new UDDIPublicationImpl(), new UDDIInquiryImpl());
 	private static TckBusinessService tckBusinessService  = new TckBusinessService(new UDDIPublicationImpl(), new UDDIInquiryImpl());
-	private static TckFindEntity tckFindEntity            = new TckFindEntity(new UDDIInquiryImpl());
 	
 	private static String authInfoJoe                = null;
 	private static String authInfoSam                = null;

Added: juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_110_FindBusinessTest.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_110_FindBusinessTest.java?rev=1467686&view=auto
==============================================================================
--- juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_110_FindBusinessTest.java (added)
+++ juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_110_FindBusinessTest.java Sat Apr 13 20:02:27 2013
@@ -0,0 +1,140 @@
+package org.apache.juddi.api.impl;
+
+/*
+ * Copyright 2001-2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.List;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.juddi.Registry;
+import org.apache.juddi.v3.tck.TckBusiness;
+import org.apache.juddi.v3.tck.TckPublisher;
+import org.apache.juddi.v3.tck.TckSecurity;
+import org.apache.juddi.v3.tck.TckTModel;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.uddi.api_v3.BusinessInfo;
+import org.uddi.api_v3.BusinessList;
+import org.uddi.api_v3.FindBusiness;
+import org.uddi.api_v3.ServiceInfo;
+import org.uddi.api_v3.TModelBag;
+import org.uddi.v3_service.UDDISecurityPortType;
+
+/**
+ * Test to verify JUDDI-398
+ * 
+ * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>
+ */
+public class API_110_FindBusinessTest 
+{
+	final static String TOM_PUBLISHER_TMODEL_XML      = "uddi_data/tompublisher/tModelKeyGen.xml";
+	final static String TOM_PUBLISHER_TMODEL01_XML 	  = "uddi_data/tompublisher/tModel01.xml";
+	final static String TOM_PUBLISHER_TMODEL02_XML 	  = "uddi_data/tompublisher/tModel02.xml";
+
+	final static String TOM_PUBLISHER_TMODEL_KEY      = "uddi:uddi.tompublisher.com:keygenerator";
+	final static String TOM_PUBLISHER_TMODEL01_KEY      = "uddi:uddi.tompublisher.com:tmodeltest01";
+	final static String TOM_PUBLISHER_TMODEL01_NAME 	= "tmodeltest01";
+	final static String TOM_PUBLISHER_TMODEL02_KEY      = "uddi:uddi.tompublisher.com:tmodeltest02";
+
+	final static String TOM_BUSINESS_XML        = "uddi_data/tompublisher/businessEntity.xml";
+    final static String TOM_BUSINESS_KEY        = "uddi:uddi.tompublisher.com:businesstest01";
+	
+    final static String TOM_PUBLISHER_SERVICEINFO_NAME = "servicetest01";
+    
+    private static Log logger = LogFactory.getLog(API_110_FindBusinessTest.class);
+	
+    private static API_010_PublisherTest api010       = new API_010_PublisherTest();
+    private static TckTModel tckTModel                = new TckTModel(new UDDIPublicationImpl(), new UDDIInquiryImpl());
+    private static TckBusiness tckBusiness            = new TckBusiness(new UDDIPublicationImpl(), new UDDIInquiryImpl());
+    private static UDDIInquiryImpl inquiry            = new UDDIInquiryImpl();
+	protected static String authInfoJoe               = null;
+
+	@AfterClass
+	public static void stopManager() throws ConfigurationException {
+		Registry.stop();
+	}
+	
+	@BeforeClass
+	public static void startManager() throws ConfigurationException {
+		Registry.start();
+		
+		logger.debug("Getting auth tokens..");
+		try {
+			api010.saveJoePublisher();
+			api010.saveSamSyndicator();
+			UDDISecurityPortType security      = new UDDISecurityImpl();
+        	 authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(),  TckPublisher.getJoePassword());
+        	 Assert.assertNotNull(authInfoJoe);
+    
+	     } catch (Exception e) {
+	    	 logger.error(e.getMessage(), e);
+				Assert.fail("Could not obtain authInfo token.");
+	     } 
+	}
+	
+	@Test
+	public void findBusinessByTModelBag() {
+		try {
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
+			
+			tckBusiness.saveBusinesses(authInfoJoe, TOM_BUSINESS_XML, TOM_BUSINESS_KEY, 1);
+			
+			try {
+				int size = 0;
+				BusinessList bl = null;
+	
+				FindBusiness fbb = new FindBusiness();
+				TModelBag tmb = new TModelBag();
+				tmb.getTModelKey().add(TOM_PUBLISHER_TMODEL01_KEY);
+				fbb.setTModelBag(tmb);
+				bl = inquiry.findBusiness(fbb);
+				size = bl.getBusinessInfos().getBusinessInfo().size();
+				if (size != 1) {
+					Assert.fail("Should have found one entry on FindBusiness with TModelBag, "
+							+ "found " + size);
+				} else {
+					List<BusinessInfo> biList = bl.getBusinessInfos().getBusinessInfo();
+					if (biList.get(0).getServiceInfos().getServiceInfo().size() != 2) {
+						Assert.fail("Should have found two ServiceInfos");
+					} else {
+							List<ServiceInfo> siList = biList.get(0).getServiceInfos().getServiceInfo();
+							ServiceInfo si = siList.get(0);
+							if (!TOM_PUBLISHER_SERVICEINFO_NAME.equals(si.getName().get(0).getValue())) {
+								Assert.fail("Should have found " + TOM_PUBLISHER_TMODEL01_NAME + " as the "
+										+ "ServiceInfo name, found " + si.getName().get(0).getValue());
+							}
+					}
+				}
+			} catch (Exception e) {
+				e.printStackTrace();
+				Assert.fail(e.getMessage());
+			}
+		} finally {
+			tckBusiness.deleteBusinesses(authInfoJoe, TOM_BUSINESS_XML, TOM_BUSINESS_KEY, 1);
+			
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
+
+		}
+	}
+	
+}

Added: juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_120_CombineCategoryBagsFindServiceTest.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_120_CombineCategoryBagsFindServiceTest.java?rev=1467686&view=auto
==============================================================================
--- juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_120_CombineCategoryBagsFindServiceTest.java (added)
+++ juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_120_CombineCategoryBagsFindServiceTest.java Sat Apr 13 20:02:27 2013
@@ -0,0 +1,271 @@
+package org.apache.juddi.api.impl;
+
+/*
+ * Copyright 2001-2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.List;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.juddi.Registry;
+import org.apache.juddi.v3.client.UDDIConstants;
+import org.apache.juddi.v3.tck.TckBusiness;
+import org.apache.juddi.v3.tck.TckPublisher;
+import org.apache.juddi.v3.tck.TckSecurity;
+import org.apache.juddi.v3.tck.TckTModel;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.uddi.api_v3.CategoryBag;
+import org.uddi.api_v3.FindQualifiers;
+import org.uddi.api_v3.FindService;
+import org.uddi.api_v3.KeyedReference;
+import org.uddi.api_v3.ServiceInfo;
+import org.uddi.api_v3.ServiceList;
+import org.uddi.v3_service.UDDISecurityPortType;
+
+/**
+ * Test to verify JUDDI-456
+ * 
+ * Test does a find_service with the combinedCategoryBags findQualifier set, expects
+ * back one service with a serviceKey of uddi:uddi.tompublisher.com:servicetest02.
+ * 
+ * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>
+ */
+public class API_120_CombineCategoryBagsFindServiceTest 
+{
+    final static String TOM_PUBLISHER_TMODEL_XML      = "uddi_data/tompublisher/tModelKeyGen.xml";
+    final static String TOM_PUBLISHER_TMODEL01_XML 	  = "uddi_data/tompublisher/tModel01.xml";
+    final static String TOM_PUBLISHER_TMODEL02_XML 	  = "uddi_data/tompublisher/tModel02.xml";
+
+    final static String TOM_PUBLISHER_TMODEL_KEY      = "uddi:uddi.tompublisher.com:keygenerator";
+    final static String TOM_PUBLISHER_TMODEL01_KEY    = "uddi:uddi.tompublisher.com:tmodeltest01";
+    final static String TOM_PUBLISHER_TMODEL01_NAME   = "tmodeltest01";
+    final static String TOM_PUBLISHER_TMODEL02_KEY    = "uddi:uddi.tompublisher.com:tmodeltest02";
+
+    final static String TOM_BUSINESS1_XML       = "uddi_data/tompublisher/juddi456-business1.xml";
+    final static String TOM_BUSINESS2_XML       = "uddi_data/tompublisher/juddi456-business2.xml";
+    final static String TOM_BUSINESS5_XML       = "uddi_data/tompublisher/juddi456-business5.xml";
+    final static String TOM_BUSINESS1_KEY       = "uddi:uddi.tompublisher.com:businesstest01";
+    final static String TOM_BUSINESS2_KEY       = "uddi:uddi.tompublisher.com:businesstest02";
+    final static String TOM_BUSINESS5_KEY       = "uddi:uddi.tompublisher.com:businesstest05";
+
+    final static String SERVICE_KEY1 = "uddi:uddi.tompublisher.com:servicetest01";
+    final static String SERVICE_KEY5 = "uddi:uddi.tompublisher.com:servicetest05";
+    
+    final static String TOM_PUBLISHER_SERVICEINFO_NAME = "servicetest01";
+    
+    private static Log logger = LogFactory.getLog(API_120_CombineCategoryBagsFindServiceTest.class);
+	
+    private static API_010_PublisherTest api010       = new API_010_PublisherTest();
+    private static TckTModel tckTModel                = new TckTModel(new UDDIPublicationImpl(), new UDDIInquiryImpl());
+    private static TckBusiness tckBusiness            = new TckBusiness(new UDDIPublicationImpl(), new UDDIInquiryImpl());
+    private static UDDIInquiryImpl inquiry            = new UDDIInquiryImpl();
+	protected static String authInfoJoe               = null;
+	
+	@AfterClass
+	public static void stopManager() throws ConfigurationException {
+		Registry.stop();
+	}
+	
+	@BeforeClass
+	public static void startManager() throws ConfigurationException {
+		Registry.start();
+		
+		logger.debug("Getting auth tokens..");
+		try {
+			api010.saveJoePublisher();
+			api010.saveSamSyndicator();
+			UDDISecurityPortType security      = new UDDISecurityImpl();
+        	 authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(),  TckPublisher.getJoePassword());
+        	 Assert.assertNotNull(authInfoJoe);
+    
+	     } catch (Exception e) {
+	    	 logger.error(e.getMessage(), e);
+				Assert.fail("Could not obtain authInfo token.");
+	     } 
+	}
+	
+	@Test
+	public void findServiceByCategoryBag() {
+		try {
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
+			
+			tckBusiness.saveBusinesses(authInfoJoe, TOM_BUSINESS1_XML, TOM_BUSINESS1_KEY, 1);
+			tckBusiness.saveBusinesses(authInfoJoe, TOM_BUSINESS2_XML, TOM_BUSINESS2_KEY, 1);
+			tckBusiness.saveBusinesses(authInfoJoe, TOM_BUSINESS5_XML, TOM_BUSINESS5_KEY, 1);
+			try {
+				int size = 0;
+				ServiceList sl = null;
+
+				FindService fs = new FindService();
+				
+				//by default keys are ADD, we should only find service 5
+                KeyedReference keyRef1 = new KeyedReference();
+                keyRef1.setTModelKey(TOM_PUBLISHER_TMODEL01_KEY);
+                keyRef1.setKeyValue("value-z");
+                
+                KeyedReference keyRef2 = new KeyedReference();
+                keyRef2.setTModelKey(TOM_PUBLISHER_TMODEL02_KEY);
+				keyRef2.setKeyValue("value-x");
+				
+				CategoryBag cb = new CategoryBag();
+				cb.getKeyedReference().add(keyRef1);
+				cb.getKeyedReference().add(keyRef2);
+				fs.setCategoryBag(cb);
+				
+				sl = inquiry.findService(fs);
+				if (sl.getServiceInfos() == null) {
+                    Assert.fail("Should have found one entry on FindService with TModelBag, "
+                       + "found " + size);
+				}
+				size = sl.getServiceInfos().getServiceInfo().size();
+				if (size != 1) {
+					Assert.fail("Should have found one entry on FindService with TModelBag, "
+							+ "found " + size);
+				} else {
+				    List<ServiceInfo> siList = sl.getServiceInfos().getServiceInfo();
+					String serviceKey = siList.get(0).getServiceKey();
+					if (!SERVICE_KEY5.equals(serviceKey)) {
+					    Assert.fail("Should have found service key " + SERVICE_KEY5
+					            + " but found [" + serviceKey + "]");
+					}
+				}
+			} catch (Exception e) {
+				e.printStackTrace();
+				Assert.fail(e.getMessage());
+			}
+		} finally {
+            tckBusiness.deleteBusinesses(authInfoJoe, TOM_BUSINESS1_XML, TOM_BUSINESS1_KEY, 1);
+            tckBusiness.deleteBusinesses(authInfoJoe, TOM_BUSINESS2_XML, TOM_BUSINESS2_KEY, 1);
+            tckBusiness.deleteBusinesses(authInfoJoe, TOM_BUSINESS5_XML, TOM_BUSINESS5_KEY, 1);
+			
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
+		}
+	}
+	
+	@Test
+	public void findNoServiceByCategoryBag() {
+		try {
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
+			
+			tckBusiness.saveBusinesses(authInfoJoe, TOM_BUSINESS1_XML, TOM_BUSINESS1_KEY, 1);
+			tckBusiness.saveBusinesses(authInfoJoe, TOM_BUSINESS2_XML, TOM_BUSINESS2_KEY, 1);
+			tckBusiness.saveBusinesses(authInfoJoe, TOM_BUSINESS5_XML, TOM_BUSINESS5_KEY, 1);
+			try {
+				int size = 0;
+				ServiceList sl = null;
+
+				FindService fs = new FindService();
+				
+				//by default keys are ADD, we should only find service 5
+                KeyedReference keyRef1 = new KeyedReference();
+                keyRef1.setTModelKey(TOM_PUBLISHER_TMODEL01_KEY);
+                keyRef1.setKeyValue("value-y");
+               
+				CategoryBag cb = new CategoryBag();
+				cb.getKeyedReference().add(keyRef1);
+				fs.setCategoryBag(cb);
+				
+				sl = inquiry.findService(fs);
+				if (sl.getServiceInfos() != null) {
+                    Assert.fail("Should have found no entries on FindService, "
+                       + " found " + size);
+				}
+			} catch (Exception e) {
+				e.printStackTrace();
+				Assert.fail(e.getMessage());
+			}
+		} finally {
+            tckBusiness.deleteBusinesses(authInfoJoe, TOM_BUSINESS1_XML, TOM_BUSINESS1_KEY, 1);
+            tckBusiness.deleteBusinesses(authInfoJoe, TOM_BUSINESS2_XML, TOM_BUSINESS2_KEY, 1);
+            tckBusiness.deleteBusinesses(authInfoJoe, TOM_BUSINESS5_XML, TOM_BUSINESS5_KEY, 1);
+			
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
+		}
+	}
+	/*
+	 * For a combinedCategoryBag, we find a service if either the categoryBag on the service
+	 * matches, or one of the categoryBags on the bindings.
+	 */
+	@Test
+	public void findServiceByCombinedCategoryBag() {
+		try {
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
+			
+			tckBusiness.saveBusinesses(authInfoJoe, TOM_BUSINESS1_XML, TOM_BUSINESS1_KEY, 1);
+			tckBusiness.saveBusinesses(authInfoJoe, TOM_BUSINESS2_XML, TOM_BUSINESS2_KEY, 1);
+			try {
+				int size = 0;
+				ServiceList sl = null;
+
+				FindService fs = new FindService();
+				FindQualifiers fqs = new FindQualifiers();
+				fqs.getFindQualifier().add(UDDIConstants.COMBINE_CATEGORY_BAGS);
+				fs.setFindQualifiers(fqs);
+
+                KeyedReference keyRef1 = new KeyedReference();
+                keyRef1.setTModelKey(TOM_PUBLISHER_TMODEL01_KEY);
+                keyRef1.setKeyValue("value-y");
+				
+				CategoryBag cb = new CategoryBag();
+				cb.getKeyedReference().add(keyRef1);
+				fs.setCategoryBag(cb);
+				
+				sl = inquiry.findService(fs);
+				if (sl.getServiceInfos() == null) {
+                    Assert.fail("Should have found one entry on FindService with TModelBag, "
+                       + "found " + size);
+				}
+				size = sl.getServiceInfos().getServiceInfo().size();
+				if (size != 1) {
+					Assert.fail("Should have found one entry on FindService with TModelBag, "
+							+ "found " + size);
+				} else {
+				    List<ServiceInfo> siList = sl.getServiceInfos().getServiceInfo();
+					String serviceKey = siList.get(0).getServiceKey();
+					if (!SERVICE_KEY1.equals(serviceKey)) {
+					    Assert.fail("Should have found service key " + SERVICE_KEY1
+					            + " but found [" + serviceKey + "]");
+					}
+				}
+			} catch (Exception e) {
+				e.printStackTrace();
+				Assert.fail(e.getMessage());
+			}
+		} finally {
+            tckBusiness.deleteBusinesses(authInfoJoe, TOM_BUSINESS1_XML, TOM_BUSINESS1_KEY, 1);
+            tckBusiness.deleteBusinesses(authInfoJoe, TOM_BUSINESS2_XML, TOM_BUSINESS2_KEY, 1);
+			
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
+		}
+	}
+	
+}

Added: juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_130_CombineCategoryBagsFindBusinessTest.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_130_CombineCategoryBagsFindBusinessTest.java?rev=1467686&view=auto
==============================================================================
--- juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_130_CombineCategoryBagsFindBusinessTest.java (added)
+++ juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_130_CombineCategoryBagsFindBusinessTest.java Sat Apr 13 20:02:27 2013
@@ -0,0 +1,230 @@
+package org.apache.juddi.api.impl;
+
+/*
+ * Copyright 2001-2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.List;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.juddi.Registry;
+import org.apache.juddi.v3.tck.TckBusiness;
+import org.apache.juddi.v3.tck.TckPublisher;
+import org.apache.juddi.v3.tck.TckSecurity;
+import org.apache.juddi.v3.tck.TckTModel;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.uddi.api_v3.BusinessInfo;
+import org.uddi.api_v3.BusinessList;
+import org.uddi.api_v3.CategoryBag;
+import org.uddi.api_v3.FindBusiness;
+import org.uddi.api_v3.FindQualifiers;
+import org.uddi.api_v3.KeyedReference;
+import org.uddi.v3_service.UDDISecurityPortType;
+
+/**
+ * Test to verify JUDDI-456, does a findBusiness query with combineCategoryBags findQualifier.
+ * 
+ * Expected result is one returned businessEntity with a businessKey of uddi:uddi.tompublisher.com:businesstest04
+ * 
+ * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>
+ */
+public class API_130_CombineCategoryBagsFindBusinessTest 
+{
+	final static String TOM_PUBLISHER_TMODEL_XML      = "uddi_data/tompublisher/tModelKeyGen.xml";
+	final static String TOM_PUBLISHER_TMODEL01_XML 	  = "uddi_data/tompublisher/tModel01.xml";
+	final static String TOM_PUBLISHER_TMODEL02_XML 	  = "uddi_data/tompublisher/tModel02.xml";
+
+	final static String TOM_PUBLISHER_TMODEL_KEY      = "uddi:uddi.tompublisher.com:keygenerator";
+	final static String TOM_PUBLISHER_TMODEL01_KEY      = "uddi:uddi.tompublisher.com:tmodeltest01";
+	final static String TOM_PUBLISHER_TMODEL01_NAME 	= "tmodeltest01";
+	final static String TOM_PUBLISHER_TMODEL02_KEY      = "uddi:uddi.tompublisher.com:tmodeltest02";
+
+	final static String TOM_BUSINESS1_XML       = "uddi_data/tompublisher/juddi456-business3.xml";
+	final static String TOM_BUSINESS2_XML       = "uddi_data/tompublisher/juddi456-business4.xml";
+	final static String TOM_BUSINESS545_XML       = "uddi_data/tompublisher/juddi545-business.xml";
+
+	final static String TOM_BUSINESS1_KEY        = "uddi:uddi.tompublisher.com:businesstest03";
+	final static String TOM_BUSINESS2_KEY        = "uddi:uddi.tompublisher.com:businesstest04";
+	final static String TOM_BUSINESS545_KEY        = "uddi:uddi.tompublisher.com:businesstest545";
+
+	final static String BUSINESS_KEY    = "uddi:uddi.tompublisher.com:businesstest04";
+	final static String BUSINESS_KEY545 = "uddi:uddi.tompublisher.com:businesstest545";
+
+	private static Log logger = LogFactory.getLog(API_130_CombineCategoryBagsFindBusinessTest.class);
+
+	private static API_010_PublisherTest api010       = new API_010_PublisherTest();
+    private static TckTModel tckTModel                = new TckTModel(new UDDIPublicationImpl(), new UDDIInquiryImpl());
+    private static TckBusiness tckBusiness      = new TckBusiness(new UDDIPublicationImpl(), new UDDIInquiryImpl());
+    private static UDDIInquiryImpl inquiry             = new UDDIInquiryImpl();
+    
+	protected static String authInfoJoe                = null;
+
+	@AfterClass
+	public static void stopManager() throws ConfigurationException {
+		Registry.stop();
+	}
+	
+	@BeforeClass
+	public static void startManager() throws ConfigurationException {
+		Registry.start();
+		
+		logger.debug("Getting auth tokens..");
+		try {
+			api010.saveJoePublisher();
+			api010.saveSamSyndicator();
+			UDDISecurityPortType security      = new UDDISecurityImpl();
+        	 authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(),  TckPublisher.getJoePassword());
+        	 Assert.assertNotNull(authInfoJoe);
+    
+	     } catch (Exception e) {
+	    	 logger.error(e.getMessage(), e);
+				Assert.fail("Could not obtain authInfo token.");
+	     } 
+	}
+	
+	@Test
+	public void findBusiness() {
+		try {
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
+
+			tckBusiness.saveBusiness(authInfoJoe, TOM_BUSINESS1_XML, TOM_BUSINESS1_KEY);
+			tckBusiness.saveBusiness(authInfoJoe, TOM_BUSINESS2_XML, TOM_BUSINESS2_KEY);
+			try {
+				int size = 0;
+				BusinessList bl = null;
+
+				FindBusiness fb = new FindBusiness();
+				FindQualifiers fqs = new FindQualifiers();
+				fqs.getFindQualifier().add("combineCategoryBags");
+				fb.setFindQualifiers(fqs);
+
+				KeyedReference keyRef1 = new KeyedReference();
+				keyRef1.setTModelKey(TOM_PUBLISHER_TMODEL01_KEY);
+				keyRef1.setKeyValue("value-z");
+
+				KeyedReference keyRef2 = new KeyedReference();
+				keyRef2.setTModelKey(TOM_PUBLISHER_TMODEL02_KEY);
+				keyRef2.setKeyValue("value-x");
+
+				CategoryBag cb = new CategoryBag();
+				cb.getKeyedReference().add(keyRef1);
+				cb.getKeyedReference().add(keyRef2);
+				fb.setCategoryBag(cb);
+
+				bl = inquiry.findBusiness(fb);
+				if (bl.getBusinessInfos() == null) {
+					Assert.fail("Should have found one entry on FindBusiness with TModelBag, "
+							+ "found " + size);
+				}
+				size = bl.getBusinessInfos().getBusinessInfo().size();
+				if (size != 1) {
+					Assert.fail("Should have found one entry on FindBusiness with TModelBag, "
+							+ "found " + size);
+				} else {
+					List<BusinessInfo> biList = bl.getBusinessInfos().getBusinessInfo();
+					String businessKey = biList.get(0).getBusinessKey();
+					if (!BUSINESS_KEY.equals(businessKey)) {
+						Assert.fail("Should have found business key " + BUSINESS_KEY
+								+ " but found [" + businessKey + "]");
+					}
+				}
+			} catch (Exception e) {
+				e.printStackTrace();
+				Assert.fail(e.getMessage());
+			}
+		} finally {
+			tckBusiness.deleteBusiness(authInfoJoe, TOM_BUSINESS1_XML, TOM_BUSINESS1_KEY);
+			tckBusiness.deleteBusiness(authInfoJoe, TOM_BUSINESS2_XML, TOM_BUSINESS2_KEY);
+
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
+
+		}
+	}
+	
+	@Test
+	public void findBusinessJUDDI545() {
+		try {
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
+
+			tckBusiness.saveBusiness(authInfoJoe, TOM_BUSINESS545_XML, TOM_BUSINESS545_KEY);
+			
+			try {
+				int size = 0;
+				BusinessList bl = null;
+
+				FindBusiness fb = new FindBusiness();
+				FindQualifiers fqs = new FindQualifiers();
+				fqs.getFindQualifier().add("combineCategoryBags");
+				fb.setFindQualifiers(fqs);
+
+				KeyedReference keyRef1 = new KeyedReference();
+				keyRef1.setTModelKey(TOM_PUBLISHER_TMODEL01_KEY);
+				keyRef1.setKeyValue("value-z");
+
+				KeyedReference keyRef2 = new KeyedReference();
+				keyRef2.setTModelKey(TOM_PUBLISHER_TMODEL02_KEY);
+				keyRef2.setKeyValue("value-x");
+				
+				KeyedReference keyRef3 = new KeyedReference();
+				keyRef3.setTModelKey(TOM_PUBLISHER_TMODEL01_KEY);
+				keyRef3.setKeyValue("value-y");
+
+				CategoryBag cb = new CategoryBag();
+				cb.getKeyedReference().add(keyRef1);
+				cb.getKeyedReference().add(keyRef2);
+				cb.getKeyedReference().add(keyRef3);
+				fb.setCategoryBag(cb);
+
+				bl = inquiry.findBusiness(fb);
+				if (bl.getBusinessInfos() == null) {
+					Assert.fail("Should have found one entry on FindBusiness with TModelBag, "
+							+ "found " + size);
+				}
+				size = bl.getBusinessInfos().getBusinessInfo().size();
+				if (size != 1) {
+					Assert.fail("Should have found one entry on FindBusiness with TModelBag, "
+							+ "found " + size);
+				} else {
+					List<BusinessInfo> biList = bl.getBusinessInfos().getBusinessInfo();
+					String businessKey = biList.get(0).getBusinessKey();
+					if (!BUSINESS_KEY545.equals(businessKey)) {
+						Assert.fail("Should have found business key " + BUSINESS_KEY545
+								+ " but found [" + businessKey + "]");
+					}
+				}
+			} catch (Exception e) {
+				e.printStackTrace();
+				Assert.fail(e.getMessage());
+			}
+		} finally {
+			tckBusiness.deleteBusiness(authInfoJoe, TOM_BUSINESS545_XML, TOM_BUSINESS545_KEY);
+
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
+
+		}
+	}	
+}

Modified: juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business1.xml
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business1.xml?rev=1467686&r1=1467685&r2=1467686&view=diff
==============================================================================
--- juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business1.xml (original)
+++ juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business1.xml Sat Apr 13 20:02:27 2013
@@ -30,7 +30,7 @@
                     </bindingTemplate> 
                 </bindingTemplates> 
                 <categoryBag> 
-                    <keyedReference tModelKey="uddi:uddi.tompublisher.com:tmodeltest02" keyValue="value-x"/> 
+                    <keyedReference tModelKey="uddi:uddi.tompublisher.com:tmodeltest02" keyValue="value-z"/> 
                 </categoryBag> 
             </businessService> 
         </businessServices> 

Added: juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business5.xml
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business5.xml?rev=1467686&view=auto
==============================================================================
--- juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business5.xml (added)
+++ juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business5.xml Sat Apr 13 20:02:27 2013
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright 2001-2009 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */ -->
+
+<businessEntity xmlns="urn:uddi-org:api_v3" xmlns:xml="http://www.w3.org/XML/1998/namespace" businessKey="uddi:uddi.tompublisher.com:businesstest05"> 
+        <name>businesstest05</name> 
+        <businessServices> 
+            <businessService serviceKey="uddi:uddi.tompublisher.com:servicetest05"> 
+                <name>servicetest05</name> 
+                <bindingTemplates> 
+                    <bindingTemplate bindingKey="uddi:uddi.tompublisher.com:bindingtest05"> 
+                        <accessPoint>http://genericaccesspoint.com</accessPoint>
+                        <categoryBag> 
+                            <keyedReference tModelKey="uddi:uddi.tompublisher.com:tmodeltest01" keyValue="value-y"/> 
+                        </categoryBag>
+                    </bindingTemplate> 
+                </bindingTemplates> 
+                <categoryBag>
+                    <keyedReference tModelKey="uddi:uddi.tompublisher.com:tmodeltest01" keyValue="value-z"/>
+                    <keyedReference tModelKey="uddi:uddi.tompublisher.com:tmodeltest02" keyValue="value-x"/>
+                </categoryBag>
+            </businessService> 
+        </businessServices> 
+        <categoryBag>
+            <keyedReference tModelKey="uddi:uddi.tompublisher.com:tmodeltest01" keyValue="value-y"/>
+        </categoryBag>
+</businessEntity> 
+
+

Added: juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi545-business.xml
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi545-business.xml?rev=1467686&view=auto
==============================================================================
--- juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi545-business.xml (added)
+++ juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi545-business.xml Sat Apr 13 20:02:27 2013
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright 2001-2009 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */ -->
+<businessEntity xmlns="urn:uddi-org:api_v3" xmlns:xml="http://www.w3.org/XML/1998/namespace" 
+    businessKey="uddi:uddi.tompublisher.com:businesstest545">
+        <name>businesstest545</name>
+        <businessServices>
+            <businessService serviceKey="uddi:uddi.tompublisher.com:servicetest01">
+                <name>servicetest01</name>
+                <bindingTemplates>
+                    <bindingTemplate bindingKey="uddi:uddi.tompublisher.com:bindingtest01">
+                        <accessPoint>http://genericaccesspoint.com</accessPoint>
+                        <categoryBag>
+                            <keyedReference tModelKey="uddi:uddi.tompublisher.com:tmodeltest01" keyValue="value-z"/>
+                        </categoryBag>
+                    </bindingTemplate>
+                    <bindingTemplate bindingKey="uddi:uddi.tompublisher.com:bindingtest02">
+                        <accessPoint>http://genericaccesspoint2.com</accessPoint>
+                        <categoryBag>
+                            <keyedReference tModelKey="uddi:uddi.tompublisher.com:tmodeltest02" keyValue="value-x"/>
+                        </categoryBag>
+                    </bindingTemplate>
+               </bindingTemplates>
+            </businessService>
+        </businessServices>
+        <categoryBag>
+            <keyedReference tModelKey="uddi:uddi.tompublisher.com:tmodeltest01" keyValue="value-y"/>
+        </categoryBag>
+</businessEntity>

Copied: juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_110_FindBusinessIntegrationTest.java (from r1464796, juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_110_FindServicesIntegrationTest.java)
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_110_FindBusinessIntegrationTest.java?p2=juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_110_FindBusinessIntegrationTest.java&p1=juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_110_FindServicesIntegrationTest.java&r1=1464796&r2=1467686&rev=1467686&view=diff
==============================================================================
--- juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_110_FindServicesIntegrationTest.java (original)
+++ juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_110_FindBusinessIntegrationTest.java Sat Apr 13 20:02:27 2013
@@ -40,7 +40,7 @@ import org.uddi.v3_service.UDDISecurityP
  * 
  * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>
  */
-public class UDDI_110_FindServicesIntegrationTest 
+public class UDDI_110_FindBusinessIntegrationTest 
 {
 	final static String TOM_PUBLISHER_TMODEL_XML      = "uddi_data/tompublisher/tModelKeyGen.xml";
 	final static String TOM_PUBLISHER_TMODEL01_XML 	  = "uddi_data/tompublisher/tModel01.xml";
@@ -100,11 +100,11 @@ public class UDDI_110_FindServicesIntegr
 	}
 	
 	@Test
-	public void tompublisher() {
+	public void findBusinessByTModelBag() {
 		try {
 			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
-			tckTModel01.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
-			tckTModel02.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
 			
 			tckBusiness.saveBusinesses(authInfoJoe, TOM_BUSINESS_XML, TOM_BUSINESS_KEY, 1);
 			
@@ -142,8 +142,8 @@ public class UDDI_110_FindServicesIntegr
 			tckBusiness.deleteBusinesses(authInfoJoe, TOM_BUSINESS_XML, TOM_BUSINESS_KEY, 1);
 			
 			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
-			tckTModel01.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
-			tckTModel02.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
 
 		}
 	}

Modified: juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_120_CombineCategoryBagsFindServiceIntegrationTest.java
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_120_CombineCategoryBagsFindServiceIntegrationTest.java?rev=1467686&r1=1467685&r2=1467686&view=diff
==============================================================================
--- juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_120_CombineCategoryBagsFindServiceIntegrationTest.java (original)
+++ juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_120_CombineCategoryBagsFindServiceIntegrationTest.java Sat Apr 13 20:02:27 2013
@@ -20,6 +20,7 @@ import java.util.List;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.juddi.v3.client.UDDIConstants;
 import org.apache.juddi.v3.client.config.UDDIClerkManager;
 import org.apache.juddi.v3.client.transport.Transport;
 import org.junit.AfterClass;
@@ -61,21 +62,21 @@ public class UDDI_120_CombineCategoryBag
 
     final static String TOM_BUSINESS1_XML       = "uddi_data/tompublisher/juddi456-business1.xml";
     final static String TOM_BUSINESS2_XML       = "uddi_data/tompublisher/juddi456-business2.xml";
+    final static String TOM_BUSINESS5_XML       = "uddi_data/tompublisher/juddi456-business5.xml";
     final static String TOM_BUSINESS1_KEY        = "uddi:uddi.tompublisher.com:businesstest01";
     final static String TOM_BUSINESS2_KEY        = "uddi:uddi.tompublisher.com:businesstest02";
+    final static String TOM_BUSINESS5_KEY       = "uddi:uddi.tompublisher.com:businesstest05";
 
-    final static String SERVICE_KEY = "uddi:uddi.tompublisher.com:servicetest02";
+    final static String SERVICE_KEY1 = "uddi:uddi.tompublisher.com:servicetest01";
+    final static String SERVICE_KEY5 = "uddi:uddi.tompublisher.com:servicetest05";
     
     final static String TOM_PUBLISHER_SERVICEINFO_NAME = "servicetest01";
     
-    private static Log logger = LogFactory.getLog(UDDI_040_BusinessServiceIntegrationTest.class);
+    private static Log logger = LogFactory.getLog(UDDI_120_CombineCategoryBagsFindServiceIntegrationTest.class);
 	
 	protected static TckTModel tckTModel               = null;
-	protected static TckTModel tckTModel01             = null;
-	protected static TckTModel tckTModel02             = null;	
+	protected static TckBusiness tckBusiness           = null;
 	
-	protected static TckBusiness tckBusiness1          = null;
-	protected static TckBusiness tckBusiness2          = null;
 	protected static String authInfoJoe                = null;
 	
 	private static UDDIInquiryPortType inquiry = null;
@@ -101,10 +102,7 @@ public class UDDI_120_CombineCategoryBag
         	 inquiry = transport.getUDDIInquiryService();
         	 
         	 tckTModel  = new TckTModel(publication, inquiry);
-        	 tckTModel01 = new TckTModel(publication, inquiry);
-        	 tckTModel02 = new TckTModel(publication, inquiry);
-        	 tckBusiness1 = new TckBusiness(publication, inquiry);
-        	 tckBusiness2 = new TckBusiness(publication, inquiry); 
+        	 tckBusiness = new TckBusiness(publication, inquiry);
 	     } catch (Exception e) {
 	    	 logger.error(e.getMessage(), e);
 				Assert.fail("Could not obtain authInfo token.");
@@ -112,29 +110,28 @@ public class UDDI_120_CombineCategoryBag
 	}
 	
 	@Test
-	public void tompublisher() {
+	public void findServiceByCategoryBag() {
 		try {
 			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
-			tckTModel01.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
-			tckTModel02.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
 			
-			tckBusiness1.saveBusinesses(authInfoJoe, TOM_BUSINESS1_XML, TOM_BUSINESS1_KEY, 1);
-			tckBusiness2.saveBusinesses(authInfoJoe, TOM_BUSINESS2_XML, TOM_BUSINESS2_KEY, 1);
+			tckBusiness.saveBusinesses(authInfoJoe, TOM_BUSINESS1_XML, TOM_BUSINESS1_KEY, 1);
+			tckBusiness.saveBusinesses(authInfoJoe, TOM_BUSINESS2_XML, TOM_BUSINESS2_KEY, 1);
+			tckBusiness.saveBusinesses(authInfoJoe, TOM_BUSINESS5_XML, TOM_BUSINESS5_KEY, 1);
 			try {
 				int size = 0;
 				ServiceList sl = null;
 
 				FindService fs = new FindService();
-				FindQualifiers fqs = new FindQualifiers();
-				fqs.getFindQualifier().add("combineCategoryBags");
-				fs.setFindQualifiers(fqs);
-
-	                        KeyedReference keyRef1 = new KeyedReference();
-	                        keyRef1.setTModelKey(TOM_PUBLISHER_TMODEL01_KEY);
-	                        keyRef1.setKeyValue("value-z");
-	                        
-	                        KeyedReference keyRef2 = new KeyedReference();
-	                        keyRef2.setTModelKey(TOM_PUBLISHER_TMODEL02_KEY);
+				
+				//by default keys are ADD, we should only find service 5
+                KeyedReference keyRef1 = new KeyedReference();
+                keyRef1.setTModelKey(TOM_PUBLISHER_TMODEL01_KEY);
+                keyRef1.setKeyValue("value-z");
+                
+                KeyedReference keyRef2 = new KeyedReference();
+                keyRef2.setTModelKey(TOM_PUBLISHER_TMODEL02_KEY);
 				keyRef2.setKeyValue("value-x");
 				
 				CategoryBag cb = new CategoryBag();
@@ -144,18 +141,18 @@ public class UDDI_120_CombineCategoryBag
 				
 				sl = inquiry.findService(fs);
 				if (sl.getServiceInfos() == null) {
-                                    Assert.fail("Should have found one entry on FindBusiness with TModelBag, "
-                                            + "found " + size);
+                    Assert.fail("Should have found one entry on FindService with TModelBag, "
+                       + "found " + size);
 				}
 				size = sl.getServiceInfos().getServiceInfo().size();
 				if (size != 1) {
-					Assert.fail("Should have found one entry on FindBusiness with TModelBag, "
+					Assert.fail("Should have found one entry on FindService with TModelBag, "
 							+ "found " + size);
 				} else {
-				        List<ServiceInfo> siList = sl.getServiceInfos().getServiceInfo();
+				    List<ServiceInfo> siList = sl.getServiceInfos().getServiceInfo();
 					String serviceKey = siList.get(0).getServiceKey();
-					if (!SERVICE_KEY.equals(serviceKey)) {
-					    Assert.fail("Should have found service key " + SERVICE_KEY
+					if (!SERVICE_KEY5.equals(serviceKey)) {
+					    Assert.fail("Should have found service key " + SERVICE_KEY5
 					            + " but found [" + serviceKey + "]");
 					}
 				}
@@ -164,13 +161,118 @@ public class UDDI_120_CombineCategoryBag
 				Assert.fail(e.getMessage());
 			}
 		} finally {
-                        tckBusiness1.deleteBusinesses(authInfoJoe, TOM_BUSINESS1_XML, TOM_BUSINESS1_KEY, 1);
-                        tckBusiness2.deleteBusinesses(authInfoJoe, TOM_BUSINESS2_XML, TOM_BUSINESS2_KEY, 1);
+            tckBusiness.deleteBusinesses(authInfoJoe, TOM_BUSINESS1_XML, TOM_BUSINESS1_KEY, 1);
+            tckBusiness.deleteBusinesses(authInfoJoe, TOM_BUSINESS2_XML, TOM_BUSINESS2_KEY, 1);
+            tckBusiness.deleteBusinesses(authInfoJoe, TOM_BUSINESS5_XML, TOM_BUSINESS5_KEY, 1);
 			
 			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
-			tckTModel01.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
-			tckTModel02.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
+		}
+	}
+	
+	@Test
+	public void findNoServiceByCategoryBag() {
+		try {
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
+			
+			tckBusiness.saveBusinesses(authInfoJoe, TOM_BUSINESS1_XML, TOM_BUSINESS1_KEY, 1);
+			tckBusiness.saveBusinesses(authInfoJoe, TOM_BUSINESS2_XML, TOM_BUSINESS2_KEY, 1);
+			tckBusiness.saveBusinesses(authInfoJoe, TOM_BUSINESS5_XML, TOM_BUSINESS5_KEY, 1);
+			try {
+				int size = 0;
+				ServiceList sl = null;
+
+				FindService fs = new FindService();
+				
+				//by default keys are ADD, we should only find service 5
+                KeyedReference keyRef1 = new KeyedReference();
+                keyRef1.setTModelKey(TOM_PUBLISHER_TMODEL01_KEY);
+                keyRef1.setKeyValue("value-y");
+               
+				CategoryBag cb = new CategoryBag();
+				cb.getKeyedReference().add(keyRef1);
+				fs.setCategoryBag(cb);
+				
+				sl = inquiry.findService(fs);
+				if (sl.getServiceInfos() != null) {
+                    Assert.fail("Should have found no entries on FindService, "
+                       + " found " + size);
+				}
+			} catch (Exception e) {
+				e.printStackTrace();
+				Assert.fail(e.getMessage());
+			}
+		} finally {
+            tckBusiness.deleteBusinesses(authInfoJoe, TOM_BUSINESS1_XML, TOM_BUSINESS1_KEY, 1);
+            tckBusiness.deleteBusinesses(authInfoJoe, TOM_BUSINESS2_XML, TOM_BUSINESS2_KEY, 1);
+            tckBusiness.deleteBusinesses(authInfoJoe, TOM_BUSINESS5_XML, TOM_BUSINESS5_KEY, 1);
+			
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
+		}
+	}
+	/*
+	 * For a combinedCategoryBag, we find a service if either the categoryBag on the service
+	 * matches, or one of the categoryBags on the bindings.
+	 */
+	@Test
+	public void findServiceByCombinedCategoryBag() {
+		try {
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
+			
+			tckBusiness.saveBusinesses(authInfoJoe, TOM_BUSINESS1_XML, TOM_BUSINESS1_KEY, 1);
+			tckBusiness.saveBusinesses(authInfoJoe, TOM_BUSINESS2_XML, TOM_BUSINESS2_KEY, 1);
+			try {
+				int size = 0;
+				ServiceList sl = null;
 
+				FindService fs = new FindService();
+				FindQualifiers fqs = new FindQualifiers();
+				fqs.getFindQualifier().add(UDDIConstants.COMBINE_CATEGORY_BAGS);
+				fs.setFindQualifiers(fqs);
+
+                KeyedReference keyRef1 = new KeyedReference();
+                keyRef1.setTModelKey(TOM_PUBLISHER_TMODEL01_KEY);
+                keyRef1.setKeyValue("value-y");
+				
+				CategoryBag cb = new CategoryBag();
+				cb.getKeyedReference().add(keyRef1);
+				fs.setCategoryBag(cb);
+				
+				sl = inquiry.findService(fs);
+				if (sl.getServiceInfos() == null) {
+                    Assert.fail("Should have found one entry on FindService with TModelBag, "
+                       + "found " + size);
+				}
+				size = sl.getServiceInfos().getServiceInfo().size();
+				if (size != 1) {
+					Assert.fail("Should have found one entry on FindService with TModelBag, "
+							+ "found " + size);
+				} else {
+				    List<ServiceInfo> siList = sl.getServiceInfos().getServiceInfo();
+					String serviceKey = siList.get(0).getServiceKey();
+					if (!SERVICE_KEY1.equals(serviceKey)) {
+					    Assert.fail("Should have found service key " + SERVICE_KEY1
+					            + " but found [" + serviceKey + "]");
+					}
+				}
+			} catch (Exception e) {
+				e.printStackTrace();
+				Assert.fail(e.getMessage());
+			}
+		} finally {
+            tckBusiness.deleteBusinesses(authInfoJoe, TOM_BUSINESS1_XML, TOM_BUSINESS1_KEY, 1);
+            tckBusiness.deleteBusinesses(authInfoJoe, TOM_BUSINESS2_XML, TOM_BUSINESS2_KEY, 1);
+			
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
 		}
 	}
 	



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org
For additional commands, e-mail: commits-help@juddi.apache.org