site.createSection("SectionName", null, null);
site.createSection(new MultiLanguageString("SectionName"), null, null);
    public void testCreateSection() {        Date dateBeforeCreation;        Date dateAfterCreation;        Section section;        try {            site.createSection(null, null, null);            fail("Expected NullPointerException!");        } catch (NullPointerException e) {            assertEquals("Size unexpected!", 1, site.getAssociatedSectionsCount());        }        try {            site.createSection("SectionName", null, null);            fail("Expected NullPointerException!");        } catch (NullPointerException e) {            assertEquals("Size unexpected!", 1, site.getAssociatedSectionsCount());        }        try {            site.createSection(null, parentSection, 1);            fail("Expected NullPointerException!");        } catch (NullPointerException e) {            assertEquals("Size unexpected!", 1, site.getAssociatedSectionsCount());        }        // Create Section to a Site at last position        dateBeforeCreation = Calendar.getInstance().getTime();        sleep(1000);        site.createSection("SectionNameLast", null, -1);        sleep(1000);        dateAfterCreation = Calendar.getInstance().getTime();        assertEquals("Size unexpected!", 2, site.getAssociatedSectionsCount());        section = (Section) site.getAssociatedSections().get(0); // Last Inserted        assertEquals("Different Section Name!", "SectionNameLast", section.getName());        assertNull("Expected Null ParentSection!", section.getSuperiorSection());        assertEquals("Different ParentSection Order!", new Integer(0), parentSection.getSectionOrder());        assertEquals("Different Section Order!", new Integer(1), section.getSectionOrder());        assertTrue("Expected LastModificationDate After an initial timestamp!", section                .getLastModifiedDate().after(dateBeforeCreation));        assertTrue("Expected LastModificationDate Before an end timestamp!", section                .getLastModifiedDate().before(dateAfterCreation));        assertEquals("Different Section Site", site, section.getSite());        assertNotNull("Expected Not Null Section items!", section.getAssociatedItems());        assertNotNull("Expected Not Null Section SubSections!", section.getAssociatedSections());        // Create Section to a Site between "ParentSection" and        // "SectionNameLast"        dateBeforeCreation = Calendar.getInstance().getTime();        sleep(1000);        site.createSection("SectionNameBetween", null, 1);        sleep(1000);        dateAfterCreation = Calendar.getInstance().getTime();        assertEquals("Size unexpected!", 3, site.getAssociatedSectionsCount());        section = (Section) site.getAssociatedSections().get(0); // Last Inserted        assertEquals("Different Section Name!", "SectionNameBetween", section.getName());        assertNull("Expected Null ParentSection!", section.getSuperiorSection());        assertEquals("Different Section Order!", new Integer(1), section.getSectionOrder());        assertEquals("Different ParentSection Order!", new Integer(0), parentSection.getSectionOrder());        assertEquals("Different \"SectionNameLast\" Order!", new Integer(2), site.getAssociatedSections().get(                1).getSectionOrder());        assertTrue("Expected LastModificationDate After an initial timestamp!", section                .getLastModifiedDate().after(dateBeforeCreation));        assertTrue("Expected LastModificationDate Before an end timestamp!", section                .getLastModifiedDate().before(dateAfterCreation));        assertEquals("Different Section Site", site, section.getSite());        assertNotNull("Expected Not Null Section items!", section.getAssociatedItems());        assertNotNull("Expected Not Null Section SubSections!", section.getAssociatedSections());        // Create Section to a Site at start position        dateBeforeCreation = Calendar.getInstance().getTime();        sleep(1000);        site.createSection("SectionNameStart", null, 0);        sleep(1000);        dateAfterCreation = Calendar.getInstance().getTime();        assertEquals("Size unexpected!", 4, site.getAssociatedSectionsCount());        section = (Section) site.getAssociatedSections().get(0); // Last Inserted        assertEquals("Different Section Name!", "SectionNameStart", section.getName());        assertNull("Expected Null ParentSection!", section.getSuperiorSection());        assertEquals("Different Section Order!", new Integer(0), section.getSectionOrder());        assertEquals("Different ParentSection Order!", new Integer(1), parentSection.getSectionOrder());        assertEquals("Different \"SectionNameBetween\" Order!", new Integer(2), site                .getAssociatedSections().get(1).getSectionOrder());        assertEquals("Different \"SectionNameLast\" Order!", new Integer(3), site.getAssociatedSections().get(                2).getSectionOrder());        assertTrue("Expected LastModificationDate After an initial timestamp!", section                .getLastModifiedDate().after(dateBeforeCreation));        assertTrue("Expected LastModificationDate Before an end timestamp!", section                .getLastModifiedDate().before(dateAfterCreation));        assertEquals("Different Section Site", site, section.getSite());        assertNotNull("Expected Not Null Section items!", section.getAssociatedItems());        assertNotNull("Expected Not Null Section SubSections!", section.getAssociatedSections());        // Create SubSection to a Site and ParentSection        dateBeforeCreation = Calendar.getInstance().getTime();        sleep(1000);        site.createSection("SubSectionNameStart", parentSection, -1);        sleep(1000);        dateAfterCreation = Calendar.getInstance().getTime();        assertEquals("Size unexpected!", 5, site.getAssociatedSectionsCount());        assertEquals("Size unexpected!", 1, parentSection.getAssociatedSectionsCount());        section = (Section) parentSection.getAssociatedSections().get(0); // Last        // Inserted        assertEquals("Different SubSection Name!", "SubSectionNameStart", section.getName());        assertEquals("Different ParentSection!", parentSection, section.getSuperiorSection());        assertEquals("Different SubSection Order!", new Integer(0), section.getSectionOrder());        assertTrue("Expected LastModificationDate After an initial timestamp!", section                .getLastModifiedDate().after(dateBeforeCreation));        assertTrue("Expected LastModificationDate Before an end timestamp!", section                .getLastModifiedDate().before(dateAfterCreation));        assertEquals("Different Section Site", site, section.getSite());        assertNotNull("Expected Not Null Section items!", section.getAssociatedItems());        assertNotNull("Expected Not Null Section SubSections!", section.getAssociatedSections());        // Create SubSection to a Site and ParentSection at last postion        dateBeforeCreation = Calendar.getInstance().getTime();        sleep(1000);        site.createSection("SubSectionNameLast", parentSection, -1);        sleep(1000);        dateAfterCreation = Calendar.getInstance().getTime();        assertEquals("Size unexpected!", 6, site.getAssociatedSectionsCount());        assertEquals("Size unexpected!", 2, parentSection.getAssociatedSectionsCount());        section = (Section) parentSection.getAssociatedSections().get(0); // Last        // Inserted        assertEquals("Different SubSection Name!", "SubSectionNameLast", section.getName());        assertEquals("Different ParentSection!", parentSection, section.getSuperiorSection());        assertEquals("Different SubSection Order!", new Integer(1), section.getSectionOrder());        assertEquals("Different \"SubSectionNameStart\" Order!", new Integer(0), parentSection                .getAssociatedSections().get(1).getSectionOrder());        assertTrue("Expected LastModificationDate After an initial timestamp!", section                .getLastModifiedDate().after(dateBeforeCreation));        assertTrue("Expected LastModificationDate Before an end timestamp!", section                .getLastModifiedDate().before(dateAfterCreation));        assertEquals("Different Section Site", site, section.getSite());        assertNotNull("Expected Not Null Section items!", section.getAssociatedItems());        assertNotNull("Expected Not Null Section SubSections!", section.getAssociatedSections());        // Create SubSection to a Site and ParentSection between        // "SubSectionNameStart" and "SubSectionNameLast"        dateBeforeCreation = Calendar.getInstance().getTime();        sleep(1000);        site.createSection("SubSectionNameBetween", parentSection, 1);        sleep(1000);        dateAfterCreation = Calendar.getInstance().getTime();        assertEquals("Size unexpected!", 7, site.getAssociatedSectionsCount());        assertEquals("Size unexpected!", 3, parentSection.getAssociatedSectionsCount());        section = (Section) parentSection.getAssociatedSections().get(0); // Last        // Inserted        assertEquals("Different SubSection Name!", "SubSectionNameBetween", section.getName());        assertEquals("Different ParentSection!", parentSection, section.getSuperiorSection());        assertEquals("Different SubSection Order!", new Integer(1), section.getSectionOrder());        assertEquals("Different \"SubSectionNameStart\" Order!", new Integer(0), parentSection                .getAssociatedSections().get(2).getSectionOrder());        assertEquals("Different \"SubSectionNameLast\" Order!", new Integer(2), parentSection                .getAssociatedSections().get(1).getSectionOrder());        assertTrue("Expected LastModificationDate After an initial timestamp!", section                .getLastModifiedDate().after(dateBeforeCreation));        assertTrue("Expected LastModificationDate Before an end timestamp!", section                .getLastModifiedDate().before(dateAfterCreation));        assertEquals("Different Section Site", site, section.getSite());        assertNotNull("Expected Not Null Section items!", section.getAssociatedItems());        assertNotNull("Expected Not Null Section SubSections!", section.getAssociatedSections());        // Create SubSection to a Site and ParentSection at start position        dateBeforeCreation = Calendar.getInstance().getTime();        sleep(1000);        site.createSection("SubSectionNameFirst", parentSection, 0);        sleep(1000);        dateAfterCreation = Calendar.getInstance().getTime();        assertEquals("Size unexpected!", 8, site.getAssociatedSectionsCount());        assertEquals("Size unexpected!", 4, parentSection.getAssociatedSectionsCount());        section = (Section) parentSection.getAssociatedSections().get(0); // Last        // Inserted        assertEquals("Different SubSection Name!", "SubSectionNameFirst", section.getName());        assertEquals("Different ParentSection!", parentSection, section.getSuperiorSection());        assertEquals("Different SubSection Order!", new Integer(0), section.getSectionOrder());        assertEquals("Different \"SubSectionNameStart\" Order!", new Integer(1), parentSection                .getAssociatedSections().get(3).getSectionOrder());        assertEquals("Different \"SubSectionNameBetween\" Order!", new Integer(2), parentSection                .getAssociatedSections().get(1).getSectionOrder());        assertEquals("Different \"SubSectionNameLast\" Order!", new Integer(3), parentSection                .getAssociatedSections().get(2).getSectionOrder());        assertTrue("Expected LastModificationDate After an initial timestamp!", section                .getLastModifiedDate().after(dateBeforeCreation));        assertTrue("Expected LastModificationDate Before an end timestamp!", section                .getLastModifiedDate().before(dateAfterCreation));        assertEquals("Different Section Site", site, section.getSite());        assertNotNull("Expected Not Null Section items!", section.getAssociatedItems());        assertNotNull("Expected Not Null Section SubSections!", section.getAssociatedSections());    }