Commit fd0b9bdf9af67627e9ac3de8e66df8d7d8815c21
1 parent
880e82dd
Exists in
master
Ajustes nos testes das extensões referentes à correção do
ResourceBundleProducer.
Showing
3 changed files
with
28 additions
and
22 deletions
Show diff stats
impl/extension/jpa/src/test/java/br/gov/frameworkdemoiselle/internal/producer/EntityManagerFactoryProducerTest.java
| ... | ... | @@ -9,6 +9,7 @@ import static org.powermock.reflect.Whitebox.setInternalState; |
| 9 | 9 | |
| 10 | 10 | import java.util.Collections; |
| 11 | 11 | import java.util.HashMap; |
| 12 | +import java.util.Locale; | |
| 12 | 13 | import java.util.Map; |
| 13 | 14 | |
| 14 | 15 | import javax.persistence.EntityManagerFactory; |
| ... | ... | @@ -39,7 +40,7 @@ public class EntityManagerFactoryProducerTest { |
| 39 | 40 | @Before |
| 40 | 41 | public void setUp() { |
| 41 | 42 | logger = createMock(Logger.class); |
| 42 | - bundle = new ResourceBundleProducer().create("demoiselle-jpa-bundle"); | |
| 43 | + bundle = new ResourceBundleProducer().create("demoiselle-jpa-bundle", Locale.getDefault()); | |
| 43 | 44 | producer = new EntityManagerFactoryProducer(); |
| 44 | 45 | cache = Collections.synchronizedMap(new HashMap<String, EntityManagerFactory>()); |
| 45 | 46 | setInternalState(producer, Map.class, cache); | ... | ... |
impl/extension/jpa/src/test/java/br/gov/frameworkdemoiselle/internal/producer/EntityManagerProducerTest.java
| ... | ... | @@ -46,6 +46,7 @@ import static org.powermock.reflect.Whitebox.setInternalState; |
| 46 | 46 | |
| 47 | 47 | import java.util.Collections; |
| 48 | 48 | import java.util.HashMap; |
| 49 | +import java.util.Locale; | |
| 49 | 50 | import java.util.Map; |
| 50 | 51 | |
| 51 | 52 | import javax.enterprise.inject.spi.Annotated; |
| ... | ... | @@ -86,11 +87,11 @@ public class EntityManagerProducerTest { |
| 86 | 87 | private Annotated annotated; |
| 87 | 88 | |
| 88 | 89 | private Name name; |
| 89 | - | |
| 90 | + | |
| 90 | 91 | private EntityManagerFactory emf; |
| 91 | - | |
| 92 | + | |
| 92 | 93 | private Map<String, EntityManager> cache; |
| 93 | - | |
| 94 | + | |
| 94 | 95 | private EntityManager em; |
| 95 | 96 | |
| 96 | 97 | @Before |
| ... | ... | @@ -105,7 +106,7 @@ public class EntityManagerProducerTest { |
| 105 | 106 | replay(emf, Persistence.class); |
| 106 | 107 | |
| 107 | 108 | producer = new EntityManagerProducer(); |
| 108 | - bundle = new ResourceBundleProducer().create("demoiselle-jpa-bundle"); | |
| 109 | + bundle = new ResourceBundleProducer().create("demoiselle-jpa-bundle", Locale.getDefault()); | |
| 109 | 110 | logger = createMock(Logger.class); |
| 110 | 111 | |
| 111 | 112 | setInternalState(producer, ResourceBundle.class, bundle); |
| ... | ... | @@ -126,14 +127,14 @@ public class EntityManagerProducerTest { |
| 126 | 127 | producer.close(); |
| 127 | 128 | verify(em); |
| 128 | 129 | } |
| 129 | - | |
| 130 | + | |
| 130 | 131 | @Test |
| 131 | 132 | public void testGetCache() { |
| 132 | 133 | cache = Collections.synchronizedMap(new HashMap<String, EntityManager>()); |
| 133 | 134 | setInternalState(producer, Map.class, cache); |
| 134 | 135 | Assert.assertEquals(cache, producer.getCache()); |
| 135 | 136 | } |
| 136 | - | |
| 137 | + | |
| 137 | 138 | @After |
| 138 | 139 | public void tearDown() { |
| 139 | 140 | producer = null; |
| ... | ... | @@ -166,16 +167,16 @@ public class EntityManagerProducerTest { |
| 166 | 167 | |
| 167 | 168 | @Test |
| 168 | 169 | public void testCreateWithPersistenceUnitNameFromPersistenceXML() { |
| 169 | - | |
| 170 | + | |
| 170 | 171 | Map<String, EntityManagerFactory> cache = Collections |
| 171 | - .synchronizedMap(new HashMap<String, EntityManagerFactory>()); | |
| 172 | - | |
| 172 | + .synchronizedMap(new HashMap<String, EntityManagerFactory>()); | |
| 173 | + | |
| 173 | 174 | cache.put("pu1", emf); |
| 174 | - | |
| 175 | + | |
| 175 | 176 | EntityManagerFactoryProducer entityManagerFactoryProducer = createMock(EntityManagerFactoryProducer.class); |
| 176 | - | |
| 177 | + | |
| 177 | 178 | expect(entityManagerFactoryProducer.getCache()).andReturn(cache); |
| 178 | - | |
| 179 | + | |
| 179 | 180 | expect(annotated.isAnnotationPresent(Name.class)).andReturn(false); |
| 180 | 181 | expect(ip.getAnnotated()).andReturn(annotated).anyTimes(); |
| 181 | 182 | expect(config.getPersistenceUnitName()).andReturn(null); |
| ... | ... | @@ -183,7 +184,7 @@ public class EntityManagerProducerTest { |
| 183 | 184 | replay(annotated, ip, config, entityManagerFactoryProducer); |
| 184 | 185 | |
| 185 | 186 | setInternalState(producer, EntityManagerFactoryProducer.class, entityManagerFactoryProducer); |
| 186 | - | |
| 187 | + | |
| 187 | 188 | EntityManagerProxy entityManagerProxy = (EntityManagerProxy) producer.create(ip, config); |
| 188 | 189 | assertNotNull(entityManagerProxy); |
| 189 | 190 | } | ... | ... |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/template/AbstractEditPageBeanTest.java
| ... | ... | @@ -47,6 +47,8 @@ import static org.powermock.api.easymock.PowerMock.replayAll; |
| 47 | 47 | import static org.powermock.api.easymock.PowerMock.verifyAll; |
| 48 | 48 | import static org.powermock.reflect.Whitebox.setInternalState; |
| 49 | 49 | |
| 50 | +import java.util.Locale; | |
| 51 | + | |
| 50 | 52 | import javax.faces.component.UIViewRoot; |
| 51 | 53 | import javax.faces.context.FacesContext; |
| 52 | 54 | import javax.faces.convert.Converter; |
| ... | ... | @@ -70,7 +72,8 @@ import br.gov.frameworkdemoiselle.util.ResourceBundle; |
| 70 | 72 | import com.sun.faces.util.Util; |
| 71 | 73 | |
| 72 | 74 | @RunWith(PowerMockRunner.class) |
| 73 | -@PrepareForTest({ Parameter.class, Beans.class, Reflections.class, Converter.class, FacesContext.class, Util.class, Faces.class }) | |
| 75 | +@PrepareForTest({ Parameter.class, Beans.class, Reflections.class, Converter.class, FacesContext.class, Util.class, | |
| 76 | + Faces.class }) | |
| 74 | 77 | public class AbstractEditPageBeanTest { |
| 75 | 78 | |
| 76 | 79 | private AbstractEditPageBean<Contact, Object> pageBean; |
| ... | ... | @@ -79,7 +82,7 @@ public class AbstractEditPageBeanTest { |
| 79 | 82 | |
| 80 | 83 | @Before |
| 81 | 84 | public void before() { |
| 82 | - bundle = new ResourceBundleProducer().create("demoiselle-jsf-bundle"); | |
| 85 | + bundle = new ResourceBundleProducer().create("demoiselle-jsf-bundle", Locale.getDefault()); | |
| 83 | 86 | |
| 84 | 87 | pageBean = new AbstractEditPageBean<Contact, Object>() { |
| 85 | 88 | |
| ... | ... | @@ -242,23 +245,23 @@ public class AbstractEditPageBeanTest { |
| 242 | 245 | @SuppressWarnings("unchecked") |
| 243 | 246 | public void testGetLongId() { |
| 244 | 247 | mockStatic(Faces.class); |
| 245 | - | |
| 248 | + | |
| 246 | 249 | FacesContext facesContext = createMock(FacesContext.class); |
| 247 | 250 | Converter converter = createMock(Converter.class); |
| 248 | 251 | UIViewRoot viewRoot = createMock(UIViewRoot.class); |
| 249 | 252 | Parameter<String> parameter = createMock(Parameter.class); |
| 250 | - | |
| 253 | + | |
| 251 | 254 | setInternalState(pageBean, "facesContext", facesContext); |
| 252 | 255 | setInternalState(pageBean, "id", parameter); |
| 253 | 256 | setInternalState(pageBean, "idClass", Long.class, AbstractEditPageBean.class); |
| 254 | - | |
| 257 | + | |
| 255 | 258 | String value = "1"; |
| 256 | - | |
| 259 | + | |
| 257 | 260 | expect(parameter.getValue()).andReturn(value); |
| 258 | 261 | expect(facesContext.getViewRoot()).andReturn(viewRoot); |
| 259 | 262 | expect(Faces.getConverter(Long.class)).andReturn(converter); |
| 260 | 263 | expect(converter.getAsObject(facesContext, viewRoot, value)).andReturn(Long.valueOf(value)); |
| 261 | - | |
| 264 | + | |
| 262 | 265 | replayAll(); |
| 263 | 266 | assertEquals(Long.valueOf(value), pageBean.getId()); |
| 264 | 267 | verifyAll(); |
| ... | ... | @@ -276,7 +279,8 @@ public class AbstractEditPageBeanTest { |
| 276 | 279 | try { |
| 277 | 280 | pageBean.getId(); |
| 278 | 281 | } catch (DemoiselleException cause) { |
| 279 | - assertEquals(bundle.getString("id-converter-not-found", Contact.class.getCanonicalName()), cause.getMessage()); | |
| 282 | + assertEquals(bundle.getString("id-converter-not-found", Contact.class.getCanonicalName()), | |
| 283 | + cause.getMessage()); | |
| 280 | 284 | } |
| 281 | 285 | |
| 282 | 286 | verifyAll(); | ... | ... |