ComponenentRequestHandler doesn't exist when testing using TestNG

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

ComponenentRequestHandler doesn't exist when testing using TestNG

abangkis
Hello, i have a tapestry app that consist of 1-2 pages, and lots of
services. The apps is used to crawl another website. The apps uses hibernate
module, quartz and some other contribution. Because of the nature of my
apps, i want to test the services class using TestNG. I've created a simple
test that build the tapestry registry for my services and run it. But i
received an error that the ComponentRequestHandler doesn't exist. Here's the
contribution in the appmodule, test file and the stack trace. I wonder what
I've missed ?


Cheers,
Abangkis

public class AppModule {
....

public void
contributeComponentRequestHandler(OrderedConfiguration<ComponentRequestFilter>
configuration) {
 configuration.addInstance("PageProtectionFilter",
PageProtectionFilter.class);
}
 public void contributeRequestHandler(OrderedConfiguration<RequestFilter>
configuration,
 PageRenderLinkSource pageRenderLinkSource) {
final HashSet<String> ASSETS_WHITE_LIST = new
HashSet<String>(Arrays.asList("jpg", "jpeg", "png", "gif", "js",
 "css", "ico", "html", "json"));
configuration.add("AssetProtectionFilter", new
AssetProtectionFilter(ASSETS_WHITE_LIST, pageRenderLinkSource),
 "before:*");
 }
....
}

public class MyTest {
private Registry registry;

@Test
 public void f() {
String pageName = "DummyPage";
MovieManager movieManager = registry.getService(MovieManager.class);
 String result = movieManager.getMovieTitle(pageName);
assertEquals("Gullivers Island", result);
 }

@BeforeClass
public void beforeClass() {
// registry = IOCUtilities.buildDefaultRegistry();
initRegistry();
}

private void initRegistry() {
RegistryBuilder builder = new RegistryBuilder();
 builder.add(ChenilleKitQuartzModule.class);
  builder.add(AppModule.class);
 registry = builder.build();
registry.performRegistryStartup();
}

@AfterClass
public void afterClass() {
registry.shutdown();
 }

}

FAILED CONFIGURATION: @BeforeClass beforeClass
java.lang.IllegalArgumentException: Contribution
net.mreunion.cinematorserver.services.AppModule.contributeComponentRequestHandler(OrderedConfiguration)
(at AppModule.java:145) is for service 'ComponentRequestHandler', which does
not exist.
 at
org.apache.tapestry5.ioc.internal.RegistryImpl.validateContributeDefs(RegistryImpl.java:253)
at
org.apache.tapestry5.ioc.internal.RegistryImpl.<init>(RegistryImpl.java:229)
 at org.apache.tapestry5.ioc.RegistryBuilder.build(RegistryBuilder.java:170)
at
net.mreunion.cinematorserver.TestEscapedCharacter.initRegistry(MyTest .java:45)
 at
net.mreunion.cinematorserver.TestEscapedCharacter.beforeClass(MyTest .java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
at
org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:74)
 at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:525)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:202)
 at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:130)
at
org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:173)
 at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:105)
at org.testng.TestRunner.runWorkers(TestRunner.java:1125)
 at org.testng.TestRunner.privateRun(TestRunner.java:749)
at org.testng.TestRunner.run(TestRunner.java:600)
 at org.testng.SuiteRunner.runTest(SuiteRunner.java:317)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:312)
 at org.testng.SuiteRunner.privateRun(SuiteRunner.java:274)
at org.testng.SuiteRunner.run(SuiteRunner.java:223)
 at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
 at org.testng.TestNG.runSuitesSequentially(TestNG.java:995)
at org.testng.TestNG.runSuitesLocally(TestNG.java:920)
 at org.testng.TestNG.run(TestNG.java:856)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:110)
 at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:174)


--
http://www.mreunion-labs.net/
twitter : @mreunionlabs
blog : mreunion.wordpress.com
Follow our android survey at :
http://www.mreunion-labs.net/downloads:dlapk/MySurvey.apk
Reply | Threaded
Open this post in threaded view
|

Re: ComponenentRequestHandler doesn't exist when testing using TestNG

joshcanfield
It doesn't look like you are including TapestryModule in your registry.
Since you're building the registry you're in charge kit adding all the
modules.

Optionally you could add @SubModule(TapestryModule.class) to your AppModule
to make the dependency explicit.
On Jan 5, 2011 4:25 AM, "abangkis" <[hidden email]> wrote:
> Hello, i have a tapestry app that consist of 1-2 pages, and lots of
> services. The apps is used to crawl another website. The apps uses
hibernate
> module, quartz and some other contribution. Because of the nature of my
> apps, i want to test the services class using TestNG. I've created a
simple
> test that build the tapestry registry for my services and run it. But i
> received an error that the ComponentRequestHandler doesn't exist. Here's
the
> contribution in the appmodule, test file and the stack trace. I wonder
what

> I've missed ?
>
>
> Cheers,
> Abangkis
>
> public class AppModule {
> ....
>
> public void
>
contributeComponentRequestHandler(OrderedConfiguration<ComponentRequestFilter>

> configuration) {
> configuration.addInstance("PageProtectionFilter",
> PageProtectionFilter.class);
> }
> public void contributeRequestHandler(OrderedConfiguration<RequestFilter>
> configuration,
> PageRenderLinkSource pageRenderLinkSource) {
> final HashSet<String> ASSETS_WHITE_LIST = new
> HashSet<String>(Arrays.asList("jpg", "jpeg", "png", "gif", "js",
> "css", "ico", "html", "json"));
> configuration.add("AssetProtectionFilter", new
> AssetProtectionFilter(ASSETS_WHITE_LIST, pageRenderLinkSource),
> "before:*");
> }
> ....
> }
>
> public class MyTest {
> private Registry registry;
>
> @Test
> public void f() {
> String pageName = "DummyPage";
> MovieManager movieManager = registry.getService(MovieManager.class);
> String result = movieManager.getMovieTitle(pageName);
> assertEquals("Gullivers Island", result);
> }
>
> @BeforeClass
> public void beforeClass() {
> // registry = IOCUtilities.buildDefaultRegistry();
> initRegistry();
> }
>
> private void initRegistry() {
> RegistryBuilder builder = new RegistryBuilder();
> builder.add(ChenilleKitQuartzModule.class);
> builder.add(AppModule.class);
> registry = builder.build();
> registry.performRegistryStartup();
> }
>
> @AfterClass
> public void afterClass() {
> registry.shutdown();
> }
>
> }
>
> FAILED CONFIGURATION: @BeforeClass beforeClass
> java.lang.IllegalArgumentException: Contribution
>
net.mreunion.cinematorserver.services.AppModule.contributeComponentRequestHandler(OrderedConfiguration)
> (at AppModule.java:145) is for service 'ComponentRequestHandler', which
does
> not exist.
> at
>
org.apache.tapestry5.ioc.internal.RegistryImpl.validateContributeDefs(RegistryImpl.java:253)
> at
>
org.apache.tapestry5.ioc.internal.RegistryImpl.<init>(RegistryImpl.java:229)
> at
org.apache.tapestry5.ioc.RegistryBuilder.build(RegistryBuilder.java:170)
> at
> net.mreunion.cinematorserver.TestEscapedCharacter.initRegistry(MyTest
.java:45)
> at
> net.mreunion.cinematorserver.TestEscapedCharacter.beforeClass(MyTest
.java:33)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at
>
org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:74)
> at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:525)
> at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:202)
> at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:130)
> at
>
org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:173)

> at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:105)
> at org.testng.TestRunner.runWorkers(TestRunner.java:1125)
> at org.testng.TestRunner.privateRun(TestRunner.java:749)
> at org.testng.TestRunner.run(TestRunner.java:600)
> at org.testng.SuiteRunner.runTest(SuiteRunner.java:317)
> at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:312)
> at org.testng.SuiteRunner.privateRun(SuiteRunner.java:274)
> at org.testng.SuiteRunner.run(SuiteRunner.java:223)
> at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
> at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
> at org.testng.TestNG.runSuitesSequentially(TestNG.java:995)
> at org.testng.TestNG.runSuitesLocally(TestNG.java:920)
> at org.testng.TestNG.run(TestNG.java:856)
> at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:110)
> at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)
> at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:174)
>
>
> --
> http://www.mreunion-labs.net/
> twitter : @mreunionlabs
> blog : mreunion.wordpress.com
> Follow our android survey at :
> http://www.mreunion-labs.net/downloads:dlapk/MySurvey.apk
Reply | Threaded
Open this post in threaded view
|

Re: ComponenentRequestHandler doesn't exist when testing using TestNG

abangkis
Hi josh, thanks a lot. I follow your advice and tries to include all the
module that i could think of. This is the modified initRegistry method :

private void initRegistry() {
 RegistryBuilder builder = new RegistryBuilder();
  builder.add(TapestryModule.class);
  builder.add(AppModule.class);
  builder.add(HibernateCoreModule.class);
 builder.add(ChenilleKitQuartzModule.class);
registry = builder.build();
registry.performRegistryStartup();
 }

Adding TapestryModule fix the previous error, but i think I'm missing a
little something here. The ChennileKitQuartzModule throw a null pointer
exception

Caused by: java.lang.RuntimeException: Error invoking service contribution
method
net.mreunion.cinematorserver.services.AppModule.contributeSchedulerFactory(ApplicationGlobals,
OrderedConfiguration): java.lang.NullPointerException
 at
