Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JerseyTest Default port change to test REST WEB SERVICE

I made a test case to test my Rest Web Service. but in test case I am seeing that the request is going to default port of jersey test framework which is http://localhost:9998 whereas my service is register on http://localhost:8080. I am unable to find that how can I change its port to 8080

public class UMServiceTest extends JerseyTest {


    @Override
    public Application configure() {
        enable(TestProperties.LOG_TRAFFIC);
        enable(TestProperties.DUMP_ENTITY);
        return new ResourceConfig(UMService.class);
    }    


    @Test
    public void testFetchAll() {
        System.out.println(getBaseUri()+"==========");
        Response output = target("usermanagement").path("um").path("user").request().get();
        assertEquals("should return status 200", 200, output.getStatus());
        //assertNotNull("Should return list", output.getEntity());
    }
like image 522
Despicable Avatar asked Oct 21 '25 13:10

Despicable


1 Answers

You could change the Systemproperty from TestProperties for the JerseyTest too.

public class UMServiceTest extends JerseyTest
{
    static
    {
        System.setProperty("jersey.config.test.container.port", "0");
    }
...
like image 160
GF. Service Avatar answered Oct 23 '25 03:10

GF. Service



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!