Hello,
I am trying to write test cases for our nuxeo app and I find this
extremely difficult to do. Among other problems, I am presently stuck on
the following test case:

  @Test
  public void aDocumentWithPicturesCanProvideMultiview() throws Exception {
    // session object is created using a test repository along the line 
    // of what is done in OSGIRepositoryTestCase. 
    DocumentModel root = session.getRootDocument();
    DocumentModel document1 = session.createDocumentModel(
        root.getPathAsString(), "document", "Folder");
    document1.setProperty("dublincore", "description", "toto");
    document1 = session.createDocument(document1);
    // type News as among other facet MultiviewPicture
    DocumentModel fils = session.createDocumentModel(
        document1.getPathAsString(), "fils" + 1, "News");
    fils = session.createDocument(fils);
    fils.setProperty("dublincore", "description", "fils" + 1 + " description");
    fils.setProperty("dublincore", "valid", Calendar.getInstance());
    // PortalPictureAdapter just creates the various views for a given 
    // image
    PortalPictureAdapter adapter = (PortalPictureAdapter) 
fils.getAdapter(PictureResourceAdapter.class);
    URL uri = getClass().getResource("/web/resources/images/layer_print.jpg");
    // I had lot of troubles creating a Blob from a Stream (ie. using 
StreamingBlob.createFromInputStream) because the stream is 
    // read twice: once for extracting metadata, the other one for the data
    Blob blob = new URLBlob(uri, "image/jpeg");
    boolean ret = adapter.createPicture(blob, "toto.jpg", "Thumbnail");
    session.save();
    DocumentModel documentModel = 
session.getChildren(document1.getRef()).get(0);
    MultiviewPicture multiview = 
documentModel.getAdapter(MultiviewPicture.class);
    System.err.println(fils.getRef());
    assertEquals(fils.getRef(), documentModel.getRef());
    assertEquals(fils, documentModel);
    assertNotNull(fils.getAdapter(MultiviewPicture.class).getView("Thumbnail"));
    // test fails here
    assertNotNull(multiview.getView("Thumbnail"));
  }

The fact that the last assertion fails can be traced to the various
views not being populated. I tried to debug step-by-step the creation of
the document from getChildren() and it seems that the readModel() method
does not extract/find the pictures from the repository.

Am I forgetting something obvious ?

Regards,
Arnaud Bailly



Ce message et toutes les pièces jointes sont établis à l'attention exclusive de 
leurs destinataires et sont confidentiels. Si vous recevez ce message par 
erreur, merci de le détruire et d'en avertir immédiatement l'expéditeur. 
L'internet ne permettant pas d'assurer l'intégrité de ce message, le contenu de 
ce message ne représente en aucun cas un engagement de la part de Leroy Merlin.

_______________________________________________
ECM mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm

Reply via email to