1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00
This commit is contained in:
Andrew Gvozdev 2012-01-26 14:34:13 -05:00
parent 0fdc3d95c3
commit cdc386ba11
19 changed files with 456 additions and 345 deletions

View file

@ -12,7 +12,7 @@ Export-Package: org.eclipse.cdt.core.cdescriptor.tests,
org.eclipse.cdt.core.internal.tests;x-internal:=true, org.eclipse.cdt.core.internal.tests;x-internal:=true,
org.eclipse.cdt.core.internal.tests.filesystem.ram, org.eclipse.cdt.core.internal.tests.filesystem.ram,
org.eclipse.cdt.core.language, org.eclipse.cdt.core.language,
org.eclipse.cdt.core.language.settings.providers;x-internal:=true, org.eclipse.cdt.core.language.settings.providers,
org.eclipse.cdt.core.model.tests, org.eclipse.cdt.core.model.tests,
org.eclipse.cdt.core.parser.tests, org.eclipse.cdt.core.parser.tests,
org.eclipse.cdt.core.parser.tests.ast2, org.eclipse.cdt.core.parser.tests.ast2,

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010, 2011 Andrew Gvozdev and others. * Copyright (c) 2010, 2012 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -13,7 +13,9 @@ package org.eclipse.cdt.core.language.settings.providers;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestSuite; import junit.framework.TestSuite;
/**
* Test suite to cover core Language Settings Providers functionality.
*/
public class AllLanguageSettingsProvidersCoreTests { public class AllLanguageSettingsProvidersCoreTests {
public static void main(String[] args) { public static void main(String[] args) {
junit.textui.TestRunner.run(suite()); junit.textui.TestRunner.run(suite());
@ -24,7 +26,7 @@ public class AllLanguageSettingsProvidersCoreTests {
suite.addTest(LanguageSettingsExtensionsTests.suite()); suite.addTest(LanguageSettingsExtensionsTests.suite());
suite.addTest(LanguageSettingsManagerTests.suite()); suite.addTest(LanguageSettingsManagerTests.suite());
suite.addTest(LanguageSettingsSerializableTests.suite()); suite.addTest(LanguageSettingsSerializableProviderTests.suite());
suite.addTest(LanguageSettingsPersistenceProjectTests.suite()); suite.addTest(LanguageSettingsPersistenceProjectTests.suite());
suite.addTest(LanguageSettingsListenersTests.suite()); suite.addTest(LanguageSettingsListenersTests.suite());
suite.addTest(LanguageSettingsScannerInfoProviderTests.suite()); suite.addTest(LanguageSettingsScannerInfoProviderTests.suite());

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2011 Andrew Gvozdev and others. * Copyright (c) 2009, 2012 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -34,7 +34,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
/** /**
* Test cases testing LanguageSettingsProvider functionality * Test cases testing LanguageSettingsProvider extensions
*/ */
public class LanguageSettingsExtensionsTests extends BaseTestCase { public class LanguageSettingsExtensionsTests extends BaseTestCase {
// These should match corresponding entries defined in plugin.xml // These should match corresponding entries defined in plugin.xml
@ -57,7 +57,7 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
/*package*/ static final String EXTENSION_REGISTERER_PROVIDER_ID = "org.eclipse.cdt.core.tests.language.settings.listener.registerer.provider"; /*package*/ static final String EXTENSION_REGISTERER_PROVIDER_ID = "org.eclipse.cdt.core.tests.language.settings.listener.registerer.provider";
/*package*/ static final String EXTENSION_USER_PROVIDER_ID = "org.eclipse.cdt.ui.UserLanguageSettingsProvider"; /*package*/ static final String EXTENSION_USER_PROVIDER_ID = "org.eclipse.cdt.ui.UserLanguageSettingsProvider";
// These are made up // Arbitrary sample parameters used by the test
private static final String PROVIDER_0 = "test.provider.0.id"; private static final String PROVIDER_0 = "test.provider.0.id";
private static final String PROVIDER_NAME_0 = "test.provider.0.name"; private static final String PROVIDER_NAME_0 = "test.provider.0.name";
private static final String LANG_ID = "test.lang.id"; private static final String LANG_ID = "test.lang.id";
@ -104,10 +104,11 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
} }
/** /**
* Check that regular ICLanguageSettingsProvider extension defined in plugin.xml is accessible. * Check that regular {@link ICLanguageSettingsProvider} extension defined in plugin.xml is accessible.
*/ */
public void testExtension() throws Exception { public void testExtension() throws Exception {
{ {
// test provider defined as an extension
List<ILanguageSettingsProvider> providers = LanguageSettingsManager.getWorkspaceProviders(); List<ILanguageSettingsProvider> providers = LanguageSettingsManager.getWorkspaceProviders();
List<String> ids = new ArrayList<String>(); List<String> ids = new ArrayList<String>();
for (ILanguageSettingsProvider provider : providers) { for (ILanguageSettingsProvider provider : providers) {
@ -117,7 +118,7 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
} }
{ {
// test provider not in the list // test provider that is not in the list
ILanguageSettingsProvider providerExt = LanguageSettingsManager.getExtensionProviderCopy("missing.povider", true); ILanguageSettingsProvider providerExt = LanguageSettingsManager.getExtensionProviderCopy("missing.povider", true);
assertNull(providerExt); assertNull(providerExt);
} }
@ -126,7 +127,7 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
ILanguageSettingsProvider providerExtCopy = LanguageSettingsManager.getExtensionProviderCopy(EXTENSION_BASE_PROVIDER_ID, true); ILanguageSettingsProvider providerExtCopy = LanguageSettingsManager.getExtensionProviderCopy(EXTENSION_BASE_PROVIDER_ID, true);
assertNull(providerExtCopy); assertNull(providerExtCopy);
// get raw extension provider - retrieve the only instance via workspace provider // test raw workspace provider defined as an extension
ILanguageSettingsProvider providerExt = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID); ILanguageSettingsProvider providerExt = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID);
assertTrue(LanguageSettingsManager.isWorkspaceProvider(providerExt)); assertTrue(LanguageSettingsManager.isWorkspaceProvider(providerExt));
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(providerExt); ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(providerExt);
@ -167,7 +168,7 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
} }
/** /**
* Check that subclassed LanguageSettingsBaseProvider extension defined in plugin.xml is accessible. * Check that subclassed {@link LanguageSettingsBaseProvider} extension defined in plugin.xml is accessible.
*/ */
public void testExtensionBaseProviderSubclass() throws Exception { public void testExtensionBaseProviderSubclass() throws Exception {
// get test plugin extension provider // get test plugin extension provider
@ -217,18 +218,18 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
} }
/** /**
* Basic test for LanguageSettingsBaseProvider. * Basic test for {@link LanguageSettingsBaseProvider}.
*/ */
public void testBaseProvider() throws Exception { public void testBaseProvider() throws Exception {
// define benchmarks
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>(); List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(new CIncludePathEntry("path0", 0)); entries.add(new CIncludePathEntry("path0", 0));
List<String> languages = new ArrayList<String>(2); List<String> languages = new ArrayList<String>(2);
languages.add("bogus.language.id"); languages.add("bogus.language.id");
languages.add(LANG_ID); languages.add(LANG_ID);
// add default provider // create base provider
LanguageSettingsBaseProvider provider = new LanguageSettingsBaseProvider( LanguageSettingsBaseProvider provider = new LanguageSettingsBaseProvider(PROVIDER_0, PROVIDER_NAME_0, languages, entries);
PROVIDER_0, PROVIDER_NAME_0, languages, entries);
{ {
// attempt to get entries for wrong language // attempt to get entries for wrong language
@ -251,7 +252,7 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
} }
/** /**
* TODO * Test ability to configure {@link LanguageSettingsBaseProvider}.
*/ */
public void testBaseProviderConfigure() throws Exception { public void testBaseProviderConfigure() throws Exception {
// sample entries // sample entries
@ -300,7 +301,7 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
} }
/** /**
* LanguageSettingsBaseProvider is not allowed to be configured twice. * {@link LanguageSettingsBaseProvider} is not allowed to be configured twice.
*/ */
public void testBaseProviderCantReconfigure() throws Exception { public void testBaseProviderCantReconfigure() throws Exception {
// create LanguageSettingsBaseProvider // create LanguageSettingsBaseProvider
@ -319,7 +320,7 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
} }
/** /**
* TODO * Test {@link LanguageSettingsSerializableProvider} defined via extension point.
*/ */
public void testSerializableProvider() throws Exception { public void testSerializableProvider() throws Exception {
// get test plugin extension for serializable provider // get test plugin extension for serializable provider
@ -342,7 +343,7 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
} }
/** /**
* TODO * Test {@link ILanguageSettingsEditableProvider} defined via extension point.
*/ */
public void testEditableProvider() throws Exception { public void testEditableProvider() throws Exception {
// Non-editable providers cannot be copied so they are singletons // Non-editable providers cannot be copied so they are singletons

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2011, 2011 Andrew Gvozdev and others. * Copyright (c) 2011, 2012 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -23,13 +23,14 @@ import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.testplugin.ResourceHelper; import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
/** /**
* Test cases testing LanguageSettingsProvider functionality * Test cases to cover {@link ILanguageSettingsChangeListener} capabilities.
*/ */
public class LanguageSettingsListenersTests extends BaseTestCase { public class LanguageSettingsListenersTests extends BaseTestCase {
// Must match provider id defined as extension point // These should match corresponding entries defined in plugin.xml
private static final String EXTENSION_REGISTERER_PROVIDER_ID = LanguageSettingsExtensionsTests.EXTENSION_REGISTERER_PROVIDER_ID; private static final String EXTENSION_REGISTERER_PROVIDER_ID = LanguageSettingsExtensionsTests.EXTENSION_REGISTERER_PROVIDER_ID;
private static final String EXTENSION_EDITABLE_PROVIDER_ID = LanguageSettingsExtensionsTests.EXTENSION_EDITABLE_PROVIDER_ID; private static final String EXTENSION_EDITABLE_PROVIDER_ID = LanguageSettingsExtensionsTests.EXTENSION_EDITABLE_PROVIDER_ID;
@ -39,25 +40,25 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
private static final String PROVIDER_CUSTOM_GLOBAL_NAME = "test.provider.custom.global.name"; private static final String PROVIDER_CUSTOM_GLOBAL_NAME = "test.provider.custom.global.name";
private static final CMacroEntry SAMPLE_LSE = new CMacroEntry("MACRO", "value",0); private static final CMacroEntry SAMPLE_LSE = new CMacroEntry("MACRO", "value",0);
/**
* Mock {@link ILanguageSettingsChangeListener}.
*/
private class MockLanguageSettingsChangeListener implements ILanguageSettingsChangeListener { private class MockLanguageSettingsChangeListener implements ILanguageSettingsChangeListener {
private int count = 0; private int count = 0;
private ILanguageSettingsChangeEvent lastEvent = null; private ILanguageSettingsChangeEvent lastEvent = null;
@Override @Override
public void handleEvent(ILanguageSettingsChangeEvent event) { public void handleEvent(ILanguageSettingsChangeEvent event) {
count++; count++;
lastEvent = event; lastEvent = event;
} }
public int getCount() { public int getCount() {
return count; return count;
} }
public void resetCount() { public void resetCount() {
count = 0; count = 0;
lastEvent = null; lastEvent = null;
} }
public ILanguageSettingsChangeEvent getLastEvent() { public ILanguageSettingsChangeEvent getLastEvent() {
return lastEvent; return lastEvent;
} }
@ -82,7 +83,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
LanguageSettingsManager.unregisterLanguageSettingsChangeListener(mockLseListener); LanguageSettingsManager.unregisterLanguageSettingsChangeListener(mockLseListener);
LanguageSettingsManager.setWorkspaceProviders(null); LanguageSettingsManager.setWorkspaceProviders(null);
super.tearDown(); super.tearDown(); // includes ResourceHelper cleanup
} }
/** /**
@ -102,6 +103,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
} }
/** /**
* Check that global provider does not get unnecessarily registered on start.
*/ */
public void testListenerRegisterer_CheckExtensionProvider() throws Exception { public void testListenerRegisterer_CheckExtensionProvider() throws Exception {
// check if extension provider exists // check if extension provider exists
@ -113,15 +115,17 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
} }
/** /**
* Test events triggered for non-shared configuration owned provider.
*/ */
public void testListenerRegisterer_OneOwnedByCfg() throws Exception { public void testListenerRegisterer_OneOwnedByCfg() throws Exception {
// create project
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName()); IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
{ {
// get project descriptions // get project descriptions
ICProjectDescription writableProjDescription = CoreModel.getDefault().getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(writableProjDescription); assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
@ -135,7 +139,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertEquals(1, storedProviders.size()); assertEquals(1, storedProviders.size());
// write to project description // write to project description
CoreModel.getDefault().setProjectDescription(project, writableProjDescription); CoreModel.getDefault().setProjectDescription(project, prjDescriptionWritable);
assertEquals(1, MockListenerRegisterer.getCount(PROVIDER_1)); assertEquals(1, MockListenerRegisterer.getCount(PROVIDER_1));
} }
{ {
@ -146,7 +150,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
{ {
// reopen the project // reopen the project
project.open(null); project.open(null);
CoreModel.getDefault().getProjectDescription(project); // initialize project description
CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
assertEquals(1, MockListenerRegisterer.getCount(PROVIDER_1)); assertEquals(1, MockListenerRegisterer.getCount(PROVIDER_1));
// and delete // and delete
project.delete(true, null); project.delete(true, null);
@ -156,8 +161,10 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
} }
/** /**
* Test events triggered for non-shared configuration owned multiple providers.
*/ */
public void testListenerRegisterer_TwoOwnedByCfgs() throws Exception { public void testListenerRegisterer_TwoOwnedByCfgs() throws Exception {
// create project
IProject project = ResourceHelper.createCDTProject(this.getName(), null, new String[] { IProject project = ResourceHelper.createCDTProject(this.getName(), null, new String[] {
"org.eclipse.cdt.core.tests.configuration.id.1", "org.eclipse.cdt.core.tests.configuration.id.1",
"org.eclipse.cdt.core.tests.configuration.id.2", "org.eclipse.cdt.core.tests.configuration.id.2",
@ -165,9 +172,9 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
{ {
// get project descriptions // get project descriptions
ICProjectDescription writableProjDescription = CoreModel.getDefault().getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(writableProjDescription); assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(2, cfgDescriptions.length); assertEquals(2, cfgDescriptions.length);
ICConfigurationDescription cfgDescription1 = cfgDescriptions[0]; ICConfigurationDescription cfgDescription1 = cfgDescriptions[0];
ICConfigurationDescription cfgDescription2 = cfgDescriptions[1]; ICConfigurationDescription cfgDescription2 = cfgDescriptions[1];
@ -194,7 +201,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
} }
// write to project description // write to project description
CoreModel.getDefault().setProjectDescription(project, writableProjDescription); CoreModel.getDefault().setProjectDescription(project, prjDescriptionWritable);
assertEquals(2, MockListenerRegisterer.getCount(PROVIDER_1)); assertEquals(2, MockListenerRegisterer.getCount(PROVIDER_1));
} }
{ {
@ -205,7 +212,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
{ {
// reopen the project // reopen the project
project.open(null); project.open(null);
CoreModel.getDefault().getProjectDescription(project); // initialize project description
CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
assertEquals(2, MockListenerRegisterer.getCount(PROVIDER_1)); assertEquals(2, MockListenerRegisterer.getCount(PROVIDER_1));
// and delete // and delete
project.delete(true, null); project.delete(true, null);
@ -215,14 +223,16 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
} }
/** /**
* Test events triggered for shared provider.
*/ */
public void testListenerRegisterer_OneGlobal() throws Exception { public void testListenerRegisterer_OneGlobal() throws Exception {
// create project
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName()); IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
{ {
// get project descriptions // get project descriptions
ICProjectDescription writableProjDescription = CoreModel.getDefault().getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(writableProjDescription); assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
@ -236,7 +246,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertEquals(1, storedProviders.size()); assertEquals(1, storedProviders.size());
// write to project description // write to project description
CoreModel.getDefault().setProjectDescription(project, writableProjDescription); CoreModel.getDefault().setProjectDescription(project, prjDescriptionWritable);
assertEquals(1, MockListenerRegisterer.getCount(EXTENSION_REGISTERER_PROVIDER_ID)); assertEquals(1, MockListenerRegisterer.getCount(EXTENSION_REGISTERER_PROVIDER_ID));
} }
{ {
@ -247,7 +257,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
{ {
// reopen the project // reopen the project
project.open(null); project.open(null);
CoreModel.getDefault().getProjectDescription(project); // initialize project description
CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
assertEquals(1, MockListenerRegisterer.getCount(EXTENSION_REGISTERER_PROVIDER_ID)); assertEquals(1, MockListenerRegisterer.getCount(EXTENSION_REGISTERER_PROVIDER_ID));
// and delete // and delete
project.delete(true, null); project.delete(true, null);
@ -257,8 +268,10 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
} }
/** /**
* Test events triggered for multiple shared providers.
*/ */
public void testListenerRegisterer_TwoGlobal() throws Exception { public void testListenerRegisterer_TwoGlobal() throws Exception {
// create project
IProject project = ResourceHelper.createCDTProject(this.getName(), null, new String[] { IProject project = ResourceHelper.createCDTProject(this.getName(), null, new String[] {
"org.eclipse.cdt.core.tests.configuration.id.1", "org.eclipse.cdt.core.tests.configuration.id.1",
"org.eclipse.cdt.core.tests.configuration.id.2", "org.eclipse.cdt.core.tests.configuration.id.2",
@ -268,9 +281,9 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// retrieve global provider // retrieve global provider
ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID); ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID);
// get project descriptions // get project descriptions
ICProjectDescription writableProjDescription = CoreModel.getDefault().getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(writableProjDescription); assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(2, cfgDescriptions.length); assertEquals(2, cfgDescriptions.length);
ICConfigurationDescription cfgDescription1 = cfgDescriptions[0]; ICConfigurationDescription cfgDescription1 = cfgDescriptions[0];
ICConfigurationDescription cfgDescription2 = cfgDescriptions[1]; ICConfigurationDescription cfgDescription2 = cfgDescriptions[1];
@ -294,7 +307,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertEquals(1, storedProviders.size()); assertEquals(1, storedProviders.size());
} }
// write to project description // write to project description
CoreModel.getDefault().setProjectDescription(project, writableProjDescription); CoreModel.getDefault().setProjectDescription(project, prjDescriptionWritable);
assertEquals(1, MockListenerRegisterer.getCount(EXTENSION_REGISTERER_PROVIDER_ID)); assertEquals(1, MockListenerRegisterer.getCount(EXTENSION_REGISTERER_PROVIDER_ID));
} }
{ {
@ -305,7 +318,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
{ {
// reopen the project // reopen the project
project.open(null); project.open(null);
CoreModel.getDefault().getProjectDescription(project); // initialize project description
CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
assertEquals(1, MockListenerRegisterer.getCount(EXTENSION_REGISTERER_PROVIDER_ID)); assertEquals(1, MockListenerRegisterer.getCount(EXTENSION_REGISTERER_PROVIDER_ID));
// and delete // and delete
project.delete(true, null); project.delete(true, null);
@ -314,8 +328,10 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
} }
/** /**
* Test events triggered for shared provider when the provider removed from the list.
*/ */
public void testListenerRegisterer_TwoGlobalMinusOne() throws Exception { public void testListenerRegisterer_TwoGlobalMinusOne() throws Exception {
// create project
IProject project = ResourceHelper.createCDTProject(this.getName(), null, new String[] { IProject project = ResourceHelper.createCDTProject(this.getName(), null, new String[] {
"org.eclipse.cdt.core.tests.configuration.id.1", "org.eclipse.cdt.core.tests.configuration.id.1",
"org.eclipse.cdt.core.tests.configuration.id.2", "org.eclipse.cdt.core.tests.configuration.id.2",
@ -325,9 +341,9 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// retrieve workspace provider // retrieve workspace provider
ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID); ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID);
// get project descriptions // get project descriptions
ICProjectDescription writableProjDescription = CoreModel.getDefault().getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(writableProjDescription); assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(2, cfgDescriptions.length); assertEquals(2, cfgDescriptions.length);
ICConfigurationDescription cfgDescription1 = cfgDescriptions[0]; ICConfigurationDescription cfgDescription1 = cfgDescriptions[0];
ICConfigurationDescription cfgDescription2 = cfgDescriptions[1]; ICConfigurationDescription cfgDescription2 = cfgDescriptions[1];
@ -351,16 +367,16 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertEquals(1, storedProviders.size()); assertEquals(1, storedProviders.size());
} }
// write to project description // write to project description
CoreModel.getDefault().setProjectDescription(project, writableProjDescription); CoreModel.getDefault().setProjectDescription(project, prjDescriptionWritable);
assertEquals(1, MockListenerRegisterer.getCount(EXTENSION_REGISTERER_PROVIDER_ID)); assertEquals(1, MockListenerRegisterer.getCount(EXTENSION_REGISTERER_PROVIDER_ID));
} }
{ {
// retrieve workspace provider // retrieve workspace provider
ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID); ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID);
// get project descriptions // get project descriptions
ICProjectDescription writableProjDescription = CoreModel.getDefault().getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(writableProjDescription); assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(2, cfgDescriptions.length); assertEquals(2, cfgDescriptions.length);
ICConfigurationDescription cfgDescription1 = cfgDescriptions[0]; ICConfigurationDescription cfgDescription1 = cfgDescriptions[0];
ICConfigurationDescription cfgDescription2 = cfgDescriptions[1]; ICConfigurationDescription cfgDescription2 = cfgDescriptions[1];
@ -375,7 +391,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertEquals(0, storedProviders.size()); assertEquals(0, storedProviders.size());
} }
// write to project description // write to project description
CoreModel.getDefault().setProjectDescription(project, writableProjDescription); CoreModel.getDefault().setProjectDescription(project, prjDescriptionWritable);
assertEquals(1, MockListenerRegisterer.getCount(EXTENSION_REGISTERER_PROVIDER_ID)); assertEquals(1, MockListenerRegisterer.getCount(EXTENSION_REGISTERER_PROVIDER_ID));
} }
{ {
@ -386,15 +402,16 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
} }
/** /**
* Test events triggered for shared provider define in multiple projects.
*/ */
public void testListenerRegisterer_GlobalProviderTwoProjects() throws Exception { public void testListenerRegisterer_GlobalProviderTwoProjects() throws Exception {
// create project 1 // create project 1
IProject project_1 = ResourceHelper.createCDTProjectWithConfig(this.getName() + ".1"); IProject project_1 = ResourceHelper.createCDTProjectWithConfig(this.getName() + ".1");
{ {
// get project descriptions // get project descriptions
ICProjectDescription writableProjDescription = CoreModel.getDefault().getProjectDescription(project_1); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project_1, true);
assertNotNull(writableProjDescription); assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
@ -408,7 +425,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertEquals(1, storedProviders.size()); assertEquals(1, storedProviders.size());
// write to project description // write to project description
CoreModel.getDefault().setProjectDescription(project_1, writableProjDescription); CoreModel.getDefault().setProjectDescription(project_1, prjDescriptionWritable);
assertEquals(1, MockListenerRegisterer.getCount(EXTENSION_REGISTERER_PROVIDER_ID)); assertEquals(1, MockListenerRegisterer.getCount(EXTENSION_REGISTERER_PROVIDER_ID));
} }
@ -416,9 +433,9 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
IProject project_2 = ResourceHelper.createCDTProjectWithConfig(this.getName() + ".2"); IProject project_2 = ResourceHelper.createCDTProjectWithConfig(this.getName() + ".2");
{ {
// get project descriptions // get project descriptions
ICProjectDescription writableProjDescription = CoreModel.getDefault().getProjectDescription(project_2); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project_2, true);
assertNotNull(writableProjDescription); assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
@ -432,7 +449,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertEquals(1, storedProviders.size()); assertEquals(1, storedProviders.size());
// write to project description // write to project description
CoreModel.getDefault().setProjectDescription(project_2, writableProjDescription); CoreModel.getDefault().setProjectDescription(project_2, prjDescriptionWritable);
assertEquals(1, MockListenerRegisterer.getCount(EXTENSION_REGISTERER_PROVIDER_ID)); assertEquals(1, MockListenerRegisterer.getCount(EXTENSION_REGISTERER_PROVIDER_ID));
} }
@ -450,8 +467,10 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
} }
/** /**
* Test events triggered for shared global providers not included in any configuration.
*/ */
public void testListenerRegisterer_GlobalProviderNotInUse() throws Exception { public void testListenerRegisterer_GlobalProviderNotInUse() throws Exception {
// create project
ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(PROVIDER_CUSTOM_GLOBAL); ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(PROVIDER_CUSTOM_GLOBAL);
// the global custom provider has not been added yet // the global custom provider has not been added yet
@ -477,8 +496,10 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
} }
/** /**
* Test events triggered for shared global provider replacing another one in global list.
*/ */
public void testListenerRegisterer_GlobalProviderAddRemoveOutsideTheProject() throws Exception { public void testListenerRegisterer_GlobalProviderAddRemoveOutsideTheProject() throws Exception {
// create project
ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(PROVIDER_CUSTOM_GLOBAL); ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(PROVIDER_CUSTOM_GLOBAL);
// the global custom provider has not been added yet // the global custom provider has not been added yet
@ -491,9 +512,9 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName()); IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
{ {
// get project descriptions // get project descriptions
ICProjectDescription writableProjDescription = CoreModel.getDefault().getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(writableProjDescription); assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
@ -506,7 +527,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertEquals(1, storedProviders.size()); assertEquals(1, storedProviders.size());
// write to project description // write to project description
CoreModel.getDefault().setProjectDescription(project, writableProjDescription); CoreModel.getDefault().setProjectDescription(project, prjDescriptionWritable);
// the global custom provider has not been added yet // the global custom provider has not been added yet
assertEquals(0, MockListenerRegisterer.getCount(PROVIDER_CUSTOM_GLOBAL)); assertEquals(0, MockListenerRegisterer.getCount(PROVIDER_CUSTOM_GLOBAL));
} }
@ -534,15 +555,17 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
} }
/** /**
* Test events triggered when empty provider added and the resulting list of entries does not change.
*/ */
public void testNotification_cfgProvider_AddEmptyProvider() throws Exception { public void testNotification_cfgProvider_AddEmptyProvider() throws Exception {
// create project
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName()); IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
// First clear default providers // First clear default providers
{ {
// get project descriptions // get project descriptions
ICProjectDescription writableProjDescription = CoreModel.getDefault().getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(writableProjDescription); assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
@ -554,7 +577,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertEquals(0, storedProviders.size()); assertEquals(0, storedProviders.size());
// write to project description // write to project description
CoreModel.getDefault().setProjectDescription(project, writableProjDescription); CoreModel.getDefault().setProjectDescription(project, prjDescriptionWritable);
} }
// register mock listener to inspect the notifications // register mock listener to inspect the notifications
@ -565,9 +588,9 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// Add empty provider // Add empty provider
{ {
// get project descriptions // get project descriptions
ICProjectDescription writableProjDescription = CoreModel.getDefault().getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(writableProjDescription); assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
@ -581,7 +604,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertEquals(1, storedProviders.size()); assertEquals(1, storedProviders.size());
// write to project description // write to project description
CoreModel.getDefault().setProjectDescription(project, writableProjDescription); CoreModel.getDefault().setProjectDescription(project, prjDescriptionWritable);
} }
// No notifications expected // No notifications expected
@ -590,15 +613,17 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
} }
/** /**
* Test events triggered where non-empty provider added.
*/ */
public void testNotification_cfgProvider_AddNonEmptyProvider() throws Exception { public void testNotification_cfgProvider_AddNonEmptyProvider() throws Exception {
// create project
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName()); IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
// First clear default providers // First clear default providers
{ {
// get project descriptions // get project descriptions
ICProjectDescription writableProjDescription = CoreModel.getDefault().getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(writableProjDescription); assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
@ -610,7 +635,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertEquals(0, storedProviders.size()); assertEquals(0, storedProviders.size());
// write to project description // write to project description
CoreModel.getDefault().setProjectDescription(project, writableProjDescription); CoreModel.getDefault().setProjectDescription(project, prjDescriptionWritable);
} }
// register mock listener to inspect the notifications // register mock listener to inspect the notifications
@ -621,9 +646,9 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// Add non-empty provider // Add non-empty provider
{ {
// get project descriptions // get project descriptions
ICProjectDescription writableProjDescription = CoreModel.getDefault().getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(writableProjDescription); assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescription = cfgDescriptions[0];
String cfgDescriptionId = cfgDescription.getId(); String cfgDescriptionId = cfgDescription.getId();
@ -641,7 +666,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertEquals(1, storedProviders.size()); assertEquals(1, storedProviders.size());
// write to project description // write to project description
CoreModel.getDefault().setProjectDescription(project, writableProjDescription); CoreModel.getDefault().setProjectDescription(project, prjDescriptionWritable);
// inspect notifications // inspect notifications
assertEquals(1, mockLseListener.getCount()); assertEquals(1, mockLseListener.getCount());
@ -655,16 +680,18 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
} }
/** /**
* Test events triggered during serialization.
*/ */
public void testNotification_cfgProvider_SerializeEntries() throws Exception { public void testNotification_cfgProvider_SerializeEntries() throws Exception {
// create project
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName()); IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
// add the mock provider // add the mock provider
{ {
// get project descriptions // get project descriptions
ICProjectDescription writableProjDescription = CoreModel.getDefault().getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(writableProjDescription); assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
@ -677,7 +704,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertEquals(1, storedProviders.size()); assertEquals(1, storedProviders.size());
// write to project description // write to project description
CoreModel.getDefault().setProjectDescription(project, writableProjDescription); CoreModel.getDefault().setProjectDescription(project, prjDescriptionWritable);
} }
// register mock listener to inspect the notifications // register mock listener to inspect the notifications
@ -688,7 +715,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// Change the provider's entries // Change the provider's entries
{ {
// get project descriptions // get project descriptions
ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project, false); ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
assertNotNull(prjDescription); assertNotNull(prjDescription);
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
@ -722,16 +749,18 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
} }
/** /**
* Test events triggered when providers are being added by 2 independent parties in parallel.
*/ */
public void testNotification_cfgProvider_SerializeEntriesConcurrent() throws Exception { public void testNotification_cfgProvider_SerializeEntriesConcurrent() throws Exception {
// create project
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName()); IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
// add the mock provider // add the mock provider
{ {
// get project descriptions // get project descriptions
ICProjectDescription writableProjDescription = CoreModel.getDefault().getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(writableProjDescription); assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
@ -744,7 +773,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertEquals(1, storedProviders.size()); assertEquals(1, storedProviders.size());
// write to project description // write to project description
CoreModel.getDefault().setProjectDescription(project, writableProjDescription); CoreModel.getDefault().setProjectDescription(project, prjDescriptionWritable);
} }
// register mock listener to inspect the notifications // register mock listener to inspect the notifications
@ -755,26 +784,26 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// Change the provider's entries concurrently // Change the provider's entries concurrently
// get project descriptions // get project descriptions
ICProjectDescription prjDescription_1 = CoreModel.getDefault().getProjectDescription(project, false); ICProjectDescription prjDescription_1 = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
assertNotNull(prjDescription_1); assertNotNull(prjDescription_1);
ICProjectDescription prjDescription_2 = CoreModel.getDefault().getProjectDescription(project, false); ICProjectDescription prjDescription_2 = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
assertNotNull(prjDescription_2); assertNotNull(prjDescription_2);
{ {
ICConfigurationDescription[] cfgDescriptions = prjDescription_1.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescription_1.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0]; ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
String cfgDescriptionId = cfgDescriptionWritable.getId(); String cfgDescriptionId = cfgDescription.getId();
// Add entries // Add entries
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>(); List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(SAMPLE_LSE); entries.add(SAMPLE_LSE);
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders(); List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
assertEquals(1, providers.size()); assertEquals(1, providers.size());
assertTrue(providers.get(0) instanceof MockLanguageSettingsEditableProvider); assertTrue(providers.get(0) instanceof MockLanguageSettingsEditableProvider);
MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0); MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0);
mockProvider.setSettingEntries(cfgDescriptionWritable, project, null, entries); mockProvider.setSettingEntries(cfgDescription, project, null, entries);
// reset count // reset count
mockLseListener.resetCount(); mockLseListener.resetCount();
@ -795,18 +824,18 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
{ {
ICConfigurationDescription[] cfgDescriptions = prjDescription_2.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescription_2.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0]; ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
String cfgDescriptionId = cfgDescriptionWritable.getId(); String cfgDescriptionId = cfgDescription.getId();
// Add same entries // Add same entries
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>(); List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(SAMPLE_LSE); entries.add(SAMPLE_LSE);
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders(); List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
assertEquals(1, providers.size()); assertEquals(1, providers.size());
assertTrue(providers.get(0) instanceof MockLanguageSettingsEditableProvider); assertTrue(providers.get(0) instanceof MockLanguageSettingsEditableProvider);
MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0); MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0);
mockProvider.setSettingEntries(cfgDescriptionWritable, project, null, entries); mockProvider.setSettingEntries(cfgDescription, project, null, entries);
// reset count // reset count
mockLseListener.resetCount(); mockLseListener.resetCount();
@ -823,15 +852,17 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
} }
/** /**
* Test events triggered during adding global empty provider.
*/ */
public void testNotification_globalProvider_AddEmptyProvider() throws Exception { public void testNotification_globalProvider_AddEmptyProvider() throws Exception {
// create project
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName()); IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
// First clear default providers // First clear default providers
{ {
// get project descriptions // get project descriptions
ICProjectDescription writableProjDescription = CoreModel.getDefault().getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(writableProjDescription); assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
@ -843,7 +874,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertEquals(0, storedProviders.size()); assertEquals(0, storedProviders.size());
// write to project description // write to project description
CoreModel.getDefault().setProjectDescription(project, writableProjDescription); CoreModel.getDefault().setProjectDescription(project, prjDescriptionWritable);
} }
// register mock listener to inspect the notifications // register mock listener to inspect the notifications
@ -854,9 +885,9 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// Add empty global provider // Add empty global provider
{ {
// get project descriptions // get project descriptions
ICProjectDescription writableProjDescription = CoreModel.getDefault().getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(writableProjDescription); assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
@ -877,7 +908,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertEquals(1, storedProviders.size()); assertEquals(1, storedProviders.size());
// write to project description // write to project description
CoreModel.getDefault().setProjectDescription(project, writableProjDescription); CoreModel.getDefault().setProjectDescription(project, prjDescriptionWritable);
} }
// No notifications expected // No notifications expected
@ -886,15 +917,17 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
} }
/** /**
* Test events triggered during adding global non-empty provider.
*/ */
public void testNotification_globalProvider_AddNonEmptyProvider() throws Exception { public void testNotification_globalProvider_AddNonEmptyProvider() throws Exception {
// create project
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName()); IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
// First clear default providers // First clear default providers
{ {
// get project descriptions // get project descriptions
ICProjectDescription writableProjDescription = CoreModel.getDefault().getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(writableProjDescription); assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
@ -906,7 +939,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertEquals(0, storedProviders.size()); assertEquals(0, storedProviders.size());
// write to project description // write to project description
CoreModel.getDefault().setProjectDescription(project, writableProjDescription); CoreModel.getDefault().setProjectDescription(project, prjDescriptionWritable);
} }
// register mock listener to inspect the notifications // register mock listener to inspect the notifications
@ -917,9 +950,9 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// Add non-empty provider // Add non-empty provider
{ {
// get project descriptions // get project descriptions
ICProjectDescription writableProjDescription = CoreModel.getDefault().getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(writableProjDescription); assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
@ -945,7 +978,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertEquals(1, storedProviders.size()); assertEquals(1, storedProviders.size());
// write to project description // write to project description
CoreModel.getDefault().setProjectDescription(project, writableProjDescription); CoreModel.getDefault().setProjectDescription(project, prjDescriptionWritable);
// inspect notifications // inspect notifications
assertEquals(1, mockLseListener.getCount()); assertEquals(1, mockLseListener.getCount());
@ -959,8 +992,10 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
} }
/** /**
* Test events triggered during serialization of global shared providers.
*/ */
public void testNotification_globalProvider_SerializeEntries() throws Exception { public void testNotification_globalProvider_SerializeEntries() throws Exception {
// create project
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName()); IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
// register mock listener to inspect the notifications // register mock listener to inspect the notifications
@ -969,9 +1004,9 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// Add empty global provider // Add empty global provider
{ {
// get project descriptions // get project descriptions
ICProjectDescription writableProjDescription = CoreModel.getDefault().getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(writableProjDescription); assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
@ -992,7 +1027,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertEquals(1, storedProviders.size()); assertEquals(1, storedProviders.size());
// write to project description // write to project description
CoreModel.getDefault().setProjectDescription(project, writableProjDescription); CoreModel.getDefault().setProjectDescription(project, prjDescriptionWritable);
} }
// Change the provider's entries // Change the provider's entries
@ -1018,7 +1053,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
LanguageSettingsManager.serializeLanguageSettingsWorkspace(); LanguageSettingsManager.serializeLanguageSettingsWorkspace();
// get cfgDescriptionId // get cfgDescriptionId
ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project, false); ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
assertNotNull(prjDescription); assertNotNull(prjDescription);
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
@ -1053,7 +1088,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
LanguageSettingsManager.serializeLanguageSettingsWorkspace(); LanguageSettingsManager.serializeLanguageSettingsWorkspace();
// get cfgDescriptionId // get cfgDescriptionId
ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project, false); ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
assertNotNull(prjDescription); assertNotNull(prjDescription);
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2011 Andrew Gvozdev and others. * Copyright (c) 2009, 2012 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -18,7 +18,6 @@ import junit.framework.TestSuite;
import org.eclipse.cdt.core.AbstractExecutableExtensionBase; import org.eclipse.cdt.core.AbstractExecutableExtensionBase;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage; import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.CIncludePathEntry; import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
import org.eclipse.cdt.core.settings.model.CMacroEntry; import org.eclipse.cdt.core.settings.model.CMacroEntry;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
@ -30,6 +29,7 @@ import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer; import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer;
import org.eclipse.cdt.internal.core.settings.model.CConfigurationDescription; import org.eclipse.cdt.internal.core.settings.model.CConfigurationDescription;
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
@ -38,7 +38,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
/** /**
* Test cases testing LanguageSettingsProvider functionality * Test cases testing {@link LanguageSettingsManager} utility methods.
*/ */
public class LanguageSettingsManagerTests extends BaseTestCase { public class LanguageSettingsManagerTests extends BaseTestCase {
// Those should match ids of plugin extensions defined in plugin.xml // Those should match ids of plugin extensions defined in plugin.xml
@ -47,61 +47,60 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
private static final String EXTENSION_SERIALIZABLE_PROVIDER_NAME = LanguageSettingsExtensionsTests.EXTENSION_SERIALIZABLE_PROVIDER_NAME; private static final String EXTENSION_SERIALIZABLE_PROVIDER_NAME = LanguageSettingsExtensionsTests.EXTENSION_SERIALIZABLE_PROVIDER_NAME;
private static final String EXTENSION_EDITABLE_PROVIDER_ID = LanguageSettingsExtensionsTests.EXTENSION_EDITABLE_PROVIDER_ID; private static final String EXTENSION_EDITABLE_PROVIDER_ID = LanguageSettingsExtensionsTests.EXTENSION_EDITABLE_PROVIDER_ID;
private static final IFile FILE_0 = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/project/path0")); // Arbitrary sample parameters used by the test case
private static final String CFG_ID = "test.configuration.id";
private static final String LANG_ID = "test.lang.id";
private static final String LANG_CPP = GPPLanguage.ID;
private static final String PROVIDER_0 = "test.provider.0.id"; private static final String PROVIDER_0 = "test.provider.0.id";
private static final String PROVIDER_1 = "test.provider.1.id"; private static final String PROVIDER_1 = "test.provider.1.id";
private static final String PROVIDER_2 = "test.provider.2.id"; private static final String PROVIDER_2 = "test.provider.2.id";
private static final String PROVIDER_NAME_0 = "test.provider.0.name"; private static final String PROVIDER_NAME_0 = "test.provider.0.name";
private static final String PROVIDER_NAME_1 = "test.provider.1.name"; private static final String PROVIDER_NAME_1 = "test.provider.1.name";
private static final String PROVIDER_NAME_2 = "test.provider.2.name"; private static final String PROVIDER_NAME_2 = "test.provider.2.name";
private static final String CFG_ID = "test.configuration.id";
private static final String LANG_ID = "test.lang.id";
private static final String LANG_CPP = GPPLanguage.ID;
private static final IFile FILE_0 = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/project/path0"));
/**
* Mock configuration description.
*/
class MockConfigurationDescription extends CModelMock.DummyCConfigurationDescription implements ILanguageSettingsProvidersKeeper { class MockConfigurationDescription extends CModelMock.DummyCConfigurationDescription implements ILanguageSettingsProvidersKeeper {
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(); List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
String[] defaultProvidersIds = null; String[] defaultProvidersIds = null;
public MockConfigurationDescription(String id) { public MockConfigurationDescription(String id) {
super(id); super(id);
} }
@Override @Override
public void setLanguageSettingProviders(List<ILanguageSettingsProvider> providers) { public void setLanguageSettingProviders(List<ILanguageSettingsProvider> providers) {
this.providers = new ArrayList<ILanguageSettingsProvider>(providers); this.providers = new ArrayList<ILanguageSettingsProvider>(providers);
} }
@Override @Override
public List<ILanguageSettingsProvider> getLanguageSettingProviders() { public List<ILanguageSettingsProvider> getLanguageSettingProviders() {
return providers; return providers;
} }
@Override @Override
public void setDefaultLanguageSettingsProvidersIds(String[] ids) { public void setDefaultLanguageSettingsProvidersIds(String[] ids) {
defaultProvidersIds = ids; defaultProvidersIds = ids;
} }
@Override @Override
public String[] getDefaultLanguageSettingsProvidersIds() { public String[] getDefaultLanguageSettingsProvidersIds() {
return defaultProvidersIds; return defaultProvidersIds;
} }
} }
/**
* Mock language sttings provider.
*/
private class MockProvider extends AbstractExecutableExtensionBase implements ILanguageSettingsProvider { private class MockProvider extends AbstractExecutableExtensionBase implements ILanguageSettingsProvider {
private List<ICLanguageSettingEntry> entries; private List<ICLanguageSettingEntry> entries;
public MockProvider(String id, String name, List<ICLanguageSettingEntry> entries) { public MockProvider(String id, String name, List<ICLanguageSettingEntry> entries) {
super(id, name); super(id, name);
this.entries = entries; this.entries = entries;
} }
@Override @Override
public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) { public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
return entries; return entries;
} }
} }
/** /**
* Constructor. * Constructor.
* @param name - name of the test. * @param name - name of the test.
@ -119,7 +118,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
@Override @Override
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
LanguageSettingsManager.setWorkspaceProviders(null); LanguageSettingsManager.setWorkspaceProviders(null);
super.tearDown(); super.tearDown(); // includes ResourceHelper cleanup
} }
/** /**
@ -142,6 +141,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
* Test ILanguageSettingsProvidersKeeper API (getters and setters). * Test ILanguageSettingsProvidersKeeper API (getters and setters).
*/ */
public void testConfigurationDescription_Providers() throws Exception { public void testConfigurationDescription_Providers() throws Exception {
// mock configuration description
MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID);
// set providers // set providers
@ -174,11 +174,11 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
// Create model project and accompanied descriptions // Create model project and accompanied descriptions
String projectName = getName(); String projectName = getName();
IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); IProject project = ResourceHelper.createCDTProjectWithConfig(projectName);
ICProjectDescription writableProjDescription = CoreModel.getDefault().getProjectDescription(project, true); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0];
assertTrue(cfgDescription instanceof CConfigurationDescription); assertTrue(cfgDescriptionWritable instanceof CConfigurationDescription);
// attempt to add duplicate providers // attempt to add duplicate providers
MockProvider dupe1 = new MockProvider(PROVIDER_0, PROVIDER_NAME_1, null); MockProvider dupe1 = new MockProvider(PROVIDER_0, PROVIDER_NAME_1, null);
@ -189,7 +189,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
providers.add(dupe2); providers.add(dupe2);
try { try {
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(providers);
fail("cfgDescription.setLanguageSettingProviders() should not accept duplicate providers"); fail("cfgDescription.setLanguageSettingProviders() should not accept duplicate providers");
} catch (Exception e) { } catch (Exception e) {
// Exception is welcome here // Exception is welcome here
@ -200,6 +200,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
* Test various cases of ill-defined providers. * Test various cases of ill-defined providers.
*/ */
public void testRudeProviders() throws Exception { public void testRudeProviders() throws Exception {
// mock configuration description
MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID);
// set impolite provider returning null by getSettingEntries() // set impolite provider returning null by getSettingEntries()
ILanguageSettingsProvider providerNull = new MockProvider(PROVIDER_1, PROVIDER_NAME_1, null); ILanguageSettingsProvider providerNull = new MockProvider(PROVIDER_1, PROVIDER_NAME_1, null);
@ -230,7 +231,6 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
add(null); add(null);
} }
}); });
{ {
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(); List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(providerNull); providers.add(providerNull);
@ -273,7 +273,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
} }
/** /**
* Test simple use case. * Test assigning and retrieving providers from a configuration.
*/ */
public void testProvider_Basic() throws Exception { public void testProvider_Basic() throws Exception {
final MockConfigurationDescription modelCfgDescription = new MockConfigurationDescription(CFG_ID); final MockConfigurationDescription modelCfgDescription = new MockConfigurationDescription(CFG_ID);
@ -377,16 +377,17 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
} }
/** /**
* Test getting entries from resource hierarchy.
*/ */
public void testProvider_ParentFolder() throws Exception { public void testProvider_ParentFolder() throws Exception {
// Create model project and accompanied descriptions // Create model project and accompanied descriptions
String projectName = getName(); String projectName = getName();
IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); IProject project = ResourceHelper.createCDTProjectWithConfig(projectName);
ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0];
assertTrue(cfgDescription instanceof CConfigurationDescription); assertTrue(cfgDescriptionWritable instanceof CConfigurationDescription);
final IFolder parentFolder = ResourceHelper.createFolder(project, "/ParentFolder/"); final IFolder parentFolder = ResourceHelper.createFolder(project, "/ParentFolder/");
assertNotNull(parentFolder); assertNotNull(parentFolder);
@ -411,13 +412,13 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
}; };
providers.add(provider); providers.add(provider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(providers);
{ {
// retrieve entries for a derived resource (in a subfolder) // retrieve entries for a derived resource (in a subfolder)
IFile derived = ResourceHelper.createFile(project, "/ParentFolder/Subfolder/resource"); IFile derived = ResourceHelper.createFile(project, "/ParentFolder/Subfolder/resource");
List<ICLanguageSettingEntry> actual = LanguageSettingsManager List<ICLanguageSettingEntry> actual = LanguageSettingsManager
.getSettingEntriesUpResourceTree(provider, cfgDescription, derived, LANG_ID); .getSettingEntriesUpResourceTree(provider, cfgDescriptionWritable, derived, LANG_ID);
// taken from parent folder // taken from parent folder
assertEquals(entries.get(0),actual.get(0)); assertEquals(entries.get(0),actual.get(0));
assertEquals(entries.size(), actual.size()); assertEquals(entries.size(), actual.size());
@ -427,30 +428,31 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
// retrieve entries for not related resource // retrieve entries for not related resource
IFile notRelated = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/AnotherFolder/Subfolder/resource")); IFile notRelated = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/AnotherFolder/Subfolder/resource"));
List<ICLanguageSettingEntry> actual = LanguageSettingsManager List<ICLanguageSettingEntry> actual = LanguageSettingsManager
.getSettingEntriesUpResourceTree(provider, cfgDescription, notRelated, LANG_ID); .getSettingEntriesUpResourceTree(provider, cfgDescriptionWritable, notRelated, LANG_ID);
assertEquals(0, actual.size()); assertEquals(0, actual.size());
} }
{ {
// test distinction between no settings and empty settings // test distinction between no settings and empty settings
List<ICLanguageSettingEntry> actual = LanguageSettingsManager List<ICLanguageSettingEntry> actual = LanguageSettingsManager
.getSettingEntriesUpResourceTree(provider, cfgDescription, emptySettingsPath, LANG_ID); .getSettingEntriesUpResourceTree(provider, cfgDescriptionWritable, emptySettingsPath, LANG_ID);
// NOT taken from parent folder // NOT taken from parent folder
assertEquals(0, actual.size()); assertEquals(0, actual.size());
} }
} }
/** /**
* Test getting entries from resource hierarchy up to default entries.
*/ */
public void testProvider_DefaultEntries() throws Exception { public void testProvider_DefaultEntries() throws Exception {
// Create model project and accompanied descriptions // Create model project and accompanied descriptions
String projectName = getName(); String projectName = getName();
IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); IProject project = ResourceHelper.createCDTProjectWithConfig(projectName);
ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0];
assertTrue(cfgDescription instanceof CConfigurationDescription); assertTrue(cfgDescriptionWritable instanceof CConfigurationDescription);
final IFolder parentFolder = ResourceHelper.createFolder(project, "/ParentFolder/"); final IFolder parentFolder = ResourceHelper.createFolder(project, "/ParentFolder/");
assertNotNull(parentFolder); assertNotNull(parentFolder);
@ -472,13 +474,13 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
}; };
providers.add(provider); providers.add(provider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(providers);
{ {
// retrieve entries for a resource // retrieve entries for a resource
IFile derived = ResourceHelper.createFile(project, "/ParentFolder/Subfolder/resource"); IFile derived = ResourceHelper.createFile(project, "/ParentFolder/Subfolder/resource");
List<ICLanguageSettingEntry> actual = LanguageSettingsManager List<ICLanguageSettingEntry> actual = LanguageSettingsManager
.getSettingEntriesUpResourceTree(provider, cfgDescription, derived, LANG_ID); .getSettingEntriesUpResourceTree(provider, cfgDescriptionWritable, derived, LANG_ID);
// default entries given // default entries given
assertEquals(entries.get(0),actual.get(0)); assertEquals(entries.get(0),actual.get(0));
assertEquals(entries.size(), actual.size()); assertEquals(entries.size(), actual.size());
@ -656,9 +658,9 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
// Create model project and accompanied descriptions // Create model project and accompanied descriptions
String projectName = getName(); String projectName = getName();
IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); IProject project = ResourceHelper.createCDTProjectWithConfig(projectName);
ICProjectDescription writableProjDescription = CoreModel.getDefault().getProjectDescription(project, true); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof CConfigurationDescription); assertTrue(cfgDescription instanceof CConfigurationDescription);
@ -683,7 +685,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
{ {
// serialize // serialize
CoreModel.getDefault().setProjectDescription(project, writableProjDescription); CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescriptionWritable);
// close and reopen the project // close and reopen the project
project.close(null); project.close(null);
project.open(null); project.open(null);
@ -691,7 +693,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
{ {
// check that test provider got loaded // check that test provider got loaded
ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project); ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
ICConfigurationDescription[] loadedCfgDescriptions = prjDescription.getConfigurations(); ICConfigurationDescription[] loadedCfgDescriptions = prjDescription.getConfigurations();
ICConfigurationDescription loadedCfgDescription = loadedCfgDescriptions[0]; ICConfigurationDescription loadedCfgDescription = loadedCfgDescriptions[0];
assertTrue(cfgDescription instanceof CConfigurationDescription); assertTrue(cfgDescription instanceof CConfigurationDescription);
@ -806,6 +808,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
} }
/** /**
* TODO - YAGNI?
*/ */
public void testBuildResourceTree_FileInFolder() throws Exception { public void testBuildResourceTree_FileInFolder() throws Exception {
// sample entries // sample entries
@ -830,6 +833,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
} }
/** /**
* TODO - YAGNI?
*/ */
public void testBuildResourceTree_FileInSubFolder() throws Exception { public void testBuildResourceTree_FileInSubFolder() throws Exception {
// sample entries // sample entries
@ -855,6 +859,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
} }
/** /**
* TODO - YAGNI?
*/ */
public void testBuildResourceTree_TwoSubFolders() throws Exception { public void testBuildResourceTree_TwoSubFolders() throws Exception {
// sample entries // sample entries
@ -888,6 +893,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
} }
/** /**
* TODO - YAGNI?
*/ */
public void testBuildResourceTree_FlippingSettings() throws Exception { public void testBuildResourceTree_FlippingSettings() throws Exception {
// sample entries // sample entries
@ -928,6 +934,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
} }
/** /**
* TODO - YAGNI?
*/ */
public void testBuildResourceTree_WithLanguage() throws Exception { public void testBuildResourceTree_WithLanguage() throws Exception {
// sample entries // sample entries

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2011 Andrew Gvozdev and others. * Copyright (c) 2009, 2012 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -18,12 +18,10 @@ import java.util.List;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.CIncludePathEntry; import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
import org.eclipse.cdt.core.settings.model.WriteAccessException; import org.eclipse.cdt.core.settings.model.WriteAccessException;
import org.eclipse.cdt.core.testplugin.CModelMock; import org.eclipse.cdt.core.testplugin.CModelMock;
import org.eclipse.cdt.core.testplugin.ResourceHelper; import org.eclipse.cdt.core.testplugin.ResourceHelper;
@ -38,7 +36,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
/** /**
* Test cases testing LanguageSettingsProvider functionality * Test cases testing LanguageSettingsProvider functionality related to persistence.
*/ */
public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
// These should match extension points defined in plugin.xml // These should match extension points defined in plugin.xml
@ -49,9 +47,11 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
private static final String EXTENSION_USER_PROVIDER_ID = LanguageSettingsExtensionsTests.EXTENSION_USER_PROVIDER_ID; private static final String EXTENSION_USER_PROVIDER_ID = LanguageSettingsExtensionsTests.EXTENSION_USER_PROVIDER_ID;
private static final ICLanguageSettingEntry EXTENSION_SERIALIZABLE_PROVIDER_ENTRY = LanguageSettingsExtensionsTests.EXTENSION_SERIALIZABLE_PROVIDER_ENTRY; private static final ICLanguageSettingEntry EXTENSION_SERIALIZABLE_PROVIDER_ENTRY = LanguageSettingsExtensionsTests.EXTENSION_SERIALIZABLE_PROVIDER_ENTRY;
// Constants from LanguageSettingsProvidersSerializer
public static final String LANGUAGE_SETTINGS_PROJECT_XML = ".settings/language.settings.xml"; public static final String LANGUAGE_SETTINGS_PROJECT_XML = ".settings/language.settings.xml";
public static final String LANGUAGE_SETTINGS_WORKSPACE_XML = "language.settings.xml"; public static final String LANGUAGE_SETTINGS_WORKSPACE_XML = "language.settings.xml";
// Arbitrary sample parameters used by the test
private static final String CFG_ID = "test.configuration.id.0"; private static final String CFG_ID = "test.configuration.id.0";
private static final String CFG_ID_2 = "test.configuration.id.2"; private static final String CFG_ID_2 = "test.configuration.id.2";
private static final String PROVIDER_0 = "test.provider.0.id"; private static final String PROVIDER_0 = "test.provider.0.id";
@ -66,50 +66,47 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
private static final String ELEM_PROVIDER = "provider "; // keep space for more reliable comparison private static final String ELEM_PROVIDER = "provider "; // keep space for more reliable comparison
private static final String ELEM_PROVIDER_REFERENCE = "provider-reference"; private static final String ELEM_PROVIDER_REFERENCE = "provider-reference";
private static CoreModel coreModel = CoreModel.getDefault(); /**
* Mock configuration description.
*/
class MockConfigurationDescription extends CModelMock.DummyCConfigurationDescription implements ILanguageSettingsProvidersKeeper { class MockConfigurationDescription extends CModelMock.DummyCConfigurationDescription implements ILanguageSettingsProvidersKeeper {
List<ILanguageSettingsProvider> providers; List<ILanguageSettingsProvider> providers;
public MockConfigurationDescription(String id) { public MockConfigurationDescription(String id) {
super(id); super(id);
} }
@Override @Override
public void setLanguageSettingProviders(List<ILanguageSettingsProvider> providers) { public void setLanguageSettingProviders(List<ILanguageSettingsProvider> providers) {
this.providers = new ArrayList<ILanguageSettingsProvider>(providers); this.providers = new ArrayList<ILanguageSettingsProvider>(providers);
} }
@Override @Override
public List<ILanguageSettingsProvider> getLanguageSettingProviders() { public List<ILanguageSettingsProvider> getLanguageSettingProviders() {
return providers; return providers;
} }
@Override @Override
public void setDefaultLanguageSettingsProvidersIds(String[] ids) { public void setDefaultLanguageSettingsProvidersIds(String[] ids) {
} }
@Override @Override
public String[] getDefaultLanguageSettingsProvidersIds() { public String[] getDefaultLanguageSettingsProvidersIds() {
return null; return null;
} }
} }
/**
* Mock project description.
*/
class MockProjectDescription extends CModelMock.DummyCProjectDescription { class MockProjectDescription extends CModelMock.DummyCProjectDescription {
ICConfigurationDescription[] cfgDescriptions; ICConfigurationDescription[] cfgDescriptions;
public MockProjectDescription(ICConfigurationDescription[] cfgDescriptions) { public MockProjectDescription(ICConfigurationDescription[] cfgDescriptions) {
this.cfgDescriptions = cfgDescriptions; this.cfgDescriptions = cfgDescriptions;
} }
public MockProjectDescription(ICConfigurationDescription cfgDescription) { public MockProjectDescription(ICConfigurationDescription cfgDescription) {
this.cfgDescriptions = new ICConfigurationDescription[] { cfgDescription }; this.cfgDescriptions = new ICConfigurationDescription[] { cfgDescription };
} }
@Override @Override
public ICConfigurationDescription[] getConfigurations() { public ICConfigurationDescription[] getConfigurations() {
return cfgDescriptions; return cfgDescriptions;
} }
@Override @Override
public ICConfigurationDescription getConfigurationById(String id) { public ICConfigurationDescription getConfigurationById(String id) {
for (ICConfigurationDescription cfgDescription : cfgDescriptions) { for (ICConfigurationDescription cfgDescription : cfgDescriptions) {
@ -126,7 +123,6 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
*/ */
public LanguageSettingsPersistenceProjectTests(String name) { public LanguageSettingsPersistenceProjectTests(String name) {
super(name); super(name);
} }
@Override @Override
@ -137,7 +133,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
@Override @Override
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
LanguageSettingsManager.setWorkspaceProviders(null); LanguageSettingsManager.setWorkspaceProviders(null);
super.tearDown(); super.tearDown(); // includes ResourceHelper cleanup
} }
/** /**
@ -156,10 +152,12 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
junit.textui.TestRunner.run(suite()); junit.textui.TestRunner.run(suite());
} }
/**
* Get read-only configuration descriptions.
*/
private ICConfigurationDescription[] getConfigurationDescriptions(IProject project) { private ICConfigurationDescription[] getConfigurationDescriptions(IProject project) {
ICProjectDescriptionManager mngr = coreModel.getProjectDescriptionManager();
// project description // project description
ICProjectDescription projectDescription = mngr.getProjectDescription(project); ICProjectDescription projectDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
assertNotNull(projectDescription); assertNotNull(projectDescription);
assertEquals(1, projectDescription.getConfigurations().length); assertEquals(1, projectDescription.getConfigurations().length);
// configuration description // configuration description
@ -168,6 +166,9 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
return cfgDescriptions; return cfgDescriptions;
} }
/**
* Get first read-only configuration description.
*/
private ICConfigurationDescription getFirstConfigurationDescription(IProject project) { private ICConfigurationDescription getFirstConfigurationDescription(IProject project) {
ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project);
@ -178,8 +179,9 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
} }
/** /**
* Persist and reload when no customized providers are defined in the workspace.
*/ */
public void testNoProviders() throws Exception { public void testWorkspacePersistence_NoProviders() throws Exception {
// serialize language settings of user defined providers (on workspace level) // serialize language settings of user defined providers (on workspace level)
LanguageSettingsProvidersSerializer.serializeLanguageSettingsWorkspace(); LanguageSettingsProvidersSerializer.serializeLanguageSettingsWorkspace();
LanguageSettingsProvidersSerializer.loadLanguageSettingsWorkspace(); LanguageSettingsProvidersSerializer.loadLanguageSettingsWorkspace();
@ -188,21 +190,22 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
} }
/** /**
* Make sure providers in configuration cannot be modified accidentally outside of API.
*/ */
public void testProjectDescription_PreventBackDoorAccess() throws Exception { public void testProjectDescription_PreventBackDoorAccess() throws Exception {
// create a project // create a project
IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
// get project descriptions // get project descriptions
ICProjectDescription writableProjDescription = coreModel.getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(writableProjDescription); assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0];
assertNotNull(cfgDescription); assertNotNull(cfgDescriptionWritable);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper);
List<ILanguageSettingsProvider> originalProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); List<ILanguageSettingsProvider> originalProviders = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders();
int originalSize = originalProviders.size(); int originalSize = originalProviders.size();
// create new provider list // create new provider list
@ -212,28 +215,29 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertTrue(originalSize != providers.size()); assertTrue(originalSize != providers.size());
// changing providers shouldn't affect the original list // changing providers shouldn't affect the original list
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(providers);
assertEquals(originalSize, originalProviders.size()); assertEquals(originalSize, originalProviders.size());
} }
/** /**
* Test assigning providers to read-only vs. writable configuration descriptions.
*/ */
public void testProjectDescription_ReadWriteProviders() throws Exception { public void testProjectDescription_ReadWriteDescription() throws Exception {
// create a project // create a project
IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
{ {
// get read-only description // get read-only description
ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false); ICProjectDescription prjDescriptionReadOnly = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
assertNotNull(prjDescription); assertNotNull(prjDescriptionReadOnly);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); ICConfigurationDescription cfgDescriptionReadOnly = prjDescriptionReadOnly.getDefaultSettingConfiguration();
assertNotNull(cfgDescription); assertNotNull(cfgDescriptionReadOnly);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescriptionReadOnly instanceof ILanguageSettingsProvidersKeeper);
// try to write to it providers // try to write to it providers
try { try {
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(); List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); ((ILanguageSettingsProvidersKeeper) cfgDescriptionReadOnly).setLanguageSettingProviders(providers);
fail("WriteAccessException was expected but it was not throw."); fail("WriteAccessException was expected but it was not throw.");
} catch (WriteAccessException e) { } catch (WriteAccessException e) {
// exception is expected // exception is expected
@ -241,7 +245,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
// try to write to it default providers ids // try to write to it default providers ids
try { try {
((ILanguageSettingsProvidersKeeper) cfgDescription).setDefaultLanguageSettingsProvidersIds(new String[] { PROVIDER_0 }); ((ILanguageSettingsProvidersKeeper) cfgDescriptionReadOnly).setDefaultLanguageSettingsProvidersIds(new String[] { PROVIDER_0 });
fail("WriteAccessException was expected but it was not throw."); fail("WriteAccessException was expected but it was not throw.");
} catch (WriteAccessException e) { } catch (WriteAccessException e) {
// exception is expected // exception is expected
@ -253,85 +257,86 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
{ {
// get project descriptions // get project descriptions
ICProjectDescription writableProjDescription = coreModel.getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(writableProjDescription); assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0];
assertNotNull(cfgDescription); assertNotNull(cfgDescriptionWritable);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper);
// create a provider and write to cfgDescription // create a provider and write to cfgDescription
LanguageSettingsSerializableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1); LanguageSettingsSerializableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1);
LanguageSettingsManager.setStoringEntriesInProjectArea(mockProvider, true); LanguageSettingsManager.setStoringEntriesInProjectArea(mockProvider, true);
mockProvider.setSettingEntries(cfgDescription, null, null, entries); mockProvider.setSettingEntries(cfgDescriptionWritable, null, null, entries);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(); List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(mockProvider); providers.add(mockProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(providers);
List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders();
assertEquals(1, storedProviders.size()); assertEquals(1, storedProviders.size());
// write to cfgDescription default providers ids // write to cfgDescription default providers ids
((ILanguageSettingsProvidersKeeper) cfgDescription).setDefaultLanguageSettingsProvidersIds(new String[] { PROVIDER_0 }); ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setDefaultLanguageSettingsProvidersIds(new String[] { PROVIDER_0 });
// apply new project description to the project model // apply new project description to the project model
coreModel.setProjectDescription(project, writableProjDescription); CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescriptionWritable);
} }
{ {
// get read-only project descriptions // get read-only project descriptions
ICProjectDescription readOnlyProjDescription = coreModel.getProjectDescription(project, false); ICProjectDescription prjDescriptionReadOnly = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
assertNotNull(readOnlyProjDescription); assertNotNull(prjDescriptionReadOnly);
ICConfigurationDescription[] cfgDescriptions = readOnlyProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionReadOnly.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescriptionReadOnly = cfgDescriptions[0];
assertNotNull(cfgDescription); assertNotNull(cfgDescriptionReadOnly);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescriptionReadOnly instanceof ILanguageSettingsProvidersKeeper);
// double-check providers // double-check providers
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionReadOnly).getLanguageSettingProviders();
assertEquals(1, providers.size()); assertEquals(1, providers.size());
ILanguageSettingsProvider loadedProvider = providers.get(0); ILanguageSettingsProvider loadedProvider = providers.get(0);
assertTrue(loadedProvider instanceof MockLanguageSettingsEditableProvider); assertTrue(loadedProvider instanceof MockLanguageSettingsEditableProvider);
assertEquals(PROVIDER_1, loadedProvider.getId()); assertEquals(PROVIDER_1, loadedProvider.getId());
assertEquals(PROVIDER_NAME_1, loadedProvider.getName()); assertEquals(PROVIDER_NAME_1, loadedProvider.getName());
// double-check provider's setting entries // double-check provider's setting entries
List<ICLanguageSettingEntry> actual = loadedProvider.getSettingEntries(cfgDescription, null, null); List<ICLanguageSettingEntry> actual = loadedProvider.getSettingEntries(cfgDescriptionReadOnly, null, null);
assertEquals(entries.get(0), actual.get(0)); assertEquals(entries.get(0), actual.get(0));
assertEquals(entries.size(), actual.size()); assertEquals(entries.size(), actual.size());
// double-check default providers ids // double-check default providers ids
String[] actualDefaultProvidersIds = ((ILanguageSettingsProvidersKeeper) cfgDescription).getDefaultLanguageSettingsProvidersIds(); String[] actualDefaultProvidersIds = ((ILanguageSettingsProvidersKeeper) cfgDescriptionReadOnly).getDefaultLanguageSettingsProvidersIds();
assertTrue(Arrays.equals(new String[] { PROVIDER_0 }, actualDefaultProvidersIds)); assertTrue(Arrays.equals(new String[] { PROVIDER_0 }, actualDefaultProvidersIds));
} }
{ {
// get writable project descriptions // get writable project descriptions
ICProjectDescription writableProjDescription = coreModel.getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(writableProjDescription); assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0];
assertNotNull(cfgDescription); assertNotNull(cfgDescriptionWritable);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper);
// check providers // check providers
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders();
assertEquals(1, providers.size()); assertEquals(1, providers.size());
ILanguageSettingsProvider loadedProvider = providers.get(0); ILanguageSettingsProvider loadedProvider = providers.get(0);
assertTrue(loadedProvider instanceof MockLanguageSettingsEditableProvider); assertTrue(loadedProvider instanceof MockLanguageSettingsEditableProvider);
assertEquals(PROVIDER_1, loadedProvider.getId()); assertEquals(PROVIDER_1, loadedProvider.getId());
assertEquals(PROVIDER_NAME_1, loadedProvider.getName()); assertEquals(PROVIDER_NAME_1, loadedProvider.getName());
// check provider's setting entries // check provider's setting entries
List<ICLanguageSettingEntry> actual = loadedProvider.getSettingEntries(cfgDescription, null, null); List<ICLanguageSettingEntry> actual = loadedProvider.getSettingEntries(cfgDescriptionWritable, null, null);
assertEquals(entries.get(0), actual.get(0)); assertEquals(entries.get(0), actual.get(0));
assertEquals(entries.size(), actual.size()); assertEquals(entries.size(), actual.size());
// check default providers ids // check default providers ids
String[] actualDefaultProvidersIds = ((ILanguageSettingsProvidersKeeper) cfgDescription).getDefaultLanguageSettingsProvidersIds(); String[] actualDefaultProvidersIds = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getDefaultLanguageSettingsProvidersIds();
assertTrue(Arrays.equals(new String[] { PROVIDER_0 }, actualDefaultProvidersIds)); assertTrue(Arrays.equals(new String[] { PROVIDER_0 }, actualDefaultProvidersIds));
} }
} }
/** /**
* Persist and reload a customized provider defined in the workspace.
*/ */
public void testWorkspacePersistence_ModifiedExtensionProvider() throws Exception { public void testWorkspacePersistence_ModifiedExtensionProvider() throws Exception {
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>(); List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
@ -376,6 +381,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
} }
/** /**
* Check persistence of unmodified extension provider in the workspace.
*/ */
public void testWorkspacePersistence_UnmodifiedExtensionProvider() throws Exception { public void testWorkspacePersistence_UnmodifiedExtensionProvider() throws Exception {
List<ICLanguageSettingEntry> extensionEntries = new ArrayList<ICLanguageSettingEntry>(); List<ICLanguageSettingEntry> extensionEntries = new ArrayList<ICLanguageSettingEntry>();
@ -419,6 +425,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
} }
/** /**
* Test persistence of global providers in the workspace.
*/ */
public void testWorkspacePersistence_GlobalProvider() throws Exception { public void testWorkspacePersistence_GlobalProvider() throws Exception {
{ {
@ -448,6 +455,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
} }
/** /**
* Test persistence of global providers with ID matching an extension provider in the workspace.
*/ */
public void testWorkspacePersistence_ShadowedExtensionProvider() throws Exception { public void testWorkspacePersistence_ShadowedExtensionProvider() throws Exception {
{ {
@ -512,6 +520,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
} }
/** /**
* Test serialization of providers to project storage.
*/ */
public void testProjectPersistence_SerializableProviderDOM() throws Exception { public void testProjectPersistence_SerializableProviderDOM() throws Exception {
Element rootElement = null; Element rootElement = null;
@ -568,6 +577,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
} }
/** /**
* Test User language settings provider defined as extension in cdt.ui.
*/ */
public void testProjectPersistence_UserProviderDOM() throws Exception { public void testProjectPersistence_UserProviderDOM() throws Exception {
Element rootElement = null; Element rootElement = null;
@ -626,6 +636,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
} }
/** /**
* Test serialization of providers to project storage where the project has multiple configurations.
*/ */
public void testProjectPersistence_TwoConfigurationsDOM() throws Exception { public void testProjectPersistence_TwoConfigurationsDOM() throws Exception {
Element rootElement = null; Element rootElement = null;
@ -766,6 +777,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
} }
/** /**
* Test serialization of providers subclassing {@link LanguageSettingsSerializableProvider}.
*/ */
public void testProjectPersistence_SubclassedSerializableProviderDOM() throws Exception { public void testProjectPersistence_SubclassedSerializableProviderDOM() throws Exception {
Element rootElement = null; Element rootElement = null;
@ -821,6 +833,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
} }
/** /**
* Serialization of providers exactly equal extension providers.
*/ */
public void testProjectPersistence_ReferenceExtensionProviderDOM() throws Exception { public void testProjectPersistence_ReferenceExtensionProviderDOM() throws Exception {
Element rootElement = null; Element rootElement = null;
@ -870,6 +883,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
} }
/** /**
* Test serialization of providers overriding/shadowing extension providers.
*/ */
public void testProjectPersistence_OverrideExtensionProviderDOM() throws Exception { public void testProjectPersistence_OverrideExtensionProviderDOM() throws Exception {
Element rootElement = null; Element rootElement = null;
@ -926,6 +940,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
/** /**
* Test serialization flavors in one storage.
*/ */
public void testProjectPersistence_MixedProvidersDOM() throws Exception { public void testProjectPersistence_MixedProvidersDOM() throws Exception {
Element rootElement = null; Element rootElement = null;
@ -937,7 +952,6 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
entries_32.add(new CIncludePathEntry("path2", 0)); entries_32.add(new CIncludePathEntry("path2", 0));
ILanguageSettingsProvider providerExt; ILanguageSettingsProvider providerExt;
ILanguageSettingsProvider providerWsp;
{ {
// Define providers a bunch // Define providers a bunch
MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID)); MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID));
@ -950,14 +964,12 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
// 1. Provider reference to extension from plugin.xml // 1. Provider reference to extension from plugin.xml
providerExt = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID); providerExt = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID);
// 2. TODO Provider reference to provider defined in the project // 2. Providers defined in a configuration
// 2.1
// 3. Providers defined in a configuration
// 3.1
LanguageSettingsSerializableProvider mockProvider1 = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0); LanguageSettingsSerializableProvider mockProvider1 = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0);
LanguageSettingsManager.setStoringEntriesInProjectArea(mockProvider1, true); LanguageSettingsManager.setStoringEntriesInProjectArea(mockProvider1, true);
mockProvider1.setSettingEntries(null, null, null, entries_31); mockProvider1.setSettingEntries(null, null, null, entries_31);
// 3.2 // 2.2
LanguageSettingsSerializableProvider mockProvider2 = new MockLanguageSettingsSerializableProvider(PROVIDER_2, PROVIDER_NAME_2); LanguageSettingsSerializableProvider mockProvider2 = new MockLanguageSettingsSerializableProvider(PROVIDER_2, PROVIDER_NAME_2);
LanguageSettingsManager.setStoringEntriesInProjectArea(mockProvider2, true); LanguageSettingsManager.setStoringEntriesInProjectArea(mockProvider2, true);
mockProvider2.setSettingEntries(null, null, null, entries_32); mockProvider2.setSettingEntries(null, null, null, entries_32);
@ -994,10 +1006,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
ILanguageSettingsProvider provider0 = providers.get(0); ILanguageSettingsProvider provider0 = providers.get(0);
assertTrue(LanguageSettingsManager.isWorkspaceProvider(provider0)); assertTrue(LanguageSettingsManager.isWorkspaceProvider(provider0));
// 2. TODO Provider reference to provider defined in the project // 2. Providers defined in a configuration
// 2.1
// 3. Providers defined in a configuration
// 3.1
{ {
ILanguageSettingsProvider provider1 = providers.get(1); ILanguageSettingsProvider provider1 = providers.get(1);
assertTrue(provider1 instanceof LanguageSettingsSerializableProvider); assertTrue(provider1 instanceof LanguageSettingsSerializableProvider);
@ -1005,7 +1015,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertEquals(entries_31.get(0), actual.get(0)); assertEquals(entries_31.get(0), actual.get(0));
assertEquals(entries_31.size(), actual.size()); assertEquals(entries_31.size(), actual.size());
} }
// 3.2 // 2.2
{ {
ILanguageSettingsProvider provider2 = providers.get(2); ILanguageSettingsProvider provider2 = providers.get(2);
assertTrue(provider2 instanceof MockLanguageSettingsSerializableProvider); assertTrue(provider2 instanceof MockLanguageSettingsSerializableProvider);
@ -1018,6 +1028,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
} }
/** /**
* Test serialization of real project.
*/ */
public void testProjectPersistence_RealProject() throws Exception { public void testProjectPersistence_RealProject() throws Exception {
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName()); IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
@ -1029,32 +1040,31 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
{ {
// get project descriptions // get project descriptions
ICProjectDescription writableProjDescription = coreModel.getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(writableProjDescription); assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0];
assertNotNull(cfgDescription); assertNotNull(cfgDescriptionWritable);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper);
// create a provider // create a provider
LanguageSettingsSerializableProvider mockProvider = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0); LanguageSettingsSerializableProvider mockProvider = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0);
LanguageSettingsManager.setStoringEntriesInProjectArea(mockProvider, true); LanguageSettingsManager.setStoringEntriesInProjectArea(mockProvider, true);
mockProvider.setSettingEntries(cfgDescription, null, null, entries); mockProvider.setSettingEntries(cfgDescriptionWritable, null, null, entries);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(); List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(mockProvider); providers.add(mockProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(providers);
List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders();
assertEquals(1, storedProviders.size()); assertEquals(1, storedProviders.size());
// write to project description // write to project description
coreModel.setProjectDescription(project, writableProjDescription); CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescriptionWritable);
IFile xmlStorageFile = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML); IFile xmlStorageFile = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
assertTrue(xmlStorageFile.exists()); assertTrue(xmlStorageFile.exists());
xmlStorageFileLocation = xmlStorageFile.getLocation().toOSString(); xmlStorageFileLocation = xmlStorageFile.getLocation().toOSString();
} }
{ {
coreModel.getProjectDescription(project);
ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project); ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project);
assertNotNull(cfgDescription); assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
@ -1088,16 +1098,16 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
{ {
// clear configuration // clear configuration
ICProjectDescription writableProjDescription = coreModel.getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0];
assertNotNull(cfgDescription); assertNotNull(cfgDescriptionWritable);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(new ArrayList<ILanguageSettingsProvider>()); ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(new ArrayList<ILanguageSettingsProvider>());
coreModel.setProjectDescription(project, writableProjDescription); CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescriptionWritable);
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders();
assertEquals(0, providers.size()); assertEquals(0, providers.size());
} }
{ {
@ -1160,6 +1170,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
} }
/** /**
* Test case when the storage is split between project and workspace area.
*/ */
public void testProjectPersistence_SplitStorageDOM() throws Exception { public void testProjectPersistence_SplitStorageDOM() throws Exception {
Element prjStorageElement = null; Element prjStorageElement = null;
@ -1230,6 +1241,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
} }
/** /**
* Test split storage in a real project.
*/ */
public void testProjectPersistence_RealProjectSplitStorage() throws Exception { public void testProjectPersistence_RealProjectSplitStorage() throws Exception {
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName()); IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
@ -1243,26 +1255,26 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
{ {
// get project descriptions // get project descriptions
ICProjectDescription writableProjDescription = coreModel.getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(writableProjDescription); assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0];
assertNotNull(cfgDescription); assertNotNull(cfgDescriptionWritable);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper);
// create a provider // create a provider
LanguageSettingsSerializableProvider mockProvider = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0); LanguageSettingsSerializableProvider mockProvider = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0);
LanguageSettingsManager.setStoringEntriesInProjectArea(mockProvider, false); LanguageSettingsManager.setStoringEntriesInProjectArea(mockProvider, false);
mockProvider.setSettingEntries(cfgDescription, null, null, entries); mockProvider.setSettingEntries(cfgDescriptionWritable, null, null, entries);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(); List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(mockProvider); providers.add(mockProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(providers);
List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders();
assertEquals(1, storedProviders.size()); assertEquals(1, storedProviders.size());
// write to project description // write to project description
coreModel.setProjectDescription(project, writableProjDescription); CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescriptionWritable);
IFile xmlStorageFile = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML); IFile xmlStorageFile = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
assertTrue(xmlStorageFile.exists()); assertTrue(xmlStorageFile.exists());
xmlStorageFileLocation = xmlStorageFile.getLocation().toOSString(); xmlStorageFileLocation = xmlStorageFile.getLocation().toOSString();
@ -1272,7 +1284,6 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertTrue(xmlStorageFileWsp.exists()); assertTrue(xmlStorageFileWsp.exists());
} }
{ {
coreModel.getProjectDescription(project);
ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project); ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project);
assertNotNull(cfgDescription); assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
@ -1311,16 +1322,16 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
{ {
// clear configuration // clear configuration
ICProjectDescription writableProjDescription = coreModel.getProjectDescription(project); ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length); assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0]; ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0];
assertNotNull(cfgDescription); assertNotNull(cfgDescriptionWritable);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(new ArrayList<ILanguageSettingsProvider>()); ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(new ArrayList<ILanguageSettingsProvider>());
coreModel.setProjectDescription(project, writableProjDescription); CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescriptionWritable);
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders();
assertEquals(0, providers.size()); assertEquals(0, providers.size());
} }
{ {
@ -1395,6 +1406,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
} }
/** /**
* Test serialization of providers referring to global shared instance.
*/ */
public void testProjectPersistence_ProviderExtensionReferenceDOM() throws Exception { public void testProjectPersistence_ProviderExtensionReferenceDOM() throws Exception {
Document doc = XmlUtil.newDocument(); Document doc = XmlUtil.newDocument();
@ -1447,6 +1459,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
} }
/** /**
* Walk the scenario when a provider is cloned to a configuration from extension.
*/ */
public void testProjectPersistence_ProviderExtensionCopyDOM() throws Exception { public void testProjectPersistence_ProviderExtensionCopyDOM() throws Exception {
Document doc = XmlUtil.newDocument(); Document doc = XmlUtil.newDocument();
@ -1499,9 +1512,9 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
} }
/** /**
* Test that default settings do not cause the files to appear in the project or file-system.
*/ */
public void testProjectPersistence_Defaults() throws Exception { public void testProjectPersistence_Defaults() throws Exception {
// AG TODO - create and check real MBS projects with some providers
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName()); IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
IFile xmlStorageFile = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML); IFile xmlStorageFile = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
assertFalse(xmlStorageFile.exists()); assertFalse(xmlStorageFile.exists());
@ -1512,6 +1525,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
} }
/** /**
* Test serialization of global providers exactly equal extension in workspace area.
*/ */
public void testWorkspacePersistence_ProviderExtensionCopy() throws Exception { public void testWorkspacePersistence_ProviderExtensionCopy() throws Exception {
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>(); List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
@ -1552,6 +1566,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
} }
/** /**
* Test that default settings do not cause the file to appear on the file-system.
*/ */
public void testWorkspacePersistence_Defaults() throws Exception { public void testWorkspacePersistence_Defaults() throws Exception {
// reset and serialize workspace providers // reset and serialize workspace providers

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2010 Andrew Gvozdev and others. * Copyright (c) 2009, 2012 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -86,7 +86,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
@Override @Override
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
super.tearDown(); super.tearDown(); // includes ResourceHelper cleanup
} }
/** /**
@ -852,8 +852,10 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
assertEquals(1, actualIncludePaths.length); assertEquals(1, actualIncludePaths.length);
} }
/**
* Get languages for the folder.
*/
private List<String> getLanguages(IFolder folder, ICConfigurationDescription cfgDescription) { private List<String> getLanguages(IFolder folder, ICConfigurationDescription cfgDescription) {
// Get first 2 languages
IPath rcPath = folder.getProjectRelativePath(); IPath rcPath = folder.getProjectRelativePath();
ICFolderDescription rcDes = (ICFolderDescription) cfgDescription.getResourceDescription(rcPath, false); ICFolderDescription rcDes = (ICFolderDescription) cfgDescription.getResourceDescription(rcPath, false);
ICLanguageSetting[] langSettings = rcDes.getLanguageSettings(); ICLanguageSetting[] langSettings = rcDes.getLanguageSettings();

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2011 Andrew Gvozdev and others. * Copyright (c) 2009, 2012 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -39,9 +39,10 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
/** /**
* Test cases testing LanguageSettingsProvider functionality * Test cases testing serialization of LanguageSettingsProviders.
*/ */
public class LanguageSettingsSerializableTests extends BaseTestCase { public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
// Arbitrary sample parameters used by the test
private static final String CFG_ID = "test.configuration.id"; private static final String CFG_ID = "test.configuration.id";
private static final ICConfigurationDescription MOCK_CFG = new CModelMock.DummyCConfigurationDescription(CFG_ID); private static final ICConfigurationDescription MOCK_CFG = new CModelMock.DummyCConfigurationDescription(CFG_ID);
private static final IResource MOCK_RC = ResourcesPlugin.getWorkspace().getRoot(); private static final IResource MOCK_RC = ResourcesPlugin.getWorkspace().getRoot();
@ -68,7 +69,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
* Constructor. * Constructor.
* @param name - name of the test. * @param name - name of the test.
*/ */
public LanguageSettingsSerializableTests(String name) { public LanguageSettingsSerializableProviderTests(String name) {
super(name); super(name);
} }
@ -80,14 +81,14 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
@Override @Override
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
super.tearDown(); super.tearDown(); // includes ResourceHelper cleanup
} }
/** /**
* @return - new TestSuite. * @return - new TestSuite.
*/ */
public static TestSuite suite() { public static TestSuite suite() {
return new TestSuite(LanguageSettingsSerializableTests.class); return new TestSuite(LanguageSettingsSerializableProviderTests.class);
} }
/** /**
@ -100,6 +101,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Test basic methods, getters and setters.
*/ */
public void testProvider_SettersGetters() throws Exception { public void testProvider_SettersGetters() throws Exception {
// benchmark data // benchmark data
@ -138,6 +140,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Test property defining whether to store entries in project or workspace area.
*/ */
public void testProvider_SetStoringEntriesInProjectArea() throws Exception { public void testProvider_SetStoringEntriesInProjectArea() throws Exception {
// create a provider // create a provider
@ -151,6 +154,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Check basic serialization.
*/ */
public void testProvider_RegularDOM() throws Exception { public void testProvider_RegularDOM() throws Exception {
Element elementProvider; Element elementProvider;
@ -198,6 +202,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Test serialization of properties of the provider.
*/ */
public void testProvider_serializeAttributesDOM() throws Exception { public void testProvider_serializeAttributesDOM() throws Exception {
Element elementProvider; Element elementProvider;
@ -245,6 +250,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Test serialization of entries.
*/ */
public void testProvider_serializeEntriesDOM() throws Exception { public void testProvider_serializeEntriesDOM() throws Exception {
Element rootElement; Element rootElement;
@ -297,6 +303,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Test serialization of empty provider.
*/ */
public void testProvider_EmptyDOM() throws Exception { public void testProvider_EmptyDOM() throws Exception {
Element elementProvider; Element elementProvider;
@ -324,6 +331,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Test serialization of custom parameter.
*/ */
public void testCustomParameterDOM() throws Exception { public void testCustomParameterDOM() throws Exception {
Element elementProvider; Element elementProvider;
@ -347,6 +355,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Test serialization to project area storage.
*/ */
public void testStoreEntriesWithProjectDOM() throws Exception { public void testStoreEntriesWithProjectDOM() throws Exception {
Element elementProvider; Element elementProvider;
@ -372,6 +381,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Test serialization of language scope.
*/ */
public void testLanguagesDOM() throws Exception { public void testLanguagesDOM() throws Exception {
List<String> expectedLanguageIds = new ArrayList<String>(); List<String> expectedLanguageIds = new ArrayList<String>();
@ -406,6 +416,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Edge cases for language scope.
*/ */
public void testLanguageScopeDOM() throws Exception { public void testLanguageScopeDOM() throws Exception {
// benchmark entries // benchmark entries
@ -491,6 +502,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Test serialization of entries when configuration description is null.
*/ */
public void testNullConfigurationDOM() throws Exception { public void testNullConfigurationDOM() throws Exception {
// provider/configuration/language/resource/settingEntry // provider/configuration/language/resource/settingEntry
@ -520,6 +532,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Test serialization of entries when language is null.
*/ */
public void testNullLanguageDOM() throws Exception { public void testNullLanguageDOM() throws Exception {
// provider/configuration/language/resource/settingEntry // provider/configuration/language/resource/settingEntry
@ -550,6 +563,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
/** /**
* Test serialization of entries when language scope is null.
*/ */
public void testNullLanguageScopeDOM() throws Exception { public void testNullLanguageScopeDOM() throws Exception {
// define benchmark entries // define benchmark entries
@ -625,6 +639,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Test serialization of entries when resource is null.
*/ */
public void testNullResourceDOM() throws Exception { public void testNullResourceDOM() throws Exception {
// provider/configuration/language/resource/settingEntry // provider/configuration/language/resource/settingEntry
@ -654,6 +669,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Test serialization of entries when configuration and language are both null.
*/ */
public void testNullConfigurationLanguageDOM() throws Exception { public void testNullConfigurationLanguageDOM() throws Exception {
// provider/configuration/language/resource/settingEntry // provider/configuration/language/resource/settingEntry
@ -684,6 +700,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Test serialization of entries when configuration and resource are both null.
*/ */
public void testNullConfigurationResourceDOM() throws Exception { public void testNullConfigurationResourceDOM() throws Exception {
// provider/configuration/language/resource/settingEntry // provider/configuration/language/resource/settingEntry
@ -714,6 +731,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Test serialization of entries when language and resource are both null.
*/ */
public void testNullLanguageResourceDOM() throws Exception { public void testNullLanguageResourceDOM() throws Exception {
// provider/configuration/language/resource/settingEntry // provider/configuration/language/resource/settingEntry
@ -744,6 +762,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Test serialization of entries when configuration, language and resource are all null.
*/ */
public void testNullConfigurationLanguageResourceFlagDOM() throws Exception { public void testNullConfigurationLanguageResourceFlagDOM() throws Exception {
// provider/configuration/language/resource/settingEntry // provider/configuration/language/resource/settingEntry
@ -777,6 +796,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Serialization of include path.
*/ */
public void testCIncludePathEntryDOM() throws Exception { public void testCIncludePathEntryDOM() throws Exception {
Element elementProvider; Element elementProvider;
@ -810,6 +830,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Serialization of include file.
*/ */
public void testCIncludeFileEntryDOM() throws Exception { public void testCIncludeFileEntryDOM() throws Exception {
Element elementProvider; Element elementProvider;
@ -842,6 +863,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Serialization of macro.
*/ */
public void testCMacroEntryDOM() throws Exception { public void testCMacroEntryDOM() throws Exception {
Element elementProvider; Element elementProvider;
@ -874,6 +896,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Serialization of macro file.
*/ */
public void testCMacroFileEntryDOM() throws Exception { public void testCMacroFileEntryDOM() throws Exception {
Element elementProvider; Element elementProvider;
@ -906,6 +929,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Serialization of library path.
*/ */
public void testCLibraryPathEntryDOM() throws Exception { public void testCLibraryPathEntryDOM() throws Exception {
Element elementProvider; Element elementProvider;
@ -938,6 +962,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Serialization of library file.
*/ */
public void testCLibraryFileEntryDOM() throws Exception { public void testCLibraryFileEntryDOM() throws Exception {
Element elementProvider; Element elementProvider;
@ -970,6 +995,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Serialization of entries of different types.
*/ */
public void testMixedSettingEntriesDOM() throws Exception { public void testMixedSettingEntriesDOM() throws Exception {
Element elementProvider; Element elementProvider;
@ -1000,6 +1026,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Serialization of entries for default and specific languages together.
*/ */
public void testLanguageAndNullDOM() throws Exception { public void testLanguageAndNullDOM() throws Exception {
Element elementProvider = null; Element elementProvider = null;
@ -1036,6 +1063,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Serialization of entries for 2 languages.
*/ */
public void testTwoLanguagesDOM() throws Exception { public void testTwoLanguagesDOM() throws Exception {
Element elementProvider = null; Element elementProvider = null;
@ -1074,6 +1102,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Serialization of entries for different resources.
*/ */
public void testTwoResourcesDOM() throws Exception { public void testTwoResourcesDOM() throws Exception {
// Create resources // Create resources
@ -1120,6 +1149,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Serialization of entries for resource hierarchy.
*/ */
public void testParentFolder() throws Exception { public void testParentFolder() throws Exception {
// Create model project and accompanied descriptions // Create model project and accompanied descriptions
@ -1171,8 +1201,10 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Test equals() and hashCode().
*/ */
public void testEquals() throws Exception { public void testEquals() throws Exception {
// create sample entries
List<ICLanguageSettingEntry> sampleEntries_1 = new ArrayList<ICLanguageSettingEntry>(); List<ICLanguageSettingEntry> sampleEntries_1 = new ArrayList<ICLanguageSettingEntry>();
sampleEntries_1.add(new CMacroEntry("MACRO0", "value0",1)); sampleEntries_1.add(new CMacroEntry("MACRO0", "value0",1));
sampleEntries_1.add(new CIncludePathEntry("path0", 1)); sampleEntries_1.add(new CIncludePathEntry("path0", 1));
@ -1181,6 +1213,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
List<ICLanguageSettingEntry> sampleEntries_2 = new ArrayList<ICLanguageSettingEntry>(); List<ICLanguageSettingEntry> sampleEntries_2 = new ArrayList<ICLanguageSettingEntry>();
sampleEntries_2.add(new CIncludePathEntry("path0", 1)); sampleEntries_2.add(new CIncludePathEntry("path0", 1));
// create sample languages
List<String> sampleLanguages = new ArrayList<String>(); List<String> sampleLanguages = new ArrayList<String>();
sampleLanguages.add(LANG_ID); sampleLanguages.add(LANG_ID);
@ -1289,6 +1322,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Test equality for properties.
*/ */
public void testEquals_DefaultProperties() throws Exception { public void testEquals_DefaultProperties() throws Exception {
// create model providers // create model providers
@ -1335,6 +1369,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Test cloning of provider.
*/ */
public void testClone() throws Exception { public void testClone() throws Exception {
// define sample data // define sample data
@ -1400,6 +1435,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Test shallow clone.
*/ */
public void testCloneShallow() throws Exception { public void testCloneShallow() throws Exception {
// define sample data // define sample data
@ -1441,6 +1477,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Verify that entries are sorted by kinds.
*/ */
public void testSort_Kinds() throws Exception { public void testSort_Kinds() throws Exception {
// create sample entries // create sample entries
@ -1496,6 +1533,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Check how entries are sorted inside a kind.
*/ */
public void testSort_Entries() throws Exception { public void testSort_Entries() throws Exception {
// create sample entries // create sample entries
@ -1553,6 +1591,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
/** /**
* Sorting including undefined entries.
*/ */
public void testSort_Undef() throws Exception { public void testSort_Undef() throws Exception {
// create sample entries // create sample entries
@ -1588,5 +1627,3 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2011 Andrew Gvozdev and others. * Copyright (c) 2009, 2012 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -10,6 +10,9 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.language.settings.providers; package org.eclipse.cdt.core.language.settings.providers;
/**
* Mock of {@link LanguageSettingsBaseProvider} for testing.
*/
public class MockLanguageSettingsBaseProvider extends LanguageSettingsBaseProvider { public class MockLanguageSettingsBaseProvider extends LanguageSettingsBaseProvider {
private static final String ATTR_PARAMETER = "parameter"; //$NON-NLS-1$ private static final String ATTR_PARAMETER = "parameter"; //$NON-NLS-1$

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2011 Andrew Gvozdev and others. * Copyright (c) 2009, 2012 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -11,9 +11,10 @@
package org.eclipse.cdt.core.language.settings.providers; package org.eclipse.cdt.core.language.settings.providers;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsSerializableProvider;
/**
* Mock of {@link ILanguageSettingsEditableProvider} for testing.
*/
public class MockLanguageSettingsEditableProvider extends LanguageSettingsSerializableProvider implements ILanguageSettingsEditableProvider { public class MockLanguageSettingsEditableProvider extends LanguageSettingsSerializableProvider implements ILanguageSettingsEditableProvider {
public MockLanguageSettingsEditableProvider() { public MockLanguageSettingsEditableProvider() {
super(); super();
@ -23,10 +24,12 @@ public class MockLanguageSettingsEditableProvider extends LanguageSettingsSerial
super(id, name); super(id, name);
} }
@Override
public MockLanguageSettingsEditableProvider cloneShallow() throws CloneNotSupportedException { public MockLanguageSettingsEditableProvider cloneShallow() throws CloneNotSupportedException {
return (MockLanguageSettingsEditableProvider) super.cloneShallow(); return (MockLanguageSettingsEditableProvider) super.cloneShallow();
} }
@Override
public MockLanguageSettingsEditableProvider clone() throws CloneNotSupportedException { public MockLanguageSettingsEditableProvider clone() throws CloneNotSupportedException {
return (MockLanguageSettingsEditableProvider) super.clone(); return (MockLanguageSettingsEditableProvider) super.clone();
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2011 Andrew Gvozdev and others. * Copyright (c) 2009, 2012 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -18,9 +18,10 @@ import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
public class MockLanguageSettingsProvider extends AbstractExecutableExtensionBase /**
implements ILanguageSettingsProvider { * Mock of {@link ILanguageSettingsProvider} for testing.
*/
public class MockLanguageSettingsProvider extends AbstractExecutableExtensionBase implements ILanguageSettingsProvider {
@Override @Override
public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) { public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
return null; return null;

View file

@ -1,19 +1,19 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2009 Andrew Gvozdev (Quoin Inc.) and others. * Copyright (c) 2009, 2012 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Andrew Gvozdev (Quoin Inc.) - initial API and implementation * Andrew Gvozdev - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.language.settings.providers; package org.eclipse.cdt.core.language.settings.providers;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsSerializableProvider; /**
* Mock of {@link LanguageSettingsSerializableProvider} for testing.
*/
public class MockLanguageSettingsSerializableProvider extends LanguageSettingsSerializableProvider { public class MockLanguageSettingsSerializableProvider extends LanguageSettingsSerializableProvider {
public MockLanguageSettingsSerializableProvider() { public MockLanguageSettingsSerializableProvider() {
super(); super();

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2011, 2011 Andrew Gvozdev and others. * Copyright (c) 2011, 2012 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -18,7 +18,7 @@ import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.Assert;
/** /**
* Language Settings Provider that keeps count how many times it has been registered. * Mock Language Settings Provider that keeps count how many times it has been registered.
*/ */
public class MockListenerRegisterer extends LanguageSettingsSerializableProvider implements ILanguageSettingsEditableProvider, ICListenerAgent { public class MockListenerRegisterer extends LanguageSettingsSerializableProvider implements ILanguageSettingsEditableProvider, ICListenerAgent {
private static MockListenerManager mockListenerManager = new MockListenerManager(); private static MockListenerManager mockListenerManager = new MockListenerManager();
@ -80,10 +80,12 @@ public class MockListenerRegisterer extends LanguageSettingsSerializableProvider
public MockListenerRegisterer(String id, String name) { public MockListenerRegisterer(String id, String name) {
super(id, name); super(id, name);
} }
@Override
public void registerListener(ICConfigurationDescription cfgDescription) { public void registerListener(ICConfigurationDescription cfgDescription) {
mockListenerManager.registerListener(this); mockListenerManager.registerListener(this);
} }
@Override
public void unregisterListener() { public void unregisterListener() {
mockListenerManager.unregisterListener(this); mockListenerManager.unregisterListener(this);
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010 Andrew Gvozdev and others. * Copyright (c) 2010, 2012 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -37,12 +37,13 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.QualifiedName;
/**
* Collection of mock classes for testing
*/
public class CModelMock { public class CModelMock {
/** /**
* Dummy implementation of ICProjectDescription for testing. * Dummy implementation of ICProjectDescription for testing.
* Feel free to override the methods you are interested to mock. * Feel free to override the methods you are interested to mock.
*
*/ */
public static class DummyCProjectDescription implements ICProjectDescription { public static class DummyCProjectDescription implements ICProjectDescription {
@ -217,7 +218,6 @@ public class CModelMock {
/** /**
* Dummy implementation of ICConfigurationDescription for testing. * Dummy implementation of ICConfigurationDescription for testing.
* Feel free to override the methods you are interested to mock. * Feel free to override the methods you are interested to mock.
*
*/ */
public static class DummyCConfigurationDescription implements ICConfigurationDescription { public static class DummyCConfigurationDescription implements ICConfigurationDescription {
private String id; private String id;

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2011, 2011 Andrew Gvozdev and others. * Copyright (c) 2011, 2012 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -35,11 +35,9 @@ import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
public class LanguageSettingsDelta { public class LanguageSettingsDelta {
// maps need to be ordered by providers // maps need to be ordered by providers
@SuppressWarnings("unused") @SuppressWarnings("unused")
private LinkedHashMap<String, // providerId private LinkedHashMap<String/*providerId*/, LanguageSettingsStorage> oldLanguageSettingsState;
LanguageSettingsStorage> oldLanguageSettingsState;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private LinkedHashMap<String, // providerId private LinkedHashMap<String/*providerId*/, LanguageSettingsStorage> newLanguageSettingsState;
LanguageSettingsStorage> newLanguageSettingsState;
/** /**
* Constructor. * Constructor.

View file

@ -236,7 +236,7 @@ public class LanguageSettingsProvidersSerializer {
*/ */
private static class LanguageSettingsChangeEvent implements ILanguageSettingsChangeEvent { private static class LanguageSettingsChangeEvent implements ILanguageSettingsChangeEvent {
private String projectName = null; private String projectName = null;
private Map<String /*cfg*/, LanguageSettingsDelta> deltaMap = new HashMap<String, LanguageSettingsDelta>(); private Map<String/*cfg*/, LanguageSettingsDelta> deltaMap = new HashMap<String, LanguageSettingsDelta>();
/** /**
* The act of creating event resets internal delta count in configuration state. * The act of creating event resets internal delta count in configuration state.
@ -732,7 +732,6 @@ public class LanguageSettingsProvidersSerializer {
return true; return true;
} }
/** /**
* Save language settings providers of a project to persistent storage. * Save language settings providers of a project to persistent storage.
* *
@ -751,7 +750,6 @@ public class LanguageSettingsProvidersSerializer {
CCorePlugin.log("Internal error while trying to serialize language settings", e); //$NON-NLS-1$ CCorePlugin.log("Internal error while trying to serialize language settings", e); //$NON-NLS-1$
} }
try { try {
// The storage could be split in two, one for provider properties, another one for entries, // The storage could be split in two, one for provider properties, another one for entries,
// depending on provider flag // depending on provider flag
@ -1177,8 +1175,8 @@ public class LanguageSettingsProvidersSerializer {
* Check that this particular element is in the association list. * Check that this particular element is in the association list.
*/ */
private static boolean isListenerInTheListOfAssociations(Collection<ListenerAssociation> list, ICListenerAgent element) { private static boolean isListenerInTheListOfAssociations(Collection<ListenerAssociation> list, ICListenerAgent element) {
// list.contains(element) won't do it as we are interested in exact object, not in equal object
for (ListenerAssociation la : list) { for (ListenerAssociation la : list) {
// we are interested in exact object, not in equal object
if (la.listener == element) if (la.listener == element)
return true; return true;
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010, 2011 Andrew Gvozdev and others. * Copyright (c) 2010, 2012 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -22,6 +22,7 @@ import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager; import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager; import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
import org.eclipse.cdt.core.parser.ExtendedScannerInfo; import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener; import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
import org.eclipse.cdt.core.parser.IScannerInfoProvider; import org.eclipse.cdt.core.parser.IScannerInfoProvider;
import org.eclipse.cdt.core.settings.model.ACPathEntry; import org.eclipse.cdt.core.settings.model.ACPathEntry;
@ -45,8 +46,12 @@ import org.eclipse.osgi.util.NLS;
* language settings providers of "default settings configuration" * language settings providers of "default settings configuration"
* (see {@link ICProjectDescription#getDefaultSettingConfiguration()}). * (see {@link ICProjectDescription#getDefaultSettingConfiguration()}).
* *
* @see IScannerInfo#getIncludePaths()
*
*/ */
public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider { public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider {
private static final String FRAMEWORK_PRIVATE_HEADERS_INCLUDE = "/__framework__.framework/PrivateHeaders/__header__"; //$NON-NLS-1$
private static final String FRAMEWORK_HEADERS_INCLUDE = "/__framework__.framework/Headers/__header__"; //$NON-NLS-1$
private static final ExtendedScannerInfo DUMMY_SCANNER_INFO = new ExtendedScannerInfo(); private static final ExtendedScannerInfo DUMMY_SCANNER_INFO = new ExtendedScannerInfo();
@Override @Override
@ -143,9 +148,11 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider
} else { } else {
ICdtVariableManager mngr = CCorePlugin.getDefault().getCdtVariableManager(); ICdtVariableManager mngr = CCorePlugin.getDefault().getCdtVariableManager();
try { try {
// FIXME IPath buildCWD can hold variables i.e. ${workspace_loc:/path} // Note that IPath buildCWD holding variables is mis-constructed,
// i.e. ${workspace_loc:/path} gets split into 2 path segments
// still, MBS does that and we need to handle that
String buildPathString = buildCWD.toString(); String buildPathString = buildCWD.toString();
buildPathString = mngr.resolveValue(buildPathString, "", null, cfgDescription); buildPathString = mngr.resolveValue(buildPathString, "", null, cfgDescription); //$NON-NLS-1$
buildCWD = new Path(buildPathString); buildCWD = new Path(buildPathString);
} catch (CdtVariableException e) { } catch (CdtVariableException e) {
CCorePlugin.log(e); CCorePlugin.log(e);
@ -212,8 +219,9 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider
IPath loc = entryPath.getLocation(); IPath loc = entryPath.getLocation();
if (loc!=null) { if (loc!=null) {
if (checkBit(entryPath.getFlags(), ICSettingEntry.FRAMEWORKS_MAC)) { if (checkBit(entryPath.getFlags(), ICSettingEntry.FRAMEWORKS_MAC)) {
locations.add(loc.append("/__framework__.framework/Headers/__header__").toOSString()); // handle frameworks, see IScannerInfo.getIncludePaths()
locations.add(loc.append("/__framework__.framework/PrivateHeaders/__header__").toOSString()); locations.add(loc.append(FRAMEWORK_HEADERS_INCLUDE).toOSString());
locations.add(loc.append(FRAMEWORK_PRIVATE_HEADERS_INCLUDE).toOSString());
} else { } else {
locations.add(loc.toOSString()); locations.add(loc.toOSString());
} }
@ -226,8 +234,9 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider
locStr = resolveEntry(locStr, cfgDescription); locStr = resolveEntry(locStr, cfgDescription);
if (locStr!=null) { if (locStr!=null) {
if (checkBit(entryPath.getFlags(), ICSettingEntry.FRAMEWORKS_MAC)) { if (checkBit(entryPath.getFlags(), ICSettingEntry.FRAMEWORKS_MAC)) {
locations.add(locStr+"/__framework__.framework/Headers/__header__"); // handle frameworks, see IScannerInfo.getIncludePaths()
locations.add(locStr+"/__framework__.framework/PrivateHeaders/__header__"); locations.add(locStr+FRAMEWORK_HEADERS_INCLUDE);
locations.add(locStr+FRAMEWORK_PRIVATE_HEADERS_INCLUDE);
} else { } else {
locations.add(locStr); locations.add(locStr);
// add relative paths again for indexer to resolve from source file location // add relative paths again for indexer to resolve from source file location

View file

@ -53,7 +53,5 @@ public class LanguageSettingsChangeListener implements ILanguageSettingsChangeLi
} }
} }
} }
} }
} }

View file

@ -76,7 +76,7 @@ Default constructor (constructor without arguments) of this class must be public
<attribute name="id" type="string" use="required"> <attribute name="id" type="string" use="required">
<annotation> <annotation>
<documentation> <documentation>
Unique ID of the provider Unique ID of the provider.
</documentation> </documentation>
</annotation> </annotation>
</attribute> </attribute>
@ -139,7 +139,7 @@ The value &quot;true&quot; of this attribute is meaningful only for providers ca
<documentation> <documentation>
Kind of language settings entry which maps to compiler options. For example, following mapping is used for gcc options: Kind of language settings entry which maps to compiler options. For example, following mapping is used for gcc options:
&lt;br&gt;&lt;samp&gt;&quot;-I&quot;&lt;/samp&gt; : includePath &lt;br&gt;&quot;&lt;samp&gt;-I&lt;/samp&gt;&quot; : includePath
&lt;br&gt;&quot;&lt;samp&gt;-D&lt;/samp&gt;&quot; : macro &lt;br&gt;&quot;&lt;samp&gt;-D&lt;/samp&gt;&quot; : macro
&lt;br&gt;&quot;&lt;samp&gt;-include&lt;/samp&gt;&quot; : includeFile &lt;br&gt;&quot;&lt;samp&gt;-include&lt;/samp&gt;&quot; : includeFile
&lt;br&gt;&quot;&lt;samp&gt;-L&lt;/samp&gt;&quot; : libraryPath &lt;br&gt;&quot;&lt;samp&gt;-L&lt;/samp&gt;&quot; : libraryPath