How to load spring HTTPInvoker to jetty in test?

I have googled this one but no luck. I just want to see the example of how to load all the services I need in embedded-jetty to be able to test in JUnit. So, my goal would be something like this.


private String url = "SERVICE_URL";

@Before
public void before() {
   // start jetty with all the services I need
}

@Test
public void shouldDoSthIWant() {
   // invoke SERVICE_URL and test.
}

Answers


The sample app found here shows how to run HttpInvoker using embedded jetty in a simple java app. You should be able adapt that code to make it work in a junit. http://code.google.com/p/jianwikis/wiki/SpringHttpRemotingWithEmbeddedJettyServer

Reproducing relevant sections of the code / configuration from that pare down here

Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(port);

Context context = new Context(server, "/", Context.SESSIONS);

DispatcherServlet dispatcherServlet = new DispatcherServlet();
dispatcherServlet.setContextConfigLocation("classpath:com/mycompany/config/DefaultServlet-servlet.xml");

ServletHolder servletHolder = new ServletHolder(dispatcherServlet);
context.addServlet(servletHolder, "/*")

DefaultServlet-servlet.xml

<!-- This default handler takes care of each of the services enumerated below -->
<bean id="defaultHandlerMapping"
    class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />

<bean id="helloService" class="com.mycompany.service.impl.HelloServiceImpl"/>

<!-- SpringHTTP Service Exposure -->

<bean name="/HelloService"
    class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter"
    lazy-init="true">
    <property name="service" ref="helloService" />
    <property name="serviceInterface"
            value="com.mycompany.service.iface.HelloService" />
</bean>

Need Your Help

How do I debug an AngularJS app in Visual Studio 2013 using Grunt?

node.js angularjs visual-studio-2013 gruntjs

I am currently trying to debug an AngularJS app I'm writing using Visual Studio 2013.

Selecting default values when specific values don't exist in where clause

sql sql-server-2008 stored-procedures

I am having difficulty finding a good way to selecting a column by a default value, when a specific value doesn't exist.