1 package com.thoughtworks.xstream.converters.reflection; 2 3 public class PureJavaReflectionProviderTest extends AbstractReflectionProviderTest { 4 5 7 public ReflectionProvider createReflectionProvider() { 8 return new PureJavaReflectionProvider(); 9 } 10 11 public void testNotCapableOfConstructingNonPublicAndNonStaticInnerClasses() { 12 assertCannotCreate(PrivateStaticInnerClass.class); 13 assertCannotCreate(PublicNonStaticInnerClass.class); 14 assertCannotCreate(PrivateNonStaticInnerClass.class); 15 } 16 17 public void testUnfortunatelyExecutesCodeInsideConstructor() { 18 try { 19 reflectionProvider.newInstance(WithConstructorThatDoesStuff.class); 20 fail("Expected code in constructor to be executed and throw an exception"); 21 } catch (UnsupportedOperationException expectedException) { 22 } 24 } 25 26 public void testIsNotCapableOfConstructingClassesWithoutDefault() { 27 assertCannotCreate(WithoutDefaultConstructor.class); 28 } 29 30 private static class PrivateStaticInnerClass { 31 } 32 33 public class PublicNonStaticInnerClass { 34 } 35 36 private class PrivateNonStaticInnerClass { 37 } 38 39 public static class WithConstructorThatDoesStuff { 40 public WithConstructorThatDoesStuff() { 41 throw new UnsupportedOperationException ("constructor called"); 42 } 43 } 44 45 public static class WithoutDefaultConstructor { 46 public WithoutDefaultConstructor(String arg) { 47 } 48 } 49 50 } 51 52 | Popular Tags |