Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Junit 5 #245

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions onebusaway-gtfs-hibernate/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
*/
package org.onebusaway.gtfs.impl;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;

import java.io.IOException;
import java.io.StringReader;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.onebusaway.csv_entities.exceptions.CsvEntityIOException;
import org.onebusaway.gtfs.model.Agency;
import org.onebusaway.gtfs.model.AgencyAndId;
Expand All @@ -43,7 +43,7 @@ public class GtfsMappingTest {

private static GtfsReader _reader;

@Before
@BeforeEach
public void setup() throws IOException {

Configuration config = new Configuration();
Expand All @@ -57,7 +57,7 @@ public void setup() throws IOException {
_reader.setEntityStore(_dao);
}

@After
@AfterEach
public void teardown() {
if (_dao != null)
_dao.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
*/
package org.onebusaway.gtfs.impl;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
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.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.File;
import java.io.IOException;
Expand All @@ -30,9 +30,9 @@

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.onebusaway.gtfs.model.Agency;
import org.onebusaway.gtfs.model.AgencyAndId;
import org.onebusaway.gtfs.model.Route;
Expand All @@ -53,7 +53,7 @@ public class HibernateGtfsRelationalDaoImplCaltrainTest {

private static HibernateGtfsRelationalDaoImpl _dao;

@BeforeClass
@BeforeAll
public static void setup() throws IOException {

Configuration config = new Configuration();
Expand All @@ -70,7 +70,7 @@ public static void setup() throws IOException {
reader.run();
}

@AfterClass
@AfterAll
public static void teardown() {
_sessionFactory.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/
package org.onebusaway.gtfs.impl;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
import java.util.HashSet;
Expand All @@ -25,9 +25,9 @@

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.onebusaway.gtfs.model.AgencyAndId;
import org.onebusaway.gtfs.model.Stop;

Expand All @@ -37,7 +37,7 @@ public class HibernateGtfsRelationalDaoImplTest {

private static HibernateGtfsRelationalDaoImpl _dao;

@Before
@BeforeEach
public void setup() throws IOException {

Configuration config = new Configuration();
Expand All @@ -48,7 +48,7 @@ public void setup() throws IOException {
_dao.open();
}

@After
@AfterEach
public void teardown() {
if (_dao != null)
_dao.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
*/
package org.onebusaway.gtfs.impl;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.File;
import java.io.IOException;
import java.util.List;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.onebusaway.gtfs.model.AgencyAndId;
import org.onebusaway.gtfs.model.Frequency;
import org.onebusaway.gtfs.model.ServiceCalendar;
Expand All @@ -44,7 +44,7 @@ public class HibernateGtfsRelationalImplBartTest {

private static HibernateGtfsRelationalDaoImpl _dao;

@BeforeClass
@BeforeAll
public static void setup() throws IOException {

Configuration config = new Configuration();
Expand All @@ -61,7 +61,7 @@ public static void setup() throws IOException {
reader.run();
}

@AfterClass
@AfterAll
public static void teardown() {
_sessionFactory.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
*/
package org.onebusaway.gtfs.impl;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.io.File;
import java.io.IOException;
import java.util.List;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.onebusaway.gtfs.model.Agency;
import org.onebusaway.gtfs.model.AgencyAndId;
import org.onebusaway.gtfs.model.Route;
Expand All @@ -39,7 +39,7 @@ public class LongRouteDescriptionTest {

private static HibernateGtfsRelationalDaoImpl _dao;

@BeforeClass
@BeforeAll
public static void setup() throws IOException {

Configuration config = new Configuration();
Expand All @@ -62,7 +62,7 @@ public static void setup() throws IOException {
reader.run();
}

@AfterClass
@AfterAll
public static void teardown() {
_sessionFactory.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.onebusaway.gtfs.model.*;
import org.onebusaway.gtfs.serialization.GtfsReader;

import java.io.File;
import java.io.IOException;
import java.util.List;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class VehicleTest {
private static SessionFactory _sessionFactory;
Expand All @@ -36,7 +36,7 @@ public class VehicleTest {

private static HibernateGtfsRelationalDaoImpl _dao;

@BeforeClass
@BeforeAll
public static void setup() throws IOException {

Configuration config = new Configuration();
Expand All @@ -59,7 +59,7 @@ public static void setup() throws IOException {
reader.run();
}

@AfterClass
@AfterAll
public static void teardown() {
_sessionFactory.close();
}
Expand Down
5 changes: 0 additions & 5 deletions onebusaway-gtfs-merge/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
*/
package org.onebusaway.gtfs_merge;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.onebusaway.gtfs.impl.GtfsRelationalDaoImpl;
import org.onebusaway.gtfs.model.*;
import org.onebusaway.gtfs.serialization.GtfsReader;
Expand Down Expand Up @@ -56,7 +56,7 @@ public class GtfsMergerTest {

private GtfsMerger _merger;

@Before
@BeforeEach
public void before() throws IOException {
_oldGtfs = MockGtfs.create();
_newGtfs = MockGtfs.create();
Expand All @@ -65,7 +65,7 @@ public void before() throws IOException {
_merger = new GtfsMerger();
}

@After
@AfterEach
public void after() {

}
Expand Down Expand Up @@ -224,7 +224,7 @@ public void testAgencyPreference() throws IOException {
pugetStopFound = true;
}
}
assertTrue("expect a puget stop", pugetStopFound);
assertTrue(pugetStopFound, "expect a puget stop");
}

@Test
Expand Down Expand Up @@ -352,7 +352,7 @@ public void testRenameStrategy() throws IOException {

assertTrue("b-sid0".matches("[a-j]-.*"));

assertTrue("expect a puget stop", pugetStopFound);
assertTrue(pugetStopFound, "expect a puget stop");
}

// tests stop, location, and location group
Expand Down Expand Up @@ -454,10 +454,11 @@ public void testStopTimeProxies() throws IOException {
boolean hasST = st.getStop()!=null;
boolean hasLoc = st.getLocation()!=null;
boolean hasLocGroup = st.getLocationGroup()!=null;
assertTrue("multiple ids found for stop: "+st.getStop()+
assertTrue( !(hasST & hasLoc | hasST && hasLocGroup | hasLoc & hasLocGroup),
"multiple ids found for stop: "+st.getStop()+
", location_id: "+st.getLocation()+
", location_id: "+st.getLocationGroup(),
!(hasST & hasLoc | hasST && hasLocGroup | hasLoc & hasLocGroup));
", location_id: "+st.getLocationGroup()
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/
package org.onebusaway.gtfs_merge;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.onebusaway.gtfs.impl.FileSupport;
import org.onebusaway.gtfs.impl.ZipHandler;

Expand All @@ -29,7 +29,7 @@
import java.util.List;
import java.util.stream.Collectors;

import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* Test appending metadata inputs as part of merge.
Expand All @@ -40,12 +40,12 @@ public class MergeExpectedFilesTest {

private FileSupport _support = new FileSupport();

@Before
@BeforeEach
public void before() throws IOException {
_merger = new GtfsMerger();
}

@After
@AfterEach
public void after() {
_support.cleanup();
}
Expand All @@ -68,8 +68,8 @@ public void testDirectoryMerge() throws Exception {
String modLocation = gtfsDirectory.getAbsolutePath() + File.separator + "modifications.txt";
File expectedFile = new File(modLocation);
// verify modifications.txt is there!!!!
assertTrue("expected modifications.txt to be present!", expectedFile.exists());
assertTrue("expected modifications.txt to be a file!", expectedFile.isFile());
assertTrue(expectedFile.exists(), "expected modifications.txt to be present!");
assertTrue(expectedFile.isFile(), "expected modifications.txt to be a file!");
StringBuffer sb = new StringBuffer();
BufferedReader br = new BufferedReader(new FileReader(expectedFile));
sb.append(br.lines().collect(Collectors.joining(System.lineSeparator())));
Expand Down
Loading
Loading