dimanche 29 mai 2016

JUnit exception "Object is not an instance of declaring method"

I have the next JUnit test, but when I execute it throws "Object is not an instance of declaring method". What could it be?

@Test
    public void testCopiarByteArray() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, InstantiationException, UnsupportedEncodingException{
        String expected = "prueba";
        String mensaje = "prueba";

        DataReader datareader = new DataReader(null, null, 100, "=");

        Method copiarByteArray = datareader.getClass().getDeclaredMethod("copiarByteArray", byte[].class, int.class);
        copiarByteArray.setAccessible(true);

        byte[] copia = (byte[]) copiarByteArray.invoke(mensaje.getBytes(), mensaje.getBytes().length);

        String actual = new String(copia, "UTF-8");

        assertEquals("failure - encription not correctly encript", expected, actual);
    }

Aucun commentaire:

Enregistrer un commentaire