@@ -0,0 +1,3501 @@
+/**%0A * Copyright (c) 2015, German Neuroinformatics Node (G-Node)%0A *%0A * All rights reserved.%0A *%0A * Redistribution and use in source and binary forms, with or without%0A * modification, are permitted under the terms of the BSD License. See%0A * LICENSE file in the root of the Project.%0A */%0A%0Apackage org.g_node.srv;%0A%0Aimport java.io.ByteArrayOutputStream;%0Aimport java.io.File;%0Aimport java.io.PrintStream;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Path;%0Aimport java.nio.file.Paths;%0A%0Aimport com.hp.hpl.jena.rdf.model.Model;%0Aimport com.hp.hpl.jena.rdf.model.ModelFactory;%0Aimport com.hp.hpl.jena.rdf.model.Resource;%0Aimport org.apache.commons.io.FileUtils;%0Aimport org.junit.After;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport static org.assertj.core.api.Assertions.assertThat;%0A%0A/**%0A * Unit tests for the %7B@link RDFService%7D class. Output and Error streams are redirected%0A * from the console to a different PrintStream and reset after tests are finished%0A * to avoid mixing tool error messages with actual test error messages.%0A *%0A * @author Michael Sonntag (sonntag@bio.lmu.de)%0A */%0Apublic class RDFServiceTest %7B%0A%0A    private final String tmpRoot = System.getProperty(%22java.io.tmpdir%22);%0A    private final String testFolderName = %22tdfservicetest%22;%0A    private final String testFileName = %22test.txt%22;%0A    private final Path testFileFolder = Paths.get(tmpRoot, testFolderName);%0A%0A    private ByteArrayOutputStream outStream = new ByteArrayOutputStream();%0A    private ByteArrayOutputStream errStream = new ByteArrayOutputStream();%0A    private PrintStream stdout;%0A    private PrintStream stderr;%0A%0A    /**%0A     * Redirect Error and Out stream and create a testfolder and the main%0A     * test file in the java temp directory.%0A     * @throws Exception%0A     */%0A    @Before%0A    public void setUp() throws Exception %7B%0A%0A        this.stdout = System.out;%0A        this.stderr = System.err;%0A%0A        this.outStream = new ByteArrayOutputStream();%0A        this.errStream = new ByteArrayOutputStream();%0A%0A        System.setOut(new PrintStream(this.outStream));%0A        System.setErr(new PrintStream(this.errStream));%0A%0A        final File currTestFile = this.testFileFolder.resolve(this.testFileName).toFile();%0A        FileUtils.write(currTestFile, %22This is a normal test file%22);%0A%0A    %7D%0A%0A    /**%0A     * Reset Error and Out stream to the console and remove all created%0A     * folders and files after the tests are done.%0A     * @throws Exception%0A     */%0A    @After%0A    public void tearDown() throws Exception %7B%0A%0A        System.setOut(this.stdout);%0A        System.setErr(this.stderr);%0A%0A        if (Files.exists(this.testFileFolder)) %7B%0A            FileUtils.deleteDirectory(this.testFileFolder.toFile());%0A        %7D%0A    %7D%0A%0A    /**%0A     * Check, that a Jena RDF model is written to file.%0A     * @throws Exception%0A     */%0A    @Test%0A    public void testWriteModelToFile() throws Exception %7B%0A        final Model model = ModelFactory.createDefaultModel();%0A        final Resource modelEntry = model.createResource();%0A%0A        final String outFileName = %22testrdf.ttl%22;%0A        final String outFilePath = this.testFileFolder.resolve(outFileName).toString();%0A        final String outFileFormat = %22TTL%22;%0A        final String testString = String.join(%0A                %22%22, %22%5BInfo%5D Writing data to RDF file, %22,%0A                outFilePath, %22 using format '%22, outFileFormat, %22'%22%0A        );%0A%0A        RDFService.writeModelToFile(outFilePath, model, outFileFormat);%0A%0A        assertThat(this.outStream.toString()).startsWith(testString);%0A    %7D%0A%7D%0A

add rdfservice tests