Class URLGenerator

java.lang.Object
de.cuioss.test.generator.impl.URLGenerator
All Implemented Interfaces:
TypedGenerator<URL>

public class URLGenerator extends Object implements TypedGenerator<URL>
Generates valid URL instances from a predefined set of well-known websites.

URL characteristics:

  • All URLs are valid and accessible
  • Mix of HTTP and HTTPS protocols
  • Includes popular tech, development, and reference sites

Available domains include:

  • Development: github.com, gitlab.com, sonarcloud.io
  • Technology: heise.de, stackoverflow.com
  • Reference: wikipedia.org, mozilla.org
  • Corporate: microsoft.com, apple.com, x-tention.com

Example usage:

 var generator = new URLGenerator();
 URL url = generator.next(); // Returns a random URL from the predefined set
 

Note: While the generator ensures syntactically correct URLs, it does not guarantee that the URLs are currently reachable.

Author:
Oliver Wolff
See Also:
  • Constructor Details

  • Method Details

    • next

      public URL next()
      Description copied from interface: TypedGenerator
      Generates the next instance based on the generator's configuration. Implementations must ensure thread-safety.
      Specified by:
      next in interface TypedGenerator<URL>
      Returns:
      A newly created instance. May be null if the generator explicitly supports null value generation.
    • getType

      public Class<URL> getType()
      Description copied from interface: TypedGenerator
      Provides type information about what kind of objects this generator creates. The default implementation uses the first non-null result from TypedGenerator.next() to determine the type.

      Note: If your generator may return null values or the generated type differs from the actual instance type, you should override this method.

      Specified by:
      getType in interface TypedGenerator<URL>
      Returns:
      The class information indicating which type this generator is responsible for.