package org.jboss.resteasy.client.spring.test.contextrefresh; import static org.junit.Assert.*; import java.util.Enumeration; import junit.framework.Assert; import org.jboss.resteasy.client.ClientRequest; import org.jboss.resteasy.client.ClientResponse; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.mortbay.jetty.Server; import org.mortbay.jetty.webapp.WebAppContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextLoader; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.web.context.WebApplicationContext; /** * RESTEASY-632. * Test suggested by Holger Morch. * * @author Ron Sigal * @version $Revision: 1.1 $ * Created Feb 12, 2012 */ //@RunWith(SpringJUnit4ClassRunner.class) //@ContextConfiguration( // locations ={ "classpath:spring-test-context-refresh-main.xml" } //// , loader=org.jboss.resteasy.client.spring.test.contextrefresh.TestContextLoader.class // ) public class NewContextRefreshTest { @BeforeClass public static void before() throws Exception { Server server = new Server(9092); WebAppContext context = new WebAppContext(); context.setDescriptor("WEB-INF/web-context-refresh.xml"); context.setResourceBase("src/test/resources"); context.setContextPath("/"); context.setParentLoaderPriority(true); server.setHandler(context); server.start(); } @Test public void testContextRefresh() throws Exception { assertTrue(TriggerRefresh.isOK()); Enumeration en = TriggerRefresh.getApplicationContext().getServletContext().getAttributeNames(); while (en.hasMoreElements()) { System.out.println(en.nextElement()); } Object o = TriggerRefresh.getApplicationContext().getServletContext().getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); System.out.println(o); assertFalse(o instanceof Exception); } }