java - JUnit Test of Code that uses GAE/J URLFetchServiceFactory.getURLFetchService() -


I have some code I'm deploying on Google App Engine - Java (GAE / J) which it uses Does URLFetchService . I want to use JUnit to test this code. This appears to be a must i have a test that uses their LocalURLFetchServiceTestConfig class is roughly as follows:

  Public class MyRemoteServiceTests {Personal Static Last LocalURLFetchServiceTestConfig urlConfig = New LocalURLFetchServiceTestConfig (); Private Static Final LocalServiceTestHelper Assistant = New LocalServiceTestHelper (urlConfig); @ First public set up () throws an exception {service = new sample service (); Helper.setUp (); } The public zero tiredown () throws up after {exception} {service = null; Helper.tairDown (); } @Test Public Zero testThatCallsCodeThatUsesUrlFetch () {Object Data = service.getRemoteDataUsingUrlFetch ("foo", "bar"); Assert.assertNotNull (data); }}   

I still believe that this trial has failed despite using the recommended "assistant" in the GAE / J documentation of the test: " API package 'urlfetch' or 'Laon ()' is said to have not been found. ".

I was thinking that using "Assistant" would be somehow setup GAE environment such that when I call URLFetchServiceFactory.getURLFetchService () my An example of the getRemoteDataUsingUrlFetch method, Returned LocalURLFetchService from within may be just "work" but that does not seem to be the case.

  • How can I test this code?
  • Am I missing something?
  • I get my getRemoteDataUsingUrlFetch to refactor so that it does not use URLFetchServiceFactory.getURLFetchService () because it makes locally inauspicious ??? (It seems that it will actually suck ...)

    Any help / suggestions much appreciated!

    Actually, it has been found that my problem fails to include two extra jars on the documentation page Was there. RTM FTW!

    • appengine- local runtime.jar
    • appengine-api-stubs.jar

Comments