/** @tests java.lang.NoSuchMethodException#NoSuchMethodException(java.lang.String) */ @TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "NoSuchMethodException", args = {java.lang.String.class}) public void test_ConstructorLjava_lang_String() { NoSuchMethodException e = new NoSuchMethodException("fixture"); assertEquals("fixture", e.getMessage()); assertNull(e.getCause()); }
/** @tests java.lang.NoSuchMethodException#NoSuchMethodException() */ @TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "NoSuchMethodException", args = {}) public void test_Constructor() { NoSuchMethodException e = new NoSuchMethodException(); assertNull(e.getMessage()); assertNull(e.getLocalizedMessage()); assertNull(e.getCause()); }
public static Object deserialize(Class<?> clazz, String data) { try { Method deserialize = clazz.getDeclaredMethod("deserialize", String.class); deserialize.setAccessible(true); return deserialize.invoke(null, data); } catch (NoSuchMethodException e) { throw new SerializeException("Could not deserialize data", e.getCause()); } catch (InvocationTargetException e) { throw new SerializeException("Could not deserialize data", e.getCause()); } catch (IllegalAccessException e) { throw new SerializeException("Could not deserialize data", e.getCause()); } }
public static String serialize(Class<?> clazz, Object object) { try { Method serialize = clazz.getDeclaredMethod("serialize"); serialize.setAccessible(true); return (String) serialize.invoke(object); } catch (NoSuchMethodException e) { throw new SerializeException( "Could not serialize Class '" + clazz.getCanonicalName() + "'", e.getCause()); } catch (InvocationTargetException e) { throw new SerializeException( "Could not serialize Class '" + clazz.getCanonicalName() + "'", e.getCause()); } catch (IllegalAccessException e) { throw new SerializeException( "Could not serialize Class '" + clazz.getCanonicalName() + "'", e.getCause()); } catch (ClassCastException e) { throw new SerializeException( "Could not serialize Class '" + clazz.getCanonicalName() + "'", e.getCause()); } }
public Object newInstance(Class<?> clazz) { try { Constructor<?> ctr = clazz.getConstructor(argClasses); return ctr.newInstance(args); } catch (NoSuchMethodException e) { throw new InjectorException( "Could not create a new instance of class '" + clazz.getCanonicalName() + "'", e.getCause()); } catch (InvocationTargetException e) { throw new InjectorException( "Could not create a new instance of class '" + clazz.getCanonicalName() + "'", e.getCause()); } catch (InstantiationException e) { throw new InjectorException( "Could not create a new instance of class '" + clazz.getCanonicalName() + "'", e.getCause()); } catch (IllegalAccessException e) { throw new InjectorException( "Could not create a new instance of class '" + clazz.getCanonicalName() + "'", e.getCause()); } }