Class CommonTestSupportUtils
- java.lang.Object
-
- org.apache.maven.scm.provider.git.CommonTestSupportUtils
-
public final class CommonTestSupportUtils extends java.lang.ObjectTODO Add javadoc
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCLASS_FILE_SUFFIXSuffix of compile Java class filesstatic java.lang.StringDEFAULT_TEST_HOST_KEY_PROVIDER_ALGORITHMstatic intDEFAULT_TEST_HOST_KEY_SIZEstatic java.lang.StringDEFAULT_TEST_HOST_KEY_TYPEstatic java.lang.StringFILE_URL_PREFIXPrefix used in URL(s) that reference a file resourcestatic java.lang.StringFILE_URL_SCHEMEURL/URI scheme that refers to a filestatic java.lang.StringJAR_FILE_SUFFIXSuffix of JAR filesstatic java.lang.StringJAR_URL_PREFIXPrefix used in URL(s) that reference a resource inside a JARstatic java.lang.StringJAR_URL_SCHEMEURL/URI scheme that refers to a JARprivate static java.util.concurrent.atomic.AtomicReference<org.apache.sshd.common.keyprovider.KeyPairProvider>KEYPAIR_PROVIDER_HOLDERprivate static java.util.Map<java.lang.String,org.apache.sshd.common.keyprovider.FileKeyPairProvider>PROVIDERS_MAPstatic charRESOURCE_SUBPATH_SEPARATORSeparator used in URL(s) that reference a resource inside a JAR to denote the sub-path inside the JARstatic java.util.List<java.lang.String>TARGET_FOLDER_NAMES
-
Constructor Summary
Constructors Modifier Constructor Description privateCommonTestSupportUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringadjustURLPathValue(java.lang.String path)static java.lang.StringadjustURLPathValue(java.net.URL url)static org.apache.sshd.common.keyprovider.KeyPairProvidercreateTestHostKeyProvider(java.lang.Class<?> anchor)static org.apache.sshd.common.keyprovider.KeyPairProvidercreateTestHostKeyProvider(java.nio.file.Path path)static org.apache.sshd.common.keyprovider.FileKeyPairProvidercreateTestKeyPairProvider(java.lang.String resource)static java.nio.file.PathdetectTargetFolder(java.lang.Class<?> anchor)static java.nio.file.PathdetectTargetFolder(java.nio.file.Path anchorFile)static java.security.KeyPairgenerateKeyPair(java.lang.String algorithm, int keySize)static java.lang.StringgetClassBytesResourceName(java.lang.Class<?> clazz)static java.lang.StringgetClassBytesResourceName(java.lang.String name)static java.net.URLgetClassBytesURL(java.lang.Class<?> clazz)static java.nio.file.PathgetClassContainerLocationPath(java.lang.Class<?> clazz)static java.net.URIgetClassContainerLocationURI(java.lang.Class<?> clazz)static java.net.URLgetClassContainerLocationURL(java.lang.Class<?> clazz)private static java.nio.file.PathgetFile(java.lang.String resource)static java.security.KeyPairgetFirstKeyPair(org.apache.sshd.common.keyprovider.KeyIdentityProvider provider)static java.security.KeyPairgetFirstKeyPair(org.apache.sshd.common.keyprovider.KeyPairProviderHolder holder)static java.lang.StringgetURLSource(java.lang.String externalForm)static java.lang.StringgetURLSource(java.net.URI uri)static java.lang.StringgetURLSource(java.net.URL url)static java.nio.file.Pathresolve(java.nio.file.Path root, java.lang.String... children)static java.nio.file.Pathresolve(java.nio.file.Path root, java.util.Collection<java.lang.String> children)static java.lang.StringstripJarURLPrefix(java.lang.String externalForm)static java.nio.file.PathtoPathSource(java.net.URI uri)Converts aURIthat may refer to an internal resource to aPathrepresenting is "source" container (e.g., if it is a resource in a JAR, then the result is the JAR's path)static java.nio.file.PathtoPathSource(java.net.URL url)Converts aURLthat may refer to an internal resource to aPathrepresenting is "source" container (e.g., if it is a resource in a JAR, then the result is the JAR's path)static <P extends org.apache.sshd.common.keyprovider.KeyIdentityProvider>
PvalidateKeyPairProvider(P provider)
-
-
-
Field Detail
-
FILE_URL_SCHEME
public static final java.lang.String FILE_URL_SCHEME
URL/URI scheme that refers to a file- See Also:
- Constant Field Values
-
FILE_URL_PREFIX
public static final java.lang.String FILE_URL_PREFIX
Prefix used in URL(s) that reference a file resource- See Also:
- Constant Field Values
-
RESOURCE_SUBPATH_SEPARATOR
public static final char RESOURCE_SUBPATH_SEPARATOR
Separator used in URL(s) that reference a resource inside a JAR to denote the sub-path inside the JAR- See Also:
- Constant Field Values
-
JAR_FILE_SUFFIX
public static final java.lang.String JAR_FILE_SUFFIX
Suffix of JAR files- See Also:
- Constant Field Values
-
JAR_URL_SCHEME
public static final java.lang.String JAR_URL_SCHEME
URL/URI scheme that refers to a JAR- See Also:
- Constant Field Values
-
JAR_URL_PREFIX
public static final java.lang.String JAR_URL_PREFIX
Prefix used in URL(s) that reference a resource inside a JAR- See Also:
- Constant Field Values
-
CLASS_FILE_SUFFIX
public static final java.lang.String CLASS_FILE_SUFFIX
Suffix of compile Java class files- See Also:
- Constant Field Values
-
TARGET_FOLDER_NAMES
public static final java.util.List<java.lang.String> TARGET_FOLDER_NAMES
-
DEFAULT_TEST_HOST_KEY_PROVIDER_ALGORITHM
public static final java.lang.String DEFAULT_TEST_HOST_KEY_PROVIDER_ALGORITHM
- See Also:
- Constant Field Values
-
DEFAULT_TEST_HOST_KEY_SIZE
public static final int DEFAULT_TEST_HOST_KEY_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_TEST_HOST_KEY_TYPE
public static final java.lang.String DEFAULT_TEST_HOST_KEY_TYPE
-
KEYPAIR_PROVIDER_HOLDER
private static final java.util.concurrent.atomic.AtomicReference<org.apache.sshd.common.keyprovider.KeyPairProvider> KEYPAIR_PROVIDER_HOLDER
-
PROVIDERS_MAP
private static final java.util.Map<java.lang.String,org.apache.sshd.common.keyprovider.FileKeyPairProvider> PROVIDERS_MAP
-
-
Method Detail
-
getClassContainerLocationURI
public static java.net.URI getClassContainerLocationURI(java.lang.Class<?> clazz) throws java.net.URISyntaxException- Parameters:
clazz- AClassobject- Returns:
- A
URIto the location of the class bytes container - e.g., the root folder, the containing JAR, etc.. Returnsnullif location could not be resolved - Throws:
java.net.URISyntaxException- if location is not a valid URI- See Also:
getClassContainerLocationURL(Class)
-
getClassContainerLocationURL
public static java.net.URL getClassContainerLocationURL(java.lang.Class<?> clazz)
- Parameters:
clazz- AClassobject- Returns:
- A
URLto the location of the class bytes container - e.g., the root folder, the containing JAR, etc.. Returnsnullif location could not be resolved
-
getURLSource
public static java.lang.String getURLSource(java.net.URI uri)
- Parameters:
uri- TheURIvalue - ignored ifnull- Returns:
- The URI(s) source path where
JAR_URL_PREFIXand any sub-resource are stripped - See Also:
getURLSource(String)
-
getURLSource
public static java.lang.String getURLSource(java.net.URL url)
- Parameters:
url- TheURLvalue - ignored ifnull- Returns:
- The URL(s) source path where
JAR_URL_PREFIXand any sub-resource are stripped - See Also:
getURLSource(String)
-
getURLSource
public static java.lang.String getURLSource(java.lang.String externalForm)
- Parameters:
externalForm- TheURL.toExternalForm()string - ignored ifnull/empty- Returns:
- The URL(s) source path where
JAR_URL_PREFIXand any sub-resource are stripped
-
adjustURLPathValue
public static java.lang.String adjustURLPathValue(java.net.URL url)
- Parameters:
url- AURL- ignored ifnull- Returns:
- The path after stripping any trailing '/' provided the path is not '/' itself
- See Also:
adjustURLPathValue(String)
-
adjustURLPathValue
public static java.lang.String adjustURLPathValue(java.lang.String path)
- Parameters:
path- A URL path value - ignored ifnull/empty- Returns:
- The path after stripping any trailing '/' provided the path is not '/' itself
-
stripJarURLPrefix
public static java.lang.String stripJarURLPrefix(java.lang.String externalForm)
-
getClassBytesURL
public static java.net.URL getClassBytesURL(java.lang.Class<?> clazz)
- Parameters:
clazz- The requestClass- Returns:
- A
URLto the location of the.classfile -nullif location could not be resolved
-
getClassBytesResourceName
public static java.lang.String getClassBytesResourceName(java.lang.Class<?> clazz)
-
getClassBytesResourceName
public static java.lang.String getClassBytesResourceName(java.lang.String name)
- Parameters:
name- The fully qualified class name - ignored ifnull/empty- Returns:
- The relative path of the class file byte-code resource
-
resolve
public static java.nio.file.Path resolve(java.nio.file.Path root, java.lang.String... children)
-
resolve
public static java.nio.file.Path resolve(java.nio.file.Path root, java.util.Collection<java.lang.String> children)
-
detectTargetFolder
public static java.nio.file.Path detectTargetFolder(java.lang.Class<?> anchor)
- Parameters:
anchor- An anchorClasswhose container we want to use as the starting point for the "target" folder lookup up the hierarchy- Returns:
- The "target" folder -
nullif not found - See Also:
detectTargetFolder(Path)
-
getClassContainerLocationPath
public static java.nio.file.Path getClassContainerLocationPath(java.lang.Class<?> clazz) throws java.lang.IllegalArgumentException- Parameters:
clazz- AClassobject- Returns:
- A
Pathof the location of the class bytes container - e.g., the root folder, the containing JAR, etc.. Returnsnullif location could not be resolved - Throws:
java.lang.IllegalArgumentException- If location is not a validPathlocation- See Also:
getClassContainerLocationURI(Class),toPathSource(URI)
-
toPathSource
public static java.nio.file.Path toPathSource(java.net.URL url) throws java.net.MalformedURLExceptionConverts aURLthat may refer to an internal resource to aPathrepresenting is "source" container (e.g., if it is a resource in a JAR, then the result is the JAR's path)- Parameters:
url- TheURL- ignored ifnull- Returns:
- The matching
Path - Throws:
java.net.MalformedURLException- If source URL does not refer to a file location- See Also:
toPathSource(URI)
-
toPathSource
public static java.nio.file.Path toPathSource(java.net.URI uri) throws java.net.MalformedURLExceptionConverts aURIthat may refer to an internal resource to aPathrepresenting is "source" container (e.g., if it is a resource in a JAR, then the result is the JAR's path)- Parameters:
uri- TheURI- ignored ifnull- Returns:
- The matching
Path - Throws:
java.net.MalformedURLException- If source URI does not refer to a file location- See Also:
getURLSource(URI)
-
detectTargetFolder
public static java.nio.file.Path detectTargetFolder(java.nio.file.Path anchorFile)
- Parameters:
anchorFile- An anchorPathwe want to use as the starting point for the "target" or "build" folder lookup up the hierarchy- Returns:
- The "target" folder -
nullif not found
-
generateKeyPair
public static java.security.KeyPair generateKeyPair(java.lang.String algorithm, int keySize) throws java.security.GeneralSecurityException- Throws:
java.security.GeneralSecurityException
-
createTestHostKeyProvider
public static org.apache.sshd.common.keyprovider.KeyPairProvider createTestHostKeyProvider(java.lang.Class<?> anchor)
-
createTestHostKeyProvider
public static org.apache.sshd.common.keyprovider.KeyPairProvider createTestHostKeyProvider(java.nio.file.Path path)
-
getFirstKeyPair
public static java.security.KeyPair getFirstKeyPair(org.apache.sshd.common.keyprovider.KeyPairProviderHolder holder)
-
getFirstKeyPair
public static java.security.KeyPair getFirstKeyPair(org.apache.sshd.common.keyprovider.KeyIdentityProvider provider)
-
getFile
private static java.nio.file.Path getFile(java.lang.String resource)
-
createTestKeyPairProvider
public static org.apache.sshd.common.keyprovider.FileKeyPairProvider createTestKeyPairProvider(java.lang.String resource)
-
validateKeyPairProvider
public static <P extends org.apache.sshd.common.keyprovider.KeyIdentityProvider> P validateKeyPairProvider(P provider)
-
-