package net.sf.jabref;

import static org.junit.Assert.assertEquals;

import java.io.File;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class JabRefPreferencesTest {

    private JabRefPreferences prefs;

    private JabRefPreferences backup;


    @Before
    public void setUp() {
        prefs = JabRefPreferences.getInstance();
        backup = prefs;
    }

    @Test
    public void testPreferencesImport() throws JabRefException {
        // the primary sort field has been changed to "editor" in this case
        File importFile = new File("src/test/resources/net/sf/jabref/customPreferences.xml");

        prefs.importPreferences(importFile.getAbsolutePath());

        String expected = "editor";
        String actual = prefs.get(JabRefPreferences.SAVE_PRIMARY_SORT_FIELD);

        assertEquals(expected, actual);
    }

    @After
    public void tearDown() {
        //clean up preferences to default state
        prefs.overwritePreferences(backup);
    }

}

@@ -83,16 +83,58 @@
 io.File;
+%0Aimport java.nio.charset.StandardCharsets;
 %0A%0Aimport
@@ -902,24 +902,249 @@
 al);%0A    %7D%0A%0A
+    @Test%0A    public void getDefaultEncodingReturnsPreviouslyStoredEncoding() %7B%0A        prefs.setDefaultEncoding(StandardCharsets.UTF_16BE);%0A        assertEquals(StandardCharsets.UTF_16BE, prefs.getDefaultEncoding());%0A    %7D%0A%0A
     @After%0A 

Add test for getting/setting default encoding in preferences