forked from eclipse-platform/eclipse.platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Failure of Bug468PerformanceTest.test eclipse-platform#715
Convert performance test to functional test case. Fixes eclipse-platform#715
- Loading branch information
1 parent
7920ebd
commit 12b0032
Showing
3 changed files
with
127 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
....tests.resources/src/org/eclipse/core/tests/internal/properties/Bug468FunctionalTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 ETAS GmbH and others, all rights reserved. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* ETAS GmbH - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.core.tests.internal.properties; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.InputStream; | ||
import org.eclipse.core.internal.properties.PropertyManager2; | ||
import org.eclipse.core.internal.resources.Workspace; | ||
import org.eclipse.core.resources.IFile; | ||
import org.eclipse.core.resources.IFolder; | ||
import org.eclipse.core.resources.IProject; | ||
import org.eclipse.core.resources.IResource; | ||
import org.eclipse.core.resources.IWorkspace; | ||
import org.eclipse.core.resources.ResourcesPlugin; | ||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.core.runtime.ICoreRunnable; | ||
import org.eclipse.core.runtime.NullProgressMonitor; | ||
import org.eclipse.core.runtime.QualifiedName; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
import org.mockito.ArgumentCaptor; | ||
import org.mockito.Captor; | ||
import org.mockito.Mockito; | ||
import org.mockito.MockitoAnnotations; | ||
|
||
//Test case for GitHub Issue 468 | ||
@RunWith(JUnit4.class) | ||
public class Bug468FunctionalTest { | ||
|
||
private static final String TO_BE_DELETED_FILE_NAME_PREFIX = "file_"; | ||
|
||
private static final String TEMP_FOLDER_NAME = "temp"; | ||
|
||
private IProject project; | ||
|
||
/* | ||
* @throws Exception If anything goes wrong during the set up. | ||
*/ | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
ResourcesPlugin.getWorkspace().run((ICoreRunnable) monitor -> { | ||
|
||
createTestProject(); | ||
IFolder tempFolder = Bug468FunctionalTest.this.project.getFolder(TEMP_FOLDER_NAME); | ||
tempFolder.create(true, true, new NullProgressMonitor()); | ||
createFile(tempFolder, TO_BE_DELETED_FILE_NAME_PREFIX + 0); | ||
|
||
}, this.project, IWorkspace.AVOID_UPDATE, new NullProgressMonitor()); | ||
} | ||
|
||
private void createTestProject() throws CoreException { | ||
Bug468FunctionalTest.this.project = ResourcesPlugin.getWorkspace().getRoot() | ||
.getProject("TestProject"); | ||
Bug468FunctionalTest.this.project.create(new NullProgressMonitor()); | ||
Bug468FunctionalTest.this.project.open(new NullProgressMonitor()); | ||
} | ||
private IFile createFile(final IFolder parent, final String fileName) throws CoreException { | ||
IFile file = parent.getFile(fileName); | ||
InputStream source = new ByteArrayInputStream(file.getName().getBytes()); | ||
file.create(source, true, new NullProgressMonitor()); | ||
file.setPersistentProperty(new QualifiedName(this.getClass().getName(), file.getName()), file.getName()); | ||
return file; | ||
} | ||
|
||
/** | ||
* Deletes the project | ||
* | ||
* @throws Exception | ||
* if any exception happens during the deleting of the project. | ||
*/ | ||
@After | ||
public void tearDown() throws Exception { | ||
this.project.delete(true, new NullProgressMonitor()); | ||
} | ||
|
||
Workspace ws; | ||
PropertyManager2 manager; | ||
/** | ||
* 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. | ||
*/ | ||
|
||
@Captor | ||
ArgumentCaptor<IResource> resourceArgCaptor; | ||
@Captor | ||
ArgumentCaptor<Integer> depthArgCapture; | ||
@Test | ||
public void test() throws CoreException { | ||
|
||
MockitoAnnotations.openMocks(this); | ||
ws = Mockito.spy(new Workspace()); | ||
manager = Mockito.spy(new PropertyManager2(ws)); | ||
|
||
IFolder tempFolder = this.project.getFolder(TEMP_FOLDER_NAME); | ||
IFile fileToBeDeleted = tempFolder.getFile(TO_BE_DELETED_FILE_NAME_PREFIX + 0); | ||
|
||
manager.deleteResource(fileToBeDeleted); | ||
|
||
Mockito.verify(manager).deleteProperties(resourceArgCaptor.capture(), depthArgCapture.capture()); | ||
Integer expectedDepth = 0; | ||
assertEquals(expectedDepth, depthArgCapture.getValue()); | ||
|
||
} | ||
} |
168 changes: 0 additions & 168 deletions
168
...tests.resources/src/org/eclipse/core/tests/internal/properties/Bug468PerformanceTest.java
This file was deleted.
Oops, something went wrong.