You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.4 KiB

package de.fd.fh;
import de.fd.fh.server.ApiTestUtils;
import de.fd.fh.server.access.web.AccessController;
import de.fd.fh.server.user.web.UserController;
import de.fd.fh.shared.Utils;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.mock;
import static spark.Spark.awaitInitialization;
import static spark.Spark.stop;
class ServerAppTest
{
private static UserController userController = mock(UserController.class);
private static AccessController accessController = mock(AccessController.class);
@BeforeAll
static void before()
{
ServerApp.initController(accessController, userController);
ServerApp.main(null);
awaitInitialization();
}
@AfterAll
static void after()
{
stop();
}
@Test
void testHalloWorld()
{
String url = "/hello";
Map<String, String> headers = new HashMap<>();
headers.put(Utils.AUTHENTICATION_HEADER, "Bearer testToken");
ApiTestUtils.TestResponse<String> res = new ApiTestUtils<String>()
.request("GET", url, null, headers, String.class);
assertNotNull(res);
assertEquals(200, res.getStatus());
assertEquals("Hello World", res.getBody());
}
}