Ejemplo n.º 1
0
  @Test
  public void testGetUrlFromDocumentView() {
    DocumentFileCodec codec = new DocumentFileCodec("nxfile");
    DocumentLocation docLoc =
        new DocumentLocationImpl("demo", new IdRef("dbefd5a0-35ee-4ed2-a023-6817714f32cf"));
    Map<String, String> params = new HashMap<String, String>();
    params.put(DocumentFileCodec.FILE_PROPERTY_PATH_KEY, "file:content");
    params.put(DocumentFileCodec.FILENAME_KEY, "mydoc.odt");
    DocumentView docView = new DocumentViewImpl(docLoc, null, params);

    String url = "nxfile/demo/dbefd5a0-35ee-4ed2-a023-6817714f32cf/file:content/mydoc.odt";
    assertEquals(url, codec.getUrlFromDocumentView(docView));
  }
Ejemplo n.º 2
0
  // same with reserved characters in file name and additional request params
  @Test
  public void testGetUrlFromDocumentViewWithReservedAndParams() {
    DocumentFileCodec codec = new DocumentFileCodec("nxfile");
    DocumentLocation docLoc =
        new DocumentLocationImpl("demo", new IdRef("dbefd5a0-35ee-4ed2-a023-6817714f32cf"));
    Map<String, String> params = new HashMap<String, String>();
    params.put(DocumentFileCodec.FILE_PROPERTY_PATH_KEY, "file:content");
    params.put(DocumentFileCodec.FILENAME_KEY, "my [doc]? \u00e9.odt");
    params.put("foo", "bar");
    DocumentView docView = new DocumentViewImpl(docLoc, null, params);

    String url =
        "nxfile/demo/dbefd5a0-35ee-4ed2-a023-6817714f32cf/file:content/my%20%5Bdoc%5D%3F%20%C3%A9.odt?foo=bar";
    assertEquals(url, codec.getUrlFromDocumentView(docView));
  }
Ejemplo n.º 3
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));
  }
Ejemplo n.º 4
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"));
  }