From 84fe8fa4196b1abcfb9ff081894c02753bcc74dc Mon Sep 17 00:00:00 2001 From: danikov Date: Fri, 16 Mar 2012 19:21:45 +0000 Subject: [PATCH] NPE guard in test formatter --- .../vcloud/director/testng/FormatApiResultsListener.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/testng/FormatApiResultsListener.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/testng/FormatApiResultsListener.java index 4f7dab346e..6abbb96dce 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/testng/FormatApiResultsListener.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/testng/FormatApiResultsListener.java @@ -18,6 +18,8 @@ */ package org.jclouds.vcloud.director.testng; +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; import java.util.Arrays; import java.util.Set; @@ -104,7 +106,9 @@ public class FormatApiResultsListener implements ITestListener { } private String getOperation(ITestResult res) { - return res.getMethod().getConstructorOrMethod().getMethod().getAnnotation(Test.class).testName(); + Method method = res.getMethod().getConstructorOrMethod().getMethod(); + Test test = method.getAnnotation(Test.class); + return test != null ? test.testName() : method.getName(); } private String getDuration() {