/[storm]/storm/org/nongnu/storm/http/client/testSimpleHTTPClient.test
ViewVC logotype

Diff of /storm/org/nongnu/storm/http/client/testSimpleHTTPClient.test

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by hemppah, Mon Apr 28 09:22:49 2003 UTC revision 1.5 by hemppah, Mon Apr 28 11:05:01 2003 UTC
# Line 22  Line 22 
22    
23  import java, org  import java, org
24    
   
25  from org.nongnu.storm.http.client import HTTPConnection  from org.nongnu.storm.http.client import HTTPConnection
26  from org.nongnu.storm.http.client import HTTPRequest  from org.nongnu.storm.http.client import HTTPRequest
27  from org.nongnu.storm.http.client import HTTPResponse  from org.nongnu.storm.http.client import HTTPResponse
28  from org.nongnu.storm.impl import TransientPool  from org.nongnu.storm.impl import TransientPool
 from org.nongnu.storm.modules.gispmap import GispP2PMap  
 from org.nongnu.storm.impl.p2p import Peer  
 from org.nongnu.storm.impl import DirPool  
29  from org.nongnu.storm.util import HTTPProxy  from org.nongnu.storm.util import HTTPProxy
30    
31  host0 = "127.0.0.1"  host0 = "127.0.0.1"
# Line 47  protocol3 = "HTTP/0.9" Line 43  protocol3 = "HTTP/0.9"
43    
44  def testHTTPClient():  def testHTTPClient():
45    
46        
47             # Create a empty pool (transient pool)
48           empty = java.util.Collections.EMPTY_SET           empty = java.util.Collections.EMPTY_SET
49           pool = TransientPool(empty)                   pool = TransientPool(empty)
50            
51           #pub = TransientPool(empty)           # Create data form block
52           #cache = TransientPool(empty)           bos = pool.getBlockOutputStream("text/plain")
53           #map1 = GispP2PMap("/home/hemppah/cvs/storm")               osw = java.io.OutputStreamWriter(bos)
54           #peer = Peer(pub, cache, map1)               osw.write("Hello, world!")
55           #pool = peer.getPool()           osw.close()
56                     block = pool.get(bos.getBlockId())        
57                     blockid = block.getId().toString()
          serverthread = java.lang.Thread(HTTPProxy(pool, 5555))  
          serverthread.start()          
58                    
59                    
60             # Start HTTP-proxy thread
61             serverthread = java.lang.Thread(HTTPProxy(pool, 5555))
62             serverthread.start()
63           print "HTTP proxy thread started..."           print "HTTP proxy thread started..."
64                    
65            
66             #Create HTTP connection to localhost
67           httpconn = org.nongnu.storm.http.client.HTTPConnection(host0, port)           httpconn = org.nongnu.storm.http.client.HTTPConnection(host0, port)
68                                    
69           req = httpconn.newRequest("GET", request, protocol2, java.lang.Boolean.FALSE)                  
70           print "Make GET request(s)..."           # Perform GET request using the ID of created block
71                     print "Perform GET request(s)..."
72             req = httpconn.newRequest("GET", "rewrite/" + blockid, protocol2, java.lang.Boolean.FALSE)
73             # Add more requests here...
74            
75            
76           resp = httpconn.send(req)                 resp = httpconn.send(req)      
77           print resp.status, resp.reason           print resp.status, resp.reason
78           #assert resp.status == "Ok"  
79                     # Conditions here...
80           httpconn.close           assert resp.status == 200
81           #java.lang.Thread.currentThread().interrupt()                    
82             httpconn.close  
83           java.lang.Thread(serverthread).interrupt()           java.lang.Thread(serverthread).interrupt()
84           print "HTTP proxy thread stopped..."               print "HTTP proxy thread stopped..."    

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26