Annotation Interface GenerateDeployment
Used to identify a method as a method which creates a deployment. The method must be static and must have a return
type of
void.
The method must accept a parameter of a known Archive type, see the deployment types
for details. An additional parameter of TestInfo may also be included on the method,
but is not required.
The name of the deployment will be the name of the test.
A GenerateDeployment method cannot be present on the same test that includes a DeploymentProducer.
These are mutually exclusive deployment descriptors.
Examples
// Simple case - infer WAR from parameter type
@GenerateDeployment
public static void deployment(WebArchive war) {
war.addClasses(TestServlet.class);
}
// Explicit JAR type
@GenerateDeployment(DeploymentType.JAR)
public static void deployment(JavaArchive jar) {
jar.addClasses(MyClass.class);
}
// With TestInfo parameter
@GenerateDeployment
public static void deployment(WebArchive war, TestInfo testInfo) {
if (testInfo.getTags().contains("cdi")) {
war.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
.addClass(CdiResource.class)
}
war.addClasses(TestServlet.class);
}
// Building an EAR with modules
@GenerateDeployment(DeploymentType.EAR)
public static void deployment(EnterpriseArchive ear) {
ear.addAsModule(Deployments.war("myapp").addClasses(TestServlet.class));
ear.addAsLibrary(Deployments.jar("mylib").addClasses(CommonUtils.class));
}
- Author:
- James R. Perkins
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe supported deployment types. -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionIndicates the type of the deployment to be produced if the deployment method has avoidreturn type.
-
Element Details
-
value
Indicates the type of the deployment to be produced if the deployment method has avoidreturn type.- Returns:
- the type of the deployment
- Default:
INFER
-