finished additional repos test

This commit is contained in:
Dimitri Rusin 2018-08-08 12:43:52 +00:00
parent 59d0f7d6be
commit dc19b11ae1

View File

@ -38,6 +38,7 @@ import org.robolectric.annotation.Config;
import java.util.Date; import java.util.Date;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.io.FileOutputStream;
import java.util.Arrays; import java.util.Arrays;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -189,45 +190,50 @@ public class RepoProviderTest extends FDroidProviderTest {
7) pubkey 7) pubkey
*/ */
String packageName = context.getPackageName(); String packageName = context.getPackageName();
FileOutputStream outputStream = new FileOutputStream("/oem/etc/" + packageName + "/additional_repos.xml"); String filepath = "/oem/etc/" + packageName + "/additional_repos.xml";
outputStream.write(("<?xml version=\"1.0\" encoding=\"utf-8\"?> try {
<resources> FileOutputStream outputStream = new FileOutputStream(filepath);
<string-array name=\"default_repos\"> outputStream.write(("<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ "<resources>"
+ "<string-array name=\"default_repos\">"
+"<!-- name -->"
+"<item>oem0Name</item>"
+"<!-- address -->"
+"<item>https://www.oem0.com/yeah/repo</item>"
+"<!-- description -->"
+"<item>I'm the first oem repo.</item>"
+"<!-- version -->"
+"<item>22</item>"
+"<!-- enabled -->"
+"<item>1</item>"
+"<!-- push requests -->"
+"<item>ignore</item>"
+"<!-- pubkey -->"
+"<item>fffff2313aaaaabcccc111</item>"
<!-- name --> +"<!-- name -->"
<item>oem0Name</item> +"<item>oem1MyNameIs</item>"
<!-- address --> +"<!-- address -->"
<item>https://www.oem0.com/yeah/repo</item> +"<item>https://www.mynameis.com/rapper/repo</item>"
<!-- description --> +"<!-- description -->"
<item>I'm the first oem repo.</item> +"<item>Who is the first repo?</item>"
<!-- version --> +"<!-- version -->"
<item>22</item> +"<item>22</item>"
<!-- enabled --> +"<!-- enabled -->"
<item>1</item> +"<item>0</item>"
<!-- push requests --> +"<!-- push requests -->"
<item>ignore</item> +"<item>ignore</item>"
<!-- pubkey --> +"<!-- pubkey -->"
<item>fffff2313aaaaabcccc111</item> +"<item>ddddddd2313aaaaabcccc111</item>"
+"</string-array>"
<!-- name --> +"</resources>"
<item>oem1MyNameIs</item> ).getBytes());
<!-- address --> outputStream.close();
<item>https://www.mynameis.com/rapper/repo</item> } catch (Exception e) {
<!-- description --> Utils.debugLog("RepoProviderTest::canAddAdditionalRepos()", "failed creating/writing file " + filepath);
<item>Who is the first repo?</item> Utils.debugLog("RepoProviderTest::canAddAdditionalRepos()", e.getMessage());
<!-- version --> return;
<item>22</item> }
<!-- enabled -->
<item>0</item>
<!-- push requests -->
<item>ignore</item>
<!-- pubkey -->
<item>ddddddd2313aaaaabcccc111</item>
</string-array>
</resources>"
).getBytes());
outputStream.close();
// Load the actual repos // Load the actual repos
List<String> defaultRepos = DBHelper.loadDefaultRepos(context); List<String> defaultRepos = DBHelper.loadDefaultRepos(context);