On Fri, Jan 8, 2016 at 2:45 PM, Malmee Weerasinghe <[email protected]> wrote:

> Hi Imesh,
>
> I have used servlets to implement the REST API as I am more familiar with
> servlets than JAX-RS.Is it fine to use servlets or should I use JAX-RS?
>

It would be better to use JAX-RS for implementing REST APIs in Java than
servlet. The down side of using servlet is that servlets do not provide
features required for implementing REST API methods. All of those
features  (handling context paths, context path parameters, query
parameters, request headers, response headers, content type, validations,
etc) need to be implemented separately. I can see that you have already
done that in above servlets.

>
> In here two servlets are used as the paths used are different when
> retrieving the JSON files. In one servlet the context path is
> migration/admin while in the other the context path is stratos/admin.
>
> What's the purpose of migration/admin?


> The values for the constants are different in the test cases. The paths
> used are different in the test cases and therefore the values are assigned
> in test cases.
>
> By design constants should be defined as final, that's why we call them
constants. Please refer [1].

[1] https://howtoprogramwithjava.com/what-is-a-constant/

Thanks


> Thanks
>
> On Fri, Jan 8, 2016 at 1:30 PM, Imesh Gunaratne <[email protected]> wrote:
>
>> Hi Malmee,
>>
>> I have few questions:
>>
>>    - Why do we use servlets to implement a REST API instead of JAX-RS?
>>    Have a look at [1].
>>    - Why are we having two servlets instead of one?
>>    - Why do we assign values to constants in runtime, don't they need to
>>    be final?
>>
>> Constants.CERTIFICATE_PATH = TestConstants.TEST_CERTIFICATE;
>> Constants.DIRECTORY_SOURCE_SCRIPT =
>> TestConstants.TEST_DIRECTORY_SOURCE_SCRIPT;
>> Constants.ROOT_DIRECTORY = TestConstants.OUTPUT_DIRECTORY;
>>
>>
>> [1]
>> https://nikolaygrozev.wordpress.com/2014/10/16/rest-with-embedded-jetty-and-jersey-in-a-single-jar-step-by-step/
>>
>> Thanks
>>
>> On Fri, Jan 8, 2016 at 9:38 AM, Malmee Weerasinghe <[email protected]>
>> wrote:
>>
>>> Hi All,
>>> We have added unit tests for the Artifact Migration Tool which converts
>>> PPaaS 4.0.0 artifact JSON files to PPaaS 4.1.x. [1]
>>>
>>> The testing is done using Jetty web server to mock the REST API by
>>> adding two servlets. The response JSONs are transformed from the tool and
>>> the output files are tested with a set of sample output files in the test
>>> case.
>>>
>>> [1]
>>> https://github.com/nishadi/product-private-paas/tree/master/tools/migration/ppaas-artifact-converter
>>>
>>> Thanks
>>>
>>>
>>> --
>>> Malmee Weerasinghe
>>> WSO2 Intern
>>> mobile : (+94)* 71 7601905* |   email :   <[email protected]>
>>> [email protected]
>>>
>>
>>
>>
>> --
>> *Imesh Gunaratne*
>> Senior Technical Lead
>> WSO2 Inc: http://wso2.com
>> T: +94 11 214 5345 M: +94 77 374 2057
>> W: http://imesh.gunaratne.org
>> Lean . Enterprise . Middleware
>>
>>
>
>
> --
> Malmee Weerasinghe
> WSO2 Intern
> mobile : (+94)* 71 7601905* |   email :   <[email protected]>
> [email protected]
>



-- 
*Imesh Gunaratne*
Senior Technical Lead
WSO2 Inc: http://wso2.com
T: +94 11 214 5345 M: +94 77 374 2057
W: http://imesh.gunaratne.org
Lean . Enterprise . Middleware
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to