Skip to content

Commit

Permalink
Ensure writer.close() is invoked by CMLWriter.
Browse files Browse the repository at this point in the history
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
johnmay authored and egonw committed Jul 22, 2014
1 parent 33c6627 commit 91d2592
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions storage/libiocml/pom.xml
Expand Up @@ -45,6 +45,11 @@
<version>1.2.17</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jgrapht</groupId>
<artifactId>jgrapht</artifactId>
Expand Down
Expand Up @@ -141,6 +141,10 @@ public CMLWriter(final Writer writer) {
public void write(int b) throws IOException {
writer.write(b);
}

@Override public void close() throws IOException {
writer.close();
}
};

initIOSettings();
Expand Down
Expand Up @@ -27,13 +27,16 @@
* */
package org.openscience.cdk.io.cml;

import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;

import javax.vecmath.Point3d;
import javax.vecmath.Vector3d;

import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import org.openscience.cdk.Atom;
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.CDKTestCase;
Expand Down Expand Up @@ -533,4 +536,10 @@ public class CML2WriterTest extends CDKTestCase {
// Assert.assertTrue(cmlContent.indexOf("<molecule id=\"D") != -1);
// Assert.assertTrue(cmlContent.indexOf("<molecule id=\"E") != -1);
// }

@Test public void writeIsClosed() throws IOException {
Writer mock = Mockito.mock(Writer.class);
new CMLWriter(mock).close();
Mockito.verify(mock).close();
}
}

0 comments on commit 91d2592

Please sign in to comment.