Re: Loading global resources in test?

2007-08-22 Thread Erik Underbjerg
I figured it out. Guess I didn't read the documentation properly  
afterall. In the documentation for addStringResourceLoader is says:


Description copied from interface: IResourceSettings
Add a string resource loader to the chain of loaders. If this is  
the first call to this method since the creation of the application  
settings then the existing chain is cleared before the new loader is  
added.


So the solution was to:

1. retrieve and save all the existing resource loaders
2. add them again
3. add the extra resource loader as below.

Then it worked.

Sorry for the trouble, and thanks for your time.

/Erik


On 21/08/2007, at 16.48, Igor Vaynberg wrote:

it looks like you are doing it properly. not sure why it doesnt  
work. you
will have to debug it and see. maybe you have to do it every time  
because it

might be creating new application instances?

-igor


On 8/21/07, Erik Underbjerg [EMAIL PROTECTED] wrote:


Thanks for the reply.

I did figure out that the WicketTester is not a subclass of
MyApplication, and therefore doesn't have access to the
MyApplication.properties file.

That's also why I was trying to do as you suggest, and add my own
StringResourceLoader to the WicketTester subclass, and load the
MyApplication.properties file manually. So as far as I can see, I'm
doing what you said, but I just can't make it work.

For some reason, even though I add a new StringResourceLoader in the
WicketTester, I can't access the resources in  
MyApplication.properties.


Am I adding it in the wrong way?

/Erik

On 21/08/2007, at 15.51, Igor Vaynberg wrote:


wicket tester uses a mock web application - not yours - so it
cannot load
those properties. i think in 1.3 we refactored it to support custom
application subclasses. i think as far as you can make it work in
1.2.6 is
to change resource settings not to throw exceptions on not-found-
resources
while testing. or you can add your own stringresourceloader to the
mock
application and make it load properties from your application's
property
file. im not sure we can properly fix this in 1.2.6 because we
cannot break
api.

-igor


On 8/20/07, Erik Underbjerg [EMAIL PROTECTED] wrote:


Right, sorry for the typo. I do have both:

src/main/java/base/MyApplication.java
src/main/java/base/MyApplication.properties

The application works as intended: When I start MyApplication, I  
can

access all constants in MyApplication.properties from various pages
and components throughout the application. So far so good.

However, when I try to access the same pages from my tests, I get
errors similar to:

wicket.WicketRuntimeException: Error attaching this
container for
rendering: [MarkupContainer [Component id = basket_item, page =
base.BasketPage, path =  
0:basket:basket_form:basket_item.BasketPanel

$BasketEditForm$1, isVisible = true, isVersioned = false]]
at wicket.MarkupContainer.internalAttach
(MarkupContainer.java:361)

[..]

Caused by: java.util.MissingResourceException: Unable to  
find

resource: MODEL_RELEASED for component:

MODEL_RESOURCE is a string constant defined in
MyApplication.properties, and it works fine when I run the app  
in the

normal way.

The tests are run a subclass of WicketTester, in src/test/java/base
with the initialization method:

public void initialize() {
getResourceSettings().addStringResourceLoader(new
ClassStringResourceLoader(this, MyApplication.class));
}

That is what I've tried, in order to load the
MyApplication.properties for my subclass of WicketTester. It just
doesn't work.

So my question is: How can I load the MyApplication.properties  
file,

so the constants in it are accessible in my tests? I'm using wicket
1.2.6.

Thanks in advance.


/Erik


On 20/08/2007, at 22.55, Igor Vaynberg wrote:


it should probably be MyApplication.properties unless you have
myApplication.java

-igor


On 8/20/07, Erik Underbjerg [EMAIL PROTECTED] wrote:


Hello,

I have just moved some localized string resources to a
myApplication.properties file, because they need to accessed by
different panels and pages, and it works fine.

However, when running my unit tests with WicketTester, it can't
find
the resources in myApplication.properties. I have been  
unsuccessful

in finding a way to add the myApplication.properties file to the
resource path of my WicketTester subclass. This is what I've  
tried,

in my subclass of WicketTester:

public void initialize() {
getResourceSettings().addStringResourceLoader(new
ClassStringResourceLoader(this, PolFotoApplication.class));
}

So: How do I add myApplication.properties to the resource path
of my
WicketTester?

Kind regards,

Erik



--- 
--

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For 

Re: Loading global resources in test?

2007-08-21 Thread Erik Underbjerg

Right, sorry for the typo. I do have both:

src/main/java/base/MyApplication.java
src/main/java/base/MyApplication.properties

The application works as intended: When I start MyApplication, I can  
access all constants in MyApplication.properties from various pages  
and components throughout the application. So far so good.


