public class SafeJenkins
extends java.lang.Object
This class provides a way for us to invoke the Jenkins.getInstance() method, during testing, without it throwing NoSuchMethod errors. Currently this method throws the following error: 'java.lang.NoSuchMethodError: hudson.util.XStream2.getConverterRegistry()Lcom/thoughtworks/xstream/converters/ConverterRegistry;'.
Unfortunately this method is invoked in many places, often nested with other static methods. This makes mocking very difficult/impossible. So, I've fashioned the following class to address these issues.
Modifier and Type | Field and Description |
---|---|
protected static hudson.util.DescribableList<hudson.slaves.NodeProperty<?>,hudson.slaves.NodePropertyDescriptor> |
globalNodeProperties
Provides a way to override the static Jenkins instance for unit testing.
|
protected static hudson.util.DescribableList<hudson.slaves.NodeProperty<?>,hudson.slaves.NodePropertyDescriptor> |
localNodeProperties |
protected static boolean |
useNativeInstance |
Constructor and Description |
---|
SafeJenkins() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
decrypt(java.lang.String encryptedMessage) |
static java.lang.String |
encrypt(java.lang.String message) |
static hudson.util.DescribableList<hudson.slaves.NodeProperty<?>,hudson.slaves.NodePropertyDescriptor> |
getGlobalNodeProperties() |
static jenkins.model.Jenkins |
getJenkinsInstance() |
static hudson.util.DescribableList<hudson.slaves.NodeProperty<?>,hudson.slaves.NodePropertyDescriptor> |
getNodeProperties() |
static boolean |
isNull(java.lang.Object object) |
static boolean |
nonNull(java.lang.Object object) |
static void |
useNativeInstance(boolean useNativeInstance) |
protected static hudson.util.DescribableList<hudson.slaves.NodeProperty<?>,hudson.slaves.NodePropertyDescriptor> globalNodeProperties
protected static hudson.util.DescribableList<hudson.slaves.NodeProperty<?>,hudson.slaves.NodePropertyDescriptor> localNodeProperties
protected static boolean useNativeInstance
public static void useNativeInstance(boolean useNativeInstance)
public static jenkins.model.Jenkins getJenkinsInstance()
public static hudson.util.DescribableList<hudson.slaves.NodeProperty<?>,hudson.slaves.NodePropertyDescriptor> getGlobalNodeProperties()
public static hudson.util.DescribableList<hudson.slaves.NodeProperty<?>,hudson.slaves.NodePropertyDescriptor> getNodeProperties()
public static java.lang.String encrypt(java.lang.String message)
public static java.lang.String decrypt(java.lang.String encryptedMessage)
public static boolean isNull(java.lang.Object object)
public static boolean nonNull(java.lang.Object object)