Example #1
0
  public boolean compareResults(Object expected, Object result) {
    if (expected == null && result == null) {
      return true;
    }

    if (expected == null || result == null) {
      return false;
    }

    if (expected instanceof Object[] && result instanceof Object[]) {
      return Arrays.equals((Object[]) expected, (Object[]) result);
    } else if (expected instanceof byte[] && result instanceof byte[]) {
      return Arrays.equals((byte[]) expected, (byte[]) result);
    }

    if (expected instanceof InputStream && result instanceof InputStream) {
      return IOUtils.toString((InputStream) expected)
          .equals(IOUtils.toString((InputStream) result));
    } else if (expected instanceof InputStream) {
      expected = IOUtils.toString((InputStream) expected);
    }

    // Special case for Strings: normalize comparison arguments
    if (expected instanceof String && result instanceof String) {
      expected = this.normalizeString((String) expected);
      result = this.normalizeString((String) result);
    }

    return expected.equals(result);
  }
  @Override
  protected void doSetUp() throws Exception {
    InputStream resourceStream = IOUtils.getResourceAsStream("cdcatalog-utf-8.xml", getClass());
    srcData = IOUtils.toString(resourceStream, "UTF-8").getBytes("UTF-8");

    resourceStream = IOUtils.getResourceAsStream("cdcatalog-us-ascii.xml", getClass());
    resultData = IOUtils.toString(resourceStream, "US-ASCII");
  }
Example #3
0
 // @Override
 protected void doSetUp() throws Exception {
   org.dom4j.Document dom4jDoc =
       DocumentHelper.parseText(
           IOUtils.toString(
               IOUtils.getResourceAsStream("cdcatalog-utf-8.xml", getClass()), "UTF-8"));
   srcData = new DOMWriter().write(dom4jDoc);
   resultData =
       IOUtils.toString(
           IOUtils.getResourceAsStream("cdcatalog-us-ascii.xml", getClass()), "US-ASCII");
 }
  /**
   * {@sample.xml ../../../doc/azure-blob-service-connector.xml.sample
   * azure-blog-service:downloadBlob}
   *
   * @param friend Name to be used to generate a greeting message.
   * @return A greeting message
   * @throws StorageException
   * @throws URISyntaxException
   */
  @Processor
  public void uploadBlob(String container, String fileName, InputStream fileStream)
      throws Exception {
    BlobContainerPermissions containerPermissions = new BlobContainerPermissions();
    containerPermissions.setPublicAccess(BlobContainerPublicAccessType.CONTAINER);

    CloudBlobContainer blobContainer =
        this.config.getServiceClient().getContainerReference(container);
    blobContainer.createIfNotExists();
    blobContainer.uploadPermissions(containerPermissions);

    CloudBlockBlob blob = blobContainer.getBlockBlobReference(fileName);
    blob.uploadText(IOUtils.toString(fileStream, "UTF-8"));
  }