Working Testconfiguration

master
Markus Kreth 7 years ago
parent 96f80af447
commit b2ca1903b8
  1. 31
      .settings/org.eclipse.wst.common.component
  2. 33
      pom.xml
  3. 11
      src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/VaadinClubhelperApplicationTests.java
  4. 57
      src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/tests/TestConfiguration.java
  5. 25
      src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/tests/VaadinClubhelperApplicationTests.java

@ -1,22 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> <?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="vaadin-clubhelper-0.0.2-SNAPSHOT">
<wb-module deploy-name="vaadin-clubhelper-0.0.1-SNAPSHOT">
<wb-resource deploy-path="/" source-path="/WebContent"/> <wb-resource deploy-path="/" source-path="/WebContent"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/> <wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-resources/gwt"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-resources/gwt"/>
<property name="context-root" value="vaadin-clubhelper"/> <property name="context-root" value="vaadin-clubhelper"/>
<property name="java-output-path" value="/vaadin-clubhelper/target/classes"/> <property name="java-output-path" value="/vaadin-clubhelper/target/classes"/>
</wb-module>
</wb-module>
</project-modules> </project-modules>

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?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"> <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> <modelVersion>4.0.0</modelVersion>
<groupId>de.kreth.vaadin.clubhelper</groupId> <groupId>de.kreth.vaadin.clubhelper</groupId>
@ -147,11 +149,24 @@
<artifactId>spring-security-test</artifactId> <artifactId>spring-security-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId> <artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>simple-jndi</groupId>
<artifactId>simple-jndi</artifactId>
<version>0.11.4.1</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>com.h2database</groupId> <groupId>com.h2database</groupId>
<artifactId>h2</artifactId> <artifactId>h2</artifactId>
@ -245,13 +260,13 @@
<gwtSdkFirstInClasspath>true</gwtSdkFirstInClasspath> <gwtSdkFirstInClasspath>true</gwtSdkFirstInClasspath>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<configuration> <configuration>
<release>${java.version}</release> <release>${java.version}</release>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.tomcat.maven</groupId> <groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId> <artifactId>tomcat7-maven-plugin</artifactId>
@ -262,7 +277,7 @@
<path>/vaadin-clubhelper##${project.version}</path> <path>/vaadin-clubhelper##${project.version}</path>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>

@ -1,11 +0,0 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper;
//@RunWith(SpringRunner.class)
//@SpringBootTest
public class VaadinClubhelperApplicationTests {
// @Test
public void contextLoads() {
}
}

@ -0,0 +1,57 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.tests;
import javax.persistence.EntityManager;
import org.hibernate.SessionFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Adress;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Attendance;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Contact;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.DeletedEntry;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.GroupDef;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Persongroup;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Relative;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Startpaesse;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.StartpassStartrechte;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Version;
@Configuration
public class TestConfiguration {
@Bean
public EntityManager getEntityManager() throws Exception {
// setup the session factory
org.hibernate.cfg.Configuration configuration = createConfig();
SessionFactory sessionFactory = configuration.buildSessionFactory();
return sessionFactory.openSession();
}
public org.hibernate.cfg.Configuration createConfig() {
org.hibernate.cfg.Configuration configuration = new org.hibernate.cfg.Configuration();
configuration.addAnnotatedClass(Adress.class);
configuration.addAnnotatedClass(Attendance.class);
configuration.addAnnotatedClass(Contact.class);
configuration.addAnnotatedClass(DeletedEntry.class);
configuration.addAnnotatedClass(GroupDef.class);
configuration.addAnnotatedClass(Person.class);
configuration.addAnnotatedClass(Persongroup.class);
configuration.addAnnotatedClass(Relative.class);
configuration.addAnnotatedClass(Startpaesse.class);
configuration.addAnnotatedClass(StartpassStartrechte.class);
configuration.addAnnotatedClass(Version.class);
configuration.addInputStream(getClass().getResourceAsStream("/schema/ClubEvent.hbm.xml"));
configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
configuration.setProperty("hibernate.connection.driver_class", "org.h2.Driver");
configuration.setProperty("hibernate.connection.url", "jdbc:h2:mem:test");
configuration.setProperty("hibernate.hbm2ddl.auto", "create");
return configuration;
}
}

@ -0,0 +1,25 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.tests;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.web.reactive.server.WebTestClient;
//@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureWebTestClient
//@SpringApplicationConfiguration(classes = VaadinClubhelperApplication.class)
//@WebAppConfiguration
public class VaadinClubhelperApplicationTests {
@Autowired
private WebTestClient webClient;
@Test
public void contextLoads() {
webClient.get().uri("/").exchange().expectStatus().isOk().expectBody(String.class).isEqualTo("Hello World");
}
}
Loading…
Cancel
Save