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.
Simplify and correct FileSystemTests eclipse-platform#783
Several test classes extend the FileSystemTest. This class only provides some utility functions and always creates a local and an in-memory file store, even if the actual test does not need it. This change simplifies the test classes by removing the FileSystemTest super class. The necessary utilities are moved to a utility class. The file store creation logic is moved to an according JUnit test rule that can be instantiated for a local or in-memory file store and keeps track of setup and teardown. This also fixes a bug in interwoven, inherited setup and teardown functions (eclipse-platform#783) Fixes eclipse-platform#783.
- Loading branch information
1 parent
6beceea
commit 958ff81
Showing
12 changed files
with
235 additions
and
181 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
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
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
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
69 changes: 69 additions & 0 deletions
69
...pse.core.tests.resources/src/org/eclipse/core/tests/filesystem/FileStoreCreationRule.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,69 @@ | ||
/******************************************************************************* | ||
* Copyright (c) Vector Informatik GmbH and others. | ||
* | ||
* 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 | ||
* | ||
*******************************************************************************/ | ||
package org.eclipse.core.tests.filesystem; | ||
|
||
import java.net.URI; | ||
import org.eclipse.core.filesystem.EFS; | ||
import org.eclipse.core.filesystem.IFileStore; | ||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.core.tests.harness.FileSystemHelper; | ||
import org.eclipse.core.tests.internal.filesystem.ram.MemoryTree; | ||
import org.junit.rules.ExternalResource; | ||
|
||
/** | ||
* A test rule for automatically creating and disposing a file store for the | ||
* local file system or in memory. | ||
*/ | ||
public class FileStoreCreationRule extends ExternalResource { | ||
public enum FileSystemType { | ||
LOCAL, IN_MEMORY | ||
} | ||
|
||
private final FileSystemType fileSystemType; | ||
|
||
private IFileStore fileStore; | ||
|
||
public FileStoreCreationRule(FileSystemType fileSystemType) { | ||
this.fileSystemType = fileSystemType; | ||
} | ||
|
||
public IFileStore getFileStore() { | ||
return fileStore; | ||
} | ||
|
||
@Override | ||
protected void before() throws Throwable { | ||
switch(fileSystemType) { | ||
case LOCAL: | ||
var fileStoreLocation = FileSystemHelper.getRandomLocation(FileSystemHelper.getTempDir()); | ||
fileStore = EFS.getLocalFileSystem().getStore(fileStoreLocation); | ||
break; | ||
case IN_MEMORY: | ||
MemoryTree.TREE.deleteAll(); | ||
fileStore = EFS.getStore(URI.create("mem:/baseStore")); | ||
break; | ||
} | ||
fileStore.mkdir(EFS.NONE, null); | ||
} | ||
|
||
@Override | ||
protected void after() { | ||
try { | ||
fileStore.delete(EFS.NONE, null); | ||
} catch (CoreException e) { | ||
} | ||
switch (fileSystemType) { | ||
case IN_MEMORY: | ||
MemoryTree.TREE.deleteAll(); | ||
} | ||
} | ||
} |
131 changes: 0 additions & 131 deletions
131
...rg.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/FileSystemTest.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.