> type,
+ final Testcontainer testcontainer) throws NoSuchMethodException {
+ @SuppressWarnings("unchecked")
+ Class extends GenericContainer>> constructType = (testcontainer.type() == GenericContainer.class) ? type
+ : (Class extends GenericContainer>>) testcontainer.type();
+ if (constructType.isInterface()) {
+ throw new IllegalArgumentException(
+ String.format("Type %s is an interface and cannot be created.", constructType));
+ }
+ return constructType.getConstructor();
+ }
}
diff --git a/src/main/java/org/jboss/arquillian/testcontainers/api/Testcontainer.java b/src/main/java/org/jboss/arquillian/testcontainers/api/Testcontainer.java
index 2b7fa6e..a17dfa1 100644
--- a/src/main/java/org/jboss/arquillian/testcontainers/api/Testcontainer.java
+++ b/src/main/java/org/jboss/arquillian/testcontainers/api/Testcontainer.java
@@ -13,11 +13,11 @@
import java.lang.reflect.Field;
import java.lang.reflect.Parameter;
-import org.testcontainers.lifecycle.Startable;
+import org.testcontainers.containers.GenericContainer;
/**
* Used to annotate a field or parameter which must be an instance of a
- * {@link Startable}. A {@link DockerRequired} annotation must be present on the
+ * {@link GenericContainer}. A {@link DockerRequired} annotation must be present on the
* type to use Testcontainer injection.
*/
@Inherited
@@ -37,11 +37,11 @@
/**
* The type used to create the value for the field or parameter. The type must have a no-arg constructor.
*
- * If left as the default value, {@link Startable}, the type to construct is derived from the
+ * If left as the default value, {@link GenericContainer}, the type to construct is derived from the
* {@linkplain Field#getType() field} or {@linkplain Parameter#getType() parameter}.
*
*
* @return the type to construct
*/
- Class extends Startable> type() default Startable.class;
+ Class extends GenericContainer> type() default GenericContainer.class;
}