However, when I try to access the same pages from my tests, I get  
errors similar to:


	wicket.WicketRuntimeException: Error attaching this container for  
rendering: [MarkupContainer [Component id = basket_item, page =  
base.BasketPage, path = 0:basket:basket_form:basket_item.BasketPanel 
$BasketEditForm$1, isVisible = true, isVersioned = false]]

at wicket.MarkupContainer.internalAttach(MarkupContainer.java:361)

[..]

	Caused by: java.util.MissingResourceException: Unable to find  
resource: MODEL_RELEASED for component:


MODEL_RESOURCE is a string constant defined in  
MyApplication.properties, and it works fine when I run the app in the  
normal way.


The tests are run a subclass of WicketTester, in src/test/java/base  
with the initialization method:


public void initialize() {
	getResourceSettings().addStringResourceLoader(new  
ClassStringResourceLoader(this, MyApplication.class));

}

That is what I've tried, in order to load the  
MyApplication.properties for my subclass of WicketTester. It just  
doesn't work.


So my question is: How can I load the MyApplication.properties file,  
so the constants in it are accessible in my tests? I'm using wicket  
1.2.6.


Thanks in advance.


/Erik


On 20/08/2007, at 22.55, Igor Vaynberg wrote:


it should probably be MyApplication.properties unless you have
myApplication.java

-igor


On 8/20/07, Erik Underbjerg [EMAIL PROTECTED] wrote:


Hello,

I have just moved some localized string resources to a
myApplication.properties file, because they need to accessed by
different panels and pages, and it works fine.

However, when running my unit tests with WicketTester, it can't find
the resources in myApplication.properties. I have been unsuccessful
in finding a way to add the myApplication.properties file to the
resource path of my WicketTester subclass. This is what I've tried,
in my subclass of WicketTester:

public void initialize() {
getResourceSettings().addStringResourceLoader(new
ClassStringResourceLoader(this, PolFotoApplication.class));
}

So: How do I add myApplication.properties to the resource path of my
WicketTester?

Kind regards,

Erik



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Loading global resources in test?

2007-08-21 Thread Igor Vaynberg
wicket tester uses a mock web application - not yours - so it cannot load
those properties. i think in 1.3 we refactored it to support custom
application subclasses. i think as far as you can make it work in 1.2.6 is
to change resource settings not to throw exceptions on not-found-resources
while testing. or you can add your own stringresourceloader to the mock
application and make it load properties from your application's property
file. im not sure we can properly fix this in 1.2.6 because we cannot break
api.

-igor


On 8/20/07, Erik Underbjerg [EMAIL PROTECTED] wrote:

 Right, sorry for the typo. I do have both:

 src/main/java/base/MyApplication.java
 src/main/java/base/MyApplication.properties

 The application works as intended: When I start MyApplication, I can
 access all constants in MyApplication.properties from various pages
 and components throughout the application. So far so good.

 However, when I try to access the same pages from my tests, I get
 errors similar to:

 wicket.WicketRuntimeException: Error attaching this container for
 rendering: [MarkupContainer [Component id = basket_item, page =
 base.BasketPage, path = 0:basket:basket_form:basket_item.BasketPanel
 $BasketEditForm$1, isVisible = true, isVersioned = false]]
 at wicket.MarkupContainer.internalAttach(MarkupContainer.java:361)

 [..]

 Caused by: java.util.MissingResourceException: Unable to find
 resource: MODEL_RELEASED for component:

 MODEL_RESOURCE is a string constant defined in
 MyApplication.properties, and it works fine when I run the app in the
 normal way.

 The tests are run a subclass of WicketTester, in src/test/java/base
 with the initialization method:

 public void initialize() {
 getResourceSettings().addStringResourceLoader(new
 ClassStringResourceLoader(this, MyApplication.class));
 }

 That is what I've tried, in order to load the
 MyApplication.properties for my subclass of WicketTester. It just
 doesn't work.

 So my question is: How can I load the MyApplication.properties file,
 so the constants in it are accessible in my tests? I'm using wicket
 1.2.6.

 Thanks in advance.


 /Erik


 On 20/08/2007, at 22.55, Igor Vaynberg wrote:

  it should probably be MyApplication.properties unless you have
  myApplication.java
 
  -igor
 
 
  On 8/20/07, Erik Underbjerg [EMAIL PROTECTED] wrote:
 
  Hello,
 
  I have just moved some localized string resources to a
  myApplication.properties file, because they need to accessed by
  different panels and pages, and it works fine.
 
  However, when running my unit tests with WicketTester, it can't find
  the resources in myApplication.properties. I have been unsuccessful
  in finding a way to add the myApplication.properties file to the
  resource path of my WicketTester subclass. This is what I've tried,
  in my subclass of WicketTester:
 
  public void initialize() {
  getResourceSettings().addStringResourceLoader(new
  ClassStringResourceLoader(this, PolFotoApplication.class));
  }
 
  So: How do I add myApplication.properties to the resource path of my
  WicketTester?
 
  Kind regards,
 
  Erik


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




