@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2013 the original author or authors .
* Copyright 2002 - 2016 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -46,7 +46,7 @@ public class SerializableTypeWrapperTests {
@@ -46,7 +46,7 @@ public class SerializableTypeWrapperTests {
public void forField ( ) throws Exception {
Type type = SerializableTypeWrapper . forField ( Fields . class . getField ( "parameterizedType" ) ) ;
assertThat ( type . toString ( ) , equalTo ( "java.util.List<java.lang.String>" ) ) ;
assertSerialzable ( type ) ;
assertSeriali zable ( type ) ;
}
@Test
@ -54,7 +54,7 @@ public class SerializableTypeWrapperTests {
@@ -54,7 +54,7 @@ public class SerializableTypeWrapperTests {
Method method = Methods . class . getDeclaredMethod ( "method" , Class . class , Object . class ) ;
Type type = SerializableTypeWrapper . forMethodParameter ( MethodParameter . forMethodOrConstructor ( method , 0 ) ) ;
assertThat ( type . toString ( ) , equalTo ( "java.lang.Class<T>" ) ) ;
assertSerialzable ( type ) ;
assertSeriali zable ( type ) ;
}
@Test
@ -62,62 +62,62 @@ public class SerializableTypeWrapperTests {
@@ -62,62 +62,62 @@ public class SerializableTypeWrapperTests {
Constructor < ? > constructor = Constructors . class . getDeclaredConstructor ( List . class ) ;
Type type = SerializableTypeWrapper . forMethodParameter ( MethodParameter . forMethodOrConstructor ( constructor , 0 ) ) ;
assertThat ( type . toString ( ) , equalTo ( "java.util.List<java.lang.String>" ) ) ;
assertSerialzable ( type ) ;
assertSeriali zable ( type ) ;
}
@Test
public void forGenericSuperClass ( ) throws Exception {
Type type = SerializableTypeWrapper . forGenericSuperclass ( ArrayList . class ) ;
assertThat ( type . toString ( ) , equalTo ( "java.util.AbstractList<E>" ) ) ;
assertSerialzable ( type ) ;
assertSeriali zable ( type ) ;
}
@Test
public void forGenericInterfaces ( ) throws Exception {
Type type = SerializableTypeWrapper . forGenericInterfaces ( List . class ) [ 0 ] ;
assertThat ( type . toString ( ) , equalTo ( "java.util.Collection<E>" ) ) ;
assertSerialzable ( type ) ;
assertSeriali zable ( type ) ;
}
@Test
public void forTypeParamters ( ) throws Exception {
Type type = SerializableTypeWrapper . forTypeParameters ( List . class ) [ 0 ] ;
assertThat ( type . toString ( ) , equalTo ( "E" ) ) ;
assertSerialzable ( type ) ;
assertSeriali zable ( type ) ;
}
@Test
public void classType ( ) throws Exception {
Type type = SerializableTypeWrapper . forField ( Fields . class . getField ( "classType" ) ) ;
assertThat ( type . toString ( ) , equalTo ( "class java.lang.String" ) ) ;
assertSerialzable ( type ) ;
assertSeriali zable ( type ) ;
}
@Test
public void genericArrayType ( ) throws Exception {
GenericArrayType type = ( GenericArrayType ) SerializableTypeWrapper . forField ( Fields . class . getField ( "genericArrayType" ) ) ;
assertThat ( type . toString ( ) , equalTo ( "java.util.List<java.lang.String>[]" ) ) ;
assertSerialzable ( type ) ;
assertSerialzable ( type . getGenericComponentType ( ) ) ;
assertSeriali zable ( type ) ;
assertSeriali zable ( type . getGenericComponentType ( ) ) ;
}
@Test
public void parameterizedType ( ) throws Exception {
ParameterizedType type = ( ParameterizedType ) SerializableTypeWrapper . forField ( Fields . class . getField ( "parameterizedType" ) ) ;
assertThat ( type . toString ( ) , equalTo ( "java.util.List<java.lang.String>" ) ) ;
assertSerialzable ( type ) ;
assertSerialzable ( type . getOwnerType ( ) ) ;
assertSerialzable ( type . getRawType ( ) ) ;
assertSerialzable ( type . getActualTypeArguments ( ) ) ;
assertSerialzable ( type . getActualTypeArguments ( ) [ 0 ] ) ;
assertSeriali zable ( type ) ;
assertSeriali zable ( type . getOwnerType ( ) ) ;
assertSeriali zable ( type . getRawType ( ) ) ;
assertSeriali zable ( type . getActualTypeArguments ( ) ) ;
assertSeriali zable ( type . getActualTypeArguments ( ) [ 0 ] ) ;
}
@Test
public void typeVariableType ( ) throws Exception {
TypeVariable < ? > type = ( TypeVariable < ? > ) SerializableTypeWrapper . forField ( Fields . class . getField ( "typeVariableType" ) ) ;
assertThat ( type . toString ( ) , equalTo ( "T" ) ) ;
assertSerialzable ( type ) ;
assertSerialzable ( type . getBounds ( ) ) ;
assertSeriali zable ( type ) ;
assertSeriali zable ( type . getBounds ( ) ) ;
}
@Test
@ -125,13 +125,13 @@ public class SerializableTypeWrapperTests {
@@ -125,13 +125,13 @@ public class SerializableTypeWrapperTests {
ParameterizedType typeSource = ( ParameterizedType ) SerializableTypeWrapper . forField ( Fields . class . getField ( "wildcardType" ) ) ;
WildcardType type = ( WildcardType ) typeSource . getActualTypeArguments ( ) [ 0 ] ;
assertThat ( type . toString ( ) , equalTo ( "? extends java.lang.CharSequence" ) ) ;
assertSerialzable ( type ) ;
assertSerialzable ( type . getLowerBounds ( ) ) ;
assertSerialzable ( type . getUpperBounds ( ) ) ;
assertSeriali zable ( type ) ;
assertSeriali zable ( type . getLowerBounds ( ) ) ;
assertSeriali zable ( type . getUpperBounds ( ) ) ;
}
private void assertSerialzable ( Object source ) throws Exception {
private void assertSeriali zable ( Object source ) throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ;
ObjectOutputStream oos = new ObjectOutputStream ( bos ) ;
oos . writeObject ( source ) ;
@ -152,19 +152,19 @@ public class SerializableTypeWrapperTests {
@@ -152,19 +152,19 @@ public class SerializableTypeWrapperTests {
public T typeVariableType ;
public List < ? extends CharSequence > wildcardType ;
}
static interface Methods {
< T > List < T > method ( Class < T > p1 , T p2 ) ;
interface Methods {
< T > List < T > method ( Class < T > p1 , T p2 ) ;
}
static class Constructors {
public Constructors ( List < String > p ) {
}
}
}