Package com.kurento.kmf.repository

Examples of com.kurento.kmf.repository.RepositoryItem


  @Test(expected = DuplicateItemException.class)
  public void duplicateTest() throws IOException {

    Repository repository = getRepository();

    RepositoryItem item = repository.createRepositoryItem("file1");
    item.createOutputStreamToWrite().close();

    RepositoryItem item2 = repository.createRepositoryItem("file1");
    item2.createOutputStreamToWrite().close();

  }
View Full Code Here


    Repository repository = getRepository();

    for (int i = 0; i < 10; i++) {
      try {
        RepositoryItem item = repository.findRepositoryItemById("File"
            + i + ".txt");
        repository.remove(item);
      } catch (NoSuchElementException e) {
        // Do nothing if repository item doesn't exist
      }
    }

    for (int i = 0; i < 10; i++) {

      RepositoryItem item = repository.createRepositoryItem("File" + i
          + ".txt");
      item.putMetadataEntry("numFile", Integer.toString(i));
      item.putMetadataEntry("att", "value");
      item.putMetadataEntry("regexAtt", "token" + Integer.toString(i));
      OutputStream os = item.createOutputStreamToWrite();
      os.write(0);
      os.close();

    }

    for (int i = 0; i < 10; i++) {

      try {
        RepositoryItem item = repository.findRepositoryItemById("File"
            + i + ".txt");

        String numString = item.getMetadata().get("numFile");
        assertEquals(numString, Integer.toString(i));

        assertEquals(item.getMetadata().get("att"), "value");

      } catch (NoSuchElementException e) {
        fail("Element 'File" + i + ".txt' doesn't exist");
      }
View Full Code Here

public class PlayerEventsTest extends HttpRepositoryTest {

  @Test
  public void testFileUploadAndDownload() throws Exception {

    RepositoryItem repositoryItem = getRepository().createRepositoryItem();

    String id = repositoryItem.getId();

    File fileToUpload = new File("test-files/sample.txt");

    uploadWithEvents(repositoryItem, fileToUpload);
View Full Code Here

  }

  private File downloadWithEvents(String id) throws Exception,
      InterruptedException {

    RepositoryItem newRepositoryItem = getRepository()
        .findRepositoryItemById(id);

    RepositoryHttpPlayer player = newRepositoryItem
        .createRepositoryHttpPlayer();

    final CountDownLatch started = new CountDownLatch(1);
    player.addSessionStartedListener(new RepositoryHttpEventListener<HttpSessionStartedEvent>() {
      @Override
View Full Code Here

  @Override
  public void onContentRequest(HttpRecorderSession contentSession)
      throws Exception {
    Repository repository = contentSession.getRepository();
    RepositoryItem repositoryItem;
    String itemId = "itemJackVader";
    try {
      repositoryItem = repository.findRepositoryItemById(itemId);
      getLogger().info("Deleting existing repository '{}'", itemId);
      repository.remove(repositoryItem);
    } catch (NoSuchElementException e) {
      getLogger().info("Repository item '{}' does not previously exist",
          itemId);
    }

    repositoryItem = contentSession.getRepository().createRepositoryItem(
        itemId);
    RepositoryHttpRecorder recorder = repositoryItem
        .createRepositoryHttpRecorder();
    String mediaUrl = contentSession.getHttpServletRequest().getScheme()
        + "://" + config.getHandlerAddress() + ":"
        + contentSession.getHttpServletRequest().getServerPort()
        + recorder.getURL();
View Full Code Here

  @Test
  public void test() throws Exception {

    String id = "logo.png";

    RepositoryItem item;
    try {
      item = getRepository().findRepositoryItemById(id);
    } catch (NoSuchElementException e) {
      item = getRepository().createRepositoryItem(id);
      uploadFile(new File("test-files/" + id), item);
    }

    RepositoryHttpPlayer player = item.createRepositoryHttpPlayer();

    String url = player.getURL();

    player.setAutoTerminationTimeout(100000);
View Full Code Here

      .getLogger(ErrorEventsTest.class);

  @Test
  public void testFileUploadAndDownload() throws Exception {

    RepositoryItem item = getRepository().createRepositoryItem();

    final RepositoryHttpRecorder recorder = item
        .createRepositoryHttpRecorder();

    final CountDownLatch started = new CountDownLatch(1);
    recorder.addSessionStartedListener(new RepositoryHttpEventListener<HttpSessionStartedEvent>() {
      @Override
      public void onEvent(HttpSessionStartedEvent event) {
        started.countDown();
      }
    });

    final CountDownLatch errorLatch = new CountDownLatch(1);
    recorder.addSessionErrorListener(new RepositoryHttpEventListener<HttpSessionErrorEvent>() {
      @Override
      public void onEvent(HttpSessionErrorEvent event) {
        log.info("Error event sent");
        log.info("Exception:" + event.getCause());
        errorLatch.countDown();
      }
    });

    log.info("Start writing to URL " + recorder.getURL()
        + " the item with id '" + item.getId() + "'");

    new Thread() {
      public void run() {
        try {
          uploadFileWithPOST(recorder.getURL(), new File(
View Full Code Here

      .getLogger(RangePutTests.class);

  @Test
  public void testFileUploadWithSeqPUTs() throws Exception {

    RepositoryItem repositoryItem = getRepository().createRepositoryItem();

    String id = repositoryItem.getId();

    File fileToUpload = new File("test-files/logo.png");

    uploadFileWithSeqPUTs(repositoryItem.createRepositoryHttpRecorder(),
        fileToUpload, repositoryItem);

    RepositoryItem newRepositoryItem = getRepository()
        .findRepositoryItemById(id);

    File downloadedFile = new File("test-files/tmp/" + id);
    downloadFromURL(
        newRepositoryItem.createRepositoryHttpPlayer().getURL(),
        downloadedFile);

    assertTrue("The uploaded file and downloaded one are different",
        TestUtils.equalFiles(fileToUpload, downloadedFile));
  }
View Full Code Here

  }

  @Test
  public void testFileUploadWithPOSTAndDownload() throws Exception {

    RepositoryItem repositoryItem = getRepository().createRepositoryItem();

    String id = repositoryItem.getId();

    File fileToUpload = new File("test-files/sample.txt");
    RepositoryHttpRecorder recorder = repositoryItem
        .createRepositoryHttpRecorder();

    uploadFileWithPOST(recorder.getURL(), fileToUpload);

    recorder.stop();

    RepositoryItem newRepositoryItem = getRepository()
        .findRepositoryItemById(id);

    File downloadedFile = new File("test-files/tmp/" + id);
    downloadFromURL(
        newRepositoryItem.createRepositoryHttpPlayer().getURL(),
        downloadedFile);

    assertTrue(TestUtils.equalFiles(fileToUpload, downloadedFile));
  }
View Full Code Here

  public void execute() throws Exception {

    startServer();

    RepositoryItem repositoryItem = getRepository().createRepositoryItem();

    prepareToUploadVideo(repositoryItem);
    prepareToDownloadVideo(repositoryItem);

    stopServer();
View Full Code Here

TOP

Related Classes of com.kurento.kmf.repository.RepositoryItem

Copyright © 2018 www.massapicom. 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.