peer-at-code-backend/test/be/jeffcheasey88/peeratcode/routes/TriggerTests.java
2023-04-12 17:49:35 +02:00

54 lines
1.1 KiB
Java

package be.jeffcheasey88.peeratcode.routes;
import static org.junit.jupiter.api.Assertions.fail;
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 be.jeffcheasey88.peeratcode.Main;
import be.jeffcheasey88.peeratcode.webclient.WebClient;
@TestInstance(Lifecycle.PER_CLASS)
public class TriggerTests {
private Thread server;
private WebClient client;
private boolean ready;
@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 {
client.auth("JeffCheasey88", "TheoPueDesPieds");
client.route("/puzzleResponse/9", "POST", WebClient.buildMultiPartData("1"));
client.route("/player/", "GET");
}catch(Exception e){
e.printStackTrace();
fail(e);
}
}
}