diff --git a/api/build.gradle b/api/build.gradle
index a254b5f5..87e5f49a 100644
--- a/api/build.gradle
+++ b/api/build.gradle
@@ -18,6 +18,10 @@ android {
abortOnError false
}
+ sourceSets {
+ androidTest.assets.srcDirs += files("$projectDir/androidTest/assets".toString())
+ }
+
buildTypes {
release {
minifyEnabled true
@@ -48,6 +52,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
diff --git a/api/src/androidTest/assets/subscriptions.opml b/api/src/androidTest/assets/subscriptions.opml
new file mode 100755
index 00000000..f33900ca
--- /dev/null
+++ b/api/src/androidTest/assets/subscriptions.opml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/api/src/androidTest/java/com/readrops/api/OPMLParserTest.kt b/api/src/androidTest/java/com/readrops/api/OPMLParserTest.kt
new file mode 100644
index 00000000..27b5a232
--- /dev/null
+++ b/api/src/androidTest/java/com/readrops/api/OPMLParserTest.kt
@@ -0,0 +1,44 @@
+package com.readrops.api
+
+import android.content.Context
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.platform.app.InstrumentationRegistry
+import com.readrops.api.opml.OPMLParser
+import com.readrops.db.entities.Feed
+import com.readrops.db.entities.Folder
+import io.reactivex.schedulers.Schedulers
+import junit.framework.TestCase.assertEquals
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class OPMLParserTest {
+
+ private val context: Context = InstrumentationRegistry.getInstrumentation().context
+
+ @Test
+ fun readOpmlTest() {
+ val stream = context.resources.assets.open("subscriptions.opml")
+
+ var foldersAndFeeds: Map>? = null
+
+ OPMLParser.read(stream)
+ .observeOn(Schedulers.trampoline())
+ .subscribeOn(Schedulers.trampoline())
+ .subscribe { result -> foldersAndFeeds = result }
+
+ assertEquals(foldersAndFeeds?.size, 6)
+
+ assertEquals(foldersAndFeeds?.get(Folder("Folder 1"))?.size, 2)
+ assertEquals(foldersAndFeeds?.get(Folder("Subfolder 1"))?.size, 4)
+ assertEquals(foldersAndFeeds?.get(Folder("Subfolder 2"))?.size, 1)
+ assertEquals(foldersAndFeeds?.get(Folder("Sub subfolder 1"))?.size, 2)
+ assertEquals(foldersAndFeeds?.get(Folder("Sub subfolder 2"))?.size, 0)
+ assertEquals(foldersAndFeeds?.get(null)?.size, 2)
+ }
+
+ @Test
+ fun writeOpmlTest() {
+
+ }
+}
\ No newline at end of file