/** * Tests configuration navigation to non-existing sections (with section creation). */ @Test public void testSectionNotFoundWithCreate() { assertSectionNotFound(true);}
/** * Test configuration navigation to existing sections. */ @Test public void testSectionFound() { ConfigurationExplorer explorer; for(int i = 0; i < DEPTH; i++) { moveTo(explorer = getExplorer(), i); assert (VARIABLE_VALUE + i).equals(explorer.getSection().getVariable(VARIABLE_NAME + i)); } } }
/** * Tests the {@link ConfigurationExplorer#moveTo(String,boolean)} method. */ private void assertSectionNotFound(boolean create) { ConfigurationExplorer explorer; ConfigurationSection section; // Checks what happens when sections are not found and create is set to false. for(int i = 0; i < DEPTH; i++) { section = moveTo(explorer = getExplorer(), i); // Makes sure the 'fake' section doesn't exist. assert !explorer.moveTo(FAKE_SECTION + i, false); if(create) { // Tries to create the section and makes sure the explorer // did move to it. assert explorer.moveTo(FAKE_SECTION + i, true); assert section.getSection(FAKE_SECTION + i).equals(explorer.getSection()); } else // Makes sure the explorer didn't change section. assert explorer.getSection().equals(section); } }
/** * Tests configuration navigation to non-existing sections (without section creation). */ @Test public void testSectionNotFoundWithoutCreate() { assertSectionNotFound(false);}