This content has been marked as final.
Show 1 reply
-
1. Re: faces message bundles not resolved in SeamTest
trossmy Jan 13, 2010 3:29 PM (in response to trossmy)after googling around and digging deep into the seam source code (and not expecting any answers on this list anymore...) I opted for a mock component, that will do the job for now:
say you have the bundle defined in faces-config.xml:<resource-bundle> <base-name>logTexts</base-name> <var>log</var> </resource-bundle>
then this will not be resolved in SeamTest. Then you can workaround that issue like this:
@Name(value = "log") @AutoCreate @Install(precedence = MOCK) public class Log extends HashMap { @Override public Object get(Object key) { ResourceBundle resourceBundle = ResourceBundle.getBundle("logTexts", FacesContext.getCurrentInstance().getViewRoot().getLocale()); try { String value = resourceBundle.getString(key.toString()); return value; } catch (MissingResourceException e) { return null; } } }
I also had to add this components.xml to the test/resources/META-INF directory: (we are building with Maven)
<?xml version="1.0" encoding="UTF-8"?> <components xmlns="http://jboss.com/products/seam/components" xmlns:core="http://jboss.com/products/seam/core" xmlns:persistence="http://jboss.com/products/seam/persistence" xmlns:spring="http://jboss.com/products/seam/spring" xmlns:async="http://jboss.com/products/seam/async" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:security="http://jboss.com/products/seam/security" xmlns:web="http://jboss.com/products/seam/web" xsi:schemaLocation="http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.1.xsd http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.1.xsd http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.1.xsd http://jboss.com/products/seam/spring http://jboss.com/products/seam/spring-2.1.xsd http://jboss.com/products/seam/async http://jboss.com/products/seam/async-2.1.xsd http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.1.xsd http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.1.xsd" xmlns:transaction="http://jboss.com/products/seam/transaction"> <core:manager conversation-timeout="1200000" precedence="40" concurrent-request-timeout="500" conversation-id-parameter="cid"/> </components>