예제 #1
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);
    }
  }
예제 #2
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);
    }
  }
 /** UserDataにboolean型のPropertyに範囲検索クエリを指定した場合_400エラーとなること. */
 @Test
 public final void UserDataにboolean型のPropertyに範囲検索クエリを指定した場合_400エラーとなること() {
   String sdEntityTypeName = "SalesDetail";
   // ユーザデータの一覧取得
   Http.request("box/odatacol/list.txt")
       .with("cell", cellName)
       .with("box", boxName)
       .with("collection", colName)
       .with("entityType", sdEntityTypeName)
       .with("query", "?\\$filter=truth+ge+true&\\$inlinecount=allpages")
       .with("accept", MediaType.APPLICATION_JSON)
       .with("token", DcCoreConfig.getMasterToken())
       .returns()
       .statusCode(HttpStatus.SC_BAD_REQUEST)
       .debug();
 }
예제 #4
0
  /**
   * EntityTypeからのNP経由でPropertyを一覧取得する.
   *
   * @param token トークン
   * @param cell セル名
   * @param box ボックス名
   * @param collection コレクション名
   * @param entityTypeName EntityType名
   * @param code 期待するレスポンスコード
   * @return レスポンス
   */
  public static TResponse listLinks(
      String token, String cell, String box, String collection, String entityTypeName, int code) {

    String path = String.format("\\$metadata/%s('%s')", EntityType.EDM_TYPE_NAME, entityTypeName);
    return Http.request("box/odatacol/list-link.txt")
        .with("cellPath", cell)
        .with("boxPath", box)
        .with("colPath", collection)
        .with("srcPath", path)
        .with("trgPath", Property.EDM_TYPE_NAME)
        .with("token", token)
        .with("accept", MediaType.APPLICATION_JSON)
        .returns()
        .statusCode(code)
        .debug();
  }
예제 #5
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);
    }
  }
  /** UserDataに部分一致検索クエリに真偽値falseを指定した場合ステータスコード400が返却されること. */
  @Test
  public final void UserDataに部分一致検索クエリに真偽値falseを指定した場合ステータスコード400が返却されること() {
    // ユーザデータの一覧取得
    String sdEntityTypeName = "SalesDetail";

    Http.request("box/odatacol/list.txt")
        .with("cell", cellName)
        .with("box", boxName)
        .with("collection", colName)
        .with("entityType", sdEntityTypeName)
        .with("query", "?\\$filter=substringof%28false%2ctruth%29")
        .with("accept", MediaType.APPLICATION_JSON)
        .with("token", DcCoreConfig.getMasterToken())
        .returns()
        .statusCode(HttpStatus.SC_BAD_REQUEST)
        .debug();
  }
예제 #7
0
  /**
   * PropertyをEntityTypeからのNP経由で一覧取得する.
   *
   * @param cell セル名
   * @param box ボックス名
   * @param collection コレクション名
   * @param entityTypeName EntityType名
   * @param code 期待するレスポンスコード
   * @return レスポンス
   */
  public static TResponse listViaPropertyNP(
      String cell, String box, String collection, String entityTypeName, int code) {

    TResponse res =
        Http.request("box/odatacol/schema/listViaNP.txt")
            .with("cell", cell)
            .with("box", box)
            .with("collection", collection)
            .with("accept", MediaType.APPLICATION_JSON)
            .with("token", AbstractCase.MASTER_TOKEN_NAME)
            .with("entityType", "EntityType")
            .with("id", entityTypeName)
            .with("navPropName", "_Property")
            .returns()
            .statusCode(code)
            .debug();
    return res;
  }
예제 #8
0
  /**
   * PropertyをEntityTypeからのNP経由で登録する.
   *
   * @param token トークン
   * @param cell セル名
   * @param box ボックス名
   * @param collection コレクション名
   * @param entityTypeName EntityType名
   * @param propertyName Property名
   * @param type PropertyのType項目
   * @param nullable PropertyのNullable項目
   * @param defaultValue PropertyのDefaultValue項目
   * @param collectionKind PropertyのcollectionKind項目
   * @param isKey PropertyのisKey項目
   * @param uniqueKey PropertyのUniqueKey項目
   * @param code 期待するレスポンスコード
   * @return レスポンス
   */
  @SuppressWarnings("unchecked")
  public static TResponse createViaPropertyNP(
      String token,
      String cell,
      String box,
      String collection,
      String entityTypeName,
      String propertyName,
      String type,
      Boolean nullable,
      String defaultValue,
      String collectionKind,
      Boolean isKey,
      String uniqueKey,
      int code) {

    // リクエストボディの組み立て
    JSONObject body = new JSONObject();
    body.put("Name", propertyName);
    body.put("_EntityType.Name", entityTypeName);
    body.put("Type", type);
    body.put("Nullable", nullable);
    body.put("DefaultValue", defaultValue);
    body.put("CollectionKind", collectionKind);
    body.put("IsKey", isKey);
    body.put("UniqueKey", uniqueKey);

    TResponse res =
        Http.request("box/odatacol/schema/createViaNP.txt")
            .with("cell", cell)
            .with("box", box)
            .with("collection", collection)
            .with("accept", MediaType.APPLICATION_JSON)
            .with("contentType", MediaType.APPLICATION_JSON)
            .with("token", DcCoreConfig.getMasterToken())
            .with("entityType", "EntityType")
            .with("id", entityTypeName)
            .with("navPropName", "_Property")
            .with("body", body.toJSONString())
            .returns()
            .statusCode(code)
            .debug();
    return res;
  }
예제 #9
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);
    }
  }
예제 #10
0
  private static void cleanup() {
    String reqCell = UNIT_USER_CELL;

    try {
      // コレクションの削除
      Http.request("box/delete-box-col.txt")
          .with("cellPath", reqCell)
          .with("box", "installBox")
          .with("path", "col1/col11")
          .with("token", AbstractCase.MASTER_TOKEN_NAME)
          .returns()
          .debug();
    } catch (Exception ex) {
      log.debug(ex.getMessage());
    }

    try {
      // コレクションの削除
      Http.request("box/delete-box-col.txt")
          .with("cellPath", reqCell)
          .with("box", "installBox")
          .with("path", "col1")
          .with("token", AbstractCase.MASTER_TOKEN_NAME)
          .returns()
          .debug();
    } catch (Exception ex) {
      log.debug(ex.getMessage());
    }

    try {
      // コレクションの削除
      Http.request("box/delete-box-col.txt")
          .with("cellPath", reqCell)
          .with("box", "installBox")
          .with("path", "col3")
          .with("token", AbstractCase.MASTER_TOKEN_NAME)
          .returns()
          .debug();
    } catch (Exception ex) {
      log.debug(ex.getMessage());
    }

    try {
      // コレクションの削除
      Http.request("box/delete-box-col.txt")
          .with("cellPath", reqCell)
          .with("box", "installBox")
          .with("path", "col2")
          .with("token", AbstractCase.MASTER_TOKEN_NAME)
          .returns()
          .debug();
    } catch (Exception ex) {
      log.debug(ex.getMessage());
    }

    try {
      Http.request("cell/box-delete.txt")
          .with("cellPath", reqCell)
          .with("token", AbstractCase.MASTER_TOKEN_NAME)
          .with("boxPath", INSTALL_TARGET)
          .returns()
          .debug();
    } catch (Exception ex) {
      log.debug(ex.getMessage());
    }
  }
예제 #11
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);
    }
  }