Skip to content

Commit

Permalink
Merge pull request #538 from fwcd/java-21-ci
Browse files Browse the repository at this point in the history
Add Java 21 CI
  • Loading branch information
fwcd authored Jan 24, 2024
2 parents 9ae4ede + 8152462 commit e5d18c8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
java: [ '11', '17' ]
java: ['11', '17', '21']
steps:
- uses: actions/checkout@v4
- name: Setup JDK
Expand Down
81 changes: 42 additions & 39 deletions server/src/test/kotlin/org/javacs/kt/OverrideMemberTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.eclipse.lsp4j.TextDocumentPositionParams
import org.junit.Test
import org.hamcrest.core.Every.everyItem
import org.hamcrest.Matchers.containsInAnyOrder
import org.hamcrest.Matchers.hasItems
import org.hamcrest.Matchers.equalTo
import org.hamcrest.Matchers.hasSize
import org.junit.Assert.assertThat
Expand All @@ -17,7 +18,7 @@ class OverrideMemberTest : SingleFileTestFixture("overridemember", "OverrideMemb

val root = testResourcesRoot().resolve(workspaceRoot)
val fileUri = root.resolve(file).toUri().toString()

@Test
fun `should show all overrides for class`() {
val result = languageServer.getProtocolExtensionService().overrideMember(TextDocumentPositionParams(TextDocumentIdentifier(fileUri), position(9, 8))).get()
Expand All @@ -39,7 +40,7 @@ class OverrideMemberTest : SingleFileTestFixture("overridemember", "OverrideMemb
padding + "override fun equals(other: Any?): Boolean { }",
padding + "override fun hashCode(): Int { }",
padding + "override fun toString(): String { }"))


assertThat(ranges, everyItem(equalTo(range(9, 31, 9, 31))))
}
Expand All @@ -63,14 +64,14 @@ class OverrideMemberTest : SingleFileTestFixture("overridemember", "OverrideMemb
padding + "override fun equals(other: Any?): Boolean { }",
padding + "override fun hashCode(): Int { }",
padding + "override fun toString(): String { }"))

assertThat(ranges, everyItem(equalTo(range(12, 56, 12, 56))))
}

@Test
fun `should show NO overrides for class where all other alternatives are already implemented`() {
val result = languageServer.getProtocolExtensionService().overrideMember(TextDocumentPositionParams(TextDocumentIdentifier(fileUri), position(15, 8))).get()

assertThat(result, hasSize(0))
}

Expand All @@ -93,10 +94,10 @@ class OverrideMemberTest : SingleFileTestFixture("overridemember", "OverrideMemb
padding + "override fun equals(other: Any?): Boolean { }",
padding + "override fun hashCode(): Int { }",
padding + "override fun toString(): String { }"))

assertThat(ranges, everyItem(equalTo(range(37, 25, 37, 25))))
}

@Test
fun `should find members in jdk object`() {
val result = languageServer.getProtocolExtensionService().overrideMember(TextDocumentPositionParams(TextDocumentIdentifier(fileUri), position(39, 9))).get()
Expand All @@ -106,41 +107,43 @@ class OverrideMemberTest : SingleFileTestFixture("overridemember", "OverrideMemb
val newTexts = edits.map { it.newText }
val ranges = edits.map { it.range }

assertThat(titles, containsInAnyOrder("override fun equals(other: Any?): Boolean { }",
"override fun hashCode(): Int { }",
"override fun toString(): String { }",
"override fun run() { }",
"override fun clone(): Any { }",
"override fun start() { }",
"override fun interrupt() { }",
"override fun isInterrupted(): Boolean { }",
"override fun countStackFrames(): Int { }",
"override fun getContextClassLoader(): ClassLoader { }",
"override fun setContextClassLoader(cl: ClassLoader) { }",
"override fun getStackTrace(): (Array<(StackTraceElement..StackTraceElement?)>..Array<out (StackTraceElement..StackTraceElement?)>) { }",
"override fun getId(): Long { }",
"override fun getState(): State { }",
"override fun getUncaughtExceptionHandler(): UncaughtExceptionHandler { }",
"override fun setUncaughtExceptionHandler(eh: UncaughtExceptionHandler) { }"))
assertThat(titles, hasItems(
"override fun equals(other: Any?): Boolean { }",
"override fun hashCode(): Int { }",
"override fun toString(): String { }",
"override fun run() { }",
"override fun clone(): Any { }",
"override fun start() { }",
"override fun interrupt() { }",
"override fun isInterrupted(): Boolean { }",
"override fun countStackFrames(): Int { }",
"override fun getContextClassLoader(): ClassLoader { }",
"override fun setContextClassLoader(cl: ClassLoader) { }",
"override fun getStackTrace(): (Array<(StackTraceElement..StackTraceElement?)>..Array<out (StackTraceElement..StackTraceElement?)>) { }",
"override fun getId(): Long { }",
"override fun getState(): State { }",
"override fun getUncaughtExceptionHandler(): UncaughtExceptionHandler { }",
))

val padding = System.lineSeparator() + System.lineSeparator() + " "
assertThat(newTexts, containsInAnyOrder(padding + "override fun equals(other: Any?): Boolean { }",
padding + "override fun hashCode(): Int { }",
padding + "override fun toString(): String { }",
padding + "override fun run() { }",
padding + "override fun clone(): Any { }",
padding + "override fun start() { }",
padding + "override fun interrupt() { }",
padding + "override fun isInterrupted(): Boolean { }",
padding + "override fun countStackFrames(): Int { }",
padding + "override fun getContextClassLoader(): ClassLoader { }",
padding + "override fun setContextClassLoader(cl: ClassLoader) { }",
padding + "override fun getStackTrace(): (Array<(StackTraceElement..StackTraceElement?)>..Array<out (StackTraceElement..StackTraceElement?)>) { }",
padding + "override fun getId(): Long { }",
padding + "override fun getState(): State { }",
padding + "override fun getUncaughtExceptionHandler(): UncaughtExceptionHandler { }",
padding + "override fun setUncaughtExceptionHandler(eh: UncaughtExceptionHandler) { }"))

assertThat(newTexts, hasItems(
padding + "override fun equals(other: Any?): Boolean { }",
padding + "override fun hashCode(): Int { }",
padding + "override fun toString(): String { }",
padding + "override fun run() { }",
padding + "override fun clone(): Any { }",
padding + "override fun start() { }",
padding + "override fun interrupt() { }",
padding + "override fun isInterrupted(): Boolean { }",
padding + "override fun countStackFrames(): Int { }",
padding + "override fun getContextClassLoader(): ClassLoader { }",
padding + "override fun setContextClassLoader(cl: ClassLoader) { }",
padding + "override fun getStackTrace(): (Array<(StackTraceElement..StackTraceElement?)>..Array<out (StackTraceElement..StackTraceElement?)>) { }",
padding + "override fun getId(): Long { }",
padding + "override fun getState(): State { }",
padding + "override fun getUncaughtExceptionHandler(): UncaughtExceptionHandler { }",
))

assertThat(ranges, everyItem(equalTo(range(39, 25, 39, 25))))
}
}

0 comments on commit e5d18c8

Please sign in to comment.