API Overview API Index Package Overview Direct link to this page
JavaOnTracks 0.1.2
  net.jot.test.server. ServerTest View Javadoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package net.jot.test.server;

import java.net.InetAddress;
import java.net.Socket;
import net.jot.testing.JOTTestable;
import net.jot.testing.JOTTester;
import net.jot.web.server.JOTRequestParser;
import net.jot.web.server.JOTWebRequest;
import net.jot.web.server.JOTWebResponse;

/**
 *
 * @author thibautc
 */
public class ServerTest implements JOTTestable{

    //private final static String FAKE_SESSION_ID="HKKFFJKIUTYFYKGILU76354345JK";
    
    public void __FIXME__jotTest() throws Throwable
    {
        Socket socket=new Socket("www.google.com",80);
        JOTWebRequest request=JOTRequestParser.getTestRequest(socket, "GET /folder/test#anchor?toto=3&block=4 HTTP/1.1");
        request.getHeaders().put("Host","frenchie:8033");
        JOTWebResponse response=new JOTWebResponse(socket, request);

        // fake session id.
        //request.setsessionID=FAKE_SESSION_ID;

        String path="relative.html";
        //String redir=response.encodeURL("relative.html");
        //JOTTester.checkIf("Test redirect url",redir.equals("relative.html;jsessionid="+FAKE_SESSION_ID),redir);
        //System.out.println(response.encodeURL("relative.html#anchor"));
        //JOTTester.checkIf("Test redirect url2",response.encodeURL("relative.html#anchor").equals("relative.html;jsessionid="+FAKE_SESSION_ID+"#anchor"));
        //JOTTester.checkIf("Test redirect url3",response.encodeURL("relative.html#anchor?key=123").equals("relative.html;jsessionid="+FAKE_SESSION_ID+"#anchor?key=123"));
        //JOTTester.checkIf("Test redirect url4",response.encodeURL("/root/test/index.html#anchor?key=123").equals("/root/test/index.html;jsessionid="+FAKE_SESSION_ID+"#anchor?key=123"));
        JOTTester.checkIf("Test redirect url5",response.encodeURL("http://www.google.com/q#blah?id=3").equals("http://www.google.com/q#blah?id=3"));
        
        
        
        
        System.out.println(response.absoluteURL(path));
        JOTTester.checkIf("Test sendRedirect",response.absoluteURL(path).equals(""));


        //String path="relative.html";
        System.out.println(response.encodeRedirectURL(path));
        System.out.println(response.encodeURL(path));
        System.out.println(response.absoluteURL(path));
        path="relative.html#anchor";
        System.out.println(response.encodeRedirectURL(path));
        System.out.println(response.encodeURL(path));
        System.out.println(response.absoluteURL(path));
        path="/root/test/index.html";
        System.out.println(response.encodeRedirectURL(path));
        System.out.println(response.encodeURL(path));
        System.out.println(response.absoluteURL(path));
        path="/root/test/index.html#anchor";
        System.out.println(response.encodeRedirectURL(path));
        System.out.println(response.encodeURL(path));
        System.out.println(response.absoluteURL(path));
        path="http://www.google.com/q#blah?id=3";
        System.out.println(response.encodeRedirectURL(path));
        System.out.println(response.encodeURL(path));
        System.out.println(response.absoluteURL(path));
        socket.close();
    }

    public void jotTest() throws Throwable
    {
    }

}

Generated By: JavaOnTracks Doclet 0.1.5     ©Thibaut Colar