59 lines
1.2 KiB
Java
59 lines
1.2 KiB
Java
package dev.peerat.backend.routes;
|
|
|
|
import static org.junit.jupiter.api.Assertions.fail;
|
|
|
|
import org.json.simple.JSONObject;
|
|
import org.junit.jupiter.api.AfterAll;
|
|
import org.junit.jupiter.api.BeforeAll;
|
|
import org.junit.jupiter.api.Test;
|
|
import org.junit.jupiter.api.TestInstance;
|
|
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
|
|
|
import dev.peerat.backend.Main;
|
|
import dev.peerat.backend.WebClient;
|
|
|
|
@TestInstance(Lifecycle.PER_CLASS)
|
|
public class TmpRoutesTests {
|
|
|
|
private Thread server;
|
|
private WebClient client;
|
|
|
|
@BeforeAll
|
|
void init(){
|
|
server = new Thread(new Runnable(){
|
|
@Override
|
|
public void run(){
|
|
try {
|
|
Main.main(null);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
};
|
|
}
|
|
});
|
|
server.start();
|
|
client = new WebClient("localhost", 80);
|
|
}
|
|
|
|
@AfterAll
|
|
void close(){
|
|
server.interrupt();
|
|
}
|
|
|
|
@Test
|
|
void testOnDeployed(){
|
|
try {
|
|
JSONObject group = new JSONObject();
|
|
group.put("name", "MyTest");
|
|
group.put("chapter", 1);
|
|
|
|
client.auth("JeffCheasey88", "TheoPueDesPieds");
|
|
client.route("/groupCreate", "POST", group.toJSONString());
|
|
|
|
client.assertResponseCode(200);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
fail(e);
|
|
}
|
|
}
|
|
|
|
}
|