<commit_before>package org.demyo.utils.io;

import static org.assertj.core.api.Assertions.assertThat;

import java.io.Closeable;
import java.io.IOException;
import java.util.zip.ZipFile;

import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;

import org.junit.Test;
import org.mockito.Mockito;

/**
 * Tests for {@link DIOUtils}.
 */
public class DIOUtilsTest {
	/**
	 * Tests {@link DIOUtils#closeQuietly(Closeable)}.
	 * 
	 * @throws IOException should never be thrown.
	 */
	@Test
	public void testCloseQuietlyCloseableNormal() throws IOException {
		Closeable closeable = Mockito.mock(Closeable.class);
		DIOUtils.closeQuietly(closeable);
		Mockito.verify(closeable, Mockito.times(1)).close();
	}

	/**
	 * Tests {@link DIOUtils#closeQuietly(Closeable)} when the closeable throws an Exception.
	 * 
	 * @throws IOException should never be thrown.
	 */
	@Test
	public void testCloseQuietlyCloseableException() throws IOException {
		Closeable closeable = Mockito.mock(Closeable.class);
		Mockito.doThrow(IOException.class).when(closeable).close();
		DIOUtils.closeQuietly(closeable);
		Mockito.verify(closeable, Mockito.times(1)).close();
	}

	/**
	 * Tests {@link DIOUtils#closeQuietly(ZipFile)}.
	 * 
	 * @throws IOException should never be thrown.
	 */
	@Test
	public void testCloseQuietlyZipFileNormal() throws IOException {
		ZipFile closeable = Mockito.mock(ZipFile.class);
		DIOUtils.closeQuietly(closeable);
		Mockito.verify(closeable, Mockito.times(1)).close();
	}

	/**
	 * Tests {@link DIOUtils#closeQuietly(ZipFile)} when the closeable throws an Exception.
	 * 
	 * @throws IOException should never be thrown.
	 */
	@Test
	public void testCloseQuietlyZipFileException() throws IOException {
		ZipFile closeable = Mockito.mock(ZipFile.class);
		Mockito.doThrow(IOException.class).when(closeable).close();
		DIOUtils.closeQuietly(closeable);
		Mockito.verify(closeable, Mockito.times(1)).close();
	}

	/**
	 * Tests {@link DIOUtils#closeQuietly(XMLStreamWriter)}.
	 * 
	 * @throws XMLStreamException should never be thrown.
	 */
	@Test
	public void testCloseQuietlyXMLStreamWriterNormal() throws XMLStreamException {<commit_msg>Improving test coverage of DIOUtils.<commit_after>package org.demyo.utils.io;

import static org.assertj.core.api.Assertions.assertThat;

import java.io.Closeable;
import java.io.IOException;
import java.util.zip.ZipFile;

import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;

import org.junit.Test;
import org.mockito.Mockito;

/**
 * Tests for {@link DIOUtils}.
 */
public class DIOUtilsTest {
	/**
	 * Tests {@link DIOUtils#closeQuietly(Closeable)}.
	 * 
	 * @throws IOException should never be thrown.
	 */
	@Test
	public void testCloseQuietlyCloseableNormal() throws IOException {
		DIOUtils.closeQuietly((Closeable) null);
		Closeable closeable = Mockito.mock(Closeable.class);
		DIOUtils.closeQuietly(closeable);
		Mockito.verify(closeable, Mockito.times(1)).close();
	}

	/**
	 * Tests {@link DIOUtils#closeQuietly(Closeable)} when the closeable throws an Exception.
	 * 
	 * @throws IOException should never be thrown.
	 */
	@Test
	public void testCloseQuietlyCloseableException() throws IOException {
		Closeable closeable = Mockito.mock(Closeable.class);
		Mockito.doThrow(IOException.class).when(closeable).close();
		DIOUtils.closeQuietly(closeable);
		Mockito.verify(closeable, Mockito.times(1)).close();
	}

	/**
	 * Tests {@link DIOUtils#closeQuietly(ZipFile)}.
	 * 
	 * @throws IOException should never be thrown.
	 */
	@Test
	public void testCloseQuietlyZipFileNormal() throws IOException {
		DIOUtils.closeQuietly((ZipFile) null);
		ZipFile closeable = Mockito.mock(ZipFile.class);
		DIOUtils.closeQuietly(closeable);
		Mockito.verify(closeable, Mockito.times(1)).close();
	}

	/**
	 * Tests {@link DIOUtils#closeQuietly(ZipFile)} when the closeable throws an Exception.
	 * 
	 * @throws IOException should never be thrown.
	 */
	@Test
	public void testCloseQuietlyZipFileException() throws IOException {
		ZipFile closeable = Mockito.mock(ZipFile.class);
		Mockito.doThrow(IOException.class).when(closeable).close();
		DIOUtils.closeQuietly(closeable);
		Mockito.verify(closeable, Mockito.times(1)).close();
	}

	/**
	 * Tests {@link DIOUtils#closeQuietly(XMLStreamWriter)}.
	 * 
	 * @throws XMLStreamException should never be thrown.
	 */
	@Test
	public void testCloseQuietlyXMLStreamWriterNormal() throws XMLStreamException {
		DIOUtils.closeQuietly((XMLStreamWriter) null);
{'fraction_non_alphanumeric': 0.12111111111111111, 'fraction_numerical': 0.0017777777777777779, 'mean_word_length': 5.025435073627845, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3021303', 'n_tokens_mistral': 1513, 'n_tokens_neox': 1438, 'n_words': 288}