Package com.kurento.kmf.test.content

Source Code of com.kurento.kmf.test.content.ContentApiPerformancePlayerTest

/*
* (C) Copyright 2014 Kurento (http://kurento.org/)
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser General Public License
* (LGPL) version 2.1 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-2.1.html
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*/
package com.kurento.kmf.test.content;

import java.net.URL;

import org.junit.Assert;
import org.junit.Test;

import com.kurento.kmf.content.HttpPlayerHandler;
import com.kurento.kmf.content.HttpPlayerService;
import com.kurento.kmf.content.HttpPlayerSession;
import com.kurento.kmf.media.HttpGetEndpoint;
import com.kurento.kmf.media.MediaPipeline;
import com.kurento.kmf.media.PlayerEndpoint;
import com.kurento.kmf.test.base.ContentApiTest;
import com.kurento.kmf.test.client.JMeterClient;

/**
*
* <strong>Description</strong>: Performance test of a HTTP Player using JMeter
* as client.<br/>
* <strong>Pipeline</strong>:
* <ul>
* <li>N x (PlayerEndpoint -> HttpGetEndpoint)</li>
* </ul>
* <strong>Pass criteria</strong>:
* <ul>
* <li>Timeout waiting JMeter ending</li>
* </ul>
*
* @author Micael Gallego (micael.gallego@gmail.com)
* @author Boni Garcia (bgarcia@gsyc.es)
* @since 4.2.3
*/
public class ContentApiPerformancePlayerTest extends ContentApiTest {

  private static final String HANDLER = "/playerPerformance";

  @HttpPlayerService(path = HANDLER, redirect = true, useControlProtocol = false)
  public static class PlayerRedirect extends HttpPlayerHandler {

    private PlayerEndpoint playerEP;

    @Override
    public void onContentRequest(HttpPlayerSession session)
        throws Exception {
      MediaPipeline mp = session.getMediaPipelineFactory().create();
      session.releaseOnTerminate(mp);
      playerEP = mp.newPlayerEndpoint(
          "http://files.kurento.org/video/small.webm").build();
      HttpGetEndpoint httpEP = mp.newHttpGetEndpoint().terminateOnEOS()
          .build();
      playerEP.connect(httpEP);
      session.start(httpEP);
    }

    @Override
    public void onContentStarted(HttpPlayerSession session)
        throws Exception {
      playerEP.play();
    }
  }

  @Test
  public void testPerfPlayer() throws Exception {
    URL url = new URL("http://localhost:" + getServerPort() + HANDLER);
    JMeterClient jmeter = new JMeterClient(url);
    jmeter.setConcurrentUsers(5);
    jmeter.start();
    Assert.assertTrue("Timeout waiting JMeter ending",
        jmeter.waitForEnding());
  }

}
TOP

Related Classes of com.kurento.kmf.test.content.ContentApiPerformancePlayerTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.