아래와 같은 코드가 있습니다.

http프로토콜을 사용해서 어떠한 값이 넘어오면

참을 반환하고 없으면 거짓을 반환하는 메서드가있습니다.


그럼 이코드를 테스트 프로젝트를 생성해서 assertTrue로 true를 체크하고 싶은데 ...


테스트프로젝트 생성은 안겠는데...TestClass 에서 어떤 클래스를 extends를 해서 받아와야하는건가요??


public class ServerCheck {
    public boolean isServerOn(String host, int port){
        // Result
        boolean result = false;
        String TAG = "isServerOn";
       
        URI uri = null;

        try {
            uri = URIUtils.createURI("http", host, port, "/", null, null);

            // Http parameter setting
            HttpParams httpParams = new BasicHttpParams();
            // Http Timeout
            HttpConnectionParams.setConnectionTimeout(httpParams, 10000);

            // Create an instance of HttpClient.
            HttpClient httpClient = new DefaultHttpClient(httpParams);

            // Socket Timeout
            HttpConnectionParams.setSoTimeout(httpParams, 10000);

            // Create a method instance.
            HttpGet httpGet = new HttpGet(uri);

            Log.v(TAG, "URI ==> " + httpGet.getURI());

            // Create an instance HttpResponse
            HttpResponse httpResponse = null;

            // Execute the request
            httpResponse = httpClient.execute(httpGet);

            // Examine the response status
            Log.i(TAG, "hc ===> " + httpResponse.getStatusLine().toString());

            // Get hold of the response entity
            HttpEntity he = httpResponse.getEntity();
           
            result = true;
            if (he != null) {
                Log.v("isServerOn", "File Size is " + Long.toString(he.getContentLength()));
                result = false;
            }   

        } catch (URISyntaxException e) {
            Log.e(TAG, "getInputStreamFromURI URISyntaxException:" + e.getMessage());
        } catch (ClientProtocolException e) {
            Log.e(TAG, "getInputStreamFromURI ClientProtocolException:" + e.getMessage());
        } catch (IOException e) {
            Log.e(TAG, "getInputStreamFromURI IOException:" + e.getMessage());
        }

        return result;
    }
}

----------------------------------------------------------------

assertTrue(serverCheck.isServerOn("192.168.0.1", 5222));