Re: Loading global resources in test?

2007-08-21 Thread Erik Underbjerg

Thanks for the reply.

I did figure out that the WicketTester is not a subclass of  
MyApplication, and therefore doesn't have access to the  
MyApplication.properties file.


That's also why I was trying to do as you suggest, and add my own  
StringResourceLoader to the WicketTester subclass, and load the  
MyApplication.properties file manually. So as far as I can see, I'm  
doing what you said, but I just can't make it work.


For some reason, even though I add a new StringResourceLoader in the  
WicketTester, I can't access the resources in MyApplication.properties.


Am I adding it in the wrong way?

/Erik

On 21/08/2007, at 15.51, Igor Vaynberg wrote:

wicket tester uses a mock web application - not yours - so it  
cannot load

those properties. i think in 1.3 we refactored it to support custom
application subclasses. i think as far as you can make it work in  
1.2.6 is
to change resource settings not to throw exceptions on not-found- 
resources
while testing. or you can add your own stringresourceloader to the  
mock
application and make it load properties from your application's  
property
file. im not sure we can properly fix this in 1.2.6 because we  
cannot break

api.

-igor


On 8/20/07, Erik Underbjerg [EMAIL PROTECTED] wrote:


Right, sorry for the typo. I do have both:

src/main/java/base/MyApplication.java
src/main/java/base/MyApplication.properties

The application works as intended: When I start MyApplication, I can
access all constants in MyApplication.properties from various pages
and components throughout the application. So far so good.

However, when I try to access the same pages from my tests, I get
errors similar to:

wicket.WicketRuntimeException: Error attaching this  
container for

rendering: [MarkupContainer [Component id = basket_item, page =
base.BasketPage, path = 0:basket:basket_form:basket_item.BasketPanel
$BasketEditForm$1, isVisible = true, isVersioned = false]]
at wicket.MarkupContainer.internalAttach 
(MarkupContainer.java:361)


[..]

Caused by: java.util.MissingResourceException: Unable to find
resource: MODEL_RELEASED for component:

MODEL_RESOURCE is a string constant defined in
MyApplication.properties, and it works fine when I run the app in the
normal way.

The tests are run a subclass of WicketTester, in src/test/java/base
with the initialization method:

public void initialize() {
getResourceSettings().addStringResourceLoader(new
ClassStringResourceLoader(this, MyApplication.class));
}

That is what I've tried, in order to load the
MyApplication.properties for my subclass of WicketTester. It just
doesn't work.

So my question is: How can I load the MyApplication.properties file,
so the constants in it are accessible in my tests? I'm using wicket
1.2.6.

Thanks in advance.


/Erik


On 20/08/2007, at 22.55, Igor Vaynberg wrote:


it should probably be MyApplication.properties unless you have
myApplication.java

-igor


On 8/20/07, Erik Underbjerg [EMAIL PROTECTED] wrote:


Hello,

I have just moved some localized string resources to a
myApplication.properties file, because they need to accessed by
different panels and pages, and it works fine.

However, when running my unit tests with WicketTester, it can't  
find

the resources in myApplication.properties. I have been unsuccessful
in finding a way to add the myApplication.properties file to the
resource path of my WicketTester subclass. This is what I've tried,
in my subclass of WicketTester:

public void initialize() {
getResourceSettings().addStringResourceLoader(new
ClassStringResourceLoader(this, PolFotoApplication.class));
}

So: How do I add myApplication.properties to the resource path  
of my

WicketTester?

Kind regards,

Erik



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Loading global resources in test?

2007-08-21 Thread Igor Vaynberg
it looks like you are doing it properly. not sure why it doesnt work. you
will have to debug it and see. maybe you have to do it every time because it
might be creating new application instances?

-igor


