use of org.kiwix.kiwixmobile.ZimContentProvider in project kiwix-android by kiwix.
the class NetworkTest method setUp.
@Before
public void setUp() {
TestComponent component = DaggerTestComponent.builder().applicationModule(new ApplicationModule((KiwixApplication) getInstrumentation().getTargetContext().getApplicationContext())).build();
((KiwixApplication) getInstrumentation().getTargetContext().getApplicationContext()).setApplicationComponent(component);
new ZimContentProvider().setupDagger();
component.inject(this);
InputStream library = NetworkTest.class.getClassLoader().getResourceAsStream("library.xml");
InputStream metalinks = NetworkTest.class.getClassLoader().getResourceAsStream("test.zim.meta4");
InputStream testzim = NetworkTest.class.getClassLoader().getResourceAsStream("testzim.zim");
try {
byte[] libraryBytes = IOUtils.toByteArray(library);
mockWebServer.enqueue(new MockResponse().setBody(new String(libraryBytes)));
byte[] metalinkBytes = IOUtils.toByteArray(metalinks);
mockWebServer.enqueue(new MockResponse().setBody(new String(metalinkBytes)));
mockWebServer.enqueue(new MockResponse().setHeader("Content-Length", 357269));
Buffer buffer = new Buffer();
buffer.write(IOUtils.toByteArray(testzim));
buffer.close();
mockWebServer.enqueue(new MockResponse().setBody(buffer));
} catch (IOException e) {
e.printStackTrace();
}
}
Aggregations