Publish IUs listed in categories even when they are not associated to a
category
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/CategoryIUXMLActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/CategoryIUXMLActionTest.java
index 9ce4ba4..0c0e8a7 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/CategoryIUXMLActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/CategoryIUXMLActionTest.java
@@ -68,6 +68,11 @@
 		doCategoryNotSetTest();
 	}
 
+	public void testIUCategoryCreation07() throws Exception {
+		IQueryResult result = actionResult.query(QueryUtil.createIUCategoryQuery(), new NullProgressMonitor());
+		assertEquals("1.0", 1, queryResultSize(result));
+	}
+
 	private void doCategorySetTest() {
 		IQueryResult result = actionResult.query(QueryUtil.createIUCategoryQuery(), new NullProgressMonitor());
 		assertEquals("1.0", 1, queryResultSize(result));
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/updatesite/CategoryXMLActionTest/testIUCategoryCreation07.xml b/bundles/org.eclipse.equinox.p2.tests/testData/updatesite/CategoryXMLActionTest/testIUCategoryCreation07.xml
new file mode 100644
index 0000000..44570b7
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/updatesite/CategoryXMLActionTest/testIUCategoryCreation07.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<site>
+   <iu id="test.feature.feature.group" range="[0.0, 2.0)"/>
+</site>
\ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java
index 56e9e8d..0f0ee04 100644
--- a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java
+++ b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java
@@ -214,33 +214,54 @@
 	}
 
 	private void addSiteIUsToCategories(Map<SiteCategory, Set<IInstallableUnit>> categoriesToIUs, IPublisherInfo publisherInfo, IPublisherResult results) {
-		if (updateSite == null)
-			return;
+		Map<SiteIU, Set<SiteCategory>> iusToCategories = getIUToCategoryMappings(publisherInfo);
 		SiteModel site = updateSite.getSite();
 		if (site == null)
 			return;
 		SiteIU[] siteIUs = site.getIUs();
 		for (SiteIU siteIU : siteIUs) {
-			String[] categoryNames = siteIU.getCategoryNames();
-			if (categoryNames.length == 0)
-				continue;
 			Collection<IInstallableUnit> ius = getIUs(siteIU, publisherInfo, results);
-			if (ius.size() == 0)
+			if (ius == null)
 				continue;
-			for (String categoryName : categoryNames) {
-				SiteCategory category = site.getCategory(categoryName);
-				if (category == null)
-					continue;
-				Set<IInstallableUnit> categoryIUs = categoriesToIUs.get(category);
-				if (categoryIUs == null) {
-					categoryIUs = new HashSet<IInstallableUnit>();
-					categoriesToIUs.put(category, categoryIUs);
+			Set<SiteCategory> categories = iusToCategories.get(siteIU);
+			// if there are no categories for this feature then add it to the default category.
+			if (categories == null || categories.isEmpty())
+				categories = defaultCategorySet;
+			for (SiteCategory category : categories) {
+				Set<IInstallableUnit> iusInCategory = categoriesToIUs.get(category);
+				if (iusInCategory == null) {
+					iusInCategory = new HashSet<IInstallableUnit>();
+					categoriesToIUs.put(category, iusInCategory);
 				}
-				categoryIUs.addAll(ius);
+				iusInCategory.addAll(ius);
 			}
 		}
 	}
 
+	private Map<SiteIU, Set<SiteCategory>> getIUToCategoryMappings(IPublisherInfo publisherInfo) {
+		HashMap<SiteIU, Set<SiteCategory>> mappings = new HashMap<SiteIU, Set<SiteCategory>>();
+		if (updateSite == null)
+			return mappings;
+		SiteModel site = updateSite.getSite();
+		if (site == null)
+			return mappings;
+
+		SiteIU[] ius = site.getIUs();
+		for (int i = 0; i < ius.length; i++) {
+			//add a mapping for each category this feature belongs to
+			String[] categoryNames = ius[i].getCategoryNames();
+			Set<SiteCategory> categories = new HashSet<SiteCategory>();
+			mappings.put(ius[i], categories);
+			for (int j = 0; j < categoryNames.length; j++) {
+				SiteCategory category = site.getCategory(categoryNames[j]);
+				if (category != null)
+					categories.add(category);
+			}
+		}
+		return mappings;
+
+	}
+
 	private Collection<IInstallableUnit> getIUs(SiteIU siteIU, IPublisherInfo publisherInfo, IPublisherResult results) {
 		String id = siteIU.getID();
 		String range = siteIU.getRange();