use of org.eclipse.pde.core.plugin.IPluginExtension in project dsl-devkit by dsldevkit.
the class CheckMarkerHelpExtensionTest method testCreateExtension.
/**
* Tests if the marker help extension is correctly created.
*
* @throws Exception
* the exception
*/
@Test
public void testCreateExtension() throws Exception {
IPluginExtension extension = createMarkerHelpExtension(parser.parse(CATALOG_WITH_FIRST_CHECK_LIVE));
// Test if the extension has been created.
assertEquals("Marker help extension has been created.", CheckMarkerHelpExtensionHelper.MARKERHELP_EXTENSION_POINT_ID, extension.getPoint());
// Test if the extension contains the marker help element
IPluginElement element = (IPluginElement) extension.getChildren()[0];
assertEquals("The marker help element has the correct context id", FIRSTCHECK_CONTEXID, element.getAttribute(CheckMarkerHelpExtensionHelper.CONTEXT_ID_ATTRIBUTE_TAG).getValue());
assertEquals("The marker help element has the correct markertype", MARKERTYPE_FAST, element.getAttribute(CheckMarkerHelpExtensionHelper.MARKERTYPE_ATTRIBUTE_TAG).getValue());
}
use of org.eclipse.pde.core.plugin.IPluginExtension in project dsl-devkit by dsldevkit.
the class CheckMarkerHelpExtensionTest method testCheckHasTwoIssueCodes.
/**
* Tests if a marker help element is added if an additional issueCode is added to an existing check.
*
* @throws Exception
* the exception
*/
@Test
public void testCheckHasTwoIssueCodes() throws Exception {
IPluginExtension extension = createMarkerHelpExtension(parser.parse(CATALOG_WITH_FIRST_CHECK_LIVE));
CheckCatalog twoIssueCodes = parser.parse(CATALOG_CHECK_HAS_TWO_ISSUECODES);
markerUtil.updateExtension(twoIssueCodes, extension);
List<String> issueCodesOfCheck = Lists.newArrayList();
for (final XIssueExpression i : generatorExtension.issues(twoIssueCodes.getChecks().get(0))) {
issueCodesOfCheck.add(CheckGeneratorExtensions.issueCodeValue(twoIssueCodes.getChecks().get(0), CheckGeneratorExtensions.issueCode(i)));
}
List<String> issueCodesInExtension = Lists.newArrayList();
for (IPluginObject obj : extension.getChildren()) {
for (IPluginObject element : ((IPluginElement) obj).getChildren()) {
issueCodesInExtension.add(((IPluginElement) element).getAttribute(CheckMarkerHelpExtensionHelper.ATTRIBUTE_VALUE_TAG).getValue());
}
}
assertTrue("A marker help element for both issueCodes has been created.", Iterables.elementsEqual(issueCodesInExtension, issueCodesOfCheck));
assertEquals("extension has two marker help elements", 2, issueCodesInExtension.size());
}
use of org.eclipse.pde.core.plugin.IPluginExtension in project dsl-devkit by dsldevkit.
the class CheckContextsExtensionTest method testCreateExtension.
/**
* Tests if the contexts extension is correctly created.
*
* @throws CoreException
* core exception
*/
@Test
public void testCreateExtension() throws CoreException {
IPluginExtension extension = contextsUtil.addExtensionToPluginBase(pluginModel, catalog, ExtensionType.CONTEXTS, null);
// Test if the extension has been created.
assertEquals("Contexts extension has been created.", CheckContextsExtensionHelper.CONTEXTS_EXTENSION_POINT_ID, extension.getPoint());
// Test if the attributes are set correctly
String contextsFileName = ((IPluginElement) extension.getChildren()[0]).getAttribute(CheckContextsExtensionHelper.FILE_ATTRIBUTE_TAG).getValue();
assertEquals("Contexts File name is set correctly", CheckContextsExtensionHelper.CONTEXTS_FILE_NAME, contextsFileName);
}
use of org.eclipse.pde.core.plugin.IPluginExtension in project dsl-devkit by dsldevkit.
the class CheckTocExtensionTest method testUpdateTocExtension.
/**
* Tests if an update of a toc extension is correctly done.
*
* @throws CoreException
* the core exception
*/
@Test
public void testUpdateTocExtension() throws CoreException {
IPluginExtension extension = createErroneousTocExtension();
assertNotSame("File location is not as expected", CheckTocExtensionHelper.TOC_FILE_NAME, ((IPluginElement) extension.getChildren()[0]).getAttribute("file").getValue());
tocUtil.updateExtension(catalog, extension);
assertEquals("Toc file location is now set correctly", CheckTocExtensionHelper.TOC_FILE_NAME, ((IPluginElement) extension.getChildren()[0]).getAttribute("file").getValue());
}
use of org.eclipse.pde.core.plugin.IPluginExtension in project dsl-devkit by dsldevkit.
the class CheckTocExtensionTest method createErroneousTocExtension.
/**
* Creates an erroneous toc extension.
*
* @return the plugin extension
* @throws CoreException
* the core exception
*/
private IPluginExtension createErroneousTocExtension() throws CoreException {
IPluginExtension newExtension = pluginModel.getFactory().createExtension();
newExtension.setPoint(CheckTocExtensionHelper.TOC_EXTENSION_POINT_ID);
newExtension.setName(tocUtil.getExtensionPointName(catalog));
IPluginElement element = pluginModel.getFactory().createElement(newExtension);
element.setName("toc");
element.setAttribute("file", "dummy/file/location");
newExtension.add(element);
return newExtension;
}
Aggregations