/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.ocelotds.configuration;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import org.junit.Test;
import static org.assertj.core.api.Assertions.*;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
import org.ocelotds.Constants;

/**
 *
 * @author hhfrancois
 */
@RunWith(MockitoJUnitRunner.class)
public class AbstractFileInitializerTest {

	private AbstractFileInitializer instance = new AbstractFileInitializerImpl();

	/**
	 * Test of deleteFile method, of class AbstractFileInitializer.
	 * @throws java.io.IOException
	 */
	@Test
	public void testDeleteFile() throws IOException {
		System.out.println("deleteFile");
		File f = File.createTempFile("test", "tmp");
		String filename = f.getAbsolutePath();
		boolean result = instance.deleteFile("unknownfile");
		assertThat(result).isFalse();
		
		result = instance.deleteFile(filename);		
		assertThat(result).isTrue();
		assertThat(f).doesNotExist();
	}

	/**
	 * Test of getContentURL method, of class AbstractFileInitializer.
	 */
	@Test
	public void testGetContentURL() {
		System.out.println("getContentURL");
		URL result = instance.getContentURL(Constants.SLASH + Constants.OCELOT_CORE + Constants.JS);
		assertThat(result).isNotNull();
	}
	
	final class AbstractFileInitializerImpl extends AbstractFileInitializer {
		
	}
}
@@ -301,120 +301,330 @@
 ava.
-net.URL;%0Aimport org.junit.Test;%0Aimport static org.assertj.core.api.Assertions.*;%0Aimport org.junit.runner.RunWith
+io.InputStream;%0Aimport java.io.OutputStream;%0Aimport java.net.URL;%0Aimport org.junit.Test;%0Aimport static org.mockito.Mockito.*;%0Aimport static org.assertj.core.api.Assertions.*;%0Aimport org.junit.runner.RunWith;%0Aimport org.mockito.ArgumentCaptor;%0Aimport org.mockito.InjectMocks;%0Aimport org.mockito.Mock;%0Aimport org.mockito.Spy
 ;%0Aim
@@ -698,16 +698,41 @@
 nstants;
+%0Aimport org.slf4j.Logger;
 %0A%0A/**%0A *
@@ -837,16 +837,23 @@
 Test %7B%0A%0A
+%09@Mock%0A
 %09private
@@ -857,46 +857,52 @@
 ate 
-AbstractFileInitializer instance = new
+Logger logger;%0A%0A%09@InjectMocks%0A%09@Spy%0A%09private
  Abs
@@ -925,18 +925,25 @@
 izerImpl
-()
+ instance
 ;%0A%0A%09/**%0A
@@ -1725,84 +1725,1290 @@
 %0A%09%0A%09
-final class AbstractFileInitializerImpl extends AbstractFileInitializer %7B%0A%09%09
+/**%0A%09 * Test of writeStreamToOutputStream method, of class AbstractFileInitializer.%0A%09 * @throws java.io.IOException%0A%09 */%0A%09@Test%0A%09public void testWriteStreamToOutputStreamFailed() throws IOException %7B%0A%09%09System.out.println(%22writeStreamToOutputStream%22);%0A%09%09OutputStream out = mock(OutputStream.class);%0A%09%09InputStream in = mock(InputStream.class);%0A%09%09boolean result = instance.writeStreamToOutputStream(null, null);%0A%09%09assertThat(result).isFalse();%0A%09%09%0A%09%09result = instance.writeStreamToOutputStream(in, null);%0A%09%09assertThat(result).isFalse();%0A%0A%09%09result = instance.writeStreamToOutputStream(null, out);%0A%09%09assertThat(result).isFalse();%09%09%0A%0A%09%09when(in.read(any(byte%5B%5D.class))).thenThrow(IOException.class);%0A%09%09result = instance.writeStreamToOutputStream(in, out);%0A%09%09assertThat(result).isFalse();%09%09%0A%09%7D%0A%0A%09/**%0A%09 * Test of writeStreamToOutputStream method, of class AbstractFileInitializer.%0A%09 * @throws java.io.IOException%0A%09 */%0A%09@Test%0A%09public void testWriteStreamToOutputStream() throws IOException %7B%0A%09%09System.out.println(%22writeStreamToOutputStream%22);%0A%09%09OutputStream out = mock(OutputStream.class);%0A%09%09InputStream in = mock(InputStream.class);%0A%09%09when(in.read(any(byte%5B%5D.class))).thenReturn(5).thenReturn(-1);%0A%09%09boolean result = instance.writeStreamToOutputStream(in, out);%0A%09%09assertThat(result).isTrue();
 %0A%09%7D%0A

remove CTXPATH generation