1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for 208765: Sporadic crash saving scanner info build properties

This commit is contained in:
Anton Leherbauer 2008-01-30 11:23:28 +00:00
parent 0c825ab41c
commit 7c0b0c875a
3 changed files with 134 additions and 5 deletions

View file

@ -15,6 +15,7 @@ import junit.framework.TestSuite;
import org.eclipse.cdt.core.model.failedTests.FailedDeclaratorsTest;
import org.eclipse.cdt.core.settings.model.AllCProjectDescriptionTests;
import org.eclipse.cdt.core.settings.model.PathSettingsContainerTests;
/**
@ -52,6 +53,7 @@ public class AllCoreTests {
//the CProjectDescriptionTests now groups all New Project Model related tests
//which includes the CConfigurationDescriptionReferenceTests
suite.addTest(AllCProjectDescriptionTests.suite());
suite.addTest(PathSettingsContainerTests.suite());
suite.addTest(ASTCacheTests.suite());
suite.addTest(AsmModelBuilderTest.suite());
return suite;

View file

@ -0,0 +1,124 @@
/*******************************************************************************
* Copyright (c) 2008 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Anton Leherbauer (Wind River Systems) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.settings.model;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
/**
*/
public class PathSettingsContainerTests extends BaseTestCase {
public static TestSuite suite() {
return suite(PathSettingsContainerTests.class, "_");
}
protected void setUp() throws Exception {
}
protected void tearDown() throws Exception {
}
public void testPathSettingsContainerCreate() {
final PathSettingsContainer root= PathSettingsContainer.createRootContainer();
assertNull(root.getValue());
assertNull(root.getParentContainer());
assertTrue(root.isRoot());
assertTrue(root.isValid());
assertEquals(0, root.getChildren(false).length);
assertEquals(1, root.getChildren(true).length);
final IPath level1= new Path("level1");
final PathSettingsContainer child1= root.getChildContainer(level1, true, true);
assertNotNull(child1);
assertNull(child1.getValue());
assertSame(root, child1.getParentContainer());
assertFalse(child1.isRoot());
assertTrue(child1.isValid());
assertEquals(1, root.getChildren(false).length);
assertEquals(0, child1.getChildren(false).length);
assertEquals(1, child1.getChildren(true).length);
final String value1= "child1";
child1.setValue(value1);
assertSame(value1, child1.getValue());
final IPath level2= level1.append("level2");
final PathSettingsContainer child2= root.getChildContainer(level2, true, true);
assertNotNull(child2);
assertNull(child2.getValue());
assertSame(child1, child2.getParentContainer());
assertFalse(child2.isRoot());
assertTrue(child2.isValid());
assertEquals(1, child1.getChildren(false).length);
assertEquals(0, child2.getChildren(false).length);
assertEquals(1, child2.getChildren(true).length);
final String value2= "child2";
child2.setValue(value2);
assertSame(value2, child2.getValue());
final IPath level3= level2.append("level3");
final PathSettingsContainer child3= root.getChildContainer(level3, true, true);
assertNotNull(child3);
assertNull(child3.getValue());
assertSame(child2, child3.getParentContainer());
assertFalse(child3.isRoot());
assertTrue(child3.isValid());
assertEquals(1, child2.getChildren(false).length);
assertEquals(0, child3.getChildren(false).length);
assertEquals(1, child3.getChildren(true).length);
final String value3= "child3";
child3.setValue(value3);
assertSame(value3, child3.getValue());
assertSame(child1, root.getChildContainer(level1, true, true));
assertSame(child2, root.getChildContainer(level2, true, true));
assertSame(child3, root.getChildContainer(level3, true, true));
}
public void testPathSettingsContainerRemove() {
final PathSettingsContainer root= PathSettingsContainer.createRootContainer();
final IPath level1= new Path("level1");
final PathSettingsContainer child1= root.getChildContainer(level1, true, true);
final IPath level2= level1.append("level2");
final PathSettingsContainer child2= root.getChildContainer(level2, true, true);
final IPath level3= level2.append("level3");
final PathSettingsContainer child3= root.getChildContainer(level3, true, true);
final IPath level31= level2.append("level31");
final PathSettingsContainer child31= root.getChildContainer(level31, true, true);
child3.remove();
assertEquals(1, child2.getChildren(false).length);
assertFalse(child3.isValid());
child2.remove();
assertFalse(child2.isValid());
child31.remove();
assertEquals(0, child2.getChildren(false).length);
assertFalse(child31.isValid());
}
public void testPathSettingsContainer_Bug208765() {
final PathSettingsContainer root= PathSettingsContainer.createRootContainer();
try {
root.removeChildContainer(new Path(""));
} catch (NullPointerException npe) {
fail(npe.getMessage());
}
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007 Intel Corporation and others.
* Copyright (c) 2007, 2008 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
*
* Contributors:
* Intel Corporation - Initial API and implementation
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.settings.model.util;
@ -19,7 +20,7 @@ import java.util.Set;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
public class PathSettingsContainer {
public final class PathSettingsContainer {
private static final Object INEXISTENT_VALUE = new Object();
private static final String ROOY_PATH_NAME = Path.ROOT.toString();
// private static final boolean DEBUG = true;
@ -298,9 +299,11 @@ public class PathSettingsContainer {
internalSetValue(INEXISTENT_VALUE);
}
if(!hasChildren()) {
getDirectParentContainer().deleteChild(this);
fDirectParentContainer.checkRemove();
fDirectParentContainer = null;
if (fDirectParentContainer != null) {
fDirectParentContainer.deleteChild(this);
fDirectParentContainer.checkRemove();
fDirectParentContainer = null;
}
fRootContainer = null;
}
}