Package testapps.springtest

Source Code of testapps.springtest.AppTest

package testapps.springtest;

import org.springframework.http.client.SimpleClientHttpRequestFactory;
import testapps.springtest.components.ComponentA;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.client.RestTemplate;
import java.net.InetSocketAddress;
import java.net.Proxy;


/**
* TODO: integration test should be created out of this code
*/
@ComponentScan("testapps.springtest.components")
@Configuration
@ContextConfiguration(classes = { AppTest.class })
@RunWith(SpringJUnit4ClassRunner.class)
public class AppTest {
  @Autowired
  private ApplicationContext applicationContext;

  @Autowired
  private ComponentA component;

  @Test
  public void testAbc() {
    SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();

    Proxy proxy = new Proxy(java.net.Proxy.Type.HTTP,
      new InetSocketAddress("devproxy.rz.is24.loc", 3128));
    requestFactory.setProxy(proxy);

    RestTemplate template = new RestTemplate(requestFactory);
    //template = new RestTemplate();


    String response = template.getForObject("http://www.google.pl", String.class);
    System.out.println(response.length());
  }
}
TOP

Related Classes of testapps.springtest.AppTest

TOP
Copyright © 2018 www.massapi.com. 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.