示例#1
0
 @Test
 public void makePutRequestSendsPut() throws IOException, TmcCoreException, URISyntaxException {
   settings.setUsername("test");
   settings.setPassword("1234");
   Map<String, String> body = new HashMap<>();
   body.put("mark_as_read", "1");
   HttpResult makePutRequest =
       urlCommunicator.makePutRequest(URI.create(serverAddress + "/putty"), Optional.of(body));
   assertEquals(200, makePutRequest.getStatusCode());
 }
示例#2
0
  @Test
  public void httpPostAddsFileToRequest() throws IOException, TmcCoreException {
    settings.setUsername("test");
    settings.setPassword("1234");
    File testFile = new File("testResources/test.zip");
    HttpResult result =
        urlCommunicator.makePostWithFile(
            new FileBody(testFile),
            URI.create(serverAddress + "/kivaurl"),
            new HashMap<String, String>());

    assertEquals("All tests passed", result.getData());
  }
示例#3
0
 @Test
 public void notFoundWithoutValidParams() throws IOException, TmcCoreException {
   HttpResult result =
       urlCommunicator.makeGetRequest(URI.create(serverAddress), "ihanvaaraheaderi:1234");
   assertEquals(403, result.getStatusCode());
 }
示例#4
0
 @Test
 public void badRequestWithoutValidUrl() throws IOException, TmcCoreException {
   HttpResult result =
       urlCommunicator.makeGetRequest(URI.create(serverAddress + "/vaaraurl"), "test:1234");
   assertEquals(400, result.getStatusCode());
 }
示例#5
0
 @Test
 public void okWithValidParams() throws IOException, TmcCoreException {
   HttpResult result = urlCommunicator.makeGetRequest(URI.create(serverAddress), "test:1234");
   assertEquals(200, result.getStatusCode());
 }
示例#6
0
 @Test(expected = IOException.class)
 public void badGetRequestIsThrown() throws IOException, TmcCoreException {
   urlCommunicator.makeGetRequest(URI.create("asasdasd"), "chang:/\\\\eiparas");
 }