コード例 #1
0
  /** Boxインストールで作成する場合のコレクション配下のファイル最大数チェックのテスト. */
  @Test
  public final void Boxインストールで作成する場合のコレクション配下のファイル最大数チェックのテスト() {
    // 本テストでは子要素の最大数:20 コレクションの最大階層数:5の設定となっていることを前提とし、
    // WebDavコレクションの子要素数21(全てWebDavファイル)のBarファイルを登録して、エラーとなることを確認する。
    final String barFilePath = "/V1_1_2_bar_webdav_file_count_error.bar";
    String cellName = "collectionLimitCell";
    String box = INSTALL_TARGET;

    try {
      // テスト用Cellの作成
      CellUtils.create(cellName, TOKEN, HttpStatus.SC_CREATED);

      TResponse res = null;
      File barFile = new File(RESOURCE_PATH + barFilePath);
      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, cellName, box, headers, body);
      res.statusCode(HttpStatus.SC_ACCEPTED);
      String location = res.getHeader(HttpHeaders.LOCATION);
      String expected = UrlUtils.cellRoot(cellName) + box;
      assertEquals(expected, location);

      BarInstallTestUtils.assertBarInstallStatus(
          location, DEFAULT_SCHEMA_URL, ProgressInfo.STATUS.FAILED);
    } finally {
      // Cellの再帰的削除
      Setup.cellBulkDeletion(cellName);
    }
  }
コード例 #2
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);
    }
  }
コード例 #3
0
  /** コレクション配下のコレクション最大数チェックのテスト. */
  @Test
  public final void コレクション配下のコレクション最大数チェックのテスト() {
    // propertyで指定した要素数を超えた場合、エラーとなることを確認する。
    String cellName = "collectionLimitCell";
    String boxName = "box1";
    String colNamePrefix = "col";
    try {
      // テスト用Cellの作成
      CellUtils.create(cellName, TOKEN, HttpStatus.SC_CREATED);
      // テスト用Boxの作成
      BoxUtils.create(cellName, boxName, TOKEN, HttpStatus.SC_CREATED);

      // コレクションの子要素数の最大値を取得
      int maxChildCount = DcCoreConfig.getMaxChildResourceCount();

      // 基底コレクションの作成
      String basePath = "col1";
      Http.request("box/mkcol-normal.txt")
          .with("cellPath", cellName)
          .with("path", basePath)
          .with("token", TOKEN)
          .returns()
          .statusCode(HttpStatus.SC_CREATED);

      // 子コレクションの作成
      String path = "";
      int i;
      for (i = 1; i <= maxChildCount; i++) {
        path = basePath + "/" + colNamePrefix + String.valueOf(i);
        // Davコレクションの作成
        Http.request("box/mkcol-normal.txt")
            .with("cellPath", cellName)
            .with("path", path)
            .with("token", TOKEN)
            .returns()
            .statusCode(HttpStatus.SC_CREATED);
      }

      // 最大値を超える分の子コレクションを作成
      path = basePath + "/" + colNamePrefix + String.valueOf(i);
      // Davコレクションの作成
      Http.request("box/mkcol-normal.txt")
          .with("cellPath", cellName)
          .with("path", path)
          .with("token", TOKEN)
          .returns()
          .statusCode(HttpStatus.SC_BAD_REQUEST);
    } finally {
      // Cellの再帰的削除
      Setup.cellBulkDeletion(cellName);
    }
  }
コード例 #4
0
  /** 階層チェックのテスト_WebDavコレクションの追加. */
  @Test
  public final void 階層チェックのテスト() {
    // propertyで指定した階層数を超えた場合、エラーとなることを確認する。
    String cellName = "collectionLimitCell";
    String boxName = "box1";
    String colNamePrefix = "col";
    try {
      // テスト用Cellの作成
      CellUtils.create(cellName, TOKEN, HttpStatus.SC_CREATED);
      // テスト用Boxの作成
      BoxUtils.create(cellName, boxName, TOKEN, HttpStatus.SC_CREATED);

      // コレクションの階層数の最大値を取得
      int maxCollectionDepth = DcCoreConfig.getMaxCollectionDepth();

      // 最大値階層分のWebDavコレクションを作成
      String path = "";
      int i;
      for (i = 1; i <= maxCollectionDepth; i++) {
        if (!path.isEmpty()) {
          path += "/";
        }
        path += colNamePrefix + String.valueOf(i);
        // Davコレクションの作成
        Http.request("box/mkcol-normal.txt")
            .with("cellPath", cellName)
            .with("path", path)
            .with("token", TOKEN)
            .returns()
            .statusCode(HttpStatus.SC_CREATED);
      }

      // 最大値を超える分のWebDavコレクションを作成
      path += "/" + colNamePrefix + String.valueOf(i);
      // Davコレクションの作成(400エラーになること)
      Http.request("box/mkcol-normal.txt")
          .with("cellPath", cellName)
          .with("path", path)
          .with("token", TOKEN)
          .returns()
          .statusCode(HttpStatus.SC_BAD_REQUEST);
    } finally {
      // Cellの再帰的削除
      Setup.cellBulkDeletion(cellName);
    }
  }
コード例 #5
0
  /** 階層チェックのテスト_WebDavファイルの追加. */
  @Test
  public final void 階層チェックのテスト_WebDavファイルの追加() {
    String cellName = "collectionLimitCell";
    String boxName = "box1";
    String colNamePrefix = "col";
    try {
      // テスト用Cellの作成
      CellUtils.create(cellName, TOKEN, HttpStatus.SC_CREATED);
      // テスト用Boxの作成
      BoxUtils.create(cellName, boxName, TOKEN, HttpStatus.SC_CREATED);

      // コレクションの階層数の最大値を取得
      int maxCollectionDepth = DcCoreConfig.getMaxCollectionDepth();

      // 最大値階層分のWebDavコレクションを作成
      String path = "";
      int i;
      for (i = 1; i <= maxCollectionDepth; i++) {
        if (!path.isEmpty()) {
          path += "/";
        }
        path += colNamePrefix + String.valueOf(i);
        // Davコレクションの作成
        Http.request("box/mkcol-normal.txt")
            .with("cellPath", cellName)
            .with("path", path)
            .with("token", TOKEN)
            .returns()
            .statusCode(HttpStatus.SC_CREATED);
      }

      // WebDavファイルを作成
      path += "hoge.txt";
      // Davファイルの作成
      DavResourceUtils.createWebDavFile(
          cellName, TOKEN, "box/dav-put.txt", "hoge", boxName, path, HttpStatus.SC_CREATED);
    } finally {
      // Cellの再帰的削除
      Setup.cellBulkDeletion(cellName);
    }
  }
コード例 #6
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);
    }
  }