Skip to content

Commit

Permalink
migrate to junit 5 suite
Browse files Browse the repository at this point in the history
  • Loading branch information
carstenartur committed Sep 21, 2024
1 parent 62500c8 commit 10227b8
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,41 @@
package org.eclipse.jdt.ui.tests.quickfix.Java10;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IPackageFragment;
import java.util.Hashtable;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;

import org.eclipse.jdt.testplugin.TestOptions;

import org.eclipse.core.runtime.CoreException;

import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;

import org.eclipse.jdt.internal.corext.fix.CleanUpConstants;

import org.eclipse.jdt.ui.tests.quickfix.rules.AbstractEclipseJava;
import org.eclipse.jdt.ui.tests.quickfix.rules.EclipseJava10;

import org.eclipse.jdt.internal.ui.JavaPlugin;

public class ExplicitEncodingCleanUpTest {

@BeforeEach
protected void setUp() throws Exception {
Hashtable<String, String> defaultOptions= TestOptions.getDefaultOptions();
defaultOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, Integer.toString(120));
JavaCore.setOptions(defaultOptions);
TestOptions.initializeCodeGenerationOptions();
// Use load since restore doesn't really restore the defaults.
JavaPlugin.getDefault().getCodeTemplateStore().load();
}

@RegisterExtension
AbstractEclipseJava context = new EclipseJava10();

Expand Down Expand Up @@ -582,7 +605,7 @@ static void bla() throws UnsupportedEncodingException {
String url2=URLDecoder.decode("asdf", Charset.defaultCharset());
}
}
"""),
"""),
URLENCODER("""
package test1;
import java.io.UnsupportedEncodingException;
Expand All @@ -609,7 +632,7 @@ static void bla() throws UnsupportedEncodingException {
String url4=URLEncoder.encode("asdf", Charset.defaultCharset());
}
}
"""),
"""),
SCANNER("""
package test1;
import java.io.File;
Expand Down Expand Up @@ -640,7 +663,7 @@ static void bla() throws FileNotFoundException {
Scanner s3=new Scanner("asdf", Charset.defaultCharset());
}
}
"""),
"""),
FORMATTER("""
package test1;
import java.io.File;
Expand Down Expand Up @@ -668,7 +691,7 @@ static void bla() throws FileNotFoundException, UnsupportedEncodingException {
Formatter s=new Formatter(new File("asdf"),StandardCharsets.UTF_8);
}
}
"""),
"""),
THREE("""
package test1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.quickfix.Java10;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;

@RunWith(Suite.class)
@Suite.SuiteClasses({
ExplicitEncodingCleanUpTest.class,
@Suite
@SelectClasses({
ExplicitEncodingCleanUpTest.class
})
public class QuickFixJava10TestSuite {
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,41 @@
package org.eclipse.jdt.ui.tests.quickfix.Java8;

import java.util.Hashtable;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;

import org.eclipse.jdt.testplugin.TestOptions;

import org.eclipse.core.runtime.CoreException;

import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;

import org.eclipse.jdt.internal.corext.fix.CleanUpConstants;

import org.eclipse.jdt.ui.tests.quickfix.rules.AbstractEclipseJava;
import org.eclipse.jdt.ui.tests.quickfix.rules.EclipseJava8;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;

import org.eclipse.jdt.internal.ui.JavaPlugin;

public class ExplicitEncodingCleanUpTest {

@BeforeEach
protected void setUp() throws Exception {
Hashtable<String, String> defaultOptions= TestOptions.getDefaultOptions();
defaultOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, Integer.toString(120));
JavaCore.setOptions(defaultOptions);
TestOptions.initializeCodeGenerationOptions();
// Use load since restore doesn't really restore the defaults.
JavaPlugin.getDefault().getCodeTemplateStore().load();
}

@RegisterExtension
AbstractEclipseJava context = new EclipseJava8();

Expand Down Expand Up @@ -573,7 +596,7 @@ static void bla() throws UnsupportedEncodingException {
String url2=URLDecoder.decode("asdf");
}
}
"""),
"""),
URLENCODER("""
package test1;
import java.io.UnsupportedEncodingException;
Expand All @@ -598,7 +621,7 @@ static void bla() throws UnsupportedEncodingException {
String url4=URLEncoder.encode("asdf");
}
}
"""),
"""),
SCANNER("""
package test1;
import java.io.File;
Expand Down Expand Up @@ -627,7 +650,7 @@ static void bla() throws FileNotFoundException {
Scanner s3=new Scanner("asdf");
}
}
"""),
"""),
FORMATTER("""
package test1;
import java.io.File;
Expand Down Expand Up @@ -655,7 +678,7 @@ static void bla() throws FileNotFoundException, UnsupportedEncodingException {
Formatter s=new Formatter(new File("asdf"),StandardCharsets.UTF_8);
}
}
"""),
"""),
THREE("""
package test1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,31 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.quickfix.Java8;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import java.util.Hashtable;

@RunWith(Suite.class)
@Suite.SuiteClasses({
ExplicitEncodingCleanUpTest.class,
import org.junit.jupiter.api.BeforeEach;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;

import org.eclipse.jdt.testplugin.TestOptions;

import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;

import org.eclipse.jdt.internal.ui.JavaPlugin;

@Suite
@SelectClasses({
ExplicitEncodingCleanUpTest.class
})
public class QuickFixJava8TestSuite {
@BeforeEach
protected void setUp() throws Exception {
Hashtable<String, String> defaultOptions= TestOptions.getDefaultOptions();
defaultOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, Integer.toString(120));
JavaCore.setOptions(defaultOptions);
TestOptions.initializeCodeGenerationOptions();
// Use load since restore doesn't really restore the defaults.
JavaPlugin.getDefault().getCodeTemplateStore().load();
}
}

0 comments on commit 10227b8

Please sign in to comment.