Hi Alex,
It sounds like a good idea to manually create requests in order to unit test
an application. It should work, otherwise we'll fix it.
Also, it seems that you are not using the beta 23 version as c.n.r.container
package doesn't exist anymore :-). If possible for you, could you upgrade to
the latest version or to the SVN trunk. If this is a bug it might have been
fixed. Otherwise, please let me know which version you are using.
Note that in beta 23, you could simplify your test by doing:
RestletServer server = new RestletServer(TEST_PORT);
SubApplication app = new SubApplication(new Context());
server.setApplication(app);
server.start();
server.get("http://localhost:"+TEST_PORT+"/blah");
Best regards,
Jerome
> -----Message d'origine-----
> De : news [mailto:[EMAIL PROTECTED] De la part de Alex Combs
> Envoyé : mercredi 20 décembre 2006 01:36
> À : [email protected]
> Objet : Testing Application problems
>
> I've been trying to create a test file for an Application
> subclass that I have
> created, but when I run it I get many errors. Here is an
> example of a test case:
>
> RestletServer server = new RestletServer(TEST_PORT);
> SubApplication app = new SubApplication(new Context());
> server.setApplication(app);
> server.start();
> Request request = new Request(Method.GET,
> "http://localhost:"+TEST_PORT+"/blah");
> Response response = new Response(request);
> server.handle(request, response);
>
> Fairly straightforward? Problem is that when I run it I get a
> NullPointerException that points to
> com.noelios.restlet.container.HostScorer.beforeHandle(HostScor
> er.java:176)
>
> Possibly any ideas on what could be going wrong? Thanks.