Android Open Source - WeatherBar Client Request Test






From Project

Back to project page WeatherBar.

License

The source code is released under:

MIT License

If you think the Android project WeatherBar listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.cjbarker.wb.ws;
/*  ww w  .  j av a  2  s. c o m*/
import java.io.IOException;

import org.apache.http.HttpStatus;

import com.cjbarker.wb.ws.ClientRequest;
import com.cjbarker.wb.ws.ClientResponse;

import junit.framework.TestCase;

public class ClientRequestTest extends TestCase {
  
  private static final String URI = "http://www.google.com";
  
  private ClientRequest request;
  
  @Override
    protected void setUp() throws Exception {
        super.setUp();
        this.request = new ClientRequest(URI);
    }
    
    public void testGetters() {
      assertEquals(URI, request.getBaseURI());
      assertNotNull(request.getUserAgent());
      assertTrue(request.toString().length() > 0);
    }
    
    public void testSendRequestGet() {
      ClientResponse response = null;
      try {
        response = request.sendRequest(ClientRequest.Method.GET);
        assertNotNull(response);
        assertTrue(HttpStatus.SC_OK == response.getResponseCode());
        assertNotNull(response.getResponseMessage());
        assertNotNull(response.getHeaders());
        
        String entity = new String(response.getResponseMessage());
        assertTrue(entity.length() > 0);
        assertTrue(entity.startsWith("<!doctype html>"));
      }
      catch (IOException ioe) {
        fail(ioe.getMessage());
      }
    }

}




Java Source Code List

com.cjbarker.wb.Main.java
com.cjbarker.wb.Notifier.java
com.cjbarker.wb.Prefs.java
com.cjbarker.wb.Util.java
com.cjbarker.wb.receiver.BatteryLevel.java
com.cjbarker.wb.receiver.Connection.java
com.cjbarker.wb.receiver.Screen.java
com.cjbarker.wb.ws.ClientRequestTest.java
com.cjbarker.wb.ws.ClientRequest.java
com.cjbarker.wb.ws.ClientResponse.java
com.cjbarker.wb.ws.OpenWeatherTest.java
com.cjbarker.wb.ws.OpenWeather.java
com.cjbarker.wb.ws.WeatherTest.java
com.cjbarker.wb.ws.Weather.java