On 8/21/07, Erik Underbjerg [EMAIL PROTECTED] wrote:

 Thanks for the reply.

 I did figure out that the WicketTester is not a subclass of
 MyApplication, and therefore doesn't have access to the
 MyApplication.properties file.

 That's also why I was trying to do as you suggest, and add my own
 StringResourceLoader to the WicketTester subclass, and load the
 MyApplication.properties file manually. So as far as I can see, I'm
 doing what you said, but I just can't make it work.

 For some reason, even though I add a new StringResourceLoader in the
 WicketTester, I can't access the resources in MyApplication.properties.

 Am I adding it in the wrong way?

 /Erik

 On 21/08/2007, at 15.51, Igor Vaynberg wrote:

  wicket tester uses a mock web application - not yours - so it
  cannot load
  those properties. i think in 1.3 we refactored it to support custom
  application subclasses. i think as far as you can make it work in
  1.2.6 is
  to change resource settings not to throw exceptions on not-found-
  resources
  while testing. or you can add your own stringresourceloader to the
  mock
  application and make it load properties from your application's
  property
  file. im not sure we can properly fix this in 1.2.6 because we
  cannot break
  api.
 
  -igor
 
 
  On 8/20/07, Erik Underbjerg [EMAIL PROTECTED] wrote:
 
  Right, sorry for the typo. I do have both:
 
  src/main/java/base/MyApplication.java
  src/main/java/base/MyApplication.properties
 
  The application works as intended: When I start MyApplication, I can
  access all constants in MyApplication.properties from various pages
  and components throughout the application. So far so good.
 
  However, when I try to access the same pages from my tests, I get
  errors similar to:
 
  wicket.WicketRuntimeException: Error attaching this
  container for
  rendering: [MarkupContainer [Component id = basket_item, page =
  base.BasketPage, path = 0:basket:basket_form:basket_item.BasketPanel
  $BasketEditForm$1, isVisible = true, isVersioned = false]]
  at wicket.MarkupContainer.internalAttach
  (MarkupContainer.java:361)
 
  [..]
 
  Caused by: java.util.MissingResourceException: Unable to find
  resource: MODEL_RELEASED for component:
 
  MODEL_RESOURCE is a string constant defined in
  MyApplication.properties, and it works fine when I run the app in the
  normal way.
 
  The tests are run a subclass of WicketTester, in src/test/java/base
  with the initialization method:
 
  public void initialize() {
  getResourceSettings().addStringResourceLoader(new
  ClassStringResourceLoader(this, MyApplication.class));
  }
 
  That is what I've tried, in order to load the
  MyApplication.properties for my subclass of WicketTester. It just
  doesn't work.
 
  So my question is: How can I load the MyApplication.properties file,
  so the constants in it are accessible in my tests? I'm using wicket
  1.2.6.
 
  Thanks in advance.
 
 
  /Erik
 
 
  On 20/08/2007, at 22.55, Igor Vaynberg wrote:
 
  it should probably be MyApplication.properties unless you have
  myApplication.java
 
  -igor
 
 
  On 8/20/07, Erik Underbjerg [EMAIL PROTECTED] wrote:
 
  Hello,
 
  I have just moved some localized string resources to a
  myApplication.properties file, because they need to accessed by
  different panels and pages, and it works fine.
 
  However, when running my unit tests with WicketTester, it can't
  find
  the resources in myApplication.properties. I have been unsuccessful
  in finding a way to add the myApplication.properties file to the
  resource path of my WicketTester subclass. This is what I've tried,
  in my subclass of WicketTester:
 
  public void initialize() {
  getResourceSettings().addStringResourceLoader(new
  ClassStringResourceLoader(this, PolFotoApplication.class));
  }
 
  So: How do I add myApplication.properties to the resource path
  of my
  WicketTester?
 
  Kind regards,
 
  Erik
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




Loading global resources in test?

2007-08-20 Thread Erik Underbjerg

Hello,

I have just moved some localized string resources to a  
myApplication.properties file, because they need to accessed by  
different panels and pages, and it works fine.


However, when running my unit tests with WicketTester, it can't find  
the resources in myApplication.properties. I have been unsuccessful  
in finding a way to add the myApplication.properties file to the  
resource path of my WicketTester subclass. This is what I've tried,  
in my subclass of WicketTester:


public void initialize() {
		getResourceSettings().addStringResourceLoader(new  
ClassStringResourceLoader(this, PolFotoApplication.class));

}

So: How do I add myApplication.properties to the resource path of my  
WicketTester?


Kind regards,

Erik

Re: Loading global resources in test?

2007-08-20 Thread Igor Vaynberg
it should probably be MyApplication.properties unless you have
myApplication.java

-igor


On 8/20/07, Erik Underbjerg [EMAIL PROTECTED] wrote:

 Hello,

 I have just moved some localized string resources to a
 myApplication.properties file, because they need to accessed by
 different panels and pages, and it works fine.

 However, when running my unit tests with WicketTester, it can't find
 the resources in myApplication.properties. I have been unsuccessful
 in finding a way to add the myApplication.properties file to the
 resource path of my WicketTester subclass. This is what I've tried,
 in my subclass of WicketTester:

 public void initialize() {
 getResourceSettings().addStringResourceLoader(new
 ClassStringResourceLoader(this, PolFotoApplication.class));
 }

 So: How do I add myApplication.properties to the resource path of my
 WicketTester?

 Kind regards,

 Erik