|
|
package com.monitor;
|
|
|
|
|
|
import com.monitor.common.util.HttpRestClient;
|
|
|
import org.apache.commons.net.telnet.TelnetClient;
|
|
|
import org.apache.http.HttpResponse;
|
|
|
import org.apache.http.client.methods.HttpGet;
|
|
|
import org.apache.http.client.params.ClientPNames;
|
|
|
import org.apache.http.impl.client.BasicResponseHandler;
|
|
|
import org.apache.http.impl.client.DefaultHttpClient;
|
|
|
import org.junit.Test;
|
|
|
import org.junit.runner.RunWith;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.PropertySource;
|
|
|
import org.springframework.test.context.ContextConfiguration;
|
|
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
|
|
|
|
import java.io.*;
|
|
|
import java.net.HttpURLConnection;
|
|
|
import java.net.Socket;
|
|
|
|
|
|
/**
|
|
|
* Created by fruwei on 2016/7/5.
|
|
|
*/
|
|
|
@RunWith(SpringJUnit4ClassRunner.class)
|
|
|
@ContextConfiguration(locations = {
|
|
|
"classpath*:META-INF/spring/spring*.xml"})
|
|
|
@PropertySource({
|
|
|
"classpath:*.properties"})
|
|
|
public class HttpTest {
|
|
|
@Autowired
|
|
|
HttpRestClient httpRestClient;
|
|
|
|
|
|
@Test
|
|
|
public void test() throws IOException {
|
|
|
// String rel=httpRestClient.defaultGet("http://192.168.102.205:8080/gateway/guang/api/v1/category/get?app_version=4.4.0.1605260001&client_secret=03c54a201923249c5305bc9312276058&client_type=iphone&gender=1%2C3&os_version=8.4&screen_size=320x568&udid=778b9937f128b9077ebc76b782f46a04e06911d4&v=7&yh_channel=1",String.class);
|
|
|
String rel = "";
|
|
|
// rel = httpRestClient.defaultGet("http://192.168.102.205:8080/gateway", String.class);
|
|
|
// rel = httpRestClient.defaultGet("http://192.168.102.222:22222/?v=1", String.class);
|
|
|
// System.out.println("#################################### \n" + rel);
|
|
|
|
|
|
|
|
|
TelnetClient telnet = new TelnetClient();
|
|
|
telnet.connect("192.168.102.212", 22222);
|
|
|
InputStream in = telnet.getInputStream();
|
|
|
|
|
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
|
int i = -1;
|
|
|
while ((i = in.read()) != -1) {
|
|
|
baos.write(i);
|
|
|
}
|
|
|
|
|
|
System.out.println("################# " + baos.toString());
|
|
|
in.close();
|
|
|
baos.close();
|
|
|
telnet.disconnect();
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|