From 419a82d05e59d7bca1f2afe9bc10f85e235a9d30 Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Wed, 27 Nov 2024 11:56:17 +0100 Subject: [PATCH 1/3] TemporaryFolder in .xtext.testing, deprecate the one in xbase.testing --- .../xtext/testing/TemporaryFolder.java | 193 ++++++++++++++++++ .../xtext/xbase/testing/TemporaryFolder.java | 151 +------------- 2 files changed, 196 insertions(+), 148 deletions(-) create mode 100644 org.eclipse.xtext.testing/src/org/eclipse/xtext/testing/TemporaryFolder.java diff --git a/org.eclipse.xtext.testing/src/org/eclipse/xtext/testing/TemporaryFolder.java b/org.eclipse.xtext.testing/src/org/eclipse/xtext/testing/TemporaryFolder.java new file mode 100644 index 00000000000..d62e53857e0 --- /dev/null +++ b/org.eclipse.xtext.testing/src/org/eclipse/xtext/testing/TemporaryFolder.java @@ -0,0 +1,193 @@ +/******************************************************************************* + * Copyright (c) 2016, 2020, 2024 itemis AG (http://www.itemis.eu) and others. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ +package org.eclipse.xtext.testing; + +import java.io.File; +import java.io.IOException; +import java.io.PrintStream; +import java.nio.file.Files; + +import org.junit.Rule; +import org.junit.rules.ExternalResource; + +import com.google.inject.Singleton; + +/** + * Basically copied from {@link org.junit.rules.TemporaryFolder} + * which looks different in different junit versions and does not reset + * the private field {@link #folder} on the {@link #after()} event. + * + * Another change is that the folder is only created on demand. + * + * The TemporaryFolder Rule allows creation of files and folders that are + * guaranteed to be deleted when the test method finishes (whether it passes or + * fails): + * + *
+ * public static class HasTempFolder {
+ * 	@Rule
+ * 	public TemporaryFolder folder= new TemporaryFolder();
+ * 
+ * 	@Test
+ * 	public void testUsingTempFolder() throws IOException {
+ * 		File createdFile= folder.newFile("myfile.txt");
+ * 		File createdFolder= folder.newFolder("subfolder");
+ * 		// ...
+ * 	}
+ * }
+ * 
+ * + * @noextend This class is not intended to be subclassed by clients. + * + * @since 2.38 + */ +@Singleton +public class TemporaryFolder extends ExternalResource { + private File folder; + + private boolean initialized = false; + + @Override + protected void before() throws Throwable { + initialized = true; + } + + @Override + protected void after() { + if (folder != null) { + delete(); + folder = null; + initialized = false; + } + } + + public boolean isInitialized() { + return initialized; + } + + // public for testing purposes only + /** + * for testing purposes only. Do not use. + */ + public void create() throws IOException { + folder = Files.createTempDirectory("junit").toFile(); + } + + /** + * Returns a new fresh file with the given name under the temporary folder. + */ + public File newFile(String fileName) throws IOException { + File file= new File(getRoot(), fileName); + file.createNewFile(); + return file; + } + + /** + * Same signature as {@link java.io.File#createTempFile(String, String)}. + */ + public File createTempFile(String prefix, String suffix) throws IOException { + return File.createTempFile(prefix, suffix, getRoot()); + } + + /** + * Returns a new fresh file with a random name under the temporary folder. + */ + public File newFile() throws IOException { + return File.createTempFile("junit", null, getRoot()); + } + + /** + * Returns a new fresh folder with the given name under the temporary folder. + */ + public File newFolder(String... folderNames) { + File file = getRoot(); + for (String folderName : folderNames) { + file = new File(file, folderName); + file.mkdir(); + } + return file; + } + + /** + * Returns a new fresh folder with a random name under the temporary + * folder. + */ + public File newFolder() throws IOException { + try { + File tempDir = createTempDir(getRoot()); + addSourceInfo(tempDir); + return tempDir; + } catch (IllegalStateException e) { + throw new IOException(e.getMessage()); // IOException(e) not available prior to 1.6 + } + } + + /** + * generate '.createdBy' file with a stack trace so tests that leak temp folders can be identified later. + */ + protected void addSourceInfo(File tempDir) throws IOException { + PrintStream printStream = new PrintStream(new File(tempDir, ".createdBy")); + try { + printStream.append("This temp dir has been created from the stack below. If you want to make sure the temp folders are cleaned up after a test executed, you should add the following to your test class: \n\n"); + printStream.append(" @Rule @Inject public TemporaryFolder temporaryFolder \n\n"); + new Exception().printStackTrace(printStream); + } finally { + printStream.close(); + } + + } + + /** + * Copied from Guava 10.x but added a base dir argument + */ + private File createTempDir(File baseDir) { + String baseName = System.currentTimeMillis() + "-"; + + for (int counter = 0; counter < 10000; counter++) { + File tempDir = new File(baseDir, baseName + counter); + if (tempDir.mkdir()) { + return tempDir; + } + } + throw new IllegalStateException("Failed to create directory within " + 10000 + " attempts (tried " + baseName + + "0 to " + baseName + (10000 - 1) + ')'); + } + + /** + * @return the location of this temporary folder. + */ + public File getRoot() { + if (folder == null) { + try { + create(); + } catch(IOException e) { + throw new IllegalStateException("the temporary folder could not be created", e); + } + } + return folder; + } + + /** + * Delete all files and folders under the temporary folder. + * Usually not called directly, since it is automatically applied + * by the {@link Rule} + */ + public void delete() { + recursiveDelete(folder); + } + + private void recursiveDelete(File file) { + File[] files= file.listFiles(); + if (files != null) + for (File each : files) + recursiveDelete(each); + file.delete(); + } +} + diff --git a/org.eclipse.xtext.xbase.testing/src/org/eclipse/xtext/xbase/testing/TemporaryFolder.java b/org.eclipse.xtext.xbase.testing/src/org/eclipse/xtext/xbase/testing/TemporaryFolder.java index 8edceec1404..917fe99b6f4 100644 --- a/org.eclipse.xtext.xbase.testing/src/org/eclipse/xtext/xbase/testing/TemporaryFolder.java +++ b/org.eclipse.xtext.xbase.testing/src/org/eclipse/xtext/xbase/testing/TemporaryFolder.java @@ -8,14 +8,6 @@ *******************************************************************************/ package org.eclipse.xtext.xbase.testing; -import java.io.File; -import java.io.IOException; -import java.io.PrintStream; -import java.nio.file.Files; - -import org.junit.Rule; -import org.junit.rules.ExternalResource; - import com.google.inject.Singleton; /** @@ -44,150 +36,13 @@ * * * @noextend This class is not intended to be subclassed by clients. + * @deprecated Use {@link org.eclipse.xtext.testing.TemporaryFolder} instead * * @since 2.7 */ +@Deprecated(since = "2.38", forRemoval = true) @Singleton -public class TemporaryFolder extends ExternalResource { - private File folder; - - private boolean initialized = false; - - @Override - protected void before() throws Throwable { - initialized = true; - } - - @Override - protected void after() { - if (folder != null) { - delete(); - folder = null; - initialized = false; - } - } - - public boolean isInitialized() { - return initialized; - } - - // public for testing purposes only - /** - * for testing purposes only. Do not use. - */ - public void create() throws IOException { - folder = Files.createTempDirectory("junit").toFile(); - } - - /** - * Returns a new fresh file with the given name under the temporary folder. - */ - public File newFile(String fileName) throws IOException { - File file= new File(getRoot(), fileName); - file.createNewFile(); - return file; - } - - /** - * Same signature as {@link java.io.File#createTempFile(String, String)}. - */ - public File createTempFile(String prefix, String suffix) throws IOException { - return File.createTempFile(prefix, suffix, getRoot()); - } - - /** - * Returns a new fresh file with a random name under the temporary folder. - */ - public File newFile() throws IOException { - return File.createTempFile("junit", null, getRoot()); - } - - /** - * Returns a new fresh folder with the given name under the temporary folder. - */ - public File newFolder(String... folderNames) { - File file = getRoot(); - for (String folderName : folderNames) { - file = new File(file, folderName); - file.mkdir(); - } - return file; - } - - /** - * Returns a new fresh folder with a random name under the temporary - * folder. - */ - public File newFolder() throws IOException { - try { - File tempDir = createTempDir(getRoot()); - addSourceInfo(tempDir); - return tempDir; - } catch (IllegalStateException e) { - throw new IOException(e.getMessage()); // IOException(e) not available prior to 1.6 - } - } - - /** - * generate '.createdBy' file with a stack trace so tests that leak temp folders can be identified later. - */ - protected void addSourceInfo(File tempDir) throws IOException { - PrintStream printStream = new PrintStream(new File(tempDir, ".createdBy")); - try { - printStream.append("This temp dir has been created from the stack below. If you want to make sure the temp folders are cleaned up after a test executed, you should add the following to your test class: \n\n"); - printStream.append(" @Rule @Inject public TemporaryFolder temporaryFolder \n\n"); - new Exception().printStackTrace(printStream); - } finally { - printStream.close(); - } - - } - - /** - * Copied from Guava 10.x but added a base dir argument - */ - private File createTempDir(File baseDir) { - String baseName = System.currentTimeMillis() + "-"; - - for (int counter = 0; counter < 10000; counter++) { - File tempDir = new File(baseDir, baseName + counter); - if (tempDir.mkdir()) { - return tempDir; - } - } - throw new IllegalStateException("Failed to create directory within " + 10000 + " attempts (tried " + baseName - + "0 to " + baseName + (10000 - 1) + ')'); - } - - /** - * @return the location of this temporary folder. - */ - public File getRoot() { - if (folder == null) { - try { - create(); - } catch(IOException e) { - throw new IllegalStateException("the temporary folder could not be created", e); - } - } - return folder; - } - - /** - * Delete all files and folders under the temporary folder. - * Usually not called directly, since it is automatically applied - * by the {@link Rule} - */ - public void delete() { - recursiveDelete(folder); - } +public class TemporaryFolder extends org.eclipse.xtext.testing.TemporaryFolder { - private void recursiveDelete(File file) { - File[] files= file.listFiles(); - if (files != null) - for (File each : files) - recursiveDelete(each); - file.delete(); - } } From cc019a38ed1f2d0f158910921e6d0ae1e1d5e620 Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Wed, 27 Nov 2024 12:03:07 +0100 Subject: [PATCH 2/3] use the new TemporaryFolder --- .../core/tests/AbstractXtendTestCase.java | 2 +- .../compiler/AnnotationTestingTest.xtend | 2 +- .../macro/ActiveAnnotationsRuntimeTest.xtend | 6 +- .../tests/macro/JavaIoFileSystemTest.xtend | 2 +- .../xtend/core/tests/naming/NamingTest.java | 2 +- .../richstring/RichStringCompilerTest.java | 2 +- .../core/tests/util/TemporaryFolder.java | 191 ----------------- .../tests/compiler/AnnotationTestingTest.java | 2 +- .../macro/ActiveAnnotationsRuntimeTest.java | 2 +- .../tests/macro/JavaIoFileSystemTest.java | 2 +- .../AbstractEMFBasedPersisterTest.java | 2 +- .../eclipse/xtext/tests/TemporaryFolder.java | 192 ------------------ .../xtext/resource/ConcurrentAccessTest.java | 2 +- .../eclipse/xtext/tests/TemporaryFolder.java | 192 ------------------ .../xtext/wizard/WizardConfigurationTest.java | 1 - .../cli/CliProjectsCreatorMainTest.java | 2 +- 16 files changed, 14 insertions(+), 590 deletions(-) delete mode 100644 org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/util/TemporaryFolder.java delete mode 100644 org.eclipse.xtext.extras.tests/src/org/eclipse/xtext/tests/TemporaryFolder.java delete mode 100644 org.eclipse.xtext.tests/src/org/eclipse/xtext/tests/TemporaryFolder.java diff --git a/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/AbstractXtendTestCase.java b/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/AbstractXtendTestCase.java index 04a5f1230b0..8b09cc071ff 100644 --- a/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/AbstractXtendTestCase.java +++ b/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/AbstractXtendTestCase.java @@ -18,7 +18,6 @@ import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.xtend.core.tests.util.TemporaryFolder; import org.eclipse.xtend.core.xtend.XtendAnnotationType; import org.eclipse.xtend.core.xtend.XtendClass; import org.eclipse.xtend.core.xtend.XtendConstructor; @@ -31,6 +30,7 @@ import org.eclipse.xtext.resource.XtextResource; import org.eclipse.xtext.resource.XtextResourceSet; import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.TemporaryFolder; import org.eclipse.xtext.testing.XtextRunner; import org.eclipse.xtext.util.CancelIndicator; import org.eclipse.xtext.util.LazyStringInputStream; diff --git a/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/compiler/AnnotationTestingTest.xtend b/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/compiler/AnnotationTestingTest.xtend index e9f6e4ad672..cbe25a11af0 100644 --- a/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/compiler/AnnotationTestingTest.xtend +++ b/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/compiler/AnnotationTestingTest.xtend @@ -18,7 +18,7 @@ import org.eclipse.xtend.lib.macro.CodeGenerationContext import org.eclipse.xtend.lib.macro.TransformationContext import org.eclipse.xtend.lib.macro.declaration.ClassDeclaration import org.eclipse.xtend.lib.macro.declaration.MutableClassDeclaration -import org.eclipse.xtext.xbase.testing.TemporaryFolder +import org.eclipse.xtext.testing.TemporaryFolder import org.eclipse.xtext.xbase.testing.CompilationTestHelper import org.junit.Rule import org.junit.Test diff --git a/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/macro/ActiveAnnotationsRuntimeTest.xtend b/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/macro/ActiveAnnotationsRuntimeTest.xtend index ecd5ac88828..f6652efe3a6 100644 --- a/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/macro/ActiveAnnotationsRuntimeTest.xtend +++ b/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/macro/ActiveAnnotationsRuntimeTest.xtend @@ -22,12 +22,12 @@ import org.eclipse.xtend.core.validation.IssueCodes import org.eclipse.xtend.core.xtend.XtendFile import org.eclipse.xtend.core.xtend.XtendPackage import org.eclipse.xtext.diagnostics.Severity +import org.eclipse.xtext.resource.XtextResource +import org.eclipse.xtext.resource.XtextResourceSet import org.eclipse.xtext.testing.InjectWith -import org.eclipse.xtend.core.tests.util.TemporaryFolder +import org.eclipse.xtext.testing.TemporaryFolder import org.eclipse.xtext.testing.XtextRunner import org.eclipse.xtext.testing.validation.ValidationTestHelper -import org.eclipse.xtext.resource.XtextResource -import org.eclipse.xtext.resource.XtextResourceSet import org.eclipse.xtext.util.CancelIndicator import org.eclipse.xtext.validation.CheckMode import org.eclipse.xtext.validation.Issue diff --git a/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/macro/JavaIoFileSystemTest.xtend b/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/macro/JavaIoFileSystemTest.xtend index 103fa6feeeb..244d72144ca 100644 --- a/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/macro/JavaIoFileSystemTest.xtend +++ b/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/macro/JavaIoFileSystemTest.xtend @@ -14,9 +14,9 @@ import java.io.FileInputStream import org.eclipse.xtend.core.macro.JavaIOFileSystemSupport import org.eclipse.xtend.lib.macro.file.MutableFileSystemSupport import org.eclipse.xtend.lib.macro.file.Path -import org.eclipse.xtext.xbase.testing.TemporaryFolder import org.eclipse.xtext.parser.IEncodingProvider import org.eclipse.xtext.resource.XtextResourceSet +import org.eclipse.xtext.testing.TemporaryFolder import org.eclipse.xtext.workspace.FileProjectConfig import org.junit.Before import org.junit.Rule diff --git a/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/naming/NamingTest.java b/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/naming/NamingTest.java index f8f8e04721c..3635b9ead35 100644 --- a/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/naming/NamingTest.java +++ b/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/naming/NamingTest.java @@ -46,7 +46,7 @@ public class NamingTest extends AbstractXtendTestCase { @Test public void testQualifiedNameProvider_1() throws Exception { XtendFile file = file("package foo class Bar { def baz() {this} }"); - XtendFunction function = (XtendFunction) ((XtendClass) file.getXtendTypes().get(0)).getMembers().get(0); + XtendFunction function = (XtendFunction) file.getXtendTypes().get(0).getMembers().get(0); assertEquals(QualifiedName.create("foo", "Bar", "baz"), nameProvider.getFullyQualifiedName(function)); assertEquals(QualifiedName.create("foo", "Bar", "baz"), nameProvider.getFullyQualifiedName(associations.getDirectlyInferredOperation(function))); diff --git a/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/richstring/RichStringCompilerTest.java b/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/richstring/RichStringCompilerTest.java index 11506bd3f68..ac7841f8e61 100644 --- a/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/richstring/RichStringCompilerTest.java +++ b/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/richstring/RichStringCompilerTest.java @@ -8,8 +8,8 @@ *******************************************************************************/ package org.eclipse.xtend.core.tests.richstring; -import org.eclipse.xtend.core.tests.util.TemporaryFolder; import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.TemporaryFolder; import org.eclipse.xtext.testing.XtextRunner; import org.junit.Before; import org.junit.Rule; diff --git a/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/util/TemporaryFolder.java b/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/util/TemporaryFolder.java deleted file mode 100644 index 3d939af055c..00000000000 --- a/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/util/TemporaryFolder.java +++ /dev/null @@ -1,191 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 itemis AG (http://www.itemis.eu) and others. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - *******************************************************************************/ -package org.eclipse.xtend.core.tests.util; - -import java.io.File; -import java.io.IOException; -import java.io.PrintStream; -import java.nio.file.Files; - -import org.junit.rules.ExternalResource; - -import com.google.inject.Singleton; - -/** - * Basically copied from {@link org.junit.rules.TemporaryFolder} - * which looks different in different junit versions and does not reset - * the private field {@link #folder} on the {@link #after()} event. - * - * Another change is that the folder is only created on demand. - * - * The TemporaryFolder Rule allows creation of files and folders that are - * guaranteed to be deleted when the test method finishes (whether it passes or - * fails): - * - *
- * public static class HasTempFolder {
- * 	@Rule
- * 	public TemporaryFolder folder= new TemporaryFolder();
- * 
- * 	@Test
- * 	public void testUsingTempFolder() throws IOException {
- * 		File createdFile= folder.newFile("myfile.txt");
- * 		File createdFolder= folder.newFolder("subfolder");
- * 		// ...
- * 	}
- * }
- * 
- * - * @noextend This class is not intended to be subclassed by clients. - * - * @since 2.7 - */ -@Singleton -public class TemporaryFolder extends ExternalResource { - private File folder; - - private boolean initialized = false; - - @Override - protected void before() throws Throwable { - initialized = true; - } - - @Override - protected void after() { - if (folder != null) { - delete(); - folder = null; - initialized = false; - } - } - - public boolean isInitialized() { - return initialized; - } - - // public for testing purposes only - /** - * for testing purposes only. Do not use. - */ - public void create() throws IOException { - folder = Files.createTempDirectory("junit").toFile(); - } - - /** - * Returns a new fresh file with the given name under the temporary folder. - */ - public File newFile(String fileName) throws IOException { - File file= new File(getRoot(), fileName); - file.createNewFile(); - return file; - } - - /** - * Same signature as {@link java.io.File#createTempFile(String, String)}. - */ - public File createTempFile(String prefix, String suffix) throws IOException { - return File.createTempFile(prefix, suffix, getRoot()); - } - - /** - * Returns a new fresh file with a random name under the temporary folder. - */ - public File newFile() throws IOException { - return File.createTempFile("junit", null, getRoot()); - } - - /** - * Returns a new fresh folder with the given name under the temporary folder. - */ - public File newFolder(String... folderNames) { - File file = getRoot(); - for (String folderName : folderNames) { - file = new File(file, folderName); - file.mkdir(); - } - return file; - } - - /** - * Returns a new fresh folder with a random name under the temporary - * folder. - */ - public File newFolder() throws IOException { - try { - File tempDir = createTempDir(getRoot()); - addSourceInfo(tempDir); - return tempDir; - } catch (IllegalStateException e) { - throw new IOException(e.getMessage()); // IOException(e) not available prior to 1.6 - } - } - - /** - * generate '.createdBy' file with a stack trace so tests that leak temp folders can be identified later. - */ - protected void addSourceInfo(File tempDir) throws IOException { - PrintStream printStream = new PrintStream(new File(tempDir, ".createdBy")); - try { - printStream.append("This temp dir has been created from the stack below. If you want to make sure the temp folders are cleaned up after a test executed, you should add the following to your test class: \n\n"); - printStream.append(" @Rule @Inject public TemporaryFolder temporaryFolder \n\n"); - new Exception().printStackTrace(printStream); - } finally { - printStream.close(); - } - - } - - /** - * Copied from Guava 10.x but added a base dir argument - */ - private File createTempDir(File baseDir) { - String baseName = System.currentTimeMillis() + "-"; - - for (int counter = 0; counter < 10000; counter++) { - File tempDir = new File(baseDir, baseName + counter); - if (tempDir.mkdir()) { - return tempDir; - } - } - throw new IllegalStateException("Failed to create directory within " + 10000 + " attempts (tried " + baseName - + "0 to " + baseName + (10000 - 1) + ')'); - } - - /** - * @return the location of this temporary folder. - */ - public File getRoot() { - if (folder == null) { - try { - create(); - } catch(IOException e) { - throw new IllegalStateException("the temporary folder could not be created", e); - } - } - return folder; - } - - /** - * Delete all files and folders under the temporary folder. - * Usually not called directly, since it is automatically applied - * by the {@link Rule} - */ - public void delete() { - recursiveDelete(folder); - } - - private void recursiveDelete(File file) { - File[] files= file.listFiles(); - if (files != null) - for (File each : files) - recursiveDelete(each); - file.delete(); - } -} \ No newline at end of file diff --git a/org.eclipse.xtend.core.tests/xtend-gen/org/eclipse/xtend/core/tests/compiler/AnnotationTestingTest.java b/org.eclipse.xtend.core.tests/xtend-gen/org/eclipse/xtend/core/tests/compiler/AnnotationTestingTest.java index 8eec971173e..4f8fc1b5e0f 100644 --- a/org.eclipse.xtend.core.tests/xtend-gen/org/eclipse/xtend/core/tests/compiler/AnnotationTestingTest.java +++ b/org.eclipse.xtend.core.tests/xtend-gen/org/eclipse/xtend/core/tests/compiler/AnnotationTestingTest.java @@ -17,13 +17,13 @@ import java.util.Objects; import org.eclipse.emf.common.util.URI; import org.eclipse.xtend2.lib.StringConcatenation; +import org.eclipse.xtext.testing.TemporaryFolder; import org.eclipse.xtext.util.IAcceptor; import org.eclipse.xtext.xbase.lib.Conversions; import org.eclipse.xtext.xbase.lib.Exceptions; import org.eclipse.xtext.xbase.lib.Functions.Function1; import org.eclipse.xtext.xbase.lib.IterableExtensions; import org.eclipse.xtext.xbase.testing.CompilationTestHelper; -import org.eclipse.xtext.xbase.testing.TemporaryFolder; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; diff --git a/org.eclipse.xtend.core.tests/xtend-gen/org/eclipse/xtend/core/tests/macro/ActiveAnnotationsRuntimeTest.java b/org.eclipse.xtend.core.tests/xtend-gen/org/eclipse/xtend/core/tests/macro/ActiveAnnotationsRuntimeTest.java index 83e4902b6b5..497047af326 100644 --- a/org.eclipse.xtend.core.tests/xtend-gen/org/eclipse/xtend/core/tests/macro/ActiveAnnotationsRuntimeTest.java +++ b/org.eclipse.xtend.core.tests/xtend-gen/org/eclipse/xtend/core/tests/macro/ActiveAnnotationsRuntimeTest.java @@ -20,7 +20,6 @@ import org.eclipse.xtend.core.macro.AnnotationProcessor; import org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl; import org.eclipse.xtend.core.tests.RuntimeInjectorProvider; -import org.eclipse.xtend.core.tests.util.TemporaryFolder; import org.eclipse.xtend.core.validation.IssueCodes; import org.eclipse.xtend.core.xtend.XtendFile; import org.eclipse.xtend.core.xtend.XtendPackage; @@ -29,6 +28,7 @@ import org.eclipse.xtext.resource.XtextResource; import org.eclipse.xtext.resource.XtextResourceSet; import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.TemporaryFolder; import org.eclipse.xtext.testing.XtextRunner; import org.eclipse.xtext.testing.validation.ValidationTestHelper; import org.eclipse.xtext.util.CancelIndicator; diff --git a/org.eclipse.xtend.core.tests/xtend-gen/org/eclipse/xtend/core/tests/macro/JavaIoFileSystemTest.java b/org.eclipse.xtend.core.tests/xtend-gen/org/eclipse/xtend/core/tests/macro/JavaIoFileSystemTest.java index 645742f6379..aad5ca95301 100644 --- a/org.eclipse.xtend.core.tests/xtend-gen/org/eclipse/xtend/core/tests/macro/JavaIoFileSystemTest.java +++ b/org.eclipse.xtend.core.tests/xtend-gen/org/eclipse/xtend/core/tests/macro/JavaIoFileSystemTest.java @@ -19,6 +19,7 @@ import org.eclipse.xtend2.lib.StringConcatenation; import org.eclipse.xtext.parser.IEncodingProvider; import org.eclipse.xtext.resource.XtextResourceSet; +import org.eclipse.xtext.testing.TemporaryFolder; import org.eclipse.xtext.workspace.FileProjectConfig; import org.eclipse.xtext.workspace.IProjectConfigProvider; import org.eclipse.xtext.xbase.lib.Exceptions; @@ -27,7 +28,6 @@ import org.eclipse.xtext.xbase.lib.IterableExtensions; import org.eclipse.xtext.xbase.lib.ObjectExtensions; import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; -import org.eclipse.xtext.xbase.testing.TemporaryFolder; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; diff --git a/org.eclipse.xtext.builder.tests/src/org/eclipse/xtext/builder/builderState/AbstractEMFBasedPersisterTest.java b/org.eclipse.xtext.builder.tests/src/org/eclipse/xtext/builder/builderState/AbstractEMFBasedPersisterTest.java index c7d75cd51f0..9a84f166b01 100644 --- a/org.eclipse.xtext.builder.tests/src/org/eclipse/xtext/builder/builderState/AbstractEMFBasedPersisterTest.java +++ b/org.eclipse.xtext.builder.tests/src/org/eclipse/xtext/builder/builderState/AbstractEMFBasedPersisterTest.java @@ -24,7 +24,7 @@ import org.eclipse.xtext.resource.IEObjectDescription; import org.eclipse.xtext.resource.IReferenceDescription; import org.eclipse.xtext.resource.IResourceDescription; -import org.eclipse.xtext.tests.TemporaryFolder; +import org.eclipse.xtext.testing.TemporaryFolder; import org.eclipse.xtext.ui.shared.SharedStateModule; import org.eclipse.xtext.util.EmfStructureComparator; import org.junit.Assert; diff --git a/org.eclipse.xtext.extras.tests/src/org/eclipse/xtext/tests/TemporaryFolder.java b/org.eclipse.xtext.extras.tests/src/org/eclipse/xtext/tests/TemporaryFolder.java deleted file mode 100644 index 86676b5a5f0..00000000000 --- a/org.eclipse.xtext.extras.tests/src/org/eclipse/xtext/tests/TemporaryFolder.java +++ /dev/null @@ -1,192 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 itemis AG (http://www.itemis.eu) and others. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - *******************************************************************************/ -package org.eclipse.xtext.tests; - -import java.io.File; -import java.io.IOException; -import java.io.PrintStream; -import java.nio.file.Files; - -import org.junit.rules.ExternalResource; - -import com.google.inject.Singleton; - -/** - * Basically copied from {@link org.junit.rules.TemporaryFolder} - * which looks different in different junit versions and does not reset - * the private field {@link #folder} on the {@link #after()} event. - * - * Another change is that the folder is only created on demand. - * - * The TemporaryFolder Rule allows creation of files and folders that are - * guaranteed to be deleted when the test method finishes (whether it passes or - * fails): - * - *
- * public static class HasTempFolder {
- * 	@Rule
- * 	public TemporaryFolder folder= new TemporaryFolder();
- * 
- * 	@Test
- * 	public void testUsingTempFolder() throws IOException {
- * 		File createdFile= folder.newFile("myfile.txt");
- * 		File createdFolder= folder.newFolder("subfolder");
- * 		// ...
- * 	}
- * }
- * 
- * - * @noextend This class is not intended to be subclassed by clients. - * - * @since 2.7 - */ -@Singleton -public class TemporaryFolder extends ExternalResource { - private File folder; - - private boolean initialized = false; - - @Override - protected void before() throws Throwable { - initialized = true; - } - - @Override - protected void after() { - if (folder != null) { - delete(); - folder = null; - initialized = false; - } - } - - public boolean isInitialized() { - return initialized; - } - - // public for testing purposes only - /** - * for testing purposes only. Do not use. - */ - public void create() throws IOException { - folder = Files.createTempDirectory("junit").toFile(); - } - - /** - * Returns a new fresh file with the given name under the temporary folder. - */ - public File newFile(String fileName) throws IOException { - File file= new File(getRoot(), fileName); - file.createNewFile(); - return file; - } - - /** - * Same signature as {@link java.io.File#createTempFile(String, String)}. - */ - public File createTempFile(String prefix, String suffix) throws IOException { - return File.createTempFile(prefix, suffix, getRoot()); - } - - /** - * Returns a new fresh file with a random name under the temporary folder. - */ - public File newFile() throws IOException { - return File.createTempFile("junit", null, getRoot()); - } - - /** - * Returns a new fresh folder with the given name under the temporary folder. - */ - public File newFolder(String... folderNames) { - File file = getRoot(); - for (String folderName : folderNames) { - file = new File(file, folderName); - file.mkdir(); - } - return file; - } - - /** - * Returns a new fresh folder with a random name under the temporary - * folder. - */ - public File newFolder() throws IOException { - try { - File tempDir = createTempDir(getRoot()); - addSourceInfo(tempDir); - return tempDir; - } catch (IllegalStateException e) { - throw new IOException(e.getMessage()); // IOException(e) not available prior to 1.6 - } - } - - /** - * generate '.createdBy' file with a stack trace so tests that leak temp folders can be identified later. - */ - protected void addSourceInfo(File tempDir) throws IOException { - PrintStream printStream = new PrintStream(new File(tempDir, ".createdBy")); - try { - printStream.append("This temp dir has been created from the stack below. If you want to make sure the temp folders are cleaned up after a test executed, you should add the following to your test class: \n\n"); - printStream.append(" @Rule @Inject public TemporaryFolder temporaryFolder \n\n"); - new Exception().printStackTrace(printStream); - } finally { - printStream.close(); - } - - } - - /** - * Copied from Guava 10.x but added a base dir argument - */ - private File createTempDir(File baseDir) { - String baseName = System.currentTimeMillis() + "-"; - - for (int counter = 0; counter < 10000; counter++) { - File tempDir = new File(baseDir, baseName + counter); - if (tempDir.mkdir()) { - return tempDir; - } - } - throw new IllegalStateException("Failed to create directory within " + 10000 + " attempts (tried " + baseName - + "0 to " + baseName + (10000 - 1) + ')'); - } - - /** - * @return the location of this temporary folder. - */ - public File getRoot() { - if (folder == null) { - try { - create(); - } catch(IOException e) { - throw new IllegalStateException("the temporary folder could not be created", e); - } - } - return folder; - } - - /** - * Delete all files and folders under the temporary folder. - * Usually not called directly, since it is automatically applied - * by the {@link Rule} - */ - public void delete() { - recursiveDelete(folder); - } - - private void recursiveDelete(File file) { - File[] files= file.listFiles(); - if (files != null) - for (File each : files) - recursiveDelete(each); - file.delete(); - } -} - diff --git a/org.eclipse.xtext.tests/src/org/eclipse/xtext/resource/ConcurrentAccessTest.java b/org.eclipse.xtext.tests/src/org/eclipse/xtext/resource/ConcurrentAccessTest.java index dd8ef803d31..91d79d2562a 100644 --- a/org.eclipse.xtext.tests/src/org/eclipse/xtext/resource/ConcurrentAccessTest.java +++ b/org.eclipse.xtext.tests/src/org/eclipse/xtext/resource/ConcurrentAccessTest.java @@ -30,7 +30,7 @@ import org.eclipse.emf.mwe.utils.StandaloneSetup; import org.eclipse.xtext.testing.GlobalRegistries; import org.eclipse.xtext.testing.GlobalRegistries.GlobalStateMemento; -import org.eclipse.xtext.tests.TemporaryFolder; +import org.eclipse.xtext.testing.TemporaryFolder; import org.eclipse.xtext.util.concurrent.AbstractReadWriteAcces; import org.eclipse.xtext.util.concurrent.IReadAccess; import org.eclipse.xtext.util.concurrent.IUnitOfWork; diff --git a/org.eclipse.xtext.tests/src/org/eclipse/xtext/tests/TemporaryFolder.java b/org.eclipse.xtext.tests/src/org/eclipse/xtext/tests/TemporaryFolder.java deleted file mode 100644 index 86676b5a5f0..00000000000 --- a/org.eclipse.xtext.tests/src/org/eclipse/xtext/tests/TemporaryFolder.java +++ /dev/null @@ -1,192 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 itemis AG (http://www.itemis.eu) and others. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - *******************************************************************************/ -package org.eclipse.xtext.tests; - -import java.io.File; -import java.io.IOException; -import java.io.PrintStream; -import java.nio.file.Files; - -import org.junit.rules.ExternalResource; - -import com.google.inject.Singleton; - -/** - * Basically copied from {@link org.junit.rules.TemporaryFolder} - * which looks different in different junit versions and does not reset - * the private field {@link #folder} on the {@link #after()} event. - * - * Another change is that the folder is only created on demand. - * - * The TemporaryFolder Rule allows creation of files and folders that are - * guaranteed to be deleted when the test method finishes (whether it passes or - * fails): - * - *
- * public static class HasTempFolder {
- * 	@Rule
- * 	public TemporaryFolder folder= new TemporaryFolder();
- * 
- * 	@Test
- * 	public void testUsingTempFolder() throws IOException {
- * 		File createdFile= folder.newFile("myfile.txt");
- * 		File createdFolder= folder.newFolder("subfolder");
- * 		// ...
- * 	}
- * }
- * 
- * - * @noextend This class is not intended to be subclassed by clients. - * - * @since 2.7 - */ -@Singleton -public class TemporaryFolder extends ExternalResource { - private File folder; - - private boolean initialized = false; - - @Override - protected void before() throws Throwable { - initialized = true; - } - - @Override - protected void after() { - if (folder != null) { - delete(); - folder = null; - initialized = false; - } - } - - public boolean isInitialized() { - return initialized; - } - - // public for testing purposes only - /** - * for testing purposes only. Do not use. - */ - public void create() throws IOException { - folder = Files.createTempDirectory("junit").toFile(); - } - - /** - * Returns a new fresh file with the given name under the temporary folder. - */ - public File newFile(String fileName) throws IOException { - File file= new File(getRoot(), fileName); - file.createNewFile(); - return file; - } - - /** - * Same signature as {@link java.io.File#createTempFile(String, String)}. - */ - public File createTempFile(String prefix, String suffix) throws IOException { - return File.createTempFile(prefix, suffix, getRoot()); - } - - /** - * Returns a new fresh file with a random name under the temporary folder. - */ - public File newFile() throws IOException { - return File.createTempFile("junit", null, getRoot()); - } - - /** - * Returns a new fresh folder with the given name under the temporary folder. - */ - public File newFolder(String... folderNames) { - File file = getRoot(); - for (String folderName : folderNames) { - file = new File(file, folderName); - file.mkdir(); - } - return file; - } - - /** - * Returns a new fresh folder with a random name under the temporary - * folder. - */ - public File newFolder() throws IOException { - try { - File tempDir = createTempDir(getRoot()); - addSourceInfo(tempDir); - return tempDir; - } catch (IllegalStateException e) { - throw new IOException(e.getMessage()); // IOException(e) not available prior to 1.6 - } - } - - /** - * generate '.createdBy' file with a stack trace so tests that leak temp folders can be identified later. - */ - protected void addSourceInfo(File tempDir) throws IOException { - PrintStream printStream = new PrintStream(new File(tempDir, ".createdBy")); - try { - printStream.append("This temp dir has been created from the stack below. If you want to make sure the temp folders are cleaned up after a test executed, you should add the following to your test class: \n\n"); - printStream.append(" @Rule @Inject public TemporaryFolder temporaryFolder \n\n"); - new Exception().printStackTrace(printStream); - } finally { - printStream.close(); - } - - } - - /** - * Copied from Guava 10.x but added a base dir argument - */ - private File createTempDir(File baseDir) { - String baseName = System.currentTimeMillis() + "-"; - - for (int counter = 0; counter < 10000; counter++) { - File tempDir = new File(baseDir, baseName + counter); - if (tempDir.mkdir()) { - return tempDir; - } - } - throw new IllegalStateException("Failed to create directory within " + 10000 + " attempts (tried " + baseName - + "0 to " + baseName + (10000 - 1) + ')'); - } - - /** - * @return the location of this temporary folder. - */ - public File getRoot() { - if (folder == null) { - try { - create(); - } catch(IOException e) { - throw new IllegalStateException("the temporary folder could not be created", e); - } - } - return folder; - } - - /** - * Delete all files and folders under the temporary folder. - * Usually not called directly, since it is automatically applied - * by the {@link Rule} - */ - public void delete() { - recursiveDelete(folder); - } - - private void recursiveDelete(File file) { - File[] files= file.listFiles(); - if (files != null) - for (File each : files) - recursiveDelete(each); - file.delete(); - } -} - diff --git a/org.eclipse.xtext.tests/src/org/eclipse/xtext/xtext/wizard/WizardConfigurationTest.java b/org.eclipse.xtext.tests/src/org/eclipse/xtext/xtext/wizard/WizardConfigurationTest.java index 57e9bf6bcda..b111b634834 100644 --- a/org.eclipse.xtext.tests/src/org/eclipse/xtext/xtext/wizard/WizardConfigurationTest.java +++ b/org.eclipse.xtext.tests/src/org/eclipse/xtext/xtext/wizard/WizardConfigurationTest.java @@ -13,7 +13,6 @@ import java.util.List; import java.util.Objects; -import org.eclipse.xtext.util.JavaVersion; import org.eclipse.xtext.util.XtextVersion; import org.eclipse.xtext.xbase.lib.IterableExtensions; import org.junit.Before; diff --git a/org.eclipse.xtext.tests/src/org/eclipse/xtext/xtext/wizard/cli/CliProjectsCreatorMainTest.java b/org.eclipse.xtext.tests/src/org/eclipse/xtext/xtext/wizard/cli/CliProjectsCreatorMainTest.java index 95c2787c2b2..094a6dc6563 100644 --- a/org.eclipse.xtext.tests/src/org/eclipse/xtext/xtext/wizard/cli/CliProjectsCreatorMainTest.java +++ b/org.eclipse.xtext.tests/src/org/eclipse/xtext/xtext/wizard/cli/CliProjectsCreatorMainTest.java @@ -11,7 +11,7 @@ import java.io.File; import java.util.List; -import org.eclipse.xtext.tests.TemporaryFolder; +import org.eclipse.xtext.testing.TemporaryFolder; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; From ad2befb8a4647ad16e35d4e3e5ee5389ebe5ce07 Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Wed, 27 Nov 2024 12:09:19 +0100 Subject: [PATCH 3/3] removed use of deprecated xbase.testing.TemporaryFolder --- .../eclipse/xtend/ide/tests/AbstractXtendTestCase.java | 2 +- .../xtend/ide/tests/macros/JavaIoFileSystemTest.xtend | 2 +- .../xtend/ide/tests/macros/JavaIoFileSystemTest.java | 2 +- .../eclipse/xtext/purexbase/tests/CompilerTest.java | 2 +- .../xtext/xbase/testing/OnTheFlyJavaCompiler.java | 1 + .../xtext/xbase/testing/CompilationTestHelper.java | 1 + .../evaluation/AbstractXbaseEvaluationTest.java | 10 +++++----- .../tests/compiler/CompilationTestHelperTest.java | 2 +- .../xbase/tests/compiler/Java21RecordCompilerTest.java | 2 +- .../xbase/tests/compiler/JvmModelGeneratorTest.java | 2 +- .../tests/compiler/OnTheFlyJavaCompiler2Test.java | 2 +- .../xbase/tests/compiler/OnTheFlyJavaCompilerTest.java | 4 ++-- .../xtext/example/domainmodel/tests/CompilerTest.xtend | 2 +- .../xtext/example/domainmodel/tests/CompilerTest.java | 2 +- 14 files changed, 19 insertions(+), 17 deletions(-) diff --git a/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/AbstractXtendTestCase.java b/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/AbstractXtendTestCase.java index f3ee0d08684..ffc302ed817 100644 --- a/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/AbstractXtendTestCase.java +++ b/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/AbstractXtendTestCase.java @@ -31,12 +31,12 @@ import org.eclipse.xtext.resource.XtextResource; import org.eclipse.xtext.resource.XtextResourceSet; import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.TemporaryFolder; import org.eclipse.xtext.testing.XtextRunner; import org.eclipse.xtext.util.CancelIndicator; import org.eclipse.xtext.util.StringInputStream; import org.eclipse.xtext.validation.CheckMode; import org.eclipse.xtext.validation.Issue; -import org.eclipse.xtext.xbase.testing.TemporaryFolder; import org.junit.Assert; import org.junit.Rule; import org.junit.runner.RunWith; diff --git a/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/macros/JavaIoFileSystemTest.xtend b/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/macros/JavaIoFileSystemTest.xtend index 82fa4693bc2..e26baea59bd 100644 --- a/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/macros/JavaIoFileSystemTest.xtend +++ b/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/macros/JavaIoFileSystemTest.xtend @@ -16,8 +16,8 @@ import org.eclipse.xtend.lib.macro.file.MutableFileSystemSupport import org.eclipse.xtend.lib.macro.file.Path import org.eclipse.xtext.parser.IEncodingProvider import org.eclipse.xtext.resource.XtextResourceSet +import org.eclipse.xtext.testing.TemporaryFolder import org.eclipse.xtext.workspace.FileProjectConfig -import org.eclipse.xtext.xbase.testing.TemporaryFolder import org.junit.Before import org.junit.Rule import org.junit.Test diff --git a/org.eclipse.xtend.ide.tests/xtend-gen/org/eclipse/xtend/ide/tests/macros/JavaIoFileSystemTest.java b/org.eclipse.xtend.ide.tests/xtend-gen/org/eclipse/xtend/ide/tests/macros/JavaIoFileSystemTest.java index 45544d987ba..b5413ffd0ac 100644 --- a/org.eclipse.xtend.ide.tests/xtend-gen/org/eclipse/xtend/ide/tests/macros/JavaIoFileSystemTest.java +++ b/org.eclipse.xtend.ide.tests/xtend-gen/org/eclipse/xtend/ide/tests/macros/JavaIoFileSystemTest.java @@ -19,6 +19,7 @@ import org.eclipse.xtend2.lib.StringConcatenation; import org.eclipse.xtext.parser.IEncodingProvider; import org.eclipse.xtext.resource.XtextResourceSet; +import org.eclipse.xtext.testing.TemporaryFolder; import org.eclipse.xtext.workspace.FileProjectConfig; import org.eclipse.xtext.workspace.IProjectConfigProvider; import org.eclipse.xtext.xbase.lib.Exceptions; @@ -27,7 +28,6 @@ import org.eclipse.xtext.xbase.lib.IterableExtensions; import org.eclipse.xtext.xbase.lib.ObjectExtensions; import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; -import org.eclipse.xtext.xbase.testing.TemporaryFolder; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; diff --git a/org.eclipse.xtext.purexbase.tests/src/org/eclipse/xtext/purexbase/tests/CompilerTest.java b/org.eclipse.xtext.purexbase.tests/src/org/eclipse/xtext/purexbase/tests/CompilerTest.java index fd17696d772..21aae0397f1 100644 --- a/org.eclipse.xtext.purexbase.tests/src/org/eclipse/xtext/purexbase/tests/CompilerTest.java +++ b/org.eclipse.xtext.purexbase.tests/src/org/eclipse/xtext/purexbase/tests/CompilerTest.java @@ -11,10 +11,10 @@ import java.io.IOException; import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.TemporaryFolder; import org.eclipse.xtext.testing.XtextRunner; import org.eclipse.xtext.util.Strings; import org.eclipse.xtext.xbase.testing.CompilationTestHelper; -import org.eclipse.xtext.xbase.testing.TemporaryFolder; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/org.eclipse.xtext.xbase.testing/deprecated/org/eclipse/xtext/xbase/testing/OnTheFlyJavaCompiler.java b/org.eclipse.xtext.xbase.testing/deprecated/org/eclipse/xtext/xbase/testing/OnTheFlyJavaCompiler.java index 0f47f9679cc..0da18e773d3 100644 --- a/org.eclipse.xtext.xbase.testing/deprecated/org/eclipse/xtext/xbase/testing/OnTheFlyJavaCompiler.java +++ b/org.eclipse.xtext.xbase.testing/deprecated/org/eclipse/xtext/xbase/testing/OnTheFlyJavaCompiler.java @@ -33,6 +33,7 @@ import org.eclipse.core.runtime.URIUtil; import org.eclipse.emf.common.util.WrappedException; import org.eclipse.jdt.internal.compiler.batch.Main; +import org.eclipse.xtext.testing.TemporaryFolder; import org.eclipse.xtext.util.Files; import org.eclipse.xtext.util.JavaVersion; import org.eclipse.xtext.util.Pair; diff --git a/org.eclipse.xtext.xbase.testing/src/org/eclipse/xtext/xbase/testing/CompilationTestHelper.java b/org.eclipse.xtext.xbase.testing/src/org/eclipse/xtext/xbase/testing/CompilationTestHelper.java index 46a90cb6381..24a3b6d0275 100644 --- a/org.eclipse.xtext.xbase.testing/src/org/eclipse/xtext/xbase/testing/CompilationTestHelper.java +++ b/org.eclipse.xtext.xbase.testing/src/org/eclipse/xtext/xbase/testing/CompilationTestHelper.java @@ -42,6 +42,7 @@ import org.eclipse.xtext.resource.XtextResource; import org.eclipse.xtext.resource.XtextResourceSet; import org.eclipse.xtext.resource.impl.ResourceDescriptionsData; +import org.eclipse.xtext.testing.TemporaryFolder; import org.eclipse.xtext.util.CancelIndicator; import org.eclipse.xtext.util.Exceptions; import org.eclipse.xtext.util.IAcceptor; diff --git a/org.eclipse.xtext.xbase.testing/src/org/eclipse/xtext/xbase/testing/evaluation/AbstractXbaseEvaluationTest.java b/org.eclipse.xtext.xbase.testing/src/org/eclipse/xtext/xbase/testing/evaluation/AbstractXbaseEvaluationTest.java index 8564e799142..7986533a763 100644 --- a/org.eclipse.xtext.xbase.testing/src/org/eclipse/xtext/xbase/testing/evaluation/AbstractXbaseEvaluationTest.java +++ b/org.eclipse.xtext.xbase.testing/src/org/eclipse/xtext/xbase/testing/evaluation/AbstractXbaseEvaluationTest.java @@ -9,9 +9,9 @@ package org.eclipse.xtext.xbase.testing.evaluation; import static com.google.common.collect.Lists.newArrayList; +import static com.google.common.collect.Maps.newHashMap; import static com.google.common.collect.Sets.newHashSet; import static com.google.common.collect.Sets.newTreeSet; -import static com.google.common.collect.Maps.newHashMap; import static java.util.Collections.emptyList; import java.io.IOException; @@ -25,21 +25,21 @@ import java.util.Map; import java.util.Stack; +import org.eclipse.xtext.testing.TemporaryFolder; import org.eclipse.xtext.xbase.lib.Pair; -import org.eclipse.xtext.xbase.testing.TemporaryFolder; import org.junit.Assert; import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; +import com.google.common.collect.ImmutableMap; +import com.google.inject.Inject; + import testdata.CloseException; import testdata.ExceptionSubclass; import testdata.OuterClass; import testdata.TryBodyException; -import com.google.common.collect.ImmutableMap; -import com.google.inject.Inject; - /** * @author Sebastian Zarnekow - Initial contribution and API * @author Sven Efftinge diff --git a/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/compiler/CompilationTestHelperTest.java b/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/compiler/CompilationTestHelperTest.java index d4b228b0ca3..a039fe99cbf 100644 --- a/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/compiler/CompilationTestHelperTest.java +++ b/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/compiler/CompilationTestHelperTest.java @@ -10,13 +10,13 @@ import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.xtext.resource.FileExtensionProvider; +import org.eclipse.xtext.testing.TemporaryFolder; import org.eclipse.xtext.util.JavaVersion; import org.eclipse.xtext.util.Strings; import org.eclipse.xtext.xbase.compiler.GeneratorConfig; import org.eclipse.xtext.xbase.compiler.GeneratorConfigProvider; import org.eclipse.xtext.xbase.lib.Pair; import org.eclipse.xtext.xbase.testing.CompilationTestHelper; -import org.eclipse.xtext.xbase.testing.TemporaryFolder; import org.eclipse.xtext.xbase.tests.jvmmodel.AbstractJvmModelTest; import org.junit.Assert; import org.junit.Rule; diff --git a/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/compiler/Java21RecordCompilerTest.java b/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/compiler/Java21RecordCompilerTest.java index 39d49434846..7337c5a4869 100644 --- a/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/compiler/Java21RecordCompilerTest.java +++ b/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/compiler/Java21RecordCompilerTest.java @@ -8,10 +8,10 @@ *******************************************************************************/ package org.eclipse.xtext.xbase.tests.compiler; +import org.eclipse.xtext.testing.TemporaryFolder; import org.eclipse.xtext.util.JavaRuntimeVersion; import org.eclipse.xtext.util.Strings; import org.eclipse.xtext.xbase.testing.CompilationTestHelper; -import org.eclipse.xtext.xbase.testing.TemporaryFolder; import org.eclipse.xtext.xbase.tests.jvmmodel.AbstractJvmModelTest; import org.junit.Assume; import org.junit.Rule; diff --git a/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/compiler/JvmModelGeneratorTest.java b/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/compiler/JvmModelGeneratorTest.java index 7afcdded4ed..a0cc50c3d34 100644 --- a/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/compiler/JvmModelGeneratorTest.java +++ b/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/compiler/JvmModelGeneratorTest.java @@ -35,6 +35,7 @@ import org.eclipse.xtext.generator.IFileSystemAccess; import org.eclipse.xtext.generator.InMemoryFileSystemAccess; import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.TemporaryFolder; import org.eclipse.xtext.testing.XtextRunner; import org.eclipse.xtext.testing.validation.ValidationTestHelper; import org.eclipse.xtext.xbase.XExpression; @@ -45,7 +46,6 @@ import org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder; import org.eclipse.xtext.xbase.lib.IterableExtensions; import org.eclipse.xtext.xbase.testing.OnTheFlyJavaCompiler2; -import org.eclipse.xtext.xbase.testing.TemporaryFolder; import org.eclipse.xtext.xbase.tests.AbstractXbaseTestCase; import org.eclipse.xtext.xbase.tests.typesystem.XbaseWithLogicalContainerInjectorProvider; import org.junit.Assert; diff --git a/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/compiler/OnTheFlyJavaCompiler2Test.java b/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/compiler/OnTheFlyJavaCompiler2Test.java index c2e72ec761a..361a589d5cc 100644 --- a/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/compiler/OnTheFlyJavaCompiler2Test.java +++ b/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/compiler/OnTheFlyJavaCompiler2Test.java @@ -9,11 +9,11 @@ package org.eclipse.xtext.xbase.tests.compiler; import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.TemporaryFolder; import org.eclipse.xtext.testing.XtextRunner; import org.eclipse.xtext.util.JavaRuntimeVersion; import org.eclipse.xtext.util.JavaVersion; import org.eclipse.xtext.xbase.testing.OnTheFlyJavaCompiler2; -import org.eclipse.xtext.xbase.testing.TemporaryFolder; import org.eclipse.xtext.xbase.tests.XbaseInjectorProvider; import org.eclipse.xtext.xbase.tests.jvmmodel.AbstractJvmModelTest; import org.junit.Assume; diff --git a/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/compiler/OnTheFlyJavaCompilerTest.java b/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/compiler/OnTheFlyJavaCompilerTest.java index 146c43c6c42..865b9b90562 100644 --- a/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/compiler/OnTheFlyJavaCompilerTest.java +++ b/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/compiler/OnTheFlyJavaCompilerTest.java @@ -8,11 +8,11 @@ *******************************************************************************/ package org.eclipse.xtext.xbase.tests.compiler; -import org.eclipse.xtext.xbase.testing.TemporaryFolder; -import org.eclipse.xtext.xbase.testing.OnTheFlyJavaCompiler; +import org.eclipse.xtext.testing.TemporaryFolder; import org.eclipse.xtext.xbase.lib.Functions; import org.eclipse.xtext.xbase.lib.Functions.Function1; import org.eclipse.xtext.xbase.lib.Functions.Function2; +import org.eclipse.xtext.xbase.testing.OnTheFlyJavaCompiler; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; diff --git a/org.eclipse.xtext.xtext.ui.examples/projects/domainmodel/org.eclipse.xtext.example.domainmodel.tests/src/org/eclipse/xtext/example/domainmodel/tests/CompilerTest.xtend b/org.eclipse.xtext.xtext.ui.examples/projects/domainmodel/org.eclipse.xtext.example.domainmodel.tests/src/org/eclipse/xtext/example/domainmodel/tests/CompilerTest.xtend index aaa22911222..ed9dc329f82 100644 --- a/org.eclipse.xtext.xtext.ui.examples/projects/domainmodel/org.eclipse.xtext.example.domainmodel.tests/src/org/eclipse/xtext/example/domainmodel/tests/CompilerTest.xtend +++ b/org.eclipse.xtext.xtext.ui.examples/projects/domainmodel/org.eclipse.xtext.example.domainmodel.tests/src/org/eclipse/xtext/example/domainmodel/tests/CompilerTest.xtend @@ -10,10 +10,10 @@ package org.eclipse.xtext.example.domainmodel.tests import com.google.inject.Inject import org.eclipse.xtext.testing.InjectWith +import org.eclipse.xtext.testing.TemporaryFolder import org.eclipse.xtext.testing.XtextRunner import org.eclipse.xtext.xbase.lib.util.ReflectExtensions import org.eclipse.xtext.xbase.testing.CompilationTestHelper -import org.eclipse.xtext.xbase.testing.TemporaryFolder import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith diff --git a/org.eclipse.xtext.xtext.ui.examples/projects/domainmodel/org.eclipse.xtext.example.domainmodel.tests/xtend-gen/org/eclipse/xtext/example/domainmodel/tests/CompilerTest.java b/org.eclipse.xtext.xtext.ui.examples/projects/domainmodel/org.eclipse.xtext.example.domainmodel.tests/xtend-gen/org/eclipse/xtext/example/domainmodel/tests/CompilerTest.java index d60016cf06d..61b6fbf4256 100644 --- a/org.eclipse.xtext.xtext.ui.examples/projects/domainmodel/org.eclipse.xtext.example.domainmodel.tests/xtend-gen/org/eclipse/xtext/example/domainmodel/tests/CompilerTest.java +++ b/org.eclipse.xtext.xtext.ui.examples/projects/domainmodel/org.eclipse.xtext.example.domainmodel.tests/xtend-gen/org/eclipse/xtext/example/domainmodel/tests/CompilerTest.java @@ -12,6 +12,7 @@ import java.util.Collections; import org.eclipse.xtend2.lib.StringConcatenation; import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.TemporaryFolder; import org.eclipse.xtext.testing.XtextRunner; import org.eclipse.xtext.util.IAcceptor; import org.eclipse.xtext.xbase.lib.CollectionLiterals; @@ -19,7 +20,6 @@ import org.eclipse.xtext.xbase.lib.Extension; import org.eclipse.xtext.xbase.lib.util.ReflectExtensions; import org.eclipse.xtext.xbase.testing.CompilationTestHelper; -import org.eclipse.xtext.xbase.testing.TemporaryFolder; import org.junit.Assert; import org.junit.Rule; import org.junit.Test;