Skip to content

Commit

Permalink
Merge pull request quarkusio#17097 from famod/xstream-tests-java16
Browse files Browse the repository at this point in the history
Work around xstream issues in main ITs on Java 16
  • Loading branch information
famod authored May 9, 2021
2 parents 4fc86c2 + 1f3bddc commit b9d219c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

import static org.hamcrest.MatcherAssert.assertThat;

import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import javax.inject.Inject;

import org.hamcrest.CoreMatchers;
import org.hamcrest.Matcher;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
Expand All @@ -26,19 +25,21 @@ public class MethodSourceTest {

@ParameterizedTest
@MethodSource("provideDummyInput")
@Tag("failsOnJDK16")
public void testParameterResolver(UnusedBean.DummyInput dummyInput, Matcher<String> matcher) {
UnusedBean.DummyResult dummyResult = unusedBean.dummy(dummyInput);
assertThat(dummyResult.getResult(), matcher);
}

private static Collection<Arguments> provideDummyInput() {
return Arrays.asList(
return List.of(
Arguments.of(
new UnusedBean.DummyInput("whatever", new UnusedBean.NestedDummyInput(Arrays.asList(1, 2, 3))),
// note: List.of(...) or Arrays.asList() fails on Java 16 due to: https://github.com/x-stream/xstream/issues/253
new UnusedBean.DummyInput("whatever",
new UnusedBean.NestedDummyInput(new ArrayList<>(List.of(1, 2, 3)))),
CoreMatchers.is("whatever/6")),
Arguments.of(
new UnusedBean.DummyInput("hi", new UnusedBean.NestedDummyInput(Collections.emptyList())),
// note: Collections.emptyList() fails on Java 16 due to: https://github.com/x-stream/xstream/issues/253
new UnusedBean.DummyInput("hi", new UnusedBean.NestedDummyInput(new ArrayList<>())),
CoreMatchers.is("hi/0")));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;

import javax.inject.Inject;

import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.ExtensionContext;
Expand All @@ -30,7 +28,6 @@ public class ParameterResolverTest {
@Test
@ExtendWith(ParameterResolverTest.UnusedBeanDummyInputResolver.class)
@ExtendWith(ParameterResolverTest.SupplierParameterResolver.class)
@Tag("failsOnJDK16")
public void testParameterResolver(UnusedBean.DummyInput dummyInput, Supplier<UnusedBean.DummyInput> supplier) {
UnusedBean.DummyResult dummyResult = unusedBean.dummy(dummyInput);
assertEquals("whatever/6", dummyResult.getResult());
Expand All @@ -48,7 +45,6 @@ public void testSerializableParameterResolver(SomeSerializable someSerializable)

@Test
@ExtendWith(ParameterResolverTest.ListWithNonSerializableParameterResolver.class)
@Tag("failsOnJDK16")
public void testSerializableParameterResolverFallbackToXStream(List<NonSerializable> list) {
assertEquals("foo", list.get(0).value);
assertEquals("bar", list.get(1).value);
Expand All @@ -65,7 +61,8 @@ public boolean supportsParameter(ParameterContext parameterContext, ExtensionCon
@Override
public Object resolveParameter(ParameterContext parameterContext,
ExtensionContext extensionContext) throws ParameterResolutionException {
return new UnusedBean.DummyInput("whatever", new UnusedBean.NestedDummyInput(Arrays.asList(1, 2, 3)));
// note: List.of(...) or Arrays.asList() fails on Java 16 due to: https://github.com/x-stream/xstream/issues/253
return new UnusedBean.DummyInput("whatever", new UnusedBean.NestedDummyInput(new ArrayList<>(List.of(1, 2, 3))));
}
}

Expand All @@ -81,7 +78,8 @@ public boolean supportsParameter(ParameterContext parameterContext, ExtensionCon
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
throws ParameterResolutionException {
return (Supplier<UnusedBean.DummyInput>) () -> new UnusedBean.DummyInput("fromSupplier",
new UnusedBean.NestedDummyInput(Collections.emptyList()));
// note: Collections.emptyList() fails on Java 16 due to: https://github.com/x-stream/xstream/issues/253
new UnusedBean.NestedDummyInput(new ArrayList<>()));
}
}

Expand Down Expand Up @@ -111,7 +109,8 @@ public boolean supportsParameter(ParameterContext parameterContext, ExtensionCon
@Override
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
throws ParameterResolutionException {
return Arrays.asList(new NonSerializable("foo"), new NonSerializable("bar"));
// note: List.of(...) or Arrays.asList() fails on Java 16 due to: https://github.com/x-stream/xstream/issues/253
return new ArrayList<>(List.of(new NonSerializable("foo"), new NonSerializable("bar")));
}
}

Expand Down

0 comments on commit b9d219c

Please sign in to comment.