Skip to content

Commit

Permalink
Fix various tests so that they can run on JDK 17
Browse files Browse the repository at this point in the history
fix CanProxyToLocalhostTest: Proxy#toString changed slightly

fix JavaCompletionTask121FeaturesTest: add Record to test data

fix ConvertToRecordPatternTest and ConvertToNestedRecordPatternTest

 - enforce parsable source level for hint tests
 - update record patern syntax in tests

Stabilize JS Test testIssue215777 by Matthias

 - split golden files into two

NbTestCase method ordering is always using "natural" order

 - ClassLoader fields can not be accessed via reflection on JDK 12+
 - test method ordering options are not used anywhere atm
 - disable tests

Co-authored-by: Matthias Bläsing <mblaesing@doppel-helix.eu>
  • Loading branch information
mbien and matthiasblaesing committed Feb 9, 2024
1 parent c0f818c commit f2079bc
Show file tree
Hide file tree
Showing 18 changed files with 173 additions and 172 deletions.
4 changes: 4 additions & 0 deletions harness/nbjunit/src/org/netbeans/junit/MethodOrder.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ static void initialize() {
String orderS = findOrder();
if (!"natural".equals(orderS)) { // NOI18N
try {
// TODO: ClassLoader fields can not be accessed via reflection on JDK 12+
// see jdk.internal.reflect.Reflection#fieldFilterMap
// this won't work
Field classesF = ClassLoader.class.getDeclaredField("classes"); // NOI18N
classesF.setAccessible(true);
@SuppressWarnings("unchecked")
Expand All @@ -53,6 +56,7 @@ static void initialize() {
}
}
} catch (Exception x) {
System.err.println("WARNING: test method ordering disabled");
x.printStackTrace();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import junit.framework.TestResult;
import junit.framework.TestSuite;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;

/** Check the a-z behaviour.
Expand All @@ -33,6 +34,8 @@ public class OrderAZTest {
System.setProperty("NbTestCase.order", "a-z");
}

// method order isn't working, see comment in org.netbeans.junit.MethodOrder
@Ignore
@Test public void shuffleTest() throws ClassNotFoundException {
Class<?> load = Class.forName("org.netbeans.junit.OrderHid");
TestSuite ts = new TestSuite(load);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class OrderTest {
static {
System.setProperty("NbTestCase.order", "1314372086210");
}

@Test public void shuffleTest() throws ClassNotFoundException {
Class<?> load = Class.forName("org.netbeans.junit.OrderHid");
TestSuite ts = new TestSuite(load);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import junit.framework.TestResult;
import junit.framework.TestSuite;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;

/** Check the z-a behaviour.
Expand All @@ -33,6 +34,8 @@ public class OrderZATest {
System.setProperty("NbTestCase.order", "z-a");
}

// method order isn't working, see comment in org.netbeans.junit.MethodOrder
@Ignore
@Test public void shuffleTest() throws ClassNotFoundException {
Class<?> load = Class.forName("org.netbeans.junit.OrderHid");
TestSuite ts = new TestSuite(load);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ Process
ProcessBuilder
ProcessHandle
Readable
Record
ReflectiveOperationException
Runnable
Runtime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Process
ProcessBuilder
ProcessHandle
Readable
Record
ReflectiveOperationException
Runnable
Runtime
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void testSwitch2RuleSwitch() throws Exception {
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToRuleSwitch())
.applyFix()
Expand Down Expand Up @@ -91,7 +91,7 @@ public void testLastNotBreak() throws Exception {
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToRuleSwitch())
.applyFix()
Expand Down Expand Up @@ -122,7 +122,7 @@ public void testMultipleCases() throws Exception {
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToRuleSwitch())
.applyFix()
Expand Down Expand Up @@ -153,7 +153,7 @@ public void testFallThrough() throws Exception {
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.assertWarnings();
}
Expand All @@ -173,7 +173,7 @@ public void testMissingLastBreak() throws Exception {
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToRuleSwitch())
.applyFix()
Expand Down Expand Up @@ -204,7 +204,7 @@ public void testDefault() throws Exception {
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToRuleSwitch())
.applyFix()
Expand Down Expand Up @@ -244,7 +244,7 @@ public void testVariables1() throws Exception {
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToRuleSwitch())
.applyFix()
Expand Down Expand Up @@ -284,7 +284,7 @@ public void testFallThroughDefault1() throws Exception {
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.assertWarnings();
}
Expand All @@ -304,7 +304,7 @@ public void testFallThroughDefault2() throws Exception {
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.assertWarnings();
}
Expand All @@ -326,7 +326,7 @@ public void testTrailingEmptyCase() throws Exception {
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToRuleSwitch())
.applyFix()
Expand Down Expand Up @@ -362,7 +362,7 @@ public void testNeedsPreview() throws Exception {
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.assertWarnings();
}
Expand All @@ -381,7 +381,7 @@ public void testBreakInside1() throws Exception {
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.assertWarnings();
}
Expand All @@ -402,7 +402,7 @@ public void testBreakInside2() throws Exception {
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.findWarning("4:9-4:15:verifier:Convert switch to rule switch")
.applyFix()
Expand Down Expand Up @@ -437,7 +437,7 @@ public void testContinueInside1() throws Exception {
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.assertWarnings();
}
Expand All @@ -460,7 +460,7 @@ public void testContinueInside2() throws Exception {
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.findWarning("5:13-5:19:verifier:Convert switch to rule switch")
.applyFix()
Expand Down Expand Up @@ -501,7 +501,7 @@ public void testSwitch2SwitchExpression() throws Exception {
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToSwitchExpression())
.applyFix()
Expand Down Expand Up @@ -536,7 +536,7 @@ public void testSwitch2SwitchExpressionMultiCase() throws Exception {
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.findWarning("3:8-3:14:verifier:" + Bundle.ERR_ConvertSwitchToSwitchExpression())
.applyFix()
Expand Down Expand Up @@ -570,7 +570,7 @@ public void testSwitch2SwitchExpressionMultiCase2() throws Exception {
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.findWarning("3:8-3:14:verifier:" + Bundle.ERR_ConvertSwitchToSwitchExpression())
.applyFix()
Expand Down Expand Up @@ -601,7 +601,7 @@ public void testSwitch2SwitchExpressionOnlyDefault() throws Exception {
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.findWarning("3:8-3:14:verifier:" + Bundle.ERR_ConvertSwitchToSwitchExpression())
.applyFix()
Expand Down Expand Up @@ -636,7 +636,7 @@ public void testSwitch2SwitchExpressionNestedInnerSwitchExpression() throws Exce
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.findWarning("4:9-4:15:verifier:" + Bundle.ERR_ConvertSwitchToSwitchExpression())
.applyFix()
Expand Down Expand Up @@ -671,7 +671,7 @@ public void testSwitch2SwitchExpressionReturnValue() throws Exception {
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.findWarning("2:9-2:15:verifier:" + Bundle.ERR_ConvertSwitchToSwitchExpression())
.applyFix()
Expand Down Expand Up @@ -701,7 +701,7 @@ public void testSwitch2SwitchExpressionTypeCast() throws Exception {
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToSwitchExpression())
.applyFix()
Expand Down Expand Up @@ -731,7 +731,7 @@ public void testSwitch2SwitchExpressionTypeCastReturn() throws Exception {
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.findWarning("2:9-2:15:verifier:" + Bundle.ERR_ConvertSwitchToSwitchExpression())
.applyFix()
Expand Down Expand Up @@ -764,7 +764,7 @@ public void testSwitch2SwitchExpressionNestedSwitchExpression() throws Exception
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToSwitchExpression())
.applyFix()
Expand Down Expand Up @@ -806,7 +806,7 @@ public void testSwitch2SwitchExpressionNestedOuterSwitchStatement() throws Excep
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.findWarning("4:9-4:15:verifier:" + Bundle.ERR_ConvertSwitchToRuleSwitch())
.applyFix()
Expand Down Expand Up @@ -851,7 +851,7 @@ public void testSwitch2SwitchExpressionNestedInnerSwitchStatement() throws Excep
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.findWarning("6:16-6:22:verifier:" + Bundle.ERR_ConvertSwitchToSwitchExpression())
.applyFix()
Expand Down Expand Up @@ -893,7 +893,7 @@ public void testSwitchToRuleSwitchFormattingMultiple() throws Exception {
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToRuleSwitch())
.applyFix()
Expand Down Expand Up @@ -924,7 +924,7 @@ public void testSwitchToRuleSwitchFormattingSimple() throws Exception {
" }\n" +
" }\n" +
"}\n")
.sourceLevel(SourceVersion.latest().name())
.sourceLevel(SourceVersion.latest().ordinal())
.run(ConvertSwitchToRuleSwitch.class)
.findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToRuleSwitch())
.applyFix()
Expand Down Expand Up @@ -959,7 +959,7 @@ public void testSwitchToRuleSwitchBindingPattern() throws Exception {
" }\n" +
" }\n" +
"}\n")
.sourceLevel("21")
.sourceLevel(21)
.run(ConvertSwitchToRuleSwitch.class)
.findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToRuleSwitch())
.applyFix()
Expand Down Expand Up @@ -994,7 +994,7 @@ public void testSwitchToRuleSwitchGuardedPattern() throws Exception {
" }\n" +
" }\n" +
"}\n")
.sourceLevel("21")
.sourceLevel(21)
.run(ConvertSwitchToRuleSwitch.class)
.findWarning("3:9-3:15:verifier:" + Bundle.ERR_ConvertSwitchToRuleSwitch())
.applyFix()
Expand Down Expand Up @@ -1030,7 +1030,7 @@ public void testSwitchExpressionGuardedPattern() throws Exception {
+ " }\n"
+ " }\n"
+ "}")
.sourceLevel("21")
.sourceLevel(21)
.run(ConvertSwitchToRuleSwitch.class)
.findWarning("2:8-2:14:verifier:" + Bundle.ERR_ConvertSwitchToSwitchExpression())
.applyFix()
Expand Down
Loading

0 comments on commit f2079bc

Please sign in to comment.