<commit_before>package jp.gr.java_conf.afterthesunrise.commons.object;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Modifier;
import java.net.URL;

import javax.sound.sampled.Clip;

import org.junit.Before;
import org.junit.Test;

import com.google.common.io.ByteStreams;
import com.google.common.io.Resources;

/**
 * @author takanori.takase
 */
public class SoundsTest {

	private byte[] sample;

	@Before
	public void setUp() throws Exception {

		URL url = Resources.getResource("sample.wav");

		InputStream in = url.openStream();

		try {
			sample = ByteStreams.toByteArray(in);
		} finally {
			in.close();
		}

	}

	@Test(expected = IllegalAccessError.class)
	public void testConstructor() throws Throwable {

		Class<?> clazz = Sounds.class;

		Constructor<?> c = clazz.getDeclaredConstructor();

		assertTrue(Modifier.isPrivate(c.getModifiers()));

		c.setAccessible(true);

		try {
			c.newInstance();
		} catch (InvocationTargetException e) {
			throw e.getCause();
		}

	}

	@Test
	public void testGetClip() throws IOException {

		try {

			Clip clip = Sounds.getClip(sample);

			try {
				assertNotNull(clip);
			} finally {
				clip.close();
			}

		} catch (IllegalArgumentException e) {
			// Ignore as some platform may not like ".wav"
		}

		assertNull(Sounds.getClip(new byte[0]));

		assertNull(Sounds.getClip(null));

	}

	@Test(expected = IOException.class)
	public void testGetClip_Invalid() throws IOException {
		Sounds.getClip(new byte[] { 0 });
	}

	@Test
	public void testCloseQuietly() throws IOException {

		Clip clip = mock(Clip.class);

		Sounds.closeQuietly(clip);

		verify(clip).close();

		Sounds.closeQuietly(null);
<commit_msg>Fixed exception type.<commit_after>package jp.gr.java_conf.afterthesunrise.commons.object;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Modifier;
import java.net.URL;

import javax.sound.sampled.Clip;

import org.junit.Before;
import org.junit.Test;

import com.google.common.io.ByteStreams;
import com.google.common.io.Resources;

/**
 * @author takanori.takase
 */
public class SoundsTest {

	private byte[] sample;

	@Before
	public void setUp() throws Exception {

		URL url = Resources.getResource("sample.wav");

		InputStream in = url.openStream();

		try {
			sample = ByteStreams.toByteArray(in);
		} finally {
			in.close();
		}

	}

	@Test(expected = IllegalAccessError.class)
	public void testConstructor() throws Throwable {

		Class<?> clazz = Sounds.class;

		Constructor<?> c = clazz.getDeclaredConstructor();

		assertTrue(Modifier.isPrivate(c.getModifiers()));

		c.setAccessible(true);

		try {
			c.newInstance();
		} catch (InvocationTargetException e) {
			throw e.getCause();
		}

	}

	@Test
	public void testGetClip() throws IOException {

		try {

			Clip clip = Sounds.getClip(sample);

			try {
				assertNotNull(clip);
			} finally {
				clip.close();
			}

		} catch (IOException e) {
			// Ignore as some platform may not like ".wav"
		}

		assertNull(Sounds.getClip(new byte[0]));

		assertNull(Sounds.getClip(null));

	}

	@Test(expected = IOException.class)
	public void testGetClip_Invalid() throws IOException {
		Sounds.getClip(new byte[] { 0 });
	}

	@Test
	public void testCloseQuietly() throws IOException {

		Clip clip = mock(Clip.class);

		Sounds.closeQuietly(clip);

		verify(clip).close();

		Sounds.closeQuietly(null);

{'fraction_non_alphanumeric': 0.1241602388653894, 'fraction_numerical': 0.0009952724558347848, 'mean_word_length': 4.1937984496124034, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '1893360', 'n_tokens_mistral': 1422, 'n_tokens_neox': 1274, 'n_words': 274}