Package org.gedcom4j.parser

Examples of org.gedcom4j.parser.GedcomParser


     * @throws GedcomParserException
     * @throws IOException
     */
    @Test
    public void testToStringBigFile() throws IOException, GedcomParserException {
        GedcomParser gp = new GedcomParser();
        gp.load("sample/5.5.1 sample 1.ged");
        Gedcom g = gp.gedcom;

        for (Family f : g.families.values()) {
            assertNotNull(f.customTags.toString());
            assertFalse(0 == f.customTags.hashCode());
View Full Code Here


     * @throws GedcomParserException
     *             if the gedcom can't be parsed
     */
    @Before
    public void setUp() throws IOException, GedcomParserException {
        GedcomParser gp = new GedcomParser();
        gp.load("sample/RelationshipTest.ged");
        assertTrue(gp.errors.isEmpty());
        assertTrue(gp.warnings.isEmpty());

        g = gp.gedcom;
        assertNotNull(g);
View Full Code Here

     *             if there's a problem writing the gedcom
     */
    @Test
    public void testNonStdTagsNotWritten() throws IOException, GedcomParserException, GedcomWriterException {
        // Read original non-standard file, find non-standard birth event, assert some pre-conditions
        GedcomParser gp = new GedcomParser();
        gp.load("sample/Event Tag Test.ged");
        Gedcom gBefore = gp.gedcom;
        assertNotNull(gBefore);

        assertEquals(1, gBefore.individuals.size());
        Individual iBefore = gBefore.individuals.get("@I1@");
        assertNotNull(iBefore);

        assertNotNull(iBefore.events);
        assertEquals(4, iBefore.events.size());
        IndividualEvent eBefore = iBefore.events.get(0); // The birth event
        assertNotNull(eBefore);
        assertEquals(IndividualEventType.BIRTH, eBefore.type);
        assertNull(eBefore.yNull);
        assertNotNull(eBefore.description);

        // Write the file back out in standard format
        String fn = "tmp/" + this.getClass().getName() + ".ged";
        GedcomWriter gw = new GedcomWriter(gBefore);
        gw.validationSuppressed = true;
        gw.write(fn);

        // Read the file we just wrote back in. The non-standard part should be removed.
        gp = new GedcomParser();
        gp.load(fn);
        Gedcom gAfter = gp.gedcom;
        assertNotNull(gBefore);

        assertEquals(1, gAfter.individuals.size());
        Individual iAfter = gAfter.individuals.get("@I1@");
View Full Code Here

     *             if there's a problem writing the gedcom
     */
    @Test
    public void testValidation() throws IOException, GedcomParserException, GedcomWriterException {
        // Read original non-standard file, find non-standard birth event, assert some pre-conditions
        GedcomParser gp = new GedcomParser();
        gp.load("sample/Event Tag Test.ged");
        Gedcom gBefore = gp.gedcom;
        assertNotNull(gBefore);

        assertEquals(1, gBefore.individuals.size());
        Individual iBefore = gBefore.individuals.get("@I1@");
View Full Code Here

     * @throws GedcomParserException
     *             if the file can't be parsed
     */
    public void testValidateStressTestFile() throws IOException, GedcomParserException {
        // Load a file
        GedcomParser p = new GedcomParser();
        p.load(SAMPLE_STRESS_TEST_FILENAME);
        assertTrue(p.errors.isEmpty());
        rootValidator = new GedcomValidator(p.gedcom);
        rootValidator.validate();
        dumpFindings();
        /*
 
View Full Code Here

     * @throws GedcomWriterException
     *             if a gedcom data structure can't be written (usually due to invalid data, shouldn't happen)
     */
    public GedcomWriterTest() throws IOException, GedcomParserException, GedcomWriterException {
        // Load a file
        GedcomParser p = new GedcomParser();
        p.load(SAMPLE_STRESS_TEST_FILENAME);
        assertTrue(p.errors.isEmpty());
        gedcomOrig = p.gedcom;

        GedcomWriter gw = new GedcomWriter(gedcomOrig);
        gw.validationSuppressed = true;
        File tmpDir = new File("tmp");
        tmpDir.mkdirs();
        File tempFile = new File("tmp/gedcom4j.writertest.ged");
        gw.write(tempFile);

        FileInputStream byteStream = null;
        try {
            byteStream = new FileInputStream(tempFile);
            GedcomFileReader gfr = new GedcomFileReader(new BufferedInputStream(byteStream));
            readbackLines = gfr.getLines();
        } finally {
            if (byteStream != null) {
                byteStream.close();
            }
        }

        // Reload the file we just wrote
        p = new GedcomParser();
        p.load(tempFile.getAbsolutePath());
        for (String s : p.errors) {
            System.err.println(s);
        }
        assertTrue(p.errors.isEmpty());
        assertTrue(p.warnings.isEmpty());
View Full Code Here

     * @throws GedcomParserException
     *             if the gedcom can't be parsed
     */
    @Before
    public void setup() throws IOException, GedcomParserException {
        GedcomParser gp = new GedcomParser();

        gp.load("sample/RelationshipTest.ged");
        assertTrue(gp.errors.isEmpty());
        assertTrue(gp.warnings.isEmpty());
        g = gp.gedcom;
        assertNotNull(g);
        assertEquals("There are supposed to be 43 people in the gedcom - are you using the right file/file version?",
View Full Code Here

        // Write the test data
        gw.write("tmp/writertest551.ged");

        // Read it back
        GedcomParser gp = new GedcomParser();
        gp.load("tmp/writertest551.ged");
        assertTrue(gp.errors.isEmpty());
        assertTrue(gp.warnings.isEmpty());

        // Look for expected data
        g = gp.gedcom;
View Full Code Here

        // Write it
        GedcomWriter gw = new GedcomWriter(g1);
        gw.write("tmp/writertest551.ged");

        // Read it back
        GedcomParser gp = new GedcomParser();
        gp.load("tmp/writertest551.ged");
        assertNotNull(gp.gedcom);

        // See if we read back what we originally built
        Gedcom g2 = gp.gedcom;
        assertEquals(1, g2.multimedia.size());
View Full Code Here

     * @throws IOException
     *             if there's a problem reading the sample file
     */
    @Test
    public void testGetAncestors() throws IOException, GedcomParserException {
        GedcomParser gp = new GedcomParser();
        gp.load("sample/RelationshipTest.ged");
        assertTrue(gp.errors.isEmpty());
        assertTrue(gp.warnings.isEmpty());
        Gedcom g = gp.gedcom;
        assertNotNull(g);
        assertEquals("There are supposed to be 43 people in the gedcom - are you using the right file/file version?",
View Full Code Here

TOP

Related Classes of org.gedcom4j.parser.GedcomParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.