removed custom converter for m3 to add back in rc1; also ensure type descriptor get type always returns wrapper types if primitive
This commit is contained in:
@@ -20,7 +20,6 @@ import static junit.framework.Assert.assertNull;
|
||||
import static junit.framework.Assert.assertSame;
|
||||
import static junit.framework.Assert.fail;
|
||||
|
||||
import java.security.Principal;
|
||||
import java.util.AbstractList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -31,7 +30,6 @@ import java.util.Map;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.core.convert.ConversionException;
|
||||
import org.springframework.core.convert.ConversionExecutionException;
|
||||
import org.springframework.core.convert.ConversionExecutor;
|
||||
import org.springframework.core.convert.ConversionExecutorNotFoundException;
|
||||
@@ -348,273 +346,7 @@ public class GenericConversionServiceTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void customConverterConvertForwardIndex() {
|
||||
service.addConverter("princy", new CustomTwoWayConverter());
|
||||
ConversionExecutor executor = service.getConversionExecutor("princy", String.class, type(Principal.class));
|
||||
assertEquals("keith", ((Principal) executor.execute("keith")).getName());
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void customConverterConvertReverseIndex() {
|
||||
service.addConverter("princy", new CustomTwoWayConverter());
|
||||
ConversionExecutor executor = service.getConversionExecutor("princy", Principal.class, type(String.class));
|
||||
assertEquals("keith", executor.execute(new Principal() {
|
||||
public String getName() {
|
||||
return "keith";
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void customConverterConvertForSameType() {
|
||||
service.addConverter("trimmer", new Trimmer());
|
||||
ConversionExecutor executor = service.getConversionExecutor("trimmer", String.class, type(String.class));
|
||||
assertEquals("a string", executor.execute("a string "));
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void customConverterLookupNotCompatibleSource() {
|
||||
service.addConverter("trimmer", new Trimmer());
|
||||
try {
|
||||
service.getConversionExecutor("trimmer", Object.class, type(String.class));
|
||||
fail("Should have failed");
|
||||
} catch (ConversionException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void customConverterLookupNotCompatibleTarget() {
|
||||
service.addConverter("trimmer", new Trimmer());
|
||||
try {
|
||||
service.getConversionExecutor("trimmer", String.class, type(Object.class));
|
||||
} catch (ConversionException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void customConverterLookupNotCompatibleTargetReverse() {
|
||||
service.addConverter("princy", new CustomTwoWayConverter());
|
||||
try {
|
||||
service.getConversionExecutor("princy", Principal.class, type(Integer.class));
|
||||
} catch (ConversionException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void customConverterConvertArrayToArray() {
|
||||
service.addConverter("princy", new CustomTwoWayConverter());
|
||||
ConversionExecutor executor = service.getConversionExecutor("princy", String[].class, type(Principal[].class));
|
||||
Principal[] p = (Principal[]) executor.execute(new String[] { "princy1", "princy2" });
|
||||
assertEquals("princy1", p[0].getName());
|
||||
assertEquals("princy2", p[1].getName());
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void customConverterConvertArrayToArrayReverse() {
|
||||
service.addConverter("princy", new CustomTwoWayConverter());
|
||||
ConversionExecutor executor = service.getConversionExecutor("princy", Principal[].class, type(String[].class));
|
||||
final Principal princy1 = new Principal() {
|
||||
public String getName() {
|
||||
return "princy1";
|
||||
}
|
||||
};
|
||||
final Principal princy2 = new Principal() {
|
||||
public String getName() {
|
||||
return "princy2";
|
||||
}
|
||||
};
|
||||
String[] p = (String[]) executor.execute(new Principal[] { princy1, princy2 });
|
||||
assertEquals("princy1", p[0]);
|
||||
assertEquals("princy2", p[1]);
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void customConverterLookupArrayToArrayBogusSource() {
|
||||
service.addConverter("princy", new CustomTwoWayConverter());
|
||||
try {
|
||||
service.getConversionExecutor("princy", Integer[].class, type(Principal[].class));
|
||||
fail("Should have failed");
|
||||
} catch (ConversionExecutorNotFoundException e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void customConverterLookupArrayToArrayBogusTarget() {
|
||||
service.addConverter("princy", new CustomTwoWayConverter());
|
||||
try {
|
||||
service.getConversionExecutor("princy", Principal[].class, type(Integer[].class));
|
||||
} catch (ConversionExecutorNotFoundException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void customConverterConvertArrayToCollection() {
|
||||
service.addConverter("princy", new CustomTwoWayConverter());
|
||||
ConversionExecutor executor = service.getConversionExecutor("princy", String[].class, type(List.class));
|
||||
List list = (List) executor.execute(new String[] { "princy1", "princy2" });
|
||||
assertEquals("princy1", ((Principal) list.get(0)).getName());
|
||||
assertEquals("princy2", ((Principal) list.get(1)).getName());
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void customConverterConvertArrayToCollectionReverse() {
|
||||
service.addConverter("princy", new CustomTwoWayConverter());
|
||||
ConversionExecutor executor = service.getConversionExecutor("princy", Principal[].class, type(List.class));
|
||||
final Principal princy1 = new Principal() {
|
||||
public String getName() {
|
||||
return "princy1";
|
||||
}
|
||||
};
|
||||
final Principal princy2 = new Principal() {
|
||||
public String getName() {
|
||||
return "princy2";
|
||||
}
|
||||
};
|
||||
List p = (List) executor.execute(new Principal[] { princy1, princy2 });
|
||||
assertEquals("princy1", p.get(0));
|
||||
assertEquals("princy2", p.get(1));
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void customConverterLookupArrayToCollectionBogusSource() {
|
||||
service.addConverter("princy", new CustomTwoWayConverter());
|
||||
try {
|
||||
service.getConversionExecutor("princy", Integer[].class, type(List.class));
|
||||
fail("Should have failed");
|
||||
} catch (ConversionExecutorNotFoundException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void customConverterLookupCollectionToArray() {
|
||||
service.addConverter("princy", new CustomTwoWayConverter());
|
||||
ConversionExecutor executor = service.getConversionExecutor("princy", List.class, type(Principal[].class));
|
||||
List princyList = new ArrayList();
|
||||
princyList.add("princy1");
|
||||
princyList.add("princy2");
|
||||
Principal[] p = (Principal[]) executor.execute(princyList);
|
||||
assertEquals("princy1", p[0].getName());
|
||||
assertEquals("princy2", p[1].getName());
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void customConverterLookupCollectionToArrayReverse() {
|
||||
service.addConverter("princy", new CustomTwoWayConverter());
|
||||
ConversionExecutor executor = service.getConversionExecutor("princy", List.class, type(String[].class));
|
||||
final Principal princy1 = new Principal() {
|
||||
public String getName() {
|
||||
return "princy1";
|
||||
}
|
||||
};
|
||||
final Principal princy2 = new Principal() {
|
||||
public String getName() {
|
||||
return "princy2";
|
||||
}
|
||||
};
|
||||
List princyList = new ArrayList();
|
||||
princyList.add(princy1);
|
||||
princyList.add(princy2);
|
||||
String[] p = (String[]) executor.execute(princyList);
|
||||
assertEquals("princy1", p[0]);
|
||||
assertEquals("princy2", p[1]);
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void customConverterLookupCollectionToArrayBogusTarget() {
|
||||
service.addConverter("princy", new CustomTwoWayConverter());
|
||||
try {
|
||||
service.getConversionExecutor("princy", List.class, type(Integer[].class));
|
||||
fail("Should have failed");
|
||||
} catch (ConversionExecutorNotFoundException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void customConverterConvertObjectToArray() {
|
||||
service.addConverter("princy", new CustomTwoWayConverter());
|
||||
ConversionExecutor executor = service.getConversionExecutor("princy", String.class, type(Principal[].class));
|
||||
Principal[] p = (Principal[]) executor.execute("princy1");
|
||||
assertEquals("princy1", p[0].getName());
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void customConverterConvertObjectToArrayReverse() {
|
||||
service.addConverter("princy", new CustomTwoWayConverter());
|
||||
ConversionExecutor executor = service.getConversionExecutor("princy", Principal.class, type(String[].class));
|
||||
final Principal princy1 = new Principal() {
|
||||
public String getName() {
|
||||
return "princy1";
|
||||
}
|
||||
};
|
||||
String[] p = (String[]) executor.execute(princy1);
|
||||
assertEquals("princy1", p[0]);
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void customConverterLookupObjectToArrayBogusSource() {
|
||||
service.addConverter("princy", new CustomTwoWayConverter());
|
||||
try {
|
||||
service.getConversionExecutor("princy", Integer.class, type(Principal[].class));
|
||||
fail("Should have failed");
|
||||
} catch (ConversionExecutorNotFoundException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static class CustomTwoWayConverter implements Converter<String, Principal> {
|
||||
|
||||
public Principal convert(final String source) throws Exception {
|
||||
return new Principal() {
|
||||
public String getName() {
|
||||
return (String) source;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public String convertBack(Principal target) throws Exception {
|
||||
return ((Principal) target).getName();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class Trimmer implements Converter<String, String> {
|
||||
|
||||
public String convert(String source) throws Exception {
|
||||
return ((String) source).trim();
|
||||
}
|
||||
|
||||
public String convertBack(String target) throws Exception {
|
||||
throw new UnsupportedOperationException("Will never run");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void testSuperTwoWayConverterConverterAdaption() {
|
||||
service.addConverter(GenericConversionService.converterFor(String.class, FooEnum.class, new StringToEnum()));
|
||||
assertEquals(FooEnum.BAR, service.executeConversion("BAR", type(FooEnum.class)));
|
||||
|
||||
Reference in New Issue
Block a user