Package com.mongodb.gridfs

Examples of com.mongodb.gridfs.GridFSFile


   * @see DATAMONGO-6
   */
  @Test
  public void storesAndFindsSimpleDocument() throws IOException {

    GridFSFile reference = operations.store(resource.getInputStream(), "foo.xml");

    List<GridFSDBFile> result = operations.find(null);
    assertThat(result.size(), is(1));
    assertSame(result.get(0), reference);
  }
View Full Code Here


   */
  @Test
  public void writesMetadataCorrectly() throws IOException {

    DBObject metadata = new BasicDBObject("key", "value");
    GridFSFile reference = operations.store(resource.getInputStream(), "foo.xml", metadata);

    List<GridFSDBFile> result = operations.find(query(whereMetaData("key").is("value")));
    assertThat(result.size(), is(1));
    assertSame(result.get(0), reference);
  }
View Full Code Here

  public void marshalsComplexMetadata() throws IOException {

    Metadata metadata = new Metadata();
    metadata.version = "1.0";

    GridFSFile reference = operations.store(resource.getInputStream(), "foo.xml", metadata);
    List<GridFSDBFile> result = operations.find(query(whereFilename().is("foo.xml")));
    assertThat(result.size(), is(1));
    assertSame(result.get(0), reference);
  }
View Full Code Here

   * @see DATAMONGO-6
   */
  @Test
  public void findsFilesByResourcePattern() throws IOException {

    GridFSFile reference = operations.store(resource.getInputStream(), "foo.xml");

    GridFsResource[] resources = operations.getResources("*.xml");
    assertThat(resources.length, is(1));
    assertThat(resources[0].getId(), is(reference.getId()));
    assertThat(resources[0].contentLength(), is(reference.getLength()));
    assertThat(resources[0].getContentType(), is(reference.getContentType()));
  }
View Full Code Here

   * @see DATAMONGO-6
   */
  @Test
  public void findsFilesByResourceLocation() throws IOException {

    GridFSFile reference = operations.store(resource.getInputStream(), "foo.xml");

    GridFsResource[] resources = operations.getResources("foo.xml");
    assertThat(resources.length, is(1));
    assertThat(resources[0].getId(), is(reference.getId()));
    assertThat(resources[0].contentLength(), is(reference.getLength()));
    assertThat(resources[0].getContentType(), is(reference.getContentType()));
  }
View Full Code Here

   * @see DATAMONGO-503
   */
  @Test
  public void storesContentType() throws IOException {

    GridFSFile reference = operations.store(resource.getInputStream(), "foo2.xml", "application/xml");

    List<GridFSDBFile> result = operations.find(query(whereContentType().is("application/xml")));
    assertThat(result.size(), is(1));
    assertSame(result.get(0), reference);
  }
View Full Code Here

   * @see DATAMONGO-534
   */
  @Test
  public void considersSortWhenQueryingFiles() throws IOException {

    GridFSFile second = operations.store(resource.getInputStream(), "foo.xml");
    GridFSFile third = operations.store(resource.getInputStream(), "foobar.xml");
    GridFSFile first = operations.store(resource.getInputStream(), "bar.xml");

    Query query = new Query().with(new Sort(Direction.ASC, "filename"));

    List<GridFSDBFile> result = operations.find(query);
    assertThat(result, hasSize(3));
View Full Code Here

   * @see DATAMONGO-534
   */
  @Test
  public void queryingWithNullQueryReturnsAllFiles() throws IOException {

    GridFSFile reference = operations.store(resource.getInputStream(), "foo.xml");

    List<GridFSDBFile> result = operations.find(null);

    assertThat(result, hasSize(1));
    assertSame(result.get(0), reference);
View Full Code Here

   */
  @Test
  public void storesAndFindsSimpleDocumentWithMetadataDBObject() throws IOException {

    DBObject metadata = new BasicDBObject("key", "value");
    GridFSFile reference = operations.store(resource.getInputStream(), metadata);

    List<GridFSDBFile> result = operations.find(query(whereMetaData("key").is("value")));

    assertThat(result.size(), is(1));
    assertSame(result.get(0), reference);
View Full Code Here

  @Test
  public void storesAndFindsSimpleDocumentWithMetadataObject() throws IOException {

    Metadata metadata = new Metadata();
    metadata.version = "1.0";
    GridFSFile reference = operations.store(resource.getInputStream(), metadata);

    List<GridFSDBFile> result = operations.find(query(whereMetaData("version").is("1.0")));

    assertThat(result.size(), is(1));
    assertSame(result.get(0), reference);
View Full Code Here

TOP

Related Classes of com.mongodb.gridfs.GridFSFile

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.