All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.bazhenov.docker.AfterContainerStart Maven / Gradle / Ivy

There is a newer version: 1.6.2
Show newest version
package me.bazhenov.docker;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * Methods annotated with {@link AfterContainerStart} are called by {@link DockerTestNgListener} after
 * all containers are started.
 *
 * All parameters of those methids should be of type {@code int} and annotated with {@link ContainerPort} annotation.
 * 

* Typical usage: *

 *   @Container(name="mysql", publish=@Port(3306), image=...)
 *   @Listeners(DockerTestNgListener.class)
 *   @Listeners(DockerTestNgListener.class)
 *   class SampleTest {
 *
 *     private int mysqlPort;
 *
 *     @AfterContainerStart
 *     public void initDocker(@ContainerPort(name="mysql", port=3306) int mysqlPort) {
 *       this.mysqlPort = mysqlPort;
 *     }
 *
 *     @Test
 *     public void testMysql() {
 *       String url = "jdbc:mysql://localhost:" + mysqlPort;
 *       ...
 *     }
 *   }
 * 
*/ @SuppressWarnings("WeakerAccess") @Retention(RUNTIME) @Target(METHOD) public @interface AfterContainerStart { }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy