Class CommonTestSupportUtils

java.lang.Object
org.apache.maven.scm.provider.git.CommonTestSupportUtils

public final class CommonTestSupportUtils extends Object
TODO Add javadoc
  • Field Details

    • FILE_URL_SCHEME

      public static final String FILE_URL_SCHEME
      URL/URI scheme that refers to a file
      See Also:
    • FILE_URL_PREFIX

      public static final String FILE_URL_PREFIX
      Prefix used in URL(s) that reference a file resource
      See Also:
    • 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:
    • JAR_FILE_SUFFIX

      public static final String JAR_FILE_SUFFIX
      Suffix of JAR files
      See Also:
    • JAR_URL_SCHEME

      public static final String JAR_URL_SCHEME
      URL/URI scheme that refers to a JAR
      See Also:
    • JAR_URL_PREFIX

      public static final String JAR_URL_PREFIX
      Prefix used in URL(s) that reference a resource inside a JAR
      See Also:
    • CLASS_FILE_SUFFIX

      public static final String CLASS_FILE_SUFFIX
      Suffix of compile Java class files
      See Also:
    • TARGET_FOLDER_NAMES

      public static final List<String> TARGET_FOLDER_NAMES
    • DEFAULT_TEST_HOST_KEY_PROVIDER_ALGORITHM

      public static final String DEFAULT_TEST_HOST_KEY_PROVIDER_ALGORITHM
      See Also:
    • DEFAULT_TEST_HOST_KEY_SIZE

      public static final int DEFAULT_TEST_HOST_KEY_SIZE
      See Also:
    • DEFAULT_TEST_HOST_KEY_TYPE

      public static final String DEFAULT_TEST_HOST_KEY_TYPE
    • KEYPAIR_PROVIDER_HOLDER

      private static final AtomicReference<org.apache.sshd.common.keyprovider.KeyPairProvider> KEYPAIR_PROVIDER_HOLDER
    • PROVIDERS_MAP

      private static final Map<String, org.apache.sshd.common.keyprovider.FileKeyPairProvider> PROVIDERS_MAP
  • Constructor Details

    • CommonTestSupportUtils

      private CommonTestSupportUtils()
  • Method Details

    • getClassContainerLocationURI

      public static URI getClassContainerLocationURI(Class<?> clazz) throws URISyntaxException
      Parameters:
      clazz - A Class object
      Returns:
      A URI to the location of the class bytes container - e.g., the root folder, the containing JAR, etc.. Returns null if location could not be resolved
      Throws:
      URISyntaxException - if location is not a valid URI
      See Also:
    • getClassContainerLocationURL

      public static URL getClassContainerLocationURL(Class<?> clazz)
      Parameters:
      clazz - A Class object
      Returns:
      A URL to the location of the class bytes container - e.g., the root folder, the containing JAR, etc.. Returns null if location could not be resolved
    • getURLSource

      public static String getURLSource(URI uri)
      Parameters:
      uri - The URI value - ignored if null
      Returns:
      The URI(s) source path where JAR_URL_PREFIX and any sub-resource are stripped
      See Also:
    • getURLSource

      public static String getURLSource(URL url)
      Parameters:
      url - The URL value - ignored if null
      Returns:
      The URL(s) source path where JAR_URL_PREFIX and any sub-resource are stripped
      See Also:
    • getURLSource

      public static String getURLSource(String externalForm)
      Parameters:
      externalForm - The URL.toExternalForm() string - ignored if null/empty
      Returns:
      The URL(s) source path where JAR_URL_PREFIX and any sub-resource are stripped
    • adjustURLPathValue

      public static String adjustURLPathValue(URL url)
      Parameters:
      url - A URL - ignored if null
      Returns:
      The path after stripping any trailing '/' provided the path is not '/' itself
      See Also:
    • adjustURLPathValue

      public static String adjustURLPathValue(String path)
      Parameters:
      path - A URL path value - ignored if null/empty
      Returns:
      The path after stripping any trailing '/' provided the path is not '/' itself
    • stripJarURLPrefix

      public static String stripJarURLPrefix(String externalForm)
    • getClassBytesURL

      public static URL getClassBytesURL(Class<?> clazz)
      Parameters:
      clazz - The request Class
      Returns:
      A URL to the location of the .class file - null if location could not be resolved
    • getClassBytesResourceName

      public static String getClassBytesResourceName(Class<?> clazz)
    • getClassBytesResourceName

      public static String getClassBytesResourceName(String name)
      Parameters:
      name - The fully qualified class name - ignored if null/empty
      Returns:
      The relative path of the class file byte-code resource
    • resolve

      public static Path resolve(Path root, String... children)
    • resolve

      public static Path resolve(Path root, Collection<String> children)
    • detectTargetFolder

      public static Path detectTargetFolder(Class<?> anchor)
      Parameters:
      anchor - An anchor Class whose container we want to use as the starting point for the "target" folder lookup up the hierarchy
      Returns:
      The "target" folder - null if not found
      See Also:
    • getClassContainerLocationPath

      public static Path getClassContainerLocationPath(Class<?> clazz) throws IllegalArgumentException
      Parameters:
      clazz - A Class object
      Returns:
      A Path of the location of the class bytes container - e.g., the root folder, the containing JAR, etc.. Returns null if location could not be resolved
      Throws:
      IllegalArgumentException - If location is not a valid Path location
      See Also:
    • toPathSource

      public static Path toPathSource(URL url) throws MalformedURLException
      Converts a URL that may refer to an internal resource to a Path representing is "source" container (e.g., if it is a resource in a JAR, then the result is the JAR's path)
      Parameters:
      url - The URL - ignored if null
      Returns:
      The matching Path
      Throws:
      MalformedURLException - If source URL does not refer to a file location
      See Also:
    • toPathSource

      public static Path toPathSource(URI uri) throws MalformedURLException
      Converts a URI that may refer to an internal resource to a Path representing is "source" container (e.g., if it is a resource in a JAR, then the result is the JAR's path)
      Parameters:
      uri - The URI - ignored if null
      Returns:
      The matching Path
      Throws:
      MalformedURLException - If source URI does not refer to a file location
      See Also:
    • detectTargetFolder

      public static Path detectTargetFolder(Path anchorFile)
      Parameters:
      anchorFile - An anchor Path we want to use as the starting point for the "target" or "build" folder lookup up the hierarchy
      Returns:
      The "target" folder - null if not found
    • generateKeyPair

      public static KeyPair generateKeyPair(String algorithm, int keySize) throws GeneralSecurityException
      Throws:
      GeneralSecurityException
    • createTestHostKeyProvider

      public static org.apache.sshd.common.keyprovider.KeyPairProvider createTestHostKeyProvider(Class<?> anchor)
    • createTestHostKeyProvider

      public static org.apache.sshd.common.keyprovider.KeyPairProvider createTestHostKeyProvider(Path path)
    • getFirstKeyPair

      public static KeyPair getFirstKeyPair(org.apache.sshd.common.keyprovider.KeyPairProviderHolder holder)
    • getFirstKeyPair

      public static KeyPair getFirstKeyPair(org.apache.sshd.common.keyprovider.KeyIdentityProvider provider)
    • getFile

      private static Path getFile(String resource)
    • createTestKeyPairProvider

      public static org.apache.sshd.common.keyprovider.FileKeyPairProvider createTestKeyPairProvider(String resource)
    • validateKeyPairProvider

      public static <P extends org.apache.sshd.common.keyprovider.KeyIdentityProvider> P validateKeyPairProvider(P provider)