/*
Copyright [2013-2014] eBay Software Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

*/

package com.ccoe.build.publisher;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.net.URISyntaxException;

import org.junit.Test;

import com.ccoe.build.core.model.Session;
import com.ccoe.build.publisher.LogPublisher;
import com.ccoe.build.publisher.PublisherConfig;

public class LogPublisherTest {

	@Test
	public void testProcess() throws URISyntaxException {
		File targetFolder = new File(getClass().getResource("/").toURI());
		LogPublisher publisher = new LogPublisher(new PublisherConfig().targetFolder(targetFolder )
				.retensionDays(0));
		
		File sessionFile = new File(targetFolder, "single_session.txt");
		Session session = publisher.process(sessionFile);
		
		assertNotNull(session);
		assertEquals("CalTestParent", session.getAppName());
		
		File sessionFailFile = new File(targetFolder, "session_withexp.txt");
		session = publisher.process(sessionFailFile);
		assertNotNull(session);
		assertEquals("Test3Parent", session.getAppName());
		assertTrue(session.getExceptionMessage().contains("Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin"));
		assertTrue(session.getFullStackTrace().contains("... 19 more"));
	}
}

@@ -1058,16 +1058,18 @@
 ption %7B%0A
+//
 %09%09File t
@@ -1129,16 +1129,18 @@
 URI());%0A
+//
 %09%09LogPub
@@ -1225,16 +1225,18 @@
 older )%0A
+//
 %09%09%09%09.ret
@@ -1247,27 +1247,31 @@
 onDays(0));%0A
+//
 %09%09%0A
+//
 %09%09File sessi
@@ -1325,16 +1325,18 @@
 .txt%22);%0A
+//
 %09%09Sessio
@@ -1379,19 +1379,23 @@
 nFile);%0A
+//
 %09%09%0A
+//
 %09%09assert
@@ -1404,32 +1404,34 @@
 tNull(session);%0A
+//
 %09%09assertEquals(%22
@@ -1469,19 +1469,23 @@
 ame());%0A
+//
 %09%09%0A
+//
 %09%09File s
@@ -1548,16 +1548,18 @@
 .txt%22);%0A
+//
 %09%09sessio
@@ -1598,16 +1598,18 @@
 lFile);%0A
+//
 %09%09assert
@@ -1626,16 +1626,18 @@
 ssion);%0A
+//
 %09%09assert
@@ -1677,24 +1677,26 @@
 AppName());%0A
+//
 %09%09assertTrue
@@ -1810,16 +1810,18 @@
 gin%22));%0A
+//
 %09%09assert

comment out the test that require db connections.