コード例 #1
0
  @Test
  public void testDistroListFailure() throws Exception {
    CookieCache.put("Cookie", "JSESSIONID=2AAF431F59ACEE1CC68B43C87772C54F");
    BddErrorMessage errorMsg = new BddErrorMessage();
    errorMsg.setMessage("not found");
    ObjectMapper mapper = new ObjectMapper();
    buildReqRespWithoutReqBody(
        "http://127.0.0.1:8080/serengeti/api/distros",
        HttpMethod.GET,
        HttpStatus.NOT_FOUND,
        mapper.writeValueAsString(errorMsg));

    // get all distros
    distroCommands.getDistro(null, false);
    CookieCache.put("Cookie", "");
  }
コード例 #2
0
  @Test
  public void testDistroList() throws Exception {
    CookieCache.put("Cookie", "JSESSIONID=2AAF431F59ACEE1CC68B43C87772C54F");
    DistroRead[] distros = new DistroRead[2];
    DistroRead distro1 = new DistroRead();
    distro1.setName("Apache");
    List<String> roles1 = new ArrayList<String>();
    roles1.add("NameNode");
    roles1.add("JobTracker");
    roles1.add("DataNode");
    roles1.add("HadoopClient");
    distro1.setRoles(roles1);

    DistroRead distro2 = new DistroRead();
    distro2.setName("GP");
    List<String> roles2 = new ArrayList<String>();
    roles2.add("NameNode");
    roles2.add("JobTracker");
    roles2.add("DataNode");
    roles2.add("HadoopClient");
    roles2.add("PIG");
    roles2.add("HIVE");

    distro2.setRoles(roles2);

    distros[0] = distro1;
    distros[1] = distro2;

    ObjectMapper mapper = new ObjectMapper();

    buildReqRespWithoutReqBody(
        "http://127.0.0.1:8080/serengeti/api/distros",
        HttpMethod.GET,
        HttpStatus.OK,
        mapper.writeValueAsString(distros));

    // get all distros
    distroCommands.getDistro(null, false);
    CookieCache.put("Cookie", "");
  }
コード例 #3
0
  @Test(dataProvider = "RestClientTest.LoginDP")
  public void testLogin(LoginResponse loginResponse, Connect.ConnectType expectedConnectType)
      throws IOException {
    Mockito.when(
            loginClient.login(Matchers.anyString(), Matchers.anyString(), Matchers.anyString()))
        .thenReturn(loginResponse);
    Connect.ConnectType connectType = restClient.connect("127.0.0.1:8443", "root", "vmware");

    Assert.assertEquals(connectType, expectedConnectType);

    if (loginResponse.getSessionId() != null) {
      Assert.assertEquals(loginResponse.getSessionId(), CookieCache.get(CookieCache.COOKIE));
    }
  }
コード例 #4
0
 @AfterMethod
 public void tearDown() {
   new File("cli.properties").delete();
   CookieCache.clear();
 }