Switched junit to jupiter

master
Markus Kreth 7 years ago
parent 2b6d006fd0
commit 3664e82631
  1. 6
      pom.xml
  2. 18
      src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/AbstractDatabaseTest.java
  3. 22
      src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDaoTest.java
  4. 12
      src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDataTest.java
  5. 8
      src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDaoTest.java
  6. 5
      src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/CompetitionDetailsTest.java
  7. 16
      src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/CompetitionGroupTest.java
  8. 3
      src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/tests/VaadinClubhelperApplicationTests.java

@ -184,12 +184,6 @@
<version>${selenium.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>simple-jndi</groupId>

@ -3,7 +3,7 @@ package de.kreth.vaadin.clubhelper.vaadinclubhelper.dao;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Adress;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Attendance;
@ -22,7 +22,7 @@ public abstract class AbstractDatabaseTest {
protected SessionFactory sessionFactory;
protected Session session;
@Before
@BeforeEach
public void setUp() throws Exception {
// setup the session factory
@ -46,15 +46,11 @@ public abstract class AbstractDatabaseTest {
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.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;
}

@ -1,14 +1,14 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.dao;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.List;
import org.hibernate.query.Query;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@ -21,7 +21,7 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEventBuilder;
@RunWith(SpringRunner.class)
@DataJpaTest
@EnableAutoConfiguration
@Ignore
@Disabled
public class ClubEventDaoTest extends AbstractDatabaseTest {
@Autowired
@ -34,20 +34,16 @@ public class ClubEventDaoTest extends AbstractDatabaseTest {
public void storeEvent() {
dao.save(creteEvent());
Query<ClubEvent> query = session.createNamedQuery("ClubEvent.findAll",
ClubEvent.class);
Query<ClubEvent> query = session.createNamedQuery("ClubEvent.findAll", ClubEvent.class);
List<ClubEvent> result = query.list();
assertEquals(1, result.size());
}
private ClubEvent creteEvent() {
ClubEvent ev = ClubEventBuilder.builder().withId("id").withAllDay(true)
.withCaption("caption").withDescription("description")
.withStart(ZonedDateTime.of(2018, 8, 13, 0, 0, 0, 0,
ZoneId.systemDefault()))
.withEnd(ZonedDateTime.of(2018, 8, 13, 0, 0, 0, 0,
ZoneId.systemDefault()))
.withiCalUID("iCalUID")
ClubEvent ev = ClubEventBuilder.builder().withId("id").withAllDay(true).withCaption("caption")
.withDescription("description")
.withStart(ZonedDateTime.of(2018, 8, 13, 0, 0, 0, 0, ZoneId.systemDefault()))
.withEnd(ZonedDateTime.of(2018, 8, 13, 0, 0, 0, 0, ZoneId.systemDefault())).withiCalUID("iCalUID")
.withOrganizerDisplayName("organizerDisplayName").build();
return ev;
}

@ -1,9 +1,9 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.dao;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.sql.Connection;
import java.sql.ResultSet;
@ -22,7 +22,7 @@ import org.hibernate.IdentifierLoadAccess;
import org.hibernate.Transaction;
import org.hibernate.jdbc.Work;
import org.hibernate.query.Query;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEventBuilder;
@ -58,7 +58,7 @@ public class ClubEventDataTest extends AbstractDatabaseTest {
}
tx.commit();
for (Person p : inserted) {
assertTrue("not saved: " + p, p.getId() > 0);
assertTrue(p.getId() > 0, "not saved: " + p);
}
return inserted;
}

@ -1,14 +1,14 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.dao;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.time.LocalDate;
import java.util.List;
import org.hibernate.Transaction;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person;
@ -18,7 +18,7 @@ public class PersonDaoTest extends AbstractDatabaseTest {
private Person person;
@Override
@Before
@BeforeEach
public void setUp() throws Exception {
super.setUp();
personDao = new PersonDaoImpl();

@ -1,8 +1,8 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.data;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class CompetitionDetailsTest extends AbstractCompetitionDataTests {
@ -17,6 +17,5 @@ public class CompetitionDetailsTest extends AbstractCompetitionDataTests {
detail.parseCompetitionGroups(getGroupTable2());
assertEquals(6, detail.getCpGroups().size());
}
}

@ -1,14 +1,16 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.data;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
@Ignore
@Disabled
public class CompetitionGroupTest {
@Test
@ -86,7 +88,7 @@ public class CompetitionGroupTest {
@Test
public void testBirthYearTest() {
CompetitionGroup g = new CompetitionGroup(2000, 2009);
for (int i = 2000; i<=2009; i++) {
for (int i = 2000; i <= 2009; i++) {
assertTrue(g.isBirthyearInGroup(i));
}
assertFalse(g.isBirthyearInGroup(0));
@ -105,9 +107,9 @@ public class CompetitionGroupTest {
Pattern pattern = Pattern.compile("\\d{2,4}");
String twoYears = "text 1999 bis 2009 text";
Matcher matcher = pattern.matcher(twoYears);
assertTrue("didnt find first year", matcher.find());
assertTrue(matcher.find(), "didnt find first year");
assertEquals("1999", matcher.group());
assertTrue("didnt find second year", matcher.find());
assertTrue(matcher.find(), "didnt find second year");
assertEquals("2009", matcher.group());
}
}

@ -25,8 +25,6 @@ import org.springframework.boot.web.server.LocalServerPort;
public class VaadinClubhelperApplicationTests {
private static ChromeOptions options;
// @Autowired
// private WebTestClient webClient;
@LocalServerPort
int port;
@ -41,7 +39,6 @@ public class VaadinClubhelperApplicationTests {
options = new ChromeOptions();
options.setHeadless(!GraphicsEnvironment.isHeadless());
// options.setPageLoadStrategy(PageLoadStrategy.EAGER);
}

Loading…
Cancel
Save