org.apache.tapestry5.ioc.internal.ContributionDefImpl.invokeMethod(ContributionDefImpl.java:139)
at
org.apache.tapestry5.ioc.internal.ContributionDefImpl.contribute(ContributionDefImpl.java:82)
 at
org.apache.tapestry5.ioc.internal.RegistryImpl$9.run(RegistryImpl.java:651)
at
org.apache.tapestry5.ioc.internal.OperationTrackerImpl$1.invoke(OperationTrackerImpl.java:50)
 at
org.apache.tapestry5.ioc.internal.OperationTrackerImpl$1.invoke(OperationTrackerImpl.java:47)
at
org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:65)
 ... 98 more
Caused by: java.lang.NullPointerException
at
net.mreunion.cinematorserver.services.AppModule.contributeSchedulerFactory(AppModule.java:116)

That leads to the quartz contribution method in my app module

public static void contributeSchedulerFactory(
 @InjectService("ApplicationGlobals") ApplicationGlobals applicationGlobals,
OrderedConfiguration<URL> configuration) {
 String fileName = applicationGlobals.getServletContext().getRealPath(
"/WEB-INF/classes/quartz.properties");
 File file = new File(fileName);
if (!file.canRead())
throw new RuntimeException(String.format("can't read file '%s'",
 file.toURI()));

try {
configuration.add("configuration", file.toURI().toURL());
 } catch (MalformedURLException e) {
throw new RuntimeException(e);
}
 }

public static void contributeQuartzSchedulerManager(
 OrderedConfiguration<JobSchedulingBundle> configuration,
CrawlingJobImpl crawlingJob, JakartaCrawler crawler) {
 configuration.add("crawlScheduler", new CrawlSchedulerBundle(crawlingJob,
crawler));
}

The null pointer is in  the

String fileName = applicationGlobals.getServletContext().getRealPath(
"/WEB-INF/classes/quartz.properties");

I guess it makes sense, since TestNG is not using Servlet Context to run the
test.  Is there anyway to contribute the quartz.properties that will work
inside and outside of the servlet context  ?


Cheers,
Abangkis

On Wed, Jan 5, 2011 at 9:38 PM, Josh Canfield <[hidden email]>wrote:

> It doesn't look like you are including TapestryModule in your registry.
> Since you're building the registry you're in charge kit adding all the
> modules.
>
> Optionally you could add @SubModule(TapestryModule.class) to your AppModule
> to make the dependency explicit.
> On Jan 5, 2011 4:25 AM, "abangkis" <[hidden email]> wrote:
> > Hello, i have a tapestry app that consist of 1-2 pages, and lots of
> > services. The apps is used to crawl another website. The apps uses
> hibernate
> > module, quartz and some other contribution. Because of the nature of my
> > apps, i want to test the services class using TestNG. I've created a
> simple
> > test that build the tapestry registry for my services and run it. But i
> > received an error that the ComponentRequestHandler doesn't exist. Here's
> the
> > contribution in the appmodule, test file and the stack trace. I wonder
> what
> > I've missed ?
> >
> >
> > Cheers,
> > Abangkis
> >
> > public class AppModule {
> > ....
> >
> > public void
> >
>
> contributeComponentRequestHandler(OrderedConfiguration<ComponentRequestFilter>
> > configuration) {
> > configuration.addInstance("PageProtectionFilter",
> > PageProtectionFilter.class);
> > }
> > public void contributeRequestHandler(OrderedConfiguration<RequestFilter>
> > configuration,
> > PageRenderLinkSource pageRenderLinkSource) {
> > final HashSet<String> ASSETS_WHITE_LIST = new
> > HashSet<String>(Arrays.asList("jpg", "jpeg", "png", "gif", "js",
> > "css", "ico", "html", "json"));
> > configuration.add("AssetProtectionFilter", new
> > AssetProtectionFilter(ASSETS_WHITE_LIST, pageRenderLinkSource),
> > "before:*");
> > }
> > ....
> > }
> >
> > public class MyTest {
> > private Registry registry;
> >
> > @Test
> > public void f() {
> > String pageName = "DummyPage";
> > MovieManager movieManager = registry.getService(MovieManager.class);
> > String result = movieManager.getMovieTitle(pageName);
> > assertEquals("Gullivers Island", result);
> > }
> >
> > @BeforeClass
> > public void beforeClass() {
> > // registry = IOCUtilities.buildDefaultRegistry();
> > initRegistry();
> > }
> >
> > private void initRegistry() {
> > RegistryBuilder builder = new RegistryBuilder();
> > builder.add(ChenilleKitQuartzModule.class);
> > builder.add(AppModule.class);
> > registry = builder.build();
> > registry.performRegistryStartup();
> > }
> >
> > @AfterClass
> > public void afterClass() {
> > registry.shutdown();
> > }
> >
> > }
> >
> > FAILED CONFIGURATION: @BeforeClass beforeClass
> > java.lang.IllegalArgumentException: Contribution
> >
>
> net.mreunion.cinematorserver.services.AppModule.contributeComponentRequestHandler(OrderedConfiguration)
> > (at AppModule.java:145) is for service 'ComponentRequestHandler', which
> does
> > not exist.
> > at
> >
>
> org.apache.tapestry5.ioc.internal.RegistryImpl.validateContributeDefs(RegistryImpl.java:253)
> > at
> >
>
> org.apache.tapestry5.ioc.internal.RegistryImpl.<init>(RegistryImpl.java:229)
> > at
> org.apache.tapestry5.ioc.RegistryBuilder.build(RegistryBuilder.java:170)
> > at
> > net.mreunion.cinematorserver.TestEscapedCharacter.initRegistry(MyTest
> .java:45)
> > at
> > net.mreunion.cinematorserver.TestEscapedCharacter.beforeClass(MyTest
> .java:33)
> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> > at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> > at java.lang.reflect.Method.invoke(Unknown Source)
> > at
> >
>
> org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:74)
> > at
> org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:525)
> > at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:202)
> > at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:130)
> > at
> >
>
> org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:173)
> > at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:105)
> > at org.testng.TestRunner.runWorkers(TestRunner.java:1125)
> > at org.testng.TestRunner.privateRun(TestRunner.java:749)
> > at org.testng.TestRunner.run(TestRunner.java:600)
> > at org.testng.SuiteRunner.runTest(SuiteRunner.java:317)
> > at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:312)
> > at org.testng.SuiteRunner.privateRun(SuiteRunner.java:274)
> > at org.testng.SuiteRunner.run(SuiteRunner.java:223)
> > at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
> > at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
> > at org.testng.TestNG.runSuitesSequentially(TestNG.java:995)
> > at org.testng.TestNG.runSuitesLocally(TestNG.java:920)
> > at org.testng.TestNG.run(TestNG.java:856)
> > at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:110)
> > at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)
> > at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:174)
> >
> >
> > --
> > http://www.mreunion-labs.net/
> > twitter : @mreunionlabs
> > blog : mreunion.wordpress.com
> > Follow our android survey at :
> > http://www.mreunion-labs.net/downloads:dlapk/MySurvey.apk
>



--
http://www.mreunion-labs.net/
twitter : @mreunionlabs
blog : mreunion.wordpress.com
Follow our android survey at :
http://www.mreunion-labs.net/downloads:dlapk/MySurvey.apk
Reply | Threaded
Open this post in threaded view
|

Re: ComponenentRequestHandler doesn't exist when testing using TestNG

Donny Nadolny-2
You can contribute just the name of the file you want ("quartz.properties"),
put it in the classpath, eg in src/main/resources, and then in the place
where you need to use it, load it from the classloader as a resource:
InputStream in = getClass().getResourceAsStream("quartz.properties");
But instead of "quartz.properties" you can use the symbol that contains that
filename.


On Wed, Jan 5, 2011 at 10:06 AM, abangkis <[hidden email]> wrote:

