Search in sources :

Example 6 with Profile

use of jmri.profile.Profile in project JMRI by JMRI.

the class JmriJTablePersistenceManagerTest method testInitialize.

/**
     * Test of initialize method, of class JmriJTablePersistenceManager.
     */
@Test
@Ignore
public void testInitialize() throws Exception {
    System.out.println("initialize");
    Profile profile = null;
    JmriJTablePersistenceManager instance = new JmriJTablePersistenceManager();
    instance.initialize(profile);
    // TODO review the generated test code and remove the default call to fail.
    fail("The test case is a prototype.");
}
Also used : Profile(jmri.profile.Profile) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 7 with Profile

use of jmri.profile.Profile in project JMRI by JMRI.

the class JmriJTablePersistenceManagerTest method testSavePreferences.

/**
     * Test of savePreferences method, of class JmriJTablePersistenceManager.
     */
@Test
@Ignore
public void testSavePreferences() {
    System.out.println("savePreferences");
    Profile profile = null;
    JmriJTablePersistenceManager instance = new JmriJTablePersistenceManager();
    instance.savePreferences(profile);
    // TODO review the generated test code and remove the default call to fail.
    fail("The test case is a prototype.");
}
Also used : Profile(jmri.profile.Profile) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 8 with Profile

use of jmri.profile.Profile in project JMRI by JMRI.

the class JmriConfigurationProviderTest method testGetConfigurationFragment.

public void testGetConfigurationFragment() throws IOException {
    String id = Long.toString((new Date()).getTime());
    String elementName = "test:testElement";
    String namespace = "test";
    Profile project = new Profile(this.getName(), id, new File(this.workspace.toFile(), id));
    AuxiliaryConfiguration config = JmriConfigurationProvider.getConfiguration(project);
    Element e = config.getConfigurationFragment(elementName, namespace, true);
    assertNull(e);
    e = document.createElementNS(namespace, elementName);
    config.putConfigurationFragment(e, true);
    FileUtil.delete(project.getPath());
}
Also used : AuxiliaryConfiguration(jmri.profile.AuxiliaryConfiguration) Element(org.w3c.dom.Element) File(java.io.File) Date(java.util.Date) Profile(jmri.profile.Profile)

Example 9 with Profile

use of jmri.profile.Profile in project JMRI by JMRI.

the class JmriPreferencesProviderTest method testGetPreferences.

/**
     * Test of getPreferences method, of class JmriPreferencesProvider.
     * @throws java.io.IOException
     */
public void testGetPreferences() throws IOException {
    String id = Long.toString((new Date()).getTime());
    Profile project = new Profile(this.getName(), id, new File(this.workspace.toFile(), id));
    Class<?> clazz = this.getClass();
    Preferences shared = JmriPreferencesProvider.getPreferences(project, clazz, true);
    Preferences privat = JmriPreferencesProvider.getPreferences(project, clazz, false);
    assertNotNull(shared);
    assertNotNull(privat);
    assertNotSame(shared, privat);
    try {
        assertEquals(shared.keys().length, 0);
    } catch (BackingStoreException ex) {
        assertNotNull(ex);
    }
    try {
        assertEquals(privat.keys().length, 0);
    } catch (BackingStoreException ex) {
        assertNotNull(ex);
    }
    FileUtil.delete(project.getPath());
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) Preferences(java.util.prefs.Preferences) File(java.io.File) Date(java.util.Date) Profile(jmri.profile.Profile)

Example 10 with Profile

use of jmri.profile.Profile in project JMRI by JMRI.

the class JmriPreferencesProviderTest method testIsFirstUse.

/**
     * Test of isFirstUse method, of class JmriPreferencesProvider.
     * @throws java.io.IOException
     */
public void testIsFirstUse() throws IOException {
    String id = Long.toString((new Date()).getTime());
    Profile project = new Profile(this.getName(), id, new File(this.workspace.toFile(), id));
    JmriPreferencesProvider shared = JmriPreferencesProvider.findProvider(project.getPath(), true);
    assertEquals(shared.isFirstUse(), true);
    Preferences prefs = shared.getPreferences(this.getClass());
    prefs.put("test", "test");
    try {
        // force write
        prefs.flush();
    } catch (BackingStoreException ex) {
        assertNull(ex);
    }
    shared = new JmriPreferencesProvider(project.getPath(), true);
    assertEquals(shared.isFirstUse(), false);
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) Preferences(java.util.prefs.Preferences) File(java.io.File) Date(java.util.Date) Profile(jmri.profile.Profile)

Aggregations

Profile (jmri.profile.Profile)23 File (java.io.File)14 Date (java.util.Date)7 ArrayList (java.util.ArrayList)6 InitializationException (jmri.util.prefs.InitializationException)6 HashMap (java.util.HashMap)5 List (java.util.List)5 Set (java.util.Set)5 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 IOException (java.io.IOException)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 PropertyChangeEvent (java.beans.PropertyChangeEvent)3 HashSet (java.util.HashSet)3 Locale (java.util.Locale)3 Map (java.util.Map)3 ServiceLoader (java.util.ServiceLoader)3 ProfileUtils (jmri.profile.ProfileUtils)3 AbstractPreferencesManager (jmri.util.prefs.AbstractPreferencesManager)3 Test (org.junit.Test)3