示例#1
0
  @Test
  public void testGetDocumentViewFromUrl() {
    DocumentFileCodec codec = new DocumentFileCodec();
    codec.setPrefix("nxfile");
    String url = "nxfile/demo/dbefd5a0-35ee-4ed2-a023-6817714f32cf/file:content/mydoc.odt";
    DocumentView docView = codec.getDocumentViewFromUrl(url);

    DocumentLocation docLoc = docView.getDocumentLocation();
    assertEquals("demo", docLoc.getServerName());
    assertEquals(new IdRef("dbefd5a0-35ee-4ed2-a023-6817714f32cf"), docLoc.getDocRef());
    assertNull(docView.getViewId());
    assertNull(docView.getSubURI());

    Map<String, String> params = docView.getParameters();
    assertEquals("file:content", params.get(DocumentFileCodec.FILE_PROPERTY_PATH_KEY));
    assertEquals("mydoc.odt", params.get(DocumentFileCodec.FILENAME_KEY));
  }
示例#2
0
  // same with reserved characters in file name and params
  @Test
  public void testGetDocumentViewFromUrlWithReservedAndParams() {
    DocumentFileCodec codec = new DocumentFileCodec("nxfile");
    String url =
        "nxfile/demo/dbefd5a0-35ee-4ed2-a023-6817714f32cf/file:content/my%20%5Bdoc%5D%3F%20%C3%A9.odt?foo=bar";
    DocumentView docView = codec.getDocumentViewFromUrl(url);

    DocumentLocation docLoc = docView.getDocumentLocation();
    assertEquals("demo", docLoc.getServerName());
    assertEquals(new IdRef("dbefd5a0-35ee-4ed2-a023-6817714f32cf"), docLoc.getDocRef());
    assertNull(docView.getViewId());
    assertNull(docView.getSubURI());

    Map<String, String> params = docView.getParameters();
    assertEquals("file:content", params.get(DocumentFileCodec.FILE_PROPERTY_PATH_KEY));
    assertEquals("my [doc]? \u00e9.odt", params.get(DocumentFileCodec.FILENAME_KEY));
    assertEquals("bar", params.get("foo"));
  }