Skip to content

Commit

Permalink
Failure of Bug468PerformanceTest.test #715
Browse files Browse the repository at this point in the history
Convert performance test to functional test case.

Fixes #715

Review points addressed
The testcase from this class is moved to PropertyManagerTest.java
review points addressed
review points addressed
  • Loading branch information
lathapatil authored and HeikoKlare committed Mar 27, 2024
1 parent e6ef3f5 commit 9499fe2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 172 deletions.
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());

}
}

0 comments on commit 9499fe2

Please sign in to comment.