Skip to content

Commit

Permalink
Adding a spring boot 2 test. At the moment, it only tests successfull…
Browse files Browse the repository at this point in the history
… startup. Let's see what comes next.
  • Loading branch information
BGehrels committed Jul 18, 2018
1 parent c2ba401 commit 35f54ce
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 0 deletions.
86 changes: 86 additions & 0 deletions nakadi-producer-starter-spring-boot-2-test/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>nakadi-producer-starter-spring-boot-2-test</artifactId>
<groupId>org.zalando</groupId>


<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
</parent>

<dependencies>
<dependency>
<groupId>org.zalando</groupId>
<artifactId>nakadi-producer-spring-boot-starter</artifactId>
<version>4.1.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.zalando.stups</groupId>
<artifactId>tokens</artifactId>
<version>0.12.0-beta-2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<version>2.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>com.opentable.components</groupId>
<artifactId>otj-pg-embedded</artifactId>
<version>0.12.0</version>
<exclusions>
<exclusion>
<artifactId>postgresql</artifactId>
<groupId>postgresql</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.stefanbirkner</groupId>
<artifactId>system-rules</artifactId>
<version>1.18.0</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.zalando.nakadiproducer.tests;

import com.opentable.db.postgres.embedded.EmbeddedPostgres;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.zalando.nakadiproducer.EnableNakadiProducer;

import javax.sql.DataSource;

import java.io.IOException;

@EnableAutoConfiguration
@EnableNakadiProducer
public class Application {

public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}

@Bean
@Primary
public DataSource dataSource() throws IOException {
return embeddedPostgres().getPostgresDatabase();
}

@Bean
public EmbeddedPostgres embeddedPostgres() throws IOException {
return EmbeddedPostgres.start();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nakadi-producer.access-token-uri: http://localhost:1234
nakadi-producer.nakadi-base-uri: https://nakadi.example.org:5432
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.zalando.nakadiproducer.tests;

import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.contrib.java.lang.system.EnvironmentVariables;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.File;

@RunWith(SpringRunner.class)
@SpringBootTest(
classes = Application.class,
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
)
public class ApplicationIT {

@ClassRule
public static final EnvironmentVariables environmentVariables
= new EnvironmentVariables();

@BeforeClass
public static void fakeCredentialsDir() {
environmentVariables.set("CREDENTIALS_DIR", new File("src/main/test/tokens").getAbsolutePath());
}

@Test
public void foo() {
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
my fake token
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bearer
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<modules>
<module>nakadi-producer</module>
<module>nakadi-producer-spring-boot-starter</module>
<module>nakadi-producer-starter-spring-boot-2-test</module>
</modules>

<licenses>
Expand Down

0 comments on commit 35f54ce

Please sign in to comment.