> Hi josh, thanks a lot. I follow your advice and tries to include all the
> module that i could think of. This is the modified initRegistry method :
>
> private void initRegistry() {
>  RegistryBuilder builder = new RegistryBuilder();
>   builder.add(TapestryModule.class);
>  builder.add(AppModule.class);
>  builder.add(HibernateCoreModule.class);
>  builder.add(ChenilleKitQuartzModule.class);
> registry = builder.build();
> registry.performRegistryStartup();
>  }
>
> Adding TapestryModule fix the previous error, but i think I'm missing a
> little something here. The ChennileKitQuartzModule throw a null pointer
> exception
>
> Caused by: java.lang.RuntimeException: Error invoking service contribution
> method
>
> net.mreunion.cinematorserver.services.AppModule.contributeSchedulerFactory(ApplicationGlobals,
> OrderedConfiguration): java.lang.NullPointerException
>  at
>
> org.apache.tapestry5.ioc.internal.ContributionDefImpl.invokeMethod(ContributionDefImpl.java:139)
> at
>
> org.apache.tapestry5.ioc.internal.ContributionDefImpl.contribute(ContributionDefImpl.java:82)
>  at
> org.apache.tapestry5.ioc.internal.RegistryImpl$9.run(RegistryImpl.java:651)
> at
>
> org.apache.tapestry5.ioc.internal.OperationTrackerImpl$1.invoke(OperationTrackerImpl.java:50)
>  at
>
> org.apache.tapestry5.ioc.internal.OperationTrackerImpl$1.invoke(OperationTrackerImpl.java:47)
> at
>
> org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:65)
>  ... 98 more
> Caused by: java.lang.NullPointerException
> at
>
> net.mreunion.cinematorserver.services.AppModule.contributeSchedulerFactory(AppModule.java:116)
>
> That leads to the quartz contribution method in my app module
>
> public static void contributeSchedulerFactory(
>  @InjectService("ApplicationGlobals") ApplicationGlobals
> applicationGlobals,
> OrderedConfiguration<URL> configuration) {
>  String fileName = applicationGlobals.getServletContext().getRealPath(
> "/WEB-INF/classes/quartz.properties");
>  File file = new File(fileName);
> if (!file.canRead())
> throw new RuntimeException(String.format("can't read file '%s'",
>  file.toURI()));
>
> try {
> configuration.add("configuration", file.toURI().toURL());
>  } catch (MalformedURLException e) {
> throw new RuntimeException(e);
> }
>  }
>
> public static void contributeQuartzSchedulerManager(
>  OrderedConfiguration<JobSchedulingBundle> configuration,
> CrawlingJobImpl crawlingJob, JakartaCrawler crawler) {
>  configuration.add("crawlScheduler", new CrawlSchedulerBundle(crawlingJob,
> crawler));
> }
>
> The null pointer is in  the
>
> String fileName = applicationGlobals.getServletContext().getRealPath(
> "/WEB-INF/classes/quartz.properties");
>
> I guess it makes sense, since TestNG is not using Servlet Context to run
> the
> test.  Is there anyway to contribute the quartz.properties that will work
> inside and outside of the servlet context  ?
>
>
> Cheers,
> Abangkis
>
> On Wed, Jan 5, 2011 at 9:38 PM, Josh Canfield <[hidden email]
> >wrote:
>
> > It doesn't look like you are including TapestryModule in your registry.
> > Since you're building the registry you're in charge kit adding all the
> > modules.
> >
> > Optionally you could add @SubModule(TapestryModule.class) to your
> AppModule
> > to make the dependency explicit.
> > On Jan 5, 2011 4:25 AM, "abangkis" <[hidden email]> wrote:
> > > Hello, i have a tapestry app that consist of 1-2 pages, and lots of
> > > services. The apps is used to crawl another website. The apps uses
> > hibernate
> > > module, quartz and some other contribution. Because of the nature of my
> > > apps, i want to test the services class using TestNG. I've created a
> > simple
> > > test that build the tapestry registry for my services and run it. But i
> > > received an error that the ComponentRequestHandler doesn't exist.
> Here's
> > the
> > > contribution in the appmodule, test file and the stack trace. I wonder
> > what
> > > I've missed ?
> > >
> > >
> > > Cheers,
> > > Abangkis
> > >
> > > public class AppModule {
> > > ....
> > >
> > > public void
> > >
> >
> >
> contributeComponentRequestHandler(OrderedConfiguration<ComponentRequestFilter>
> > > configuration) {
> > > configuration.addInstance("PageProtectionFilter",
> > > PageProtectionFilter.class);
> > > }
> > > public void
> contributeRequestHandler(OrderedConfiguration<RequestFilter>
> > > configuration,
> > > PageRenderLinkSource pageRenderLinkSource) {
> > > final HashSet<String> ASSETS_WHITE_LIST = new
> > > HashSet<String>(Arrays.asList("jpg", "jpeg", "png", "gif", "js",
> > > "css", "ico", "html", "json"));
> > > configuration.add("AssetProtectionFilter", new
> > > AssetProtectionFilter(ASSETS_WHITE_LIST, pageRenderLinkSource),
> > > "before:*");
> > > }
> > > ....
> > > }
> > >
> > > public class MyTest {
> > > private Registry registry;
> > >
> > > @Test
> > > public void f() {
> > > String pageName = "DummyPage";
> > > MovieManager movieManager = registry.getService(MovieManager.class);
> > > String result = movieManager.getMovieTitle(pageName);
> > > assertEquals("Gullivers Island", result);
> > > }
> > >
> > > @BeforeClass
> > > public void beforeClass() {
> > > // registry = IOCUtilities.buildDefaultRegistry();
> > > initRegistry();
> > > }
> > >
> > > private void initRegistry() {
> > > RegistryBuilder builder = new RegistryBuilder();
> > > builder.add(ChenilleKitQuartzModule.class);
> > > builder.add(AppModule.class);
> > > registry = builder.build();
> > > registry.performRegistryStartup();
> > > }
> > >
> > > @AfterClass
> > > public void afterClass() {
> > > registry.shutdown();
> > > }
> > >
> > > }
> > >
> > > FAILED CONFIGURATION: @BeforeClass beforeClass
> > > java.lang.IllegalArgumentException: Contribution
> > >
> >
> >
> net.mreunion.cinematorserver.services.AppModule.contributeComponentRequestHandler(OrderedConfiguration)
> > > (at AppModule.java:145) is for service 'ComponentRequestHandler', which
> > does
> > > not exist.
> > > at
> > >
> >
> >
> org.apache.tapestry5.ioc.internal.RegistryImpl.validateContributeDefs(RegistryImpl.java:253)
> > > at
> > >
> >
> >
> org.apache.tapestry5.ioc.internal.RegistryImpl.<init>(RegistryImpl.java:229)
> > > at
> > org.apache.tapestry5.ioc.RegistryBuilder.build(RegistryBuilder.java:170)
> > > at
> > > net.mreunion.cinematorserver.TestEscapedCharacter.initRegistry(MyTest
> > .java:45)
> > > at
> > > net.mreunion.cinematorserver.TestEscapedCharacter.beforeClass(MyTest
> > .java:33)
> > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > > at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> > > at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> > > at java.lang.reflect.Method.invoke(Unknown Source)
> > > at
> > >
> >
> >
> org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:74)
> > > at
> > org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:525)
> > > at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:202)
> > > at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:130)
> > > at
> > >
> >
> >
> org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:173)
> > > at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:105)
> > > at org.testng.TestRunner.runWorkers(TestRunner.java:1125)
> > > at org.testng.TestRunner.privateRun(TestRunner.java:749)
> > > at org.testng.TestRunner.run(TestRunner.java:600)
> > > at org.testng.SuiteRunner.runTest(SuiteRunner.java:317)
> > > at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:312)
> > > at org.testng.SuiteRunner.privateRun(SuiteRunner.java:274)
> > > at org.testng.SuiteRunner.run(SuiteRunner.java:223)
> > > at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
> > > at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
> > > at org.testng.TestNG.runSuitesSequentially(TestNG.java:995)
> > > at org.testng.TestNG.runSuitesLocally(TestNG.java:920)
> > > at org.testng.TestNG.run(TestNG.java:856)
> > > at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:110)
> > > at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)
> > > at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:174)
> > >
> > >
> > > --
> > > http://www.mreunion-labs.net/
> > > twitter : @mreunionlabs
> > > blog : mreunion.wordpress.com
> > > Follow our android survey at :
> > > http://www.mreunion-labs.net/downloads:dlapk/MySurvey.apk
> >
>
>
>
> --
> http://www.mreunion-labs.net/
> twitter : @mreunionlabs
> blog : mreunion.wordpress.com
> Follow our android survey at :
> http://www.mreunion-labs.net/downloads:dlapk/MySurvey.apk
>
Reply | Threaded
Open this post in threaded view
|

Re: ComponenentRequestHandler doesn't exist when testing using TestNG

Howard Lewis Ship
... and this is why you either want to look at unit testing using mocks, or
at integration testing using Selenium.  In the half-ground you end up with a
lot of complications since the code is designed to run inside a servlet
container and you don't have one.

PageTester exists to mock up the servlet container; that's another option.

On Wed, Jan 5, 2011 at 8:08 AM, Donny Nadolny <[hidden email]>wrote:

> You can contribute just the name of the file you want
> ("quartz.properties"),
> put it in the classpath, eg in src/main/resources, and then in the place
> where you need to use it, load it from the classloader as a resource:
> InputStream in = getClass().getResourceAsStream("quartz.properties");
> But instead of "quartz.properties" you can use the symbol that contains
> that
> filename.
>
>
> On Wed, Jan 5, 2011 at 10:06 AM, abangkis <[hidden email]> wrote:
>
> > Hi josh, thanks a lot. I follow your advice and tries to include all the
> > module that i could think of. This is the modified initRegistry method :
> >
> > private void initRegistry() {
> >  RegistryBuilder builder = new RegistryBuilder();
> >   builder.add(TapestryModule.class);
> >  builder.add(AppModule.class);
> >  builder.add(HibernateCoreModule.class);
> >  builder.add(ChenilleKitQuartzModule.class);
> > registry = builder.build();
> > registry.performRegistryStartup();
> >  }
> >
> > Adding TapestryModule fix the previous error, but i think I'm missing a
> > little something here. The ChennileKitQuartzModule throw a null pointer
> > exception
> >
> > Caused by: java.lang.RuntimeException: Error invoking service
> contribution
> > method
> >
> >
> net.mreunion.cinematorserver.services.AppModule.contributeSchedulerFactory(ApplicationGlobals,
> > OrderedConfiguration): java.lang.NullPointerException
> >  at
> >
> >
> org.apache.tapestry5.ioc.internal.ContributionDefImpl.invokeMethod(ContributionDefImpl.java:139)
> > at
> >
> >
> org.apache.tapestry5.ioc.internal.ContributionDefImpl.contribute(ContributionDefImpl.java:82)
> >  at
> >
> org.apache.tapestry5.ioc.internal.RegistryImpl$9.run(RegistryImpl.java:651)
> > at
> >
> >
> org.apache.tapestry5.ioc.internal.OperationTrackerImpl$1.invoke(OperationTrackerImpl.java:50)
> >  at
> >
> >
> org.apache.tapestry5.ioc.internal.OperationTrackerImpl$1.invoke(OperationTrackerImpl.java:47)
> > at
> >
> >
> org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:65)
> >  ... 98 more
> > Caused by: java.lang.NullPointerException
> > at
> >
> >
> net.mreunion.cinematorserver.services.AppModule.contributeSchedulerFactory(AppModule.java:116)
> >
> > That leads to the quartz contribution method in my app module
> >
> > public static void contributeSchedulerFactory(
> >  @InjectService("ApplicationGlobals") ApplicationGlobals
> > applicationGlobals,
> > OrderedConfiguration<URL> configuration) {
> >  String fileName = applicationGlobals.getServletContext().getRealPath(
> > "/WEB-INF/classes/quartz.properties");
> >  File file = new File(fileName);
> > if (!file.canRead())
> > throw new RuntimeException(String.format("can't read file '%s'",
> >  file.toURI()));
> >
> > try {
> > configuration.add("configuration", file.toURI().toURL());
> >  } catch (MalformedURLException e) {
> > throw new RuntimeException(e);
> > }
> >  }
> >
> > public static void contributeQuartzSchedulerManager(
> >  OrderedConfiguration<JobSchedulingBundle> configuration,
> > CrawlingJobImpl crawlingJob, JakartaCrawler crawler) {
> >  configuration.add("crawlScheduler", new
> CrawlSchedulerBundle(crawlingJob,
> > crawler));
> > }
> >
> > The null pointer is in  the
> >
> > String fileName = applicationGlobals.getServletContext().getRealPath(
> > "/WEB-INF/classes/quartz.properties");
> >
> > I guess it makes sense, since TestNG is not using Servlet Context to run
> > the
> > test.  Is there anyway to contribute the quartz.properties that will work
> > inside and outside of the servlet context  ?
> >
> >
> > Cheers,
> > Abangkis
> >
> > On Wed, Jan 5, 2011 at 9:38 PM, Josh Canfield <[hidden email]
> > >wrote:
> >
> > > It doesn't look like you are including TapestryModule in your registry.
> > > Since you're building the registry you're in charge kit adding all the
> > > modules.
> > >
> > > Optionally you could add @SubModule(TapestryModule.class) to your
> > AppModule
> > > to make the dependency explicit.
> > > On Jan 5, 2011 4:25 AM, "abangkis" <[hidden email]> wrote:
> > > > Hello, i have a tapestry app that consist of 1-2 pages, and lots of
> > > > services. The apps is used to crawl another website. The apps uses
> > > hibernate
> > > > module, quartz and some other contribution. Because of the nature of
> my
> > > > apps, i want to test the services class using TestNG. I've created a
> > > simple
> > > > test that build the tapestry registry for my services and run it. But
> i
> > > > received an error that the ComponentRequestHandler doesn't exist.
> > Here's
> > > the
> > > > contribution in the appmodule, test file and the stack trace. I
> wonder
> > > what
> > > > I've missed ?
> > > >
> > > >
> > > > Cheers,
> > > > Abangkis
> > > >
> > > > public class AppModule {
> > > > ....
> > > >
> > > > public void
> > > >
> > >
> > >
> >
> contributeComponentRequestHandler(OrderedConfiguration<ComponentRequestFilter>
> > > > configuration) {
> > > > configuration.addInstance("PageProtectionFilter",
> > > > PageProtectionFilter.class);
> > > > }
> > > > public void
> > contributeRequestHandler(OrderedConfiguration<RequestFilter>
> > > > configuration,
> > > > PageRenderLinkSource pageRenderLinkSource) {
> > > > final HashSet<String> ASSETS_WHITE_LIST = new
> > > > HashSet<String>(Arrays.asList("jpg", "jpeg", "png", "gif", "js",
> > > > "css", "ico", "html", "json"));
> > > > configuration.add("AssetProtectionFilter", new
> > > > AssetProtectionFilter(ASSETS_WHITE_LIST, pageRenderLinkSource),
> > > > "before:*");
> > > > }
> > > > ....
> > > > }
> > > >
> > > > public class MyTest {
> > > > private Registry registry;
> > > >
> > > > @Test
> > > > public void f() {
> > > > String pageName = "DummyPage";
> > > > MovieManager movieManager = registry.getService(MovieManager.class);
> > > > String result = movieManager.getMovieTitle(pageName);
> > > > assertEquals("Gullivers Island", result);
> > > > }
> > > >
> > > > @BeforeClass
> > > > public void beforeClass() {
> > > > // registry = IOCUtilities.buildDefaultRegistry();
> > > > initRegistry();
> > > > }
> > > >
> > > > private void initRegistry() {
> > > > RegistryBuilder builder = new RegistryBuilder();
> > > > builder.add(ChenilleKitQuartzModule.class);
> > > > builder.add(AppModule.class);
> > > > registry = builder.build();
> > > > registry.performRegistryStartup();
> > > > }
> > > >
> > > > @AfterClass
> > > > public void afterClass() {
> > > > registry.shutdown();
> > > > }
> > > >
> > > > }
> > > >
> > > > FAILED CONFIGURATION: @BeforeClass beforeClass
> > > > java.lang.IllegalArgumentException: Contribution
> > > >
> > >
> > >
> >
> net.mreunion.cinematorserver.services.AppModule.contributeComponentRequestHandler(OrderedConfiguration)
> > > > (at AppModule.java:145) is for service 'ComponentRequestHandler',
> which
> > > does
> > > > not exist.
> > > > at
> > > >
> > >
> > >
> >
> org.apache.tapestry5.ioc.internal.RegistryImpl.validateContributeDefs(RegistryImpl.java:253)
> > > > at
> > > >
> > >
> > >
> >
> org.apache.tapestry5.ioc.internal.RegistryImpl.<init>(RegistryImpl.java:229)
> > > > at
> > >
> org.apache.tapestry5.ioc.RegistryBuilder.build(RegistryBuilder.java:170)
> > > > at
> > > > net.mreunion.cinematorserver.TestEscapedCharacter.initRegistry(MyTest
> > > .java:45)
> > > > at
> > > > net.mreunion.cinematorserver.TestEscapedCharacter.beforeClass(MyTest
> > > .java:33)
> > > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > > > at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> > > > at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> > > > at java.lang.reflect.Method.invoke(Unknown Source)
> > > > at
> > > >
> > >
> > >
> >
> org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:74)
> > > > at
> > > org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:525)
> > > > at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:202)
> > > > at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:130)
> > > > at
> > > >
> > >
> > >
> >
> org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:173)
> > > > at
> org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:105)
> > > > at org.testng.TestRunner.runWorkers(TestRunner.java:1125)
> > > > at org.testng.TestRunner.privateRun(TestRunner.java:749)
> > > > at org.testng.TestRunner.run(TestRunner.java:600)
> > > > at org.testng.SuiteRunner.runTest(SuiteRunner.java:317)
> > > > at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:312)
> > > > at org.testng.SuiteRunner.privateRun(SuiteRunner.java:274)
> > > > at org.testng.SuiteRunner.run(SuiteRunner.java:223)
> > > > at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
> > > > at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
> > > > at org.testng.TestNG.runSuitesSequentially(TestNG.java:995)
> > > > at org.testng.TestNG.runSuitesLocally(TestNG.java:920)
> > > > at org.testng.TestNG.run(TestNG.java:856)
> > > > at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:110)
> > > > at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)
> > > > at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:174)
> > > >
> > > >
> > > > --
> > > > http://www.mreunion-labs.net/
> > > > twitter : @mreunionlabs
> > > > blog : mreunion.wordpress.com
> > > > Follow our android survey at :
> > > > http://www.mreunion-labs.net/downloads:dlapk/MySurvey.apk
> > >
> >
> >
> >
> > --
> > http://www.mreunion-labs.net/
> > twitter : @mreunionlabs
> > blog : mreunion.wordpress.com
> > Follow our android survey at :
> > http://www.mreunion-labs.net/downloads:dlapk/MySurvey.apk
> >
>



--
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to learn
how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com
Reply | Threaded
Open this post in threaded view
|

Re: ComponenentRequestHandler doesn't exist when testing using TestNG

Kalle Korhonen-2
... or HtmlUnit & Jetty, see below from a recent thread on Maven users list:

subject Re: Fail a build if the web application fails to load in Jetty....
On Tue, Jan 4, 2011 at 11:10 AM, Nathan Wilhelmi <[hidden email]> wrote:

> Hi - HtmlUnit is a simpler solution for what we are trying to test right
> now. What I am really after is failing fast on the integration tests. If the
> app didn't start I would rather not run through each test and all setup
> associated with each one.
>
> -Nate
>
> Kalle Korhonen wrote:
>>
>> Why not
>> http://docs.codehaus.org/display/TYNAMO/2010/07/30/Full+web+integration+testing+in+a+single+JVM
>> and something like
>>
>> http://svn.codehaus.org/tynamo/trunk/tapestry-model/tapestry-model-test/src/main/java/org/tynamo/test/AbstractContainerTest.java
>> ?
>>
>> With an embedded Jetty, your integration tests would behave just like
>> your unit tests.
>>
>> Kalle
>>
>>
>> On Wed, Dec 29, 2010 at 1:03 PM, Nathan Wilhelmi <[hidden email]>
>> wrote:
>>
>>>
>>> Hi -
>>>
>>>  We are working on integrating Jetty deployment into our integration
>>> tests.
>>> We don't have any selenium type tests yet. Is there any to fail the build
>>> if
>>> the web application fails to start in Jetty? We would like to use this as
>>> first step.
>>>
>>> Thanks!
>>>

On Wed, Jan 5, 2011 at 9:44 AM, Howard Lewis Ship <[hidden email]> wrote:

> ... and this is why you either want to look at unit testing using mocks, or
> at integration testing using Selenium.  In the half-ground you end up with a
> lot of complications since the code is designed to run inside a servlet
> container and you don't have one.
>
> PageTester exists to mock up the servlet container; that's another option.
>
> On Wed, Jan 5, 2011 at 8:08 AM, Donny Nadolny <[hidden email]>wrote:
>
>> You can contribute just the name of the file you want
>> ("quartz.properties"),
>> put it in the classpath, eg in src/main/resources, and then in the place
>> where you need to use it, load it from the classloader as a resource:
>> InputStream in = getClass().getResourceAsStream("quartz.properties");
>> But instead of "quartz.properties" you can use the symbol that contains
>> that
>> filename.
>>
>>
>> On Wed, Jan 5, 2011 at 10:06 AM, abangkis <[hidden email]> wrote:
>>
>> > Hi josh, thanks a lot. I follow your advice and tries to include all the
>> > module that i could think of. This is the modified initRegistry method :
>> >
>> > private void initRegistry() {
>> >  RegistryBuilder builder = new RegistryBuilder();
>> >   builder.add(TapestryModule.class);
>> >  builder.add(AppModule.class);
>> >  builder.add(HibernateCoreModule.class);
>> >  builder.add(ChenilleKitQuartzModule.class);
>> > registry = builder.build();
>> > registry.performRegistryStartup();
>> >  }
>> >
>> > Adding TapestryModule fix the previous error, but i think I'm missing a
>> > little something here. The ChennileKitQuartzModule throw a null pointer
>> > exception
>> >
>> > Caused by: java.lang.RuntimeException: Error invoking service
>> contribution
>> > method
>> >
>> >
>> net.mreunion.cinematorserver.services.AppModule.contributeSchedulerFactory(ApplicationGlobals,
>> > OrderedConfiguration): java.lang.NullPointerException
>> >  at
>> >
>> >
>> org.apache.tapestry5.ioc.internal.ContributionDefImpl.invokeMethod(ContributionDefImpl.java:139)
>> > at
>> >
>> >
>> org.apache.tapestry5.ioc.internal.ContributionDefImpl.contribute(ContributionDefImpl.java:82)
>> >  at
>> >
>> org.apache.tapestry5.ioc.internal.RegistryImpl$9.run(RegistryImpl.java:651)
>> > at
>> >
>> >
>> org.apache.tapestry5.ioc.internal.OperationTrackerImpl$1.invoke(OperationTrackerImpl.java:50)
>> >  at
>> >
>> >
>> org.apache.tapestry5.ioc.internal.OperationTrackerImpl$1.invoke(OperationTrackerImpl.java:47)
>> > at
>> >
>> >
>> org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:65)
>> >  ... 98 more
>> > Caused by: java.lang.NullPointerException
>> > at
>> >
>> >
>> net.mreunion.cinematorserver.services.AppModule.contributeSchedulerFactory(AppModule.java:116)
>> >
>> > That leads to the quartz contribution method in my app module
>> >
>> > public static void contributeSchedulerFactory(
>> >  @InjectService("ApplicationGlobals") ApplicationGlobals
>> > applicationGlobals,
>> > OrderedConfiguration<URL> configuration) {
>> >  String fileName = applicationGlobals.getServletContext().getRealPath(
>> > "/WEB-INF/classes/quartz.properties");
>> >  File file = new File(fileName);
>> > if (!file.canRead())
>> > throw new RuntimeException(String.format("can't read file '%s'",
>> >  file.toURI()));
>> >
>> > try {
>> > configuration.add("configuration", file.toURI().toURL());
>> >  } catch (MalformedURLException e) {
>> > throw new RuntimeException(e);
>> > }
>> >  }
>> >
>> > public static void contributeQuartzSchedulerManager(
>> >  OrderedConfiguration<JobSchedulingBundle> configuration,
>> > CrawlingJobImpl crawlingJob, JakartaCrawler crawler) {
>> >  configuration.add("crawlScheduler", new
>> CrawlSchedulerBundle(crawlingJob,
>> > crawler));
>> > }
>> >
>> > The null pointer is in  the
>> >
>> > String fileName = applicationGlobals.getServletContext().getRealPath(
>> > "/WEB-INF/classes/quartz.properties");
>> >
>> > I guess it makes sense, since TestNG is not using Servlet Context to run
>> > the
>> > test.  Is there anyway to contribute the quartz.properties that will work
>> > inside and outside of the servlet context  ?
>> >
>> >
>> > Cheers,
>> > Abangkis
>> >
>> > On Wed, Jan 5, 2011 at 9:38 PM, Josh Canfield <[hidden email]
>> > >wrote:
>> >
>> > > It doesn't look like you are including TapestryModule in your registry.
>> > > Since you're building the registry you're in charge kit adding all the
>> > > modules.
>> > >
>> > > Optionally you could add @SubModule(TapestryModule.class) to your
>> > AppModule
>> > > to make the dependency explicit.
>> > > On Jan 5, 2011 4:25 AM, "abangkis" <[hidden email]> wrote:
>> > > > Hello, i have a tapestry app that consist of 1-2 pages, and lots of
>> > > > services. The apps is used to crawl another website. The apps uses
>> > > hibernate
>> > > > module, quartz and some other contribution. Because of the nature of
>> my
>> > > > apps, i want to test the services class using TestNG. I've created a
>> > > simple
>> > > > test that build the tapestry registry for my services and run it. But
>> i
>> > > > received an error that the ComponentRequestHandler doesn't exist.
>> > Here's
>> > > the
>> > > > contribution in the appmodule, test file and the stack trace. I
>> wonder
>> > > what
>> > > > I've missed ?
>> > > >
>> > > >
>> > > > Cheers,
>> > > > Abangkis
>> > > >
>> > > > public class AppModule {
>> > > > ....
>> > > >
>> > > > public void
>> > > >
>> > >
>> > >
>> >
>> contributeComponentRequestHandler(OrderedConfiguration<ComponentRequestFilter>
>> > > > configuration) {
>> > > > configuration.addInstance("PageProtectionFilter",
>> > > > PageProtectionFilter.class);
>> > > > }
>> > > > public void
>> > contributeRequestHandler(OrderedConfiguration<RequestFilter>
>> > > > configuration,
>> > > > PageRenderLinkSource pageRenderLinkSource) {
>> > > > final HashSet<String> ASSETS_WHITE_LIST = new
>> > > > HashSet<String>(Arrays.asList("jpg", "jpeg", "png", "gif", "js",
>> > > > "css", "ico", "html", "json"));
>> > > > configuration.add("AssetProtectionFilter", new
>> > > > AssetProtectionFilter(ASSETS_WHITE_LIST, pageRenderLinkSource),
>> > > > "before:*");
>> > > > }
>> > > > ....
>> > > > }
>> > > >
>> > > > public class MyTest {
>> > > > private Registry registry;
>> > > >
>> > > > @Test
>> > > > public void f() {
>> > > > String pageName = "DummyPage";
>> > > > MovieManager movieManager = registry.getService(MovieManager.class);
>> > > > String result = movieManager.getMovieTitle(pageName);
>> > > > assertEquals("Gullivers Island", result);
>> > > > }
>> > > >
>> > > > @BeforeClass
>> > > > public void beforeClass() {
>> > > > // registry = IOCUtilities.buildDefaultRegistry();
>> > > > initRegistry();
>> > > > }
>> > > >
>> > > > private void initRegistry() {
>> > > > RegistryBuilder builder = new RegistryBuilder();
>> > > > builder.add(ChenilleKitQuartzModule.class);
>> > > > builder.add(AppModule.class);
>> > > > registry = builder.build();
>> > > > registry.performRegistryStartup();
>> > > > }
>> > > >
>> > > > @AfterClass
>> > > > public void afterClass() {
>> > > > registry.shutdown();
>> > > > }
>> > > >
>> > > > }
>> > > >
>> > > > FAILED CONFIGURATION: @BeforeClass beforeClass
>> > > > java.lang.IllegalArgumentException: Contribution
>> > > >
>> > >
>> > >
>> >
>> net.mreunion.cinematorserver.services.AppModule.contributeComponentRequestHandler(OrderedConfiguration)
>> > > > (at AppModule.java:145) is for service 'ComponentRequestHandler',
>> which
>> > > does
>> > > > not exist.
>> > > > at
>> > > >
>> > >
>> > >
>> >
>> org.apache.tapestry5.ioc.internal.RegistryImpl.validateContributeDefs(RegistryImpl.java:253)
>> > > > at
>> > > >
>> > >
>> > >
>> >
>> org.apache.tapestry5.ioc.internal.RegistryImpl.<init>(RegistryImpl.java:229)
>> > > > at
>> > >
>> org.apache.tapestry5.ioc.RegistryBuilder.build(RegistryBuilder.java:170)
>> > > > at
>> > > > net.mreunion.cinematorserver.TestEscapedCharacter.initRegistry(MyTest
>> > > .java:45)
>> > > > at
>> > > > net.mreunion.cinematorserver.TestEscapedCharacter.beforeClass(MyTest
>> > > .java:33)
>> > > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> > > > at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>> > > > at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>> > > > at java.lang.reflect.Method.invoke(Unknown Source)
>> > > > at
>> > > >
>> > >
>> > >
>> >
>> org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:74)
>> > > > at
>> > > org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:525)
>> > > > at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:202)
>> > > > at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:130)
>> > > > at
>> > > >
>> > >
>> > >
>> >
>> org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:173)
>> > > > at
>> org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:105)
>> > > > at org.testng.TestRunner.runWorkers(TestRunner.java:1125)
>> > > > at org.testng.TestRunner.privateRun(TestRunner.java:749)
>> > > > at org.testng.TestRunner.run(TestRunner.java:600)
>> > > > at org.testng.SuiteRunner.runTest(SuiteRunner.java:317)
>> > > > at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:312)
>> > > > at org.testng.SuiteRunner.privateRun(SuiteRunner.java:274)
>> > > > at org.testng.SuiteRunner.run(SuiteRunner.java:223)
>> > > > at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
>> > > > at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
>> > > > at org.testng.TestNG.runSuitesSequentially(TestNG.java:995)
>> > > > at org.testng.TestNG.runSuitesLocally(TestNG.java:920)
>> > > > at org.testng.TestNG.run(TestNG.java:856)
>> > > > at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:110)
>> > > > at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)
>> > > > at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:174)
>> > > >
>> > > >
>> > > > --
>> > > > http://www.mreunion-labs.net/
>> > > > twitter : @mreunionlabs
>> > > > blog : mreunion.wordpress.com
>> > > > Follow our android survey at :
>> > > > http://www.mreunion-labs.net/downloads:dlapk/MySurvey.apk
>> > >
>> >
>> >
>> >
>> > --
>> > http://www.mreunion-labs.net/
>> > twitter : @mreunionlabs
>> > blog : mreunion.wordpress.com
>> > Follow our android survey at :
>> > http://www.mreunion-labs.net/downloads:dlapk/MySurvey.apk
>> >
>>
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator of Apache Tapestry
>
> The source for Tapestry training, mentoring and support. Contact me to learn
> how I can get you up and productive in Tapestry fast!
>
> (971) 678-5210
> http://howardlewisship.com
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: ComponenentRequestHandler doesn't exist when testing using TestNG

abangkis
Hi howard and Kalle, Thanks a lot for the advice :) Yes i was also looking
at the PageTester, I think its very cool :) But the apps mainly consist of 2
page. A page with a link to start the process, and the page that will show
the result of the process. All of the work will be executed on the services
from tapestry IOC. That is why I'm looking for alternative from page tester
to test the services individually :)

On Thu, Jan 6, 2011 at 1:26 AM, Kalle Korhonen
<[hidden email]>wrote:

> ... or HtmlUnit & Jetty, see below from a recent thread on Maven users
> list:
>
> subject Re: Fail a build if the web application fails to load in Jetty....
> On Tue, Jan 4, 2011 at 11:10 AM, Nathan Wilhelmi <[hidden email]>
> wrote:
> > Hi - HtmlUnit is a simpler solution for what we are trying to test right
> > now. What I am really after is failing fast on the integration tests. If
> the
> > app didn't start I would rather not run through each test and all setup
> > associated with each one.
> >
> > -Nate
> >
> > Kalle Korhonen wrote:
> >>
> >> Why not
> >>
> http://docs.codehaus.org/display/TYNAMO/2010/07/30/Full+web+integration+testing+in+a+single+JVM
> >> and something like
> >>
> >>
> http://svn.codehaus.org/tynamo/trunk/tapestry-model/tapestry-model-test/src/main/java/org/tynamo/test/AbstractContainerTest.java
> >> ?
> >>
> >> With an embedded Jetty, your integration tests would behave just like
> >> your unit tests.
> >>
> >> Kalle
> >>
> >>
> >> On Wed, Dec 29, 2010 at 1:03 PM, Nathan Wilhelmi <[hidden email]>
> >> wrote:
> >>
> >>>
> >>> Hi -
> >>>
> >>>  We are working on integrating Jetty deployment into our integration
> >>> tests.
> >>> We don't have any selenium type tests yet. Is there any to fail the
> build
> >>> if
> >>> the web application fails to start in Jetty? We would like to use this
> as
> >>> first step.
> >>>
> >>> Thanks!
> >>>
>
> On Wed, Jan 5, 2011 at 9:44 AM, Howard Lewis Ship <[hidden email]>
> wrote:
> > ... and this is why you either want to look at unit testing using mocks,
> or
> > at integration testing using Selenium.  In the half-ground you end up
> with a
> > lot of complications since the code is designed to run inside a servlet
> > container and you don't have one.
> >
> > PageTester exists to mock up the servlet container; that's another
> option.
> >
> > On Wed, Jan 5, 2011 at 8:08 AM, Donny Nadolny <[hidden email]
> >wrote:
> >
> >> You can contribute just the name of the file you want
> >> ("quartz.properties"),
> >> put it in the classpath, eg in src/main/resources, and then in the place
> >> where you need to use it, load it from the classloader as a resource:
> >> InputStream in = getClass().getResourceAsStream("quartz.properties");
> >> But instead of "quartz.properties" you can use the symbol that contains
> >> that
> >> filename.
> >>
> >>
> >> On Wed, Jan 5, 2011 at 10:06 AM, abangkis <[hidden email]> wrote:
> >>
> >> > Hi josh, thanks a lot. I follow your advice and tries to include all
> the
> >> > module that i could think of. This is the modified initRegistry method
> :
> >> >
> >> > private void initRegistry() {
> >> >  RegistryBuilder builder = new RegistryBuilder();
> >> >   builder.add(TapestryModule.class);
> >> >  builder.add(AppModule.class);
> >> >  builder.add(HibernateCoreModule.class);
> >> >  builder.add(ChenilleKitQuartzModule.class);
> >> > registry = builder.build();
> >> > registry.performRegistryStartup();
> >> >  }
> >> >
> >> > Adding TapestryModule fix the previous error, but i think I'm missing
> a
> >> > little something here. The ChennileKitQuartzModule throw a null
> pointer
> >> > exception
> >> >
> >> > Caused by: java.lang.RuntimeException: Error invoking service
> >> contribution
> >> > method
> >> >
> >> >
> >>
> net.mreunion.cinematorserver.services.AppModule.contributeSchedulerFactory(ApplicationGlobals,
> >> > OrderedConfiguration): java.lang.NullPointerException
> >> >  at
> >> >
> >> >
> >>
> org.apache.tapestry5.ioc.internal.ContributionDefImpl.invokeMethod(ContributionDefImpl.java:139)
> >> > at
> >> >
> >> >
> >>
> org.apache.tapestry5.ioc.internal.ContributionDefImpl.contribute(ContributionDefImpl.java:82)
> >> >  at
> >> >
> >>
> org.apache.tapestry5.ioc.internal.RegistryImpl$9.run(RegistryImpl.java:651)
> >> > at
> >> >
> >> >
> >>
> org.apache.tapestry5.ioc.internal.OperationTrackerImpl$1.invoke(OperationTrackerImpl.java:50)
> >> >  at
> >> >
> >> >
> >>
> org.apache.tapestry5.ioc.internal.OperationTrackerImpl$1.invoke(OperationTrackerImpl.java:47)
> >> > at
> >> >
> >> >
> >>
> org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:65)
> >> >  ... 98 more
> >> > Caused by: java.lang.NullPointerException
> >> > at
> >> >
> >> >
> >>
> net.mreunion.cinematorserver.services.AppModule.contributeSchedulerFactory(AppModule.java:116)
> >> >
> >> > That leads to the quartz contribution method in my app module
> >> >
> >> > public static void contributeSchedulerFactory(
> >> >  @InjectService("ApplicationGlobals") ApplicationGlobals
> >> > applicationGlobals,
> >> > OrderedConfiguration<URL> configuration) {
> >> >  String fileName = applicationGlobals.getServletContext().getRealPath(
> >> > "/WEB-INF/classes/quartz.properties");
> >> >  File file = new File(fileName);
> >> > if (!file.canRead())
> >> > throw new RuntimeException(String.format("can't read file '%s'",
> >> >  file.toURI()));
> >> >
> >> > try {
> >> > configuration.add("configuration", file.toURI().toURL());
> >> >  } catch (MalformedURLException e) {
> >> > throw new RuntimeException(e);
> >> > }
> >> >  }
> >> >
> >> > public static void contributeQuartzSchedulerManager(
> >> >  OrderedConfiguration<JobSchedulingBundle> configuration,
> >> > CrawlingJobImpl crawlingJob, JakartaCrawler crawler) {
> >> >  configuration.add("crawlScheduler", new
> >> CrawlSchedulerBundle(crawlingJob,
> >> > crawler));
> >> > }
> >> >
> >> > The null pointer is in  the
> >> >
> >> > String fileName = applicationGlobals.getServletContext().getRealPath(
> >> > "/WEB-INF/classes/quartz.properties");
> >> >
> >> > I guess it makes sense, since TestNG is not using Servlet Context to
> run
> >> > the
> >> > test.  Is there anyway to contribute the quartz.properties that will
> work
> >> > inside and outside of the servlet context  ?
> >> >
> >> >
> >> > Cheers,
> >> > Abangkis
> >> >
> >> > On Wed, Jan 5, 2011 at 9:38 PM, Josh Canfield <[hidden email]
> >> > >wrote:
> >> >
> >> > > It doesn't look like you are including TapestryModule in your
> registry.
> >> > > Since you're building the registry you're in charge kit adding all
> the
> >> > > modules.
> >> > >
> >> > > Optionally you could add @SubModule(TapestryModule.class) to your
> >> > AppModule
> >> > > to make the dependency explicit.
> >> > > On Jan 5, 2011 4:25 AM, "abangkis" <[hidden email]> wrote:
> >> > > > Hello, i have a tapestry app that consist of 1-2 pages, and lots
> of
> >> > > > services. The apps is used to crawl another website. The apps uses
> >> > > hibernate
> >> > > > module, quartz and some other contribution. Because of the nature
> of
> >> my
> >> > > > apps, i want to test the services class using TestNG. I've created
> a
> >> > > simple
> >> > > > test that build the tapestry registry for my services and run it.
> But
> >> i
> >> > > > received an error that the ComponentRequestHandler doesn't exist.
> >> > Here's
> >> > > the
> >> > > > contribution in the appmodule, test file and the stack trace. I
> >> wonder
> >> > > what
> >> > > > I've missed ?
> >> > > >
> >> > > >
> >> > > > Cheers,
> >> > > > Abangkis
> >> > > >
> >> > > > public class AppModule {
> >> > > > ....
> >> > > >
> >> > > > public void
> >> > > >
> >> > >
> >> > >
> >> >
> >>
> contributeComponentRequestHandler(OrderedConfiguration<ComponentRequestFilter>
> >> > > > configuration) {
> >> > > > configuration.addInstance("PageProtectionFilter",
> >> > > > PageProtectionFilter.class);
> >> > > > }
> >> > > > public void
> >> > contributeRequestHandler(OrderedConfiguration<RequestFilter>
> >> > > > configuration,
> >> > > > PageRenderLinkSource pageRenderLinkSource) {
> >> > > > final HashSet<String> ASSETS_WHITE_LIST = new
> >> > > > HashSet<String>(Arrays.asList("jpg", "jpeg", "png", "gif", "js",
> >> > > > "css", "ico", "html", "json"));
> >> > > > configuration.add("AssetProtectionFilter", new
> >> > > > AssetProtectionFilter(ASSETS_WHITE_LIST, pageRenderLinkSource),
> >> > > > "before:*");
> >> > > > }
> >> > > > ....
> >> > > > }
> >> > > >
> >> > > > public class MyTest {
> >> > > > private Registry registry;
> >> > > >
> >> > > > @Test
> >> > > > public void f() {
> >> > > > String pageName = "DummyPage";
> >> > > > MovieManager movieManager =
> registry.getService(MovieManager.class);
> >> > > > String result = movieManager.getMovieTitle(pageName);
> >> > > > assertEquals("Gullivers Island", result);
> >> > > > }
> >> > > >
> >> > > > @BeforeClass
> >> > > > public void beforeClass() {
> >> > > > // registry = IOCUtilities.buildDefaultRegistry();
> >> > > > initRegistry();
> >> > > > }
> >> > > >
> >> > > > private void initRegistry() {
> >> > > > RegistryBuilder builder = new RegistryBuilder();
> >> > > > builder.add(ChenilleKitQuartzModule.class);
> >> > > > builder.add(AppModule.class);
> >> > > > registry = builder.build();
> >> > > > registry.performRegistryStartup();
> >> > > > }
> >> > > >
> >> > > > @AfterClass
> >> > > > public void afterClass() {
> >> > > > registry.shutdown();
> >> > > > }
> >> > > >
> >> > > > }
> >> > > >
> >> > > > FAILED CONFIGURATION: @BeforeClass beforeClass
> >> > > > java.lang.IllegalArgumentException: Contribution
> >> > > >
> >> > >
> >> > >
> >> >
> >>
> net.mreunion.cinematorserver.services.AppModule.contributeComponentRequestHandler(OrderedConfiguration)
> >> > > > (at AppModule.java:145) is for service 'ComponentRequestHandler',
> >> which
> >> > > does
> >> > > > not exist.
> >> > > > at
> >> > > >
> >> > >
> >> > >
> >> >
> >>
> org.apache.tapestry5.ioc.internal.RegistryImpl.validateContributeDefs(RegistryImpl.java:253)
> >> > > > at
> >> > > >
> >> > >
> >> > >
> >> >
> >>
> org.apache.tapestry5.ioc.internal.RegistryImpl.<init>(RegistryImpl.java:229)
> >> > > > at
> >> > >
> >> org.apache.tapestry5.ioc.RegistryBuilder.build(RegistryBuilder.java:170)
> >> > > > at
> >> > > >
> net.mreunion.cinematorserver.TestEscapedCharacter.initRegistry(MyTest
> >> > > .java:45)
> >> > > > at
> >> > > >
> net.mreunion.cinematorserver.TestEscapedCharacter.beforeClass(MyTest
> >> > > .java:33)
> >> > > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >> > > > at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> >> > > > at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> >> > > > at java.lang.reflect.Method.invoke(Unknown Source)
> >> > > > at
> >> > > >
> >> > >
> >> > >
> >> >
> >>
> org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:74)
> >> > > > at
> >> > >
> org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:525)
> >> > > > at
> org.testng.internal.Invoker.invokeConfigurations(Invoker.java:202)
> >> > > > at
> org.testng.internal.Invoker.invokeConfigurations(Invoker.java:130)
> >> > > > at
> >> > > >
> >> > >
> >> > >
> >> >
> >>
> org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:173)
> >> > > > at
> >> org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:105)
> >> > > > at org.testng.TestRunner.runWorkers(TestRunner.java:1125)
> >> > > > at org.testng.TestRunner.privateRun(TestRunner.java:749)
> >> > > > at org.testng.TestRunner.run(TestRunner.java:600)
> >> > > > at org.testng.SuiteRunner.runTest(SuiteRunner.java:317)
> >> > > > at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:312)
> >> > > > at org.testng.SuiteRunner.privateRun(SuiteRunner.java:274)
> >> > > > at org.testng.SuiteRunner.run(SuiteRunner.java:223)
> >> > > > at
> org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
> >> > > > at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
> >> > > > at org.testng.TestNG.runSuitesSequentially(TestNG.java:995)
> >> > > > at org.testng.TestNG.runSuitesLocally(TestNG.java:920)
> >> > > > at org.testng.TestNG.run(TestNG.java:856)
> >> > > > at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:110)
> >> > > > at
> org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)
> >> > > > at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:174)
> >> > > >
> >> > > >
> >> > > > --
> >> > > > http://www.mreunion-labs.net/
> >> > > > twitter : @mreunionlabs
> >> > > > blog : mreunion.wordpress.com
> >> > > > Follow our android survey at :
> >> > > > http://www.mreunion-labs.net/downloads:dlapk/MySurvey.apk
> >> > >
> >> >
> >> >
> >> >
> >> > --
> >> > http://www.mreunion-labs.net/
> >> > twitter : @mreunionlabs
> >> > blog : mreunion.wordpress.com
> >> > Follow our android survey at :
> >> > http://www.mreunion-labs.net/downloads:dlapk/MySurvey.apk
> >> >
> >>
> >
> >
> >
> > --
> > Howard M. Lewis Ship
> >
> > Creator of Apache Tapestry
> >
> > The source for Tapestry training, mentoring and support. Contact me to
> learn
> > how I can get you up and productive in Tapestry fast!
> >
> > (971) 678-5210
> > http://howardlewisship.com
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
http://www.mreunion-labs.net/
twitter : @mreunionlabs
blog : mreunion.wordpress.com
Follow our android survey at :
http://www.mreunion-labs.net/downloads:dlapk/MySurvey.apk
Reply | Threaded
Open this post in threaded view
|

Re: ComponenentRequestHandler doesn't exist when testing using TestNG

abangkis
In reply to this post by Donny Nadolny-2
Hi donny, thanks. I will try this :)

On Wed, Jan 5, 2011 at 11:08 PM, Donny Nadolny <[hidden email]>wrote:

> You can contribute just the name of the file you want
> ("quartz.properties"),
> put it in the classpath, eg in src/main/resources, and then in the place
> where you need to use it, load it from the classloader as a resource:
> InputStream in = getClass().getResourceAsStream("quartz.properties");
> But instead of "quartz.properties" you can use the symbol that contains
> that
> filename.
>
>
> On Wed, Jan 5, 2011 at 10:06 AM, abangkis <[hidden email]> wrote:
>
> > Hi josh, thanks a lot. I follow your advice and tries to include all the
> > module that i could think of. This is the modified initRegistry method :
> >
> > private void initRegistry() {
> >  RegistryBuilder builder = new RegistryBuilder();
> >   builder.add(TapestryModule.class);
> >  builder.add(AppModule.class);
> >  builder.add(HibernateCoreModule.class);
> >  builder.add(ChenilleKitQuartzModule.class);
> > registry = builder.build();
> > registry.performRegistryStartup();
> >  }
> >
> > Adding TapestryModule fix the previous error, but i think I'm missing a
> > little something here. The ChennileKitQuartzModule throw a null pointer
> > exception
> >
> > Caused by: java.lang.RuntimeException: Error invoking service
> contribution
> > method
> >
> >
> net.mreunion.cinematorserver.services.AppModule.contributeSchedulerFactory(ApplicationGlobals,
> > OrderedConfiguration): java.lang.NullPointerException
> >  at
> >
> >
> org.apache.tapestry5.ioc.internal.ContributionDefImpl.invokeMethod(ContributionDefImpl.java:139)
> > at
> >
> >
> org.apache.tapestry5.ioc.internal.ContributionDefImpl.contribute(ContributionDefImpl.java:82)
> >  at
> >
> org.apache.tapestry5.ioc.internal.RegistryImpl$9.run(RegistryImpl.java:651)
> > at
> >
> >
> org.apache.tapestry5.ioc.internal.OperationTrackerImpl$1.invoke(OperationTrackerImpl.java:50)
> >  at
> >
> >
> org.apache.tapestry5.ioc.internal.OperationTrackerImpl$1.invoke(OperationTrackerImpl.java:47)
> > at
> >
> >
> org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:65)
> >  ... 98 more
> > Caused by: java.lang.NullPointerException
> > at
> >
> >
> net.mreunion.cinematorserver.services.AppModule.contributeSchedulerFactory(AppModule.java:116)
> >
> > That leads to the quartz contribution method in my app module
> >
> > public static void contributeSchedulerFactory(
> >  @InjectService("ApplicationGlobals") ApplicationGlobals
> > applicationGlobals,
> > OrderedConfiguration<URL> configuration) {
> >  String fileName = applicationGlobals.getServletContext().getRealPath(
> > "/WEB-INF/classes/quartz.properties");
> >  File file = new File(fileName);
> > if (!file.canRead())
> > throw new RuntimeException(String.format("can't read file '%s'",
> >  file.toURI()));
> >
> > try {
> > configuration.add("configuration", file.toURI().toURL());
> >  } catch (MalformedURLException e) {
> > throw new RuntimeException(e);
> > }
> >  }
> >
> > public static void contributeQuartzSchedulerManager(
> >  OrderedConfiguration<JobSchedulingBundle> configuration,
> > CrawlingJobImpl crawlingJob, JakartaCrawler crawler) {
> >  configuration.add("crawlScheduler", new
> CrawlSchedulerBundle(crawlingJob,
> > crawler));
> > }
> >
> > The null pointer is in  the
> >
> > String fileName = applicationGlobals.getServletContext().getRealPath(
> > "/WEB-INF/classes/quartz.properties");
> >
> > I guess it makes sense, since TestNG is not using Servlet Context to run
> > the
> > test.  Is there anyway to contribute the quartz.properties that will work
> > inside and outside of the servlet context  ?
> >
> >
> > Cheers,
> > Abangkis
> >
> > On Wed, Jan 5, 2011 at 9:38 PM, Josh Canfield <[hidden email]
> > >wrote:
> >
> > > It doesn't look like you are including TapestryModule in your registry.
> > > Since you're building the registry you're in charge kit adding all the
> > > modules.
> > >
> > > Optionally you could add @SubModule(TapestryModule.class) to your
> > AppModule
> > > to make the dependency explicit.
> > > On Jan 5, 2011 4:25 AM, "abangkis" <[hidden email]> wrote:
> > > > Hello, i have a tapestry app that consist of 1-2 pages, and lots of
> > > > services. The apps is used to crawl another website. The apps uses
> > > hibernate
> > > > module, quartz and some other contribution. Because of the nature of
> my
> > > > apps, i want to test the services class using TestNG. I've created a
> > > simple
> > > > test that build the tapestry registry for my services and run it. But
> i
> > > > received an error that the ComponentRequestHandler doesn't exist.
> > Here's
> > > the
> > > > contribution in the appmodule, test file and the stack trace. I
> wonder
> > > what
> > > > I've missed ?
> > > >
> > > >
> > > > Cheers,
> > > > Abangkis
> > > >
> > > > public class AppModule {
> > > > ....
> > > >
> > > > public void
> > > >
> > >
> > >
> >
> contributeComponentRequestHandler(OrderedConfiguration<ComponentRequestFilter>
> > > > configuration) {
> > > > configuration.addInstance("PageProtectionFilter",
> > > > PageProtectionFilter.class);
> > > > }
> > > > public void
> > contributeRequestHandler(OrderedConfiguration<RequestFilter>
> > > > configuration,
> > > > PageRenderLinkSource pageRenderLinkSource) {
> > > > final HashSet<String> ASSETS_WHITE_LIST = new
> > > > HashSet<String>(Arrays.asList("jpg", "jpeg", "png", "gif", "js",
> > > > "css", "ico", "html", "json"));
> > > > configuration.add("AssetProtectionFilter", new
> > > > AssetProtectionFilter(ASSETS_WHITE_LIST, pageRenderLinkSource),
> > > > "before:*");
> > > > }
> > > > ....
> > > > }
> > > >
> > > > public class MyTest {
> > > > private Registry registry;
> > > >
> > > > @Test
> > > > public void f() {
> > > > String pageName = "DummyPage";
> > > > MovieManager movieManager = registry.getService(MovieManager.class);
> > > > String result = movieManager.getMovieTitle(pageName);
> > > > assertEquals("Gullivers Island", result);
> > > > }
> > > >
> > > > @BeforeClass
> > > > public void beforeClass() {
> > > > // registry = IOCUtilities.buildDefaultRegistry();
> > > > initRegistry();
> > > > }
> > > >
> > > > private void initRegistry() {
> > > > RegistryBuilder builder = new RegistryBuilder();
> > > > builder.add(ChenilleKitQuartzModule.class);
> > > > builder.add(AppModule.class);
> > > > registry = builder.build();
> > > > registry.performRegistryStartup();
> > > > }
> > > >
> > > > @AfterClass
> > > > public void afterClass() {
> > > > registry.shutdown();
> > > > }
> > > >
> > > > }
> > > >
> > > > FAILED CONFIGURATION: @BeforeClass beforeClass
> > > > java.lang.IllegalArgumentException: Contribution
> > > >
> > >
> > >
> >
> net.mreunion.cinematorserver.services.AppModule.contributeComponentRequestHandler(OrderedConfiguration)
> > > > (at AppModule.java:145) is for service 'ComponentRequestHandler',
> which
> > > does
> > > > not exist.
> > > > at
> > > >
> > >
> > >
> >
> org.apache.tapestry5.ioc.internal.RegistryImpl.validateContributeDefs(RegistryImpl.java:253)
> > > > at
> > > >
> > >
> > >
> >
> org.apache.tapestry5.ioc.internal.RegistryImpl.<init>(RegistryImpl.java:229)
> > > > at
> > >
> org.apache.tapestry5.ioc.RegistryBuilder.build(RegistryBuilder.java:170)
> > > > at
> > > > net.mreunion.cinematorserver.TestEscapedCharacter.initRegistry(MyTest
> > > .java:45)
> > > > at
> > > > net.mreunion.cinematorserver.TestEscapedCharacter.beforeClass(MyTest
> > > .java:33)
> > > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > > > at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> > > > at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> > > > at java.lang.reflect.Method.invoke(Unknown Source)
> > > > at
> > > >
> > >
> > >
> >
> org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:74)
> > > > at
> > > org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:525)
> > > > at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:202)
> > > > at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:130)
> > > > at
> > > >
> > >
> > >
> >
> org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:173)
> > > > at
> org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:105)
> > > > at org.testng.TestRunner.runWorkers(TestRunner.java:1125)
> > > > at org.testng.TestRunner.privateRun(TestRunner.java:749)
> > > > at org.testng.TestRunner.run(TestRunner.java:600)
> > > > at org.testng.SuiteRunner.runTest(SuiteRunner.java:317)
> > > > at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:312)
> > > > at org.testng.SuiteRunner.privateRun(SuiteRunner.java:274)
> > > > at org.testng.SuiteRunner.run(SuiteRunner.java:223)
> > > > at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
> > > > at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
> > > > at org.testng.TestNG.runSuitesSequentially(TestNG.java:995)
> > > > at org.testng.TestNG.runSuitesLocally(TestNG.java:920)
> > > > at org.testng.TestNG.run(TestNG.java:856)
> > > > at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:110)
> > > > at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)
> > > > at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:174)
> > > >
> > > >
> > > > --
> > > > http://www.mreunion-labs.net/
> > > > twitter : @mreunionlabs
> > > > blog : mreunion.wordpress.com
> > > > Follow our android survey at :
> > > > http://www.mreunion-labs.net/downloads:dlapk/MySurvey.apk
> > >
> >
> >
> >
> > --
> > http://www.mreunion-labs.net/
> > twitter : @mreunionlabs
> > blog : mreunion.wordpress.com
> > Follow our android survey at :
> > http://www.mreunion-labs.net/downloads:dlapk/MySurvey.apk
> >
>



--
http://www.mreunion-labs.net/
twitter : @mreunionlabs
blog : mreunion.wordpress.com
Follow our android survey at :
http://www.mreunion-labs.net/downloads:dlapk/MySurvey.apk