|
1 | 1 | /*******************************************************************************
|
2 |
| - * Copyright (c) 2007 IBM Corporation and others. |
| 2 | + * Copyright (c) 2007, 2025 IBM Corporation and others. |
3 | 3 | *
|
4 | 4 | * This program and the accompanying materials
|
5 | 5 | * are made available under the terms of the Eclipse Public License 2.0
|
|
16 | 16 |
|
17 | 17 | import static org.junit.Assert.assertEquals;
|
18 | 18 | import static org.junit.Assert.assertNotNull;
|
| 19 | +import static org.junit.Assert.assertThrows; |
19 | 20 | import static org.junit.Assert.assertTrue;
|
20 | 21 |
|
21 | 22 | import java.math.BigDecimal;
|
22 | 23 | import java.math.BigInteger;
|
23 | 24 | import java.util.Date;
|
| 25 | +import java.util.HashSet; |
| 26 | +import java.util.List; |
| 27 | +import java.util.Set; |
24 | 28 |
|
25 | 29 | import org.eclipse.core.databinding.UpdateValueStrategy;
|
26 | 30 | import org.eclipse.core.databinding.conversion.IConverter;
|
@@ -354,4 +358,16 @@ public UpdateValueStrategy<S, D> setConverter(IConverter<? super S, ? extends D>
|
354 | 358 | return super.setConverter(converter);
|
355 | 359 | }
|
356 | 360 | }
|
| 361 | + |
| 362 | + @Test |
| 363 | + public void testDefaultConverterWithTypeErasure() { |
| 364 | + WritableValue<Set<?>> source = WritableValue.withValueType(Set.class); |
| 365 | + WritableValue<List<?>> destination = WritableValue.withValueType(List.class); |
| 366 | + |
| 367 | + UpdateStrategyStub<Set<?>, List<?>> strategy = new UpdateStrategyStub<>(); |
| 368 | + strategy.fillDefaults(source, destination); |
| 369 | + |
| 370 | + RuntimeException ex = assertThrows(RuntimeException.class, () -> strategy.convert(new HashSet<>())); |
| 371 | + assertTrue("Type erasure was missed", ex.getCause() instanceof ClassCastException); |
| 372 | + } |
357 | 373 | }
|
0 commit comments