Пример #1
0
  /** barファイルインストール受付時に400エラーとなったイベントログが取得できること. */
  @Test
  public final void barファイルインストール受付時に400エラーとなったイベントログが取得できること() {
    try {
      // CELL作成
      CellUtils.create(UNIT_USER_CELL, AbstractCase.MASTER_TOKEN_NAME, HttpStatus.SC_CREATED);

      // Barインストール実施
      String reqCell = UNIT_USER_CELL;
      String reqPath = INSTALL_TARGET;

      TResponse res = null;
      File barFile = new File(RESOURCE_PATH + BAR_FILE_MINIMUM);
      byte[] body = BarInstallTestUtils.readBarFile(barFile);
      Map<String, String> headers = new LinkedHashMap<String, String>();
      headers.put(HttpHeaders.CONTENT_LENGTH, String.valueOf(body.length));

      res = BarInstallTestUtils.request(REQUEST_NOTYPE_FILE, reqCell, reqPath, headers, body);
      res.statusCode(HttpStatus.SC_BAD_REQUEST);

      // イベント取得
      TResponse response =
          Http.request("cell/log-get.txt")
              .with("METHOD", HttpMethod.GET)
              .with("token", AbstractCase.MASTER_TOKEN_NAME)
              .with("cellPath", UNIT_USER_CELL)
              .with("collection", CURRENT_COLLECTION)
              .with("fileName", DEFAULT_LOG)
              .with("ifNoneMatch", "*")
              .returns();
      response.debug();

      // レスポンスの解析
      List<String[]> lines = BarInstallTestUtils.getListedBody(response.getBody());
      int count = 0;
      for (String[] line : lines) {
        if (line[6].equals(WebDAVMethod.MKCOL.toString())) {
          assertEquals("400", line[8].trim());
          break;
        }
        count++;
      }
      assertTrue(count < lines.size());
    } finally {
      // CELL削除
      CellUtils.delete(AbstractCase.MASTER_TOKEN_NAME, UNIT_USER_CELL);
    }
  }
Пример #2
0
  /** barファイルインストール後イベントログを取得して正常終了すること. */
  @Test
  public final void barファイルインストール後イベントログを取得して正常終了すること() {
    try {
      // CELL作成
      CellUtils.create(UNIT_USER_CELL, AbstractCase.MASTER_TOKEN_NAME, HttpStatus.SC_CREATED);

      // Barインストール実施
      String reqCell = UNIT_USER_CELL;
      String reqPath = INSTALL_TARGET;

      TResponse res = null;
      File barFile = new File(RESOURCE_PATH + BAR_FILE_MINIMUM);
      byte[] body = BarInstallTestUtils.readBarFile(barFile);
      Map<String, String> headers = new LinkedHashMap<String, String>();
      headers.put(HttpHeaders.CONTENT_TYPE, REQ_CONTENT_TYPE);
      headers.put(HttpHeaders.CONTENT_LENGTH, String.valueOf(body.length));

      res = BarInstallTestUtils.request(REQUEST_NORM_FILE, reqCell, reqPath, headers, body);
      res.statusCode(HttpStatus.SC_ACCEPTED);
      String location = res.getHeader(HttpHeaders.LOCATION);
      String expected = UrlUtils.cellRoot(reqCell) + reqPath;
      assertEquals(expected, location);

      BarInstallTestUtils.assertBarInstallStatus(
          location, DEFAULT_SCHEMA_URL, ProgressInfo.STATUS.COMPLETED);

      // イベント取得
      TResponse response =
          Http.request("cell/log-get.txt")
              .with("METHOD", HttpMethod.GET)
              .with("token", AbstractCase.MASTER_TOKEN_NAME)
              .with("cellPath", UNIT_USER_CELL)
              .with("collection", CURRENT_COLLECTION)
              .with("fileName", DEFAULT_LOG)
              .with("ifNoneMatch", "*")
              .returns();
      response.debug();

      // レスポンスの解析
      List<String[]> lines = BarInstallTestUtils.getListedBody(response.getBody());
      int count = 0;
      for (String[] line : lines) {
        if (line[6].equals(WebDAVMethod.MKCOL.toString())) {
          assertEquals("202", line[8].trim());
          break;
        }
        count++;
      }
      assertTrue(count < lines.size());
      lines.remove(count);

      int index = 0;
      checkResponseLog(
          lines,
          "[INFO ]",
          "server",
          "PL-BI-1000",
          UrlUtils.getBaseUrl() + "/UnitUserCell/installBox",
          "Bar installation started.",
          index++);
      checkResponseLog(
          lines,
          "[INFO ]",
          "server",
          "PL-BI-1001",
          "bar/00_meta/00_manifest.json",
          "Installation started.",
          index++);
      checkResponseLog(
          lines,
          "[INFO ]",
          "server",
          "PL-BI-1003",
          "bar/00_meta/00_manifest.json",
          "Installation completed.",
          index++);
      checkResponseLog(
          lines,
          "[INFO ]",
          "server",
          "PL-BI-1001",
          "bar/00_meta/90_rootprops.xml",
          "Installation started.",
          index++);
      checkResponseLog(
          lines,
          "[INFO ]",
          "server",
          "PL-BI-1003",
          "bar/00_meta/90_rootprops.xml",
          "Installation completed.",
          index++);
      checkResponseLog(
          lines,
          "[INFO ]",
          "server",
          "PL-BI-0000",
          UrlUtils.getBaseUrl() + "/UnitUserCell/installBox",
          "Bar installation completed.",
          index++);
      response.statusCode(HttpStatus.SC_OK);
    } finally {
      cleanup();
      // CELL削除
      CellUtils.delete(AbstractCase.MASTER_TOKEN_NAME, UNIT_USER_CELL);
    }
  }