java - How to configure deployment servlet contexts using jersey test framework -


so trying use junit test apis exposed via jersey 2. have on tomcat server using following context.xml connect oracle db:

/meta-inf/context.xml:

<context>    <resource name="jdbc/deliverydb"             auth="container"             type="javax.sql.datasource"             username="usernamee"             password="password"             driverclassname="oracle.jdbc.oracledriver"             url="someurl"             maxtotal="3"             maxidle="3" />  </context> 

and below junit code:

@override protected testcontainerfactory gettestcontainerfactory() {     return new grizzlywebtestcontainerfactory(); }  @override protected deploymentcontext configuredeployment(){     return servletdeploymentcontext             .forservlet(new servletcontainer( new resourceconfig( myresource.class )                     .packages("provider_package") ) )             .contextparam("contextconfiglocation", "/meta-inf/context.xml")             .initparam(serverproperties.provider_packages, "provider_package")             .build(); }  @test public void test () throws exception  {        string result = target("targeturl")             .request(mediatype.application_json)             .get(string.class);      assertequals("ok", result); } 

when run test directly above, gets resource pointed "targeturl" fine. however, in resource, attempts connect database can elements. however, fails when context lookup occurs. when manually tests using postman directly touch url, works fine.

i think it's happening because deployed servlet not seeing context.xml file correctly, or not seeing tomcat server or something. i'm not sure next steps are, , i'm aimlessly googling @ point. appreciated. thanks!


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -