use of org.eclipse.scout.rt.ui.html.json.desktop.fixtures.DesktopWithNonDisplayableOutline in project scout.rt by eclipse.
the class JsonDesktopTest method testHandleModelDownloadResource.
@Test
public void testHandleModelDownloadResource() throws Exception {
IDesktop desktop = new DesktopWithNonDisplayableOutline();
desktop.initDesktop();
JsonDesktop<IDesktop> jsonDesktop = createJsonDesktop(desktop);
jsonDesktop.handleModelOpenUri(new BinaryResource("foo.txt", null), OpenUriAction.DOWNLOAD);
jsonDesktop.handleModelOpenUri(new BinaryResource("TP6 ARL ; Zulassung (UVV) - Bearbeitung elektr. Fax-Eingang [-8874 , ABC-Prüfbericht] (1).pdf", null), OpenUriAction.DOWNLOAD);
List<JsonEvent> events = JsonTestUtility.extractEventsFromResponse(m_uiSession.currentJsonResponse(), "openUri");
JSONObject[] data = new JSONObject[2];
data[0] = events.get(0).getData();
data[1] = events.get(1).getData();
// counter = 0 first for test run
assertEquals("dynamic/" + m_uiSession.getUiSessionId() + "/2/0/foo.txt", data[0].getString("uri"));
assertEquals("dynamic/" + m_uiSession.getUiSessionId() + "/2/1/TP6%2520ARL%2520%253B%2520Zulassung%2520%2528UVV%2529%2520-%2520Bearbeitung%2520elektr.%2520Fax-Eingang%2520%255B-8874%2520%252C%2520ABC-Pr%25C3%25BCfbericht%255D%2520%25281%2529.pdf", // counter = 1 second for test run
data[1].getString("uri"));
assertEquals("download", data[0].getString("action"));
assertEquals("download", data[1].getString("action"));
// cleanup
Jobs.getJobManager().cancel(Jobs.newFutureFilterBuilder().andMatchExecutionHint(DownloadHandlerStorage.RESOURCE_CLEANUP_JOB_MARKER).toFilter(), true);
}
use of org.eclipse.scout.rt.ui.html.json.desktop.fixtures.DesktopWithNonDisplayableOutline in project scout.rt by eclipse.
the class JsonDesktopTest method testDontSendNonDisplayableOutline.
/**
* Tests whether non displayable outline is sent.
* <p>
* This reduces response size and also leverages security because the menus are never visible to the user, not even
* with the dev tools of the browser
*/
@Test
public void testDontSendNonDisplayableOutline() throws Exception {
IDesktop desktop = new DesktopWithNonDisplayableOutline();
desktop.initDesktop();
desktop.setOutline(NonDisplayableOutlineWithOneNode.class);
JsonDesktop<IDesktop> jsonDesktop = createJsonDesktop(desktop);
JsonOutline<IOutline> jsonNonDisplayableOutline = jsonDesktop.getAdapter(desktop.findOutline(NonDisplayableOutlineWithOneNode.class));
// Adapter for NonDisplayableMenu must not exist
assertNull(jsonNonDisplayableOutline);
// Json response must not contain outline
JSONObject json = jsonDesktop.toJson();
String outlineId = json.optString("outline", null);
assertNull(outlineId);
}
Aggregations