blob: 8b18035d71b8d172a9994016f5bea1866a29f666 [file] [log] [blame]
package org.eclipse.update.tests.api;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import java.net.URL;
import org.eclipse.update.core.*;
import org.eclipse.update.core.ICategory;
import org.eclipse.update.internal.core.Category;
import org.eclipse.update.internal.core.FeatureReference;
import org.eclipse.update.tests.UpdateManagerTestCase;
public class TestLocalSiteAPI extends UpdateManagerTestCase {
/**
* Test the getFeatures()
*/
public TestLocalSiteAPI(String arg0) {
super(arg0);
}
public void testFileParsing() throws Exception {
ISite site = SiteManager.getSite(new URL(SOURCE_FILE_SITE,"siteTestLocalSite/"));
IInfo[] info = site.getArchives();
if (info.length<=0){
fail("no plugins in site: "+site.getURL().toExternalForm());
}
boolean found1 = false;
boolean found2 = false;
String name1= "org.eclipse.update.core.tests.feature1.plugin2_5.0.0.jar";
String name2 = "org.eclipse.update.core.tests.feature1.plugin2_5.0.1.jar";
for (int i =0; i<info.length; i++){
if (info[i].getText().equals(name1)) found1 = true;
if (info[i].getText().equals(name2)) found2 = true;
}
if (!found1 || !found2){
fail("Cannot find plugin : org.eclipse.update.core.tests.feature1.plugin2 version 5.0.0 and 5.0.1 on the site, by parsing file system");
}
}
public void testCategories() throws Exception {
ISite site = SiteManager.getSite(SOURCE_FILE_SITE);
IFeatureReference[] ref = site.getFeatureReferences();
ICategory category = new Category("category","Label of category");
site.addCategory(category);
ref[0].addCategory(category);
ICategory[] categories = site.getCategories();
boolean found = false;
for (int index = 0; index < categories.length; index++) {
ICategory element = categories[index];
if (element.getName().equals("category")) found = true;
}
if (!found) fail("cannot find category 'category' in site");
categories = ref[0].getCategories();
found = false;
for (int index = 0; index < categories.length; index++) {
ICategory element = categories[index];
if (element.getName().equals("category")) found = true;
}
if (!found) fail("cannot find category 'category' in feature");
}
}