java - 将屏幕截图附加到 Rally 测试用例结果

标签 java rest rally

我正在使用 Rally API/Java。当我创建 Rally Testcase 时,我需要在 Rally Testcase 中附加一个屏幕截图。我正在这样做,但我的附件响应中出现错误。

响应消息为get,错误为:

{"CreateResult": {"_rallyAPIMajor": "2", "_rallyAPIMinor": "0", "Errors": ["我们很抱歉!发生了意外错误。

我们已记录此错误并将开始调查它。同时,如果您想与我们的支持团队联系,请引用以下信息:

java.lang.NullPointerException

02/25/2015 05:07:01 PM Asia/Karachi"], "警告": ["不再需要将\".js\"附加到 WSAPI 资源。"]}}

我没有收到我的请求消息,它成功创建了请求。

需要帮助!

我的附件代码如下:

// File handle for image to attach
        RandomAccessFile myImageFileHandle;
        String imageFilePath = "c:/Screenshots/";
        String imageFileName = "AWSCEUbuntuServerSmall.jpg";
        String fullImageFile = imageFilePath + imageFileName;
        String imageBase64String;
        long attachmentSize;

        // Open file
        myImageFileHandle = new RandomAccessFile(fullImageFile, "r");

//Add Attachment

                        // Get and check length
                        long longLength = myImageFileHandle.length();
                        long maxLength = 5000000;
                        if (longLength >= maxLength) throw new IOException("File size >= 5 MB Upper limit for Rally.");
                        int fileLength = (int) longLength;            

                        // Read file and return data
                        byte[] fileBytes = new byte[fileLength];
                        myImageFileHandle.readFully(fileBytes);
                        imageBase64String = Base64.encodeBase64String(fileBytes);
                        attachmentSize = fileLength;

                        // First create AttachmentContent from image string
                        JsonObject myAttachmentContent = new JsonObject();
                        myAttachmentContent.addProperty("Content", imageBase64String);
                        CreateRequest attachmentContentCreateRequest = new CreateRequest("AttachmentContent", myAttachmentContent);
                        CreateResponse attachmentContentResponse = restApi.create(attachmentContentCreateRequest);
                        String myAttachmentContentRef = Ref.getRelativeRef(attachmentContentResponse.getObject().get("_ref").getAsString());
                        System.out.println("Attachment Content created: " + myAttachmentContentRef);            

                        // Now create the Attachment itself
                        JsonObject myAttachment = new JsonObject();
                        myAttachment.addProperty("Workspace", workspaceRef);
                        myAttachment.addProperty("TestCaseResult",ref);
                        myAttachment.addProperty("Content", myAttachmentContentRef);
                        myAttachment.addProperty("Name", "AttachmentFromREST.jpg");
                        myAttachment.addProperty("Description", "Attachment From REST");
                        myAttachment.addProperty("ContentType","image/jpg");
                        //myAttachment.addProperty("Size", attachmentSize);
                        myAttachment.addProperty("User", userRef);


                        CreateRequest attachmentCreateRequest = new CreateRequest("Attachment", myAttachment);
                        CreateResponse attachmentResponse = restApi.create(attachmentCreateRequest);
                        String myAttachmentRef = Ref.getRelativeRef(attachmentResponse.getObject().get("_ref").getAsString());
                        System.out.println("Attachment  created: " + myAttachmentRef); 

最佳答案

我昨天提交了这个缺陷:将附件发布到用户的非默认工作区时出现 NullPointerException。

关于java - 将屏幕截图附加到 Rally 测试用例结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28719270/

相关文章:

java - ant jar 错误 : Execute failed: java. io.IOException : Cannot run program. ..${aapt}": error=2, 没有这样的文件或目录

java - 带身份验证的 HTTP Get 请求 Android

javascript - 读取从 API REST 返回的 JSON 对象

java - Rally:给定项目的 UserStory 计数

java - 如何测试正在运行的线程在使用 JUnit 完成后是否正确终止

java - 如何在 Mac 上使用 Java 获得纳秒分辨率

javascript - 自定义应用程序的动态高度

concurrency - 尝试保存第二个任务时来自服务的“并发”错误

Java继承类

validation - 哪个更好? 403 状态代码或 422 状态代码以及验证和身份验证失败的负载?