// Path: src/main/java/de/todesbaum/jsite/main/JarFileLocator.java
// class DefaultJarFileLocator implements JarFileLocator {
// 
// 	private final ClassLoader classLoader;
// 
// 	public DefaultJarFileLocator(ClassLoader classLoader) {
// 		this.classLoader = classLoader;
// 	}
// 
// 	@Override
// 	public Optional<File> locateJarFile() {
// 		URL resourceUrl = classLoader.getResource(Main.class.getName().replace(".", "/") + ".class");
// 		if (resourceUrl == null) {
// 			return empty();
// 		}
// 		String resource = resourceUrl.toString();
// 		if (resource.startsWith("jar:")) {
// 			try {
// 				String jarFileLocation = URLDecoder.decode(resource.substring(9, resource.indexOf(".jar!") + 4), "UTF-8");
// 				return Optional.of(new File(jarFileLocation));
// 			} catch (UnsupportedEncodingException e) {
// 				/* location is not available, ignore. */
// 			}
// 		}
// 		return empty();
// 	}
// }


import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Optional;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import net.pterodactylus.util.io.StreamCopier;
import de.todesbaum.jsite.main.JarFileLocator.DefaultJarFileLocator;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
package de.todesbaum.jsite.main;





/**
 * Unit test for {@link JarFileLocator}.
 */
public class JarFileLocatorTest {

	@Rule
	public final TemporaryFolder temporaryFolder = new TemporaryFolder();

	private static final Class<?> CLASS_TO_LOAD = Main.class;
	private static final String RESOURCE_TO_COPY = CLASS_TO_LOAD.getName().replace('.', '/') + ".class";
	private static final String PACKAGE_NAME = CLASS_TO_LOAD.getPackage().getName();
	private static final String CLASS_FILENAME = CLASS_TO_LOAD.getSimpleName() + ".class";

	@Test
	public void jarFileCanBeLocatedOnPathWithNonUsAsciiCharacters() throws Exception {
		File jarFilePath = temporaryFolder.newFolder("Фото café");
// Path: src/main/java/de/todesbaum/jsite/main/JarFileLocator.java
// class DefaultJarFileLocator implements JarFileLocator {
// 
// 	private final ClassLoader classLoader;
// 
// 	public DefaultJarFileLocator(ClassLoader classLoader) {
// 		this.classLoader = classLoader;
// 	}
// 
// 	@Override
// 	public Optional<File> locateJarFile() {
// 		URL resourceUrl = classLoader.getResource(Main.class.getName().replace(".", "/") + ".class");
// 		if (resourceUrl == null) {
// 			return empty();
// 		}
// 		String resource = resourceUrl.toString();
// 		if (resource.startsWith("jar:")) {
// 			try {
// 				String jarFileLocation = URLDecoder.decode(resource.substring(9, resource.indexOf(".jar!") + 4), "UTF-8");
// 				return Optional.of(new File(jarFileLocation));
// 			} catch (UnsupportedEncodingException e) {
// 				/* location is not available, ignore. */
// 			}
// 		}
// 		return empty();
// 	}
// }


// Path: src/test/java/de/todesbaum/jsite/main/JarFileLocatorTest.java
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Optional;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import net.pterodactylus.util.io.StreamCopier;
import de.todesbaum.jsite.main.JarFileLocator.DefaultJarFileLocator;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;

package de.todesbaum.jsite.main;





/**
 * Unit test for {@link JarFileLocator}.
 */
public class JarFileLocatorTest {

	@Rule
	public final TemporaryFolder temporaryFolder = new TemporaryFolder();

	private static final Class<?> CLASS_TO_LOAD = Main.class;
	private static final String RESOURCE_TO_COPY = CLASS_TO_LOAD.getName().replace('.', '/') + ".class";
	private static final String PACKAGE_NAME = CLASS_TO_LOAD.getPackage().getName();
	private static final String CLASS_FILENAME = CLASS_TO_LOAD.getSimpleName() + ".class";

	@Test
	public void jarFileCanBeLocatedOnPathWithNonUsAsciiCharacters() throws Exception {
		File jarFilePath = temporaryFolder.newFolder("Фото café");
		File jarFile = createJarFile(jarFilePath);