Class ClassLoaderLimiter.Builder
- Enclosing class:
- ClassLoaderLimiter
-
Method Summary
Modifier and TypeMethodDescriptionbuild()loadedAtMostOnceResource(String resourceFullName) Useful to check that a resource is being loaded only once, or never.neverLoadedClassName(String vetoedClassName) List a fully qualified class name as one that you don't expect to be loaded ever.neverLoadedResource(String resourceFullName) List a resource name as one that you don't expect to be loaded ever.neverLoadedRuntimeClassName(String vetoedClassName) List a fully qualified class name as one that you don't expect to be loaded at runtime.produceStackTraceOnLoad(String resourceFullName) When the specified resource is loaded, print a full stack trace on System out.traceAllResourceLoad(boolean enable) Simply log all resource loading events.
-
Method Details
-
neverLoadedResource
List a resource name as one that you don't expect to be loaded ever. If there is an attempt of loading the matched resource, a runtime exception will be thrown instead: useful for running integration tests to verify your assumptions.Limitations: if the resource is being loaded using the bootstrap classloader we can't check it; some frameworks explicitly request using the base classloader for resource loading (or even use the Filesystem API), so they can't be tested via this method.
- Parameters:
resourceFullName- the resource name- Returns:
- this, for method chaining.
-
neverLoadedClassName
List a fully qualified class name as one that you don't expect to be loaded ever. If there is an attempt of loading the matched class, a runtime exception will be thrown instead: useful for running integration tests to verify your assumptions.DO NOT list the name by doing using
literal.class.getName()as this will implicitly get you to load the class during the test, and produce a failure.Limitations: if the class is being loaded using the bootstrap classloader we can't check it. Most Quarkus extensions and frameworks will not use the bootstrap classloader, but some code could make use of it explicitly.
- Parameters:
vetoedClassName- the fully qualified class name- Returns:
- this, for method chaining.
-
neverLoadedRuntimeClassName
List a fully qualified class name as one that you don't expect to be loaded at runtime. If there is an attempt of loading the matched class, a runtime exception will be thrown instead: useful for running integration tests to verify your assumptions.DO NOT list the name by doing using
literal.class.getName()as this will implicitly get you to load the class during the test, and produce a failure.Limitations: if the class is being loaded using the bootstrap classloader we can't check it. Most Quarkus extensions and frameworks will not use the bootstrap classloader, but some code could make use of it explicitly.
- Parameters:
vetoedClassName- the fully qualified class name- Returns:
- this, for method chaining.
-
loadedAtMostOnceResource
Useful to check that a resource is being loaded only once, or never. If there is an attempt of loading the matched resource more than once, a runtime exception will be thrown instead: useful for running integration tests to verify your assumptions.Limitations: if the resource is being loaded using the bootstrap classloader we can't check it; some frameworks explicitly request using the base classloader for resource loading (or even use the Filesystem API), so they can't be tested via this method. Additionally, some frameworks will load the same resource but in different Quarkus build phases (which map to different classloaders); such cases will count as multiple times so it might not be suited to test this way.
- Parameters:
resourceFullName- the resource name- Returns:
- this, for method chaining.
-
produceStackTraceOnLoad
When the specified resource is loaded, print a full stack trace on System out. This is not useful for testing, but handy to trace were a certain load is coming from, should you need to diagnose a failing expectation.- Parameters:
resourceFullName-- Returns:
- this, for method chaining.
-
traceAllResourceLoad
Simply log all resource loading events. Useful to get an idea of which resources are being loaded; Note it includes resources being used to load classes.- Parameters:
enable-- Returns:
- this, for method chaining.
-
build
-