'Java testing initializationError : java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
My project is composed like this
Project: https://i.stack.imgur.com/Ttx3W.png
when i try to run the tests the error
java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at java.lang.Class.createAnnotationData(Class.java:3521)
at java.lang.Class.annotationData(Class.java:3510)
at java.lang.Class.getAnnotation(Class.java:3415)
presents itself.
I have downloaded the right libraries for junit-4 and i believe it has something to do with how the project is built because when i tried to do a test on another simpler project it worked. Maybe I have made a mistake in how I divided my space for my project or maybe I forgot some options on my settings.json file which I'll link down here settings.json
I'll also link my test project which could help identify the problem but it's very messy and unorganized so thanks to anyone that takes the time to help me
package test;
public class DemoApplicationTest {
public static DemoApplication.Logs Log;
private static final String Server = "dw.gnet.it", user = "unimore22", pass = "weblog";
private static final int port = 21;
/*
Test del metodo pulizia che controlla se vengono rimpiazzate tutte le istanze
previste dal codice quali | [ | ] | ( | ) | \ | ; | , | + |
*/
@Test
public void Testpulizia() {
String valore = "A[B]C(D)E\"F;G,H+I";
valore = valore.replace("[", "");
valore = valore.replace("]", "");
valore = valore.replace("(", "");
valore = valore.replace(")", "");
valore = valore.replace("\"", "");
valore = valore.replace(";", "");
valore = valore.replace(",", "");
valore = valore.replace("+", "");
valore = valore.toLowerCase();
assertEquals("ProvoLaStringa","ABCDEFGHI", valore.toString().toUpperCase());
}
/*
Test che controlla se il modulo LetturaFile riesce a leggere
un file di testo demo
*/
@Test
public void TestLetturaFile() throws FileNotFoundException {
Scanner sc = new Scanner(new File("/output.txt"));
String NomeFile = "/output.txt";
JSONArray ja = DemoApplication.LetturaFile(sc, NomeFile);
assertEquals("NomeFileRighe:output.txt"+"-", ja);
}
/*
Test del modulo di FTPDownload dove si controlla se viene ritornato
true se si riesce a recuperare il file e a scriverlo sull' outputstream
*/
@Test
public void TestFTPDownload() throws SocketException, IOException {
String File = new String();
OutputStream os = new FileOutputStream("output.txt");
FTPClient ftp = DemoApplication.ConnectionFTP(Server, user, pass, port);
boolean successo = false;
try{
successo = ftp.retrieveFile(File, os);
os.close();
}
catch(Exception e)
{
fail("Unexpected exeption was thrown");
}
assertEquals(true , successo);
}
/*
Test che controlla se il modulo ConnectionFTP riesce a connettersi a un
qualsiasi server ritornado true.
*/
@Test
public void TestConnectionFTP() {
String server ="test.rebex.net";
String user = "demo";
String pass = "password";
int port = 21;
FTPClient ftp = DemoApplication.ConnectionFTP(server, user, pass, port);
assertEquals(true, ftp);
}
/*
Test che controlla se il modulo procedura funziona controllando
se il return di procedura ritorna true
*/
@Test
public void TestProcedura() throws FileNotFoundException {
FTPClient ftp = DemoApplication.ConnectionFTP(Server, user, pass, port);
boolean scaricato = DemoApplication.Procedura(ftp);
assertEquals(true, scaricato);
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
