File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed 
main/java/org/testcontainers/kafka 
test/java/org/testcontainers/kafka Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 1212/** 
1313 * Testcontainers implementation for Apache Kafka. 
1414 * <p> 
15-  * Supported image: {@code apache/kafka} 
15+  * Supported image: {@code apache/kafka}, {@code apache/kafka-native}  
1616 * <p> 
1717 * Exposed ports: 9092 
1818 */ 
1919public  class  KafkaContainer  extends  GenericContainer <KafkaContainer > {
2020
2121    private  static  final  DockerImageName  DEFAULT_IMAGE_NAME  = DockerImageName .parse ("apache/kafka" );
2222
23+     private  static  final  DockerImageName  APACHE_KAFKA_NATIVE_IMAGE_NAME  = DockerImageName .parse ("apache/kafka-native" );
24+ 
2325    private  static  final  int  KAFKA_PORT  = 9092 ;
2426
2527    private  static  final  String  DEFAULT_INTERNAL_TOPIC_RF  = "1" ;
@@ -34,7 +36,7 @@ public KafkaContainer(String imageName) {
3436
3537    public  KafkaContainer (DockerImageName  dockerImageName ) {
3638        super (dockerImageName );
37-         dockerImageName .assertCompatibleWith (DEFAULT_IMAGE_NAME );
39+         dockerImageName .assertCompatibleWith (DEFAULT_IMAGE_NAME ,  APACHE_KAFKA_NATIVE_IMAGE_NAME );
3840
3941        withExposedPorts (KAFKA_PORT );
4042        withEnv ("CLUSTER_ID" , DEFAULT_CLUSTER_ID );
Original file line number Diff line number Diff line change 11package  org .testcontainers .kafka ;
22
33import  org .junit .Test ;
4+ import  org .junit .runner .RunWith ;
5+ import  org .junit .runners .Parameterized ;
46import  org .testcontainers .AbstractKafka ;
57
8+ @ RunWith (Parameterized .class )
69public  class  KafkaContainerTest  extends  AbstractKafka  {
710
11+     @ Parameterized .Parameters (name  = "{0}" )
12+     public  static  String [] params () {
13+         return  new  String [] { "apache/kafka:3.7.0" , "apache/kafka-native:3.8.0-rc3"  };
14+     }
15+ 
16+     @ Parameterized .Parameter 
17+     public  String  imageName ;
18+ 
819    @ Test 
920    public  void  testUsage () throws  Exception  {
10-         try  (KafkaContainer  kafka  = new  KafkaContainer ("apache/kafka:3.7.0" )) {
21+         try  (KafkaContainer  kafka  = new  KafkaContainer (imageName )) {
1122            kafka .start ();
1223            testKafkaFunctionality (kafka .getBootstrapServers ());
1324        }
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments