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

Test resource fixes #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
26 changes: 12 additions & 14 deletions src/test/java/com/kurtraschke/nyctrtproxy/tests/RtTestRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,13 @@
*/
package com.kurtraschke.nyctrtproxy.tests;

import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.google.inject.Scopes;
import com.google.inject.*;
import com.google.inject.name.Names;
import com.google.protobuf.ExtensionRegistry;
import com.google.transit.realtime.GtfsRealtime;
import com.google.transit.realtime.GtfsRealtimeNYCT;
import com.kurtraschke.nyctrtproxy.services.ActivatedTripMatcher;
import com.kurtraschke.nyctrtproxy.services.CloudwatchProxyDataListener;
import com.kurtraschke.nyctrtproxy.services.GtfsDataServiceProvider;
import com.kurtraschke.nyctrtproxy.services.LazyTripMatcher;
import com.kurtraschke.nyctrtproxy.services.ProxyDataListener;
import com.kurtraschke.nyctrtproxy.services.TripActivator;
import com.kurtraschke.nyctrtproxy.services.TripMatcher;
import com.kurtraschke.nyctrtproxy.services.TripUpdateProcessor;
import com.kurtraschke.nyctrtproxy.services.*;
import junit.framework.TestCase;
import org.junit.Before;
import org.onebusaway.gtfs.model.AgencyAndId;
Expand All @@ -42,6 +31,7 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;

public abstract class RtTestRunner {

Expand Down Expand Up @@ -87,7 +77,7 @@ protected static Module getTestModule(String gtfsPath, String agencyId, boolean
@Override protected void configure() {
bind(File.class)
.annotatedWith(Names.named("NYCT.gtfsPath"))
.toInstance(new File(TestCase.class.getResource("/" + gtfsPath).getFile()));
.toInstance(getTestResource(gtfsPath));

bind(GtfsDataService.class)
.toProvider(GtfsDataServiceProvider.class)
Expand Down Expand Up @@ -121,6 +111,14 @@ protected static Module getTestModule(String gtfsPath, String agencyId, boolean
};
}

private static File getTestResource(String resourcePath) {
try {
return new File(TestCase.class.getResource("/" + resourcePath).toURI().getPath());
} catch (URISyntaxException e) {
return null;
}
}

protected void setAgencyId(String agencyId) {
_agencyId = agencyId;
}
Expand Down