summaryrefslogtreecommitdiffstats
path: root/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/TestUtilities.java
diff options
context:
space:
mode:
Diffstat (limited to 'bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/TestUtilities.java')
-rw-r--r--bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/TestUtilities.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/TestUtilities.java b/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/TestUtilities.java
new file mode 100644
index 00000000000..6ff6bafd816
--- /dev/null
+++ b/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/TestUtilities.java
@@ -0,0 +1,40 @@
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.container.plugin.classanalysis;
+
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeMatcher;
+
+import java.io.File;
+
+/**
+ * @author Tony Vaagenes
+ * @author ollivir
+ */
+public class TestUtilities {
+ public static ClassFileMetaData analyzeClass(Class<?> clazz) {
+ return Analyze.analyzeClass(classFile(name(clazz)));
+ }
+
+ public static File classFile(String className) {
+ return new File("target/test-classes/" + className.replace('.', '/') + ".class");
+ }
+
+ public static String name(Class<?> clazz) {
+ return clazz.getName();
+ }
+
+ public static TypeSafeMatcher<Throwable> throwableMessage(final Matcher<String> matcher) {
+ return new TypeSafeMatcher<Throwable>() {
+ @Override
+ protected boolean matchesSafely(Throwable throwable) {
+ return matcher.matches(throwable.getMessage());
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText("expects Throwable and a message matching ").appendDescriptionOf(matcher);
+ }
+ };
+ }
+}