/*
 * MX Cheminformatics Tools for Java
 *
 * Copyright (c) 2007-2009 Metamolecular, LLC
 *
 * http://metamolecular.com
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package com.metamolecular.mx.test;

import junit.framework.TestCase;
import com.metamolecular.mx.model.*;
import com.metamolecular.mx.io.Molecules;

/**
 * @author Duan Lian
 */
public class MolfileWriterTest extends TestCase
{
    public void testWriterOutputsSubstructure()
    {
        Molecule ethylbenzene = Molecules.createEthylbenzeneWithSubstructure();

        String molfile=MoleculeKit.writeMolfile(ethylbenzene);
        Molecule molecule=MoleculeKit.readMolfile(molfile);
        assertEquals(1,molecule.countSubstructures());
    }
}

@@ -1339,16 +1339,85 @@
 lecules;
+%0Aimport com.metamolecular.mx.io.mdl.MolfileReader;%0A%0Aimport java.io.*;
 %0A%0A/**%0A *
@@ -1646,17 +1646,19 @@
  molfile
-=
+ = 
 Molecule
@@ -1714,17 +1714,19 @@
 molecule
-=
+ = 
 Molecule
@@ -1774,16 +1774,17 @@
 quals(1,
+ 
 molecule
@@ -1813,10 +1813,1162 @@
 ;%0A    %7D%0A
+    public void testWriterOutputReaderInput() throws FileNotFoundException %7B%0A        File%5B%5D molfiles = new File(%22../resources/molfiles%22).listFiles();%0A        for (File molfile : molfiles)%0A        %7B%0A            String content = null;%0A            try %7B%0A                content = getFileContent(molfile);%0A            %7D catch (IOException e) %7B%0A                e.printStackTrace();%0A                fail(%22File reading failed%22);%0A            %7D%0A            Molecule molecule1 = MoleculeKit.readMolfile(content);%0A            String molfile1 = MoleculeKit.writeMolfile(molecule1);%0A            Molecule molecule2 = MoleculeKit.readMolfile(molfile1);%0A            String molfile2 = MoleculeKit.writeMolfile(molecule2);%0A            assertEquals(molfile1,molfile2);%0A        %7D%0A    %7D%0A    private String getFileContent(File file) throws IOException %7B%0A        StringBuffer stringBuffer = new StringBuffer();%0A        BufferedReader bufferedReader = new BufferedReader(new FileReader(file));%0A        String line;%0A        while ((line = bufferedReader.readLine()) != null) %7B%0A            stringBuffer.append(line+%22%5Cn%22);%0A        %7D%0A        return stringBuffer.toString();%0A    %7D%0A
 %7D%0A

add testWriterOutputReaderInput()