Package org.serviceconnector.api.cln

Examples of org.serviceconnector.api.cln.SCFileService


    try {
      sc.setMaxConnections(20); // can be set before attach, default 100 Connections
      sc.setKeepAliveIntervalSeconds(10); // can be set before attach, default 0 -> inactive
      sc.attach(); // attaching client to SC , communication starts

      SCFileService service = sc.newFileService("file-1"); // name of the service to use

      List<String> fileNameList = service.listFiles();
      for (String fileName : fileNameList) {
        System.out.println(fileName);
      }

      File localFile = new File("src/main/resources/uploadContent.txt");
      InputStream inpStream = new FileInputStream(localFile);
      String targetFileName = "uploadContent.txt";

      service.uploadFile(targetFileName, inpStream); // regular upload

      localFile = new File("src/main/resources/downloadContent.txt");
      FileOutputStream outStream = new FileOutputStream(localFile);
      targetFileName = "uploadContent.txt";
      service.downloadFile(targetFileName, outStream); // regular download
      outStream.close();
    } catch (Exception e) {
      LOGGER.error("run", e);
    } finally {
      try {
View Full Code Here


    FileOutputStream dstStream = null;
    SCClient client = null;
    try {
      // try to connect client
      client = connectClientToService(service);
      SCFileService scFileService = client.newFileService(service.getName());
      dstStream = new FileOutputStream(dstFile);
      scFileService.downloadFile(remoteFile, dstStream);
      writer.writeStartElement("message");
      writer.writeCharacters(dstFile.getName() + "  " + status);
      writer.writeEndElement();
    } catch (Exception e) {
      status = "failed";
View Full Code Here

    /** {@inheritDoc} */
    @Override
    public Integer call() {
      try {
        SCFileService scFileService = client.newFileService(this.serviceName);
        scFileService.uploadFile(360, this.remotePath, this.is);
        // reads buffer intern until the end of output stream
        client.detach();
        return 0;
      } catch (Exception e) {
        LOGGER.error(e.toString());
View Full Code Here

    this.writeBean(writer, service);
    if (service instanceof FileService || service instanceof CascadedFileService) {
      SCClient client = null;
      // try to connect client
      client = connectClientToService(service);
      SCFileService scFileService = client.newFileService(serviceName);
      List<String> fileList = scFileService.listFiles();
      writer.writeStartElement("files");
      for (String fileName : fileList) {
        writer.writeStartElement("file");
        writer.writeCData(fileName);
        writer.writeEndElement();
View Full Code Here

    this.writeBean(writer, service);
    if (service instanceof FileService || service instanceof CascadedFileService) {
      SCClient client = null;
      // try to connect client
      client = connectClientToService(service);
      SCFileService scFileService = client.newFileService(serviceName);
      List<String> fileList = scFileService.listFiles();
      writer.writeStartElement("files");
      for (String fileName : fileList) {
        if (fileName.startsWith(Constants.LOGS_FILE_NAME)) {
          writer.writeStartElement("file");
          writer.writeCData(fileName);
View Full Code Here

   * Description: upload file via file-2 service<br>
   * Expectation: passes
   */
  @Test
  public void t01_upload() throws Exception {
    SCFileService service = client.newFileService(TestConstants.filServiceName2);
    String localFile = "uploadFile.txt";
    String localpath = "src/main/resources/";
    String remoteFileName = "uploadedFile.txt";
    File inputFile = new File(localpath + localFile);
    InputStream inpStream = new FileInputStream(inputFile);
    service.uploadFile(remoteFileName, inpStream);
    inpStream.close();
    FileUtility.waitExists(TestConstants.filServiceLocation2 + remoteFileName, 0);
    FileUtility.deleteFile(TestConstants.filServiceLocation2 + remoteFileName);
  }
View Full Code Here

   * Description: list file uploaded via file-2 service<br>
   * Expectation: passes
   */
  @Test
  public void t02_list() throws Exception {
    SCFileService service = client.newFileService(TestConstants.filServiceName2);
    // upload file first
    String localFile = "uploadFile.txt";
    String localpath = "src/main/resources/";
    String remoteFileName = "uploadedFile.txt";
    File inputFile = new File(localpath + localFile);
    InputStream inpStream = new FileInputStream(inputFile);
    service.uploadFile(180, remoteFileName, inpStream);
    inpStream.close();

    // list now
    List<String> fileNameList = service.listFiles();
    for (String fileName : fileNameList) {
      testLogger.info(fileName);
    }
    Assert.assertEquals("list is empty", 1, fileNameList.size());
    Assert.assertEquals("filename is not equal", remoteFileName, fileNameList.get(0));
View Full Code Here

   * Description: download file uploaded via file-2 service<br>
   * Expectation: passes
   */
  @Test
  public void t03_download() throws Exception {
    SCFileService service = client.newFileService(TestConstants.filServiceName2);
    // upload file first
    String localFile = "uploadFile.txt";
    String localpath = "src/main/resources/";
    String remoteFileName = "uploadedFile.txt";
    File inputFile = new File(localpath + localFile);
    InputStream inpStream = new FileInputStream(inputFile);
    service.uploadFile(180, remoteFileName, inpStream);
    inpStream.close();
    FileUtility.waitExists(TestConstants.filServiceLocation2 + remoteFileName, 0);

    // download now
    localFile = "downloadContent.txt";
    localpath = "src/main/resources/";
    remoteFileName = "uploadedFile.txt";
    File outputFile = new File(localpath + localFile);
    FileOutputStream outStream = new FileOutputStream(outputFile);
    service.downloadFile(180, remoteFileName, outStream);
    outStream.close();
    FileUtility.waitExists(localpath + localFile, 0);
    FileUtility.deleteFile(localpath + localFile);
    FileUtility.deleteFile(TestConstants.filServiceLocation2 + remoteFileName);
  }
View Full Code Here

   * Description: upload big file via file-2 service<br>
   * Expectation: passes
   */
  @Test
  public void t10_upload200MBFile() throws Exception {
    SCFileService service = client.newFileService(TestConstants.filServiceName2);
    String localFile = "upload200MBFile.txt";
    String localpath = "src/main/resources/";
    TestUtil.create200MBFile(localpath + localFile);
    String remoteFileName = localFile;
    File inputFile = new File(localpath + localFile);
    InputStream inpStream = new FileInputStream(inputFile);
    service.uploadFile(300, remoteFileName, inpStream);
    inpStream.close();
    FileUtility.deleteFile(localpath + localFile);
    FileUtility.waitExists(TestConstants.filServiceLocation2 + remoteFileName, 0);
    FileUtility.deleteFile(TestConstants.filServiceLocation2 + remoteFileName);
  }
View Full Code Here

   * Description: download big file uploaded via file-2 service<br>
   * Expectation: passes
   */
  @Test
  public void t03_download200MBFile() throws Exception {
    SCFileService service = client.newFileService(TestConstants.filServiceName2);
    // upload file first
    String localFile = "upload200MBFile.txt";
    String localpath = "src/main/resources/";
    TestUtil.create200MBFile(localpath + localFile);
    String remoteFileName = localFile;
    File inputFile = new File(localpath + localFile);
    InputStream inpStream = new FileInputStream(inputFile);
    service.uploadFile(300, remoteFileName, inpStream);
    inpStream.close();
    FileUtility.waitExists(TestConstants.filServiceLocation2 + remoteFileName, 0);
    FileUtility.deleteFile(localpath + localFile);

    // download now
    localFile = "download200MBContent.txt";
    localpath = "src/main/resources/";
    remoteFileName = "upload200MBFile.txt";
    File outputFile = new File(localpath + localFile);
    FileOutputStream outStream = new FileOutputStream(outputFile);
    service.downloadFile(300, remoteFileName, outStream); // regular download
    outStream.close();
    FileUtility.waitExists(localpath + localFile, 0);
    FileUtility.deleteFile(localpath + localFile);
    FileUtility.deleteFile(TestConstants.filServiceLocation2 + remoteFileName);
  }
View Full Code Here

TOP

Related Classes of org.serviceconnector.api.cln.SCFileService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.