Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure of Bug468PerformanceTest.test #715 #852

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
import org.junit.runners.Suite;

@RunWith(Suite.class)
@Suite.SuiteClasses({ PropertyManagerTest.class,
// Bug468PerformanceTest.class
})

@Suite.SuiteClasses({ PropertyManagerTest.class })
public class AllPropertiesTests {
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2017 IBM Corporation and others.
* Copyright (c) 2000, 2024 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -43,11 +43,15 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.tests.resources.WorkspaceTestRule;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;

public class PropertyManagerTest {

Expand Down Expand Up @@ -550,4 +554,39 @@ public void testSimpleUpdate() throws CoreException {
}
}

/**
* Whenever a delete operation is called on an IFile it's properties also
* deleted from .index file. This Test case validates for given IFile resource
* Zero depth is calculated to traverse through folders for loading right index
* file and delete its properties, because the required index file is present
* under corresponding bucket of the folder same as the IFile and no need to
* traverse to Infinite depth.
*/
@Test
public void testFileDeleteTraversalDepth() throws CoreException {
Workspace ws;
PropertyManager2 manager;

ArgumentCaptor<IResource> resourceArgCaptor = ArgumentCaptor.forClass(IResource.class);
ArgumentCaptor<Integer> depthArgCapture = ArgumentCaptor.forClass(Integer.class);

IFolder tempFolder = project.getFolder("temp");
tempFolder.create(true, true, new NullProgressMonitor());

IFile fileToBeDeleted = tempFolder.getFile("testfile" + 0);
fileToBeDeleted.create(createRandomContentsStream(), true, createTestMonitor());
fileToBeDeleted.setPersistentProperty(new QualifiedName(this.getClass().getName(), fileToBeDeleted.getName()),
fileToBeDeleted.getName());

MockitoAnnotations.openMocks(this);
ws = Mockito.spy(new Workspace());
manager = Mockito.spy(new PropertyManager2(ws));

manager.deleteResource(fileToBeDeleted);

Mockito.verify(manager).deleteProperties(resourceArgCaptor.capture(), depthArgCapture.capture());
Integer expectedDepth = 0;
assertEquals(expectedDepth, depthArgCapture.getValue());

}
}