Package org.tap4j.ext.testng

Examples of org.tap4j.ext.testng.TAPAttribute


    {
      filesMap = new LinkedHashMap<String, Object>();
    }
    else
    {
      TAPAttribute attr = (TAPAttribute)o;
      if ( attr.getMethod() != method )
      {
        filesMap = new LinkedHashMap<String, Object>();
      }
      else
      {
        filesMap = (Map<String, Object>) attr.getValue();
      }
    }
   
    final Map<String, Object> fileMap = new LinkedHashMap<String, Object>();
   
    final File file = screenshot.getFile();
   
    // These properties were not randomly chosen. Some of them were 
    // defined in a TAP Wiki page. I know I have the link is somewhere here...
    fileMap.put("File-Location", file.getAbsolutePath() );
    fileMap.put("File-Title", screenshot.getTitle() );
    fileMap.put("File-Description", screenshot.getDescription() );
    fileMap.put("File-Size", file.length() );
    fileMap.put("File-Name", file.getName());
   
    byte[] fileData = null;
    try
    {
      fileData = FileUtils.readFileToByteArray(file);
    }
    catch (IOException e)
    {
      Assert.fail("Failed to read file to byte array.", e);
    }
    final String content = Base64.encodeBase64String( fileData );
   
    fileMap.put("File-Content", content);
    fileMap.put("File-Type", screenshot.getFileType());
   
    filesMap.put(file.getAbsolutePath(), fileMap);
   
    final TAPAttribute attribute = new TAPAttribute(method, filesMap);
    context.setAttribute("Files", attribute);
  }
View Full Code Here

TOP

Related Classes of org.tap4j.ext.testng.TAPAttribute

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.