title: Set baseUrl for JerseyTest when using InMemoryTestContainerFactory
body: <p>I am new to <code>JerseyTest</code>. I have created a few unit tests for my controllers by following the numerous posts on the subject as well as the various questions on this site. I am using <code>InMemoryTestContainerFactory</code> as my tests are very simple. However, there does not seem to be a way to set <code>baseUri</code> during set up. What do I set my target to? My test classes extend the following class:</p>
  
  <pre><code>public abstract class ApiTest extends JerseyTest {
  
      @Override
      protected TestContainerFactory getTestContainerFactory() {
          return new InMemoryTestContainerFactory();
      }
  
      @Override
      protected ResourceConfig configure() {
          ResourceConfig rc = new ResourceConfig()
                  .register(SpringLifecycleListener.class)
                  .register(RequestContextFilter.class)
                  .register(this)
                  .property("contextConfig", new AnnotationConfigApplicationContext(ApplicationConfiguration.class));
  
          enable(TestProperties.LOG_TRAFFIC);
          enable(TestProperties.DUMP_ENTITY);
          forceSet(TestProperties.CONTAINER_PORT, "0");
  
          return configure(rc);
      }
  
      protected abstract ResourceConfig configure(ResourceConfig rc);
  }
  </code></pre>
  
  <p>Sample test class: </p>
  
  <pre><code>public class ResourceTest extends ApiTest {
  
      private final Client webClient = ClientBuilder.newClient();
  
      @Rule
      public ExpectedException thrown = ExpectedException.none();
  
      @Mock
      private ResourceService service;
  
      @Before
      public void setUp() throws Exception {
          initMocks(this);
      }
  
      @Override
      protected ResourceConfig configure(ResourceConfig rc) {
          rc.register(Resource.class);
          return rc;
      }
  
      @Test
      public void testGetResource() {
  
          Response response = webClient
                  .target("http://localhost:8080")
                  .path("/resource")
                  .queryParam("id", "some_id_json")
                  .request(MediaType.APPLICATION_JSON_TYPE)
                  .get();
  
          assertThat(response.getStatus(), is(Response.Status.BAD_REQUEST));
          assertThat(response.readEntity(Errors.class).getMessages().get(0), isA(String.class));
      }
  }
  </code></pre>
  
  <p>None of the sample code available on this site seem to be configuring the <code>baseUri</code>(see <a href="https://stackoverflow.com/a/28620966/341008">this</a> for example). And yet, if I set it to some arbitrary value <code>http://localhost:xxx</code> I get connection refused (obviously?). If I set it to just the path, I get the error <code>base URL is not absolute</code>.</p>