Package siena.remote

Examples of siena.remote.URLConnector


import siena.remote.URLConnector;

public class URLConnectorTest extends TestCase {
 
  public void testURLConnector() throws Exception {
    URLConnector connector = new URLConnector();
   
    Properties properties = new Properties();
    properties.setProperty("backend", "http://example.com/");
    connector.configure(properties);
   
    connector.connect();
   
    OutputStream out = connector.getOutputStream();
    out.close();
   
    InputStream in = connector.getInputStream();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
   
    byte[] buff = new byte[1024];
    int read;
    do {
      read = in.read(buff);
      if(read == -1) break;
      baos.write(buff, 0, read);
    } while(true);
   
    String s = new String(baos.toByteArray());
    assertTrue(s.indexOf("http://www.rfc-editor.org/rfc/rfc2606.txt") > 0);
   
    connector.close();
  }
View Full Code Here


   
    connector.close();
  }
 
  public void testMalformedURL() {
    URLConnector connector = new URLConnector();
   
    Properties properties = new Properties();
    properties.setProperty("backend", "hello");
    try {
      connector.configure(properties);
    } catch(SienaException e) {
      return;
    }
    fail("configure() should have been failed due to a MalformedURLException");
  }
View Full Code Here

TOP

Related Classes of siena.remote.URLConnector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.