Skip to content

Commit ae5dd54

Browse files
committed
Add @⁠Disabled tests for primitive varargs array to Object[] conversion
1 parent e088892 commit ae5dd54

File tree

3 files changed

+58
-2
lines changed

3 files changed

+58
-2
lines changed

spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java

+34-2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import java.util.regex.Pattern;
4444
import java.util.stream.Stream;
4545

46+
import org.junit.jupiter.api.Disabled;
4647
import org.junit.jupiter.api.Test;
4748

4849
import org.springframework.core.MethodParameter;
@@ -603,6 +604,12 @@ void convertStringArrayToIntArray() {
603604
assertThat(result).containsExactly(1, 2, 3);
604605
}
605606

607+
@Test
608+
void convertIntArrayToStringArray() {
609+
String[] result = conversionService.convert(new int[] {1, 2, 3}, String[].class);
610+
assertThat(result).containsExactly("1", "2", "3");
611+
}
612+
606613
@Test
607614
void convertIntegerArrayToIntegerArray() {
608615
Integer[] result = conversionService.convert(new Integer[] {1, 2, 3}, Integer[].class);
@@ -615,6 +622,12 @@ void convertIntegerArrayToIntArray() {
615622
assertThat(result).containsExactly(1, 2, 3);
616623
}
617624

625+
@Test
626+
void convertIntArrayToIntegerArray() {
627+
Integer[] result = conversionService.convert(new int[] {1, 2}, Integer[].class);
628+
assertThat(result).containsExactly(1, 2);
629+
}
630+
618631
@Test
619632
void convertObjectArrayToIntegerArray() {
620633
Integer[] result = conversionService.convert(new Object[] {1, 2, 3}, Integer[].class);
@@ -627,15 +640,34 @@ void convertObjectArrayToIntArray() {
627640
assertThat(result).containsExactly(1, 2, 3);
628641
}
629642

643+
@Disabled("Primitive array to Object[] conversion is not currently supported")
644+
@Test
645+
void convertIntArrayToObjectArray() {
646+
Object[] result = conversionService.convert(new int[] {1, 2}, Object[].class);
647+
assertThat(result).containsExactly(1, 2);
648+
}
649+
650+
@Test
651+
void convertIntArrayToFloatArray() {
652+
Float[] result = conversionService.convert(new int[] {1, 2}, Float[].class);
653+
assertThat(result).containsExactly(1.0F, 2.0F);
654+
}
655+
656+
@Test
657+
void convertIntArrayToPrimitiveFloatArray() {
658+
float[] result = conversionService.convert(new int[] {1, 2}, float[].class);
659+
assertThat(result).containsExactly(1.0F, 2.0F);
660+
}
661+
630662
@Test
631-
void convertByteArrayToWrapperArray() {
663+
void convertPrimitiveByteArrayToByteWrapperArray() {
632664
byte[] byteArray = {1, 2, 3};
633665
Byte[] converted = conversionService.convert(byteArray, Byte[].class);
634666
assertThat(converted).isEqualTo(new Byte[]{1, 2, 3});
635667
}
636668

637669
@Test
638-
void convertArrayToArrayAssignable() {
670+
void convertIntArrayToIntArray() {
639671
int[] result = conversionService.convert(new int[] {1, 2, 3}, int[].class);
640672
assertThat(result).containsExactly(1, 2, 3);
641673
}

spring-expression/src/test/java/org/springframework/expression/spel/MethodInvocationTests.java

+8
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.ArrayList;
2424
import java.util.List;
2525

26+
import org.junit.jupiter.api.Disabled;
2627
import org.junit.jupiter.api.Test;
2728

2829
import org.springframework.expression.Expression;
@@ -356,6 +357,13 @@ void testVarargsWithPrimitiveArrayType() {
356357
evaluate("formatPrimitiveVarargs('x -> %s %s', '2', 3.0d)", "x -> 2 3", String.class);
357358
}
358359

360+
@Disabled("Primitive array to Object[] conversion is not currently supported")
361+
@Test
362+
void testVarargsWithPrimitiveArrayToObjectArrayConversion() {
363+
evaluate("formatObjectVarargs('x -> %s %s %s', new short[]{1, 2, 3})", "x -> 1 2 3", String.class); // short[] to Object[]
364+
evaluate("formatObjectVarargs('x -> %s %s %s', new int[]{1, 2, 3})", "x -> 1 2 3", String.class); // int[] to Object[]
365+
}
366+
359367
@Test
360368
void testVarargsOptionalInvocation() {
361369
// Calling 'public String optionalVarargsMethod(Optional<String>... values)'

spring-expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java

+16
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.expression.spel;
1818

19+
import org.junit.jupiter.api.Disabled;
1920
import org.junit.jupiter.api.Test;
2021

2122
import org.springframework.expression.spel.standard.SpelExpressionParser;
@@ -198,6 +199,21 @@ void functionWithPrimitiveVarargsViaMethodHandle() {
198199
evaluate("#formatPrimitiveVarargs('x -> %s %s %s', new String[]{'1', '2', '3'})", "x -> 1 2 3", String.class); // String[] to int[]
199200
}
200201

202+
@Disabled("Primitive array to Object[] conversion is not currently supported")
203+
@Test
204+
void functionFromMethodWithVarargsAndPrimitiveArrayToObjectArrayConversion() {
205+
evaluate("#varargsObjectFunction(new short[]{1, 2, 3})", "[1, 2, 3]", String.class); // short[] to Object[]
206+
evaluate("#varargsObjectFunction(new int[]{1, 2, 3})", "[1, 2, 3]", String.class); // int[] to Object[]
207+
}
208+
209+
@Disabled("Primitive array to Object[] conversion is not currently supported")
210+
@Test
211+
void functionFromMethodHandleWithVarargsAndPrimitiveArrayToObjectArrayConversion() {
212+
evaluate("#message('x -> %s %s %s', new short[]{1, 2, 3})", "x -> 1 2 3", String.class); // short[] to Object[]
213+
evaluate("#message('x -> %s %s %s', new int[]{1, 2, 3})", "x -> 1 2 3", String.class); // int[] to Object[]
214+
evaluate("#formatObjectVarargs('x -> %s %s %s', new int[]{1, 2, 3})", "x -> 1 2 3", String.class); // int[] to Object[]
215+
}
216+
201217
@Test
202218
void functionMethodMustBeStatic() throws Exception {
203219
SpelExpressionParser parser = new SpelExpressionParser();

0 commit comments

Comments
 (0)