package com.kurento.kmf.media;

import java.io.IOException;

import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.kurento.kmf.media.MainMixer;
import com.kurento.kmf.media.MediaException;
import com.kurento.kmf.media.MediaManager;
import com.kurento.kmf.media.MediaManagerFactory;
import com.kurento.kmf.media.PlayerEndPoint;
import com.kurento.kmf.media.RecorderEndPoint;
import com.kurento.kmf.media.RtpEndPoint;
import com.kurento.kms.api.MediaType;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/kmf-api-test-context.xml")
public class SyncMediaServerTest {

	@Autowired
	@Qualifier("mediaManagerFactory")
	private MediaManagerFactory mediaManagerFactory;

	private MediaManager mediaManager;

	@Before
	public void setUpBeforeClass() throws MediaException, IOException {
		mediaManager = mediaManagerFactory.createMediaManager();
	}

	@After
	public void afterClass() throws IOException {
		mediaManager.release();
	}

	@Test
	public void testStreamSync() throws MediaException, IOException,
			InterruptedException {
		RtpEndPoint stream = mediaManager.createSdpEndPoint(RtpEndPoint.class);
		System.out.println("generateOffer sessionDecriptor: "
				+ stream.generateOffer());
		System.out.println("processOffer sessionDecriptor: "
				+ stream.processOffer("processOffer test"));
		System.out.println("processAnswer sessionDecriptor: "
				+ stream.processAnswer("processAnswer test"));
		stream.release();
	}

	// TODO: Enable this test when uri endpoint is implemented
	@Ignore
	@Test
	public void testPlayer() throws MediaException, IOException {
		PlayerEndPoint player = mediaManager.createUriEndPoint(
				PlayerEndPoint.class, "");
		player.play();
		player.pause();
		player.stop();
		player.release();
	}

	// TODO: Enable this test when uri endpoint is implemented
	@Ignore
	@Test
	public void testRecorder() throws MediaException, IOException {
		RecorderEndPoint recorder = mediaManager.createUriEndPoint(
				RecorderEndPoint.class, "");
		recorder.record();
		recorder.pause();
		recorder.stop();
		recorder.release();
	}

	@Test
	public void testJoinable() throws MediaException, IOException {
		RtpEndPoint streamA = mediaManager.createSdpEndPoint(RtpEndPoint.class);
		RtpEndPoint streamB = mediaManager.createSdpEndPoint(RtpEndPoint.class);

		System.out.println("MediaSrcs: " + streamA.getMediaSrcs());
		System.out.println("MediaSinks: " + streamA.getMediaSinks());

		System.out.println("MediaSrcs audio: "
				+ streamA.getMediaSrcs(MediaType.AUDIO));
		System.out.println("MediaSrcs video: "
				+ streamA.getMediaSrcs(MediaType.VIDEO));

		System.out.println("MediaSinks audio: "
				+ streamA.getMediaSinks(MediaType.AUDIO));
		System.out.println("MediaSinks video: "
				+ streamA.getMediaSinks(MediaType.VIDEO));

		streamA.release();
		streamB.release();
	}

	@Test
	public void testMixer() throws MediaException, IOException,
			InterruptedException {
		MainMixer mixer = mediaManager.createMixer(MainMixer.class);
		mixer.release();
	}

}

@@ -184,16 +184,73 @@
 unWith;%0A
+import org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A
 import o
@@ -506,320 +506,8 @@
 r;%0A%0A
-import com.kurento.kmf.media.MainMixer;%0Aimport com.kurento.kmf.media.MediaException;%0Aimport com.kurento.kmf.media.MediaManager;%0Aimport com.kurento.kmf.media.MediaManagerFactory;%0Aimport com.kurento.kmf.media.PlayerEndPoint;%0Aimport com.kurento.kmf.media.RecorderEndPoint;%0Aimport com.kurento.kmf.media.RtpEndPoint;%0A
 impo
@@ -668,16 +668,108 @@
 Test %7B%0A%0A
+%09private static final Logger log = LoggerFactory%0A%09%09%09.getLogger(SyncMediaServerTest.class);%0A%0A
 %09@Autowi
@@ -1296,34 +1296,25 @@
 ass);%0A%09%09
-System.out.println
+log.debug
 (%22genera
@@ -1332,37 +1332,33 @@
 sionDecriptor: %22
-%0A%09%09%09%09
+ 
 + stream.generat
@@ -1370,34 +1370,25 @@
 r());%0A%09%09
-System.out.println
+log.debug
 (%22proces
@@ -1465,34 +1465,25 @@
 t%22));%0A%09%09
-System.out.println
+log.debug
 (%22proces
@@ -2436,34 +2436,25 @@
 ss);%0A%0A%09%09
-System.out.println
+log.debug
 (%22MediaS
@@ -2489,34 +2489,25 @@
 s());%0A%09%09
-System.out.println
+log.debug
 (%22MediaS
@@ -2545,34 +2545,25 @@
 ());%0A%0A%09%09
-System.out.println
+log.debug
 (%22MediaS
@@ -2566,37 +2566,33 @@
 diaSrcs audio: %22
-%0A%09%09%09%09
+ 
 + streamA.getMed
@@ -2619,34 +2619,25 @@
 IO));%0A%09%09
-System.out.println
+log.debug
 (%22MediaS
@@ -2640,37 +2640,33 @@
 diaSrcs video: %22
-%0A%09%09%09%09
+ 
 + streamA.getMed
@@ -2694,34 +2694,25 @@
 O));%0A%0A%09%09
-System.out.println
+log.debug
 (%22MediaS
@@ -2720,29 +2720,25 @@
 nks audio: %22
-%0A%09%09%09%09
+ 
 + streamA.ge
@@ -2774,26 +2774,17 @@
 ;%0A%09%09
-System.out.println
+log.debug
 (%22Me
@@ -2800,21 +2800,17 @@
 video: %22
-%0A%09%09%09%09
+ 
 + stream

Use slf4j system instead of println