ZATS Cookies"

From Documentation
(Created page with "{{Template:UnderConstruction}} {{ZATSEssentialsPageHeader}} Since 1.1.0 =Cookies= We usually perform the file downloading through the <javadoc>org.zkoss.zul.Filedownload</java...")
 
Line 3: Line 3:
 
  Since 1.1.0
 
  Since 1.1.0
  
=Cookies=
+
== Cookies handling ==
 +
In order to provide developers handle the [http://www.ietf.org/rfc/rfc2965.txt HTTP cookies], ZATS Mimic introduces a group of methods on
  
We usually perform the file downloading through the <javadoc>org.zkoss.zul.Filedownload</javadoc> when some events occurred<ref>for more detail, please refer to [[ZK_Component_Reference/Essential_Components/Filedownload]]</ref>. The following is a typical example about downloading a file:
 
 
<source lang="java" high="4">
 
<zk>
 
<button id="btn" label="download">
 
<attribute name="onClick"><![CDATA[
 
org.zkoss.zul.Filedownload.save("foo.txt", "application/octet-stream");
 
]]>
 
</attribute>
 
</button>
 
</zk>
 
</source>
 
 
Actually, the downloaded mechanism is a process with two steps. When you invoke <tt>save()</tt>, the <tt>Filedownload</tt> simply notifies ZK client engine of the downloaded URL. Then, the ZK client engine downloads such files according to the received URL.
 
 
'''Notes'''
 
<references/>
 
 
== Download files in a ZATS Mimic test case ==
 
 
In order to simulate same behavior as ZK client engine doing, ZATS Mimic introduces the <tt>Resource</tt> interface. It represents a downloadable resource file at server. The typical steps for testing downloading are:
 
# perform some operations through operation agents
 
# check is there a downloadable resource through desktop agent
 
# fetch and verify the information or content of the resource
 
 
<source lang="java" high="8,9,10,11,12,13">
 
@Test
 
public void test() throws Exception {
 
Zats.init(".");
 
try {
 
DesktopAgent desktop = Zats.newClient().connect("/foo.zul");
 
Assert.assertNull(desktop.getDownloadable());
 
 
desktop.query("#btn").click();
 
Resource resource = desktop.getDownloadable();
 
Assert.assertNotNull(resource);
 
Assert.assertEquals("hello.txt", resource.getName());
 
String content = fetchContent(resource.getInputStream());
 
Assert.assertEquals("Hello world!", content);
 
} finally {
 
Zats.end();
 
}
 
}
 
</source>
 
 
* '''Line 6, 9, 10''': Because ZATS Mimic handles the response from ZK application automatically, we can get the current downloadable resource file from the <tt>DesktopAgent.getDownloadable()</tt>. The method might return <tt>null</tt> when getting the downloadable resource, it indicates that there is no downloadable resource after the previous operation.
 
 
* '''Line 11-13''': We can get more information from <tt>Resource</tt>, or fetch the content of resource file in binary through the input stream.
 
  
 
{{ZATSEssentialsPageFooter}}
 
{{ZATSEssentialsPageFooter}}

Revision as of 07:26, 8 June 2012

WarningTriangle-32x32.png This page is under construction, so we cannot guarantee the accuracy of the content!

aowang



Since 1.1.0

Cookies handling

In order to provide developers handle the HTTP cookies, ZATS Mimic introduces a group of methods on


Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.