jsentvar.RDFReaderTest.java Source code

Java tutorial

Introduction

Here is the source code for jsentvar.RDFReaderTest.java

Source

/*
 * Copyright (C) 2016 Guillem LLuch Moll <guillem72@gmail.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package jsentvar;

import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;

import org.apache.jena.rdf.model.Model;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author Guillem LLuch Moll <guillem72@gmail.com>
 */
public class RDFReaderTest {

    public RDFReaderTest() {
    }

    @BeforeClass
    public static void setUpClass() {
    }

    @AfterClass
    public static void tearDownClass() {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }

    /**
     * Test of reader method, of class RDFReader.
     * Realy, it doesn't work (I mean, test)
     * @throws java.io.IOException
     */
    @Test
    public void testReader() throws IOException {
        //miniReasoner.owl
        System.out.println("Testing RDFReader.reader");
        String inputFileName = "resources/test/miniReasoner.owl";
        RDFReader instance = new RDFReader();

        String expResult = FileUtils.readFileToString(new File("resources/test/mini_model.txt"), "utf8").trim();
        Model model = instance.reader(inputFileName);

        //FileUtils.writeStringToFile(new File("resources/test/mini_model2.txt"),model.toString());

        //String result = FileUtils.readFileToString(new File("resources/test/mini_model2.txt")).trim();
        String result = model.toString().trim();
        int diff = result.compareTo(expResult);
        System.out.println(expResult);
        System.out.println(result);
        System.out.println(diff);
        assertEquals(expResult, result);
        // TODO review the generated test code and remove the default call to fail.
        //fail("This is not the expected result");
    }

}