Search in sources :

Example 6 with ClasspathResource

use of org.apache.tapestry5.ioc.internal.util.ClasspathResource in project tapestry-5 by apache.

the class EntityManagerSourceImplTest method create.

private EntityManagerSourceImpl create(final String persistenceUnitFile) {
    PersistenceUnitConfigurer configurer = new PersistenceUnitConfigurer() {

        @Override
        @SuppressWarnings({ "unchecked", "rawtypes" })
        public void configure(TapestryPersistenceUnitInfo unitInfo) {
            Map properties = new HashMap();
            properties.put("MYKEY", "MYVALUE");
            unitInfo.transactionType(PersistenceUnitTransactionType.RESOURCE_LOCAL).persistenceProviderClassName("org.eclipse.persistence.jpa.PersistenceProvider").excludeUnlistedClasses(true).addProperty("javax.persistence.jdbc.user", "sa").addProperty("javax.persistence.jdbc.driver", "org.h2.Driver").addProperty("javax.persistence.jdbc.url", "jdbc:h2:mem:test").setEntityManagerProperties(properties);
        }
    };
    Map<String, PersistenceUnitConfigurer> configurerMap = CollectionFactory.<String, PersistenceUnitConfigurer>newMap();
    configurerMap.put("defaultpropertytest", configurer);
    EntityManagerSourceImpl emSource = new EntityManagerSourceImpl(LoggerFactory.getLogger(EntityManagerSourceImplTest.class), new ClasspathResource(persistenceUnitFile), null, configurerMap);
    return emSource;
}
Also used : ClasspathResource(org.apache.tapestry5.ioc.internal.util.ClasspathResource) HashMap(java.util.HashMap) PersistenceUnitConfigurer(org.apache.tapestry5.jpa.PersistenceUnitConfigurer) Map(java.util.Map) HashMap(java.util.HashMap) TapestryPersistenceUnitInfo(org.apache.tapestry5.jpa.TapestryPersistenceUnitInfo)

Example 7 with ClasspathResource

use of org.apache.tapestry5.ioc.internal.util.ClasspathResource in project tapestry-5 by apache.

the class PropertiesFileParserImplTest method read_utf.

@Test
public void read_utf() throws Exception {
    Resource utf8 = new ClasspathResource("org/apache/tapestry5/internal/services/messages/utf8.properties");
    PropertiesFileParser parser = getService(PropertiesFileParser.class);
    Map<String, String> properties = parser.parsePropertiesFile(utf8);
    assertEquals(properties.get("tapestry"), "\u30bf\u30da\u30b9\u30c8\u30ea\u30fc");
    assertEquals(properties.get("version"), "5");
}
Also used : ClasspathResource(org.apache.tapestry5.ioc.internal.util.ClasspathResource) Resource(org.apache.tapestry5.commons.Resource) ClasspathResource(org.apache.tapestry5.ioc.internal.util.ClasspathResource) PropertiesFileParser(org.apache.tapestry5.services.messages.PropertiesFileParser) Test(org.testng.annotations.Test)

Aggregations

ClasspathResource (org.apache.tapestry5.ioc.internal.util.ClasspathResource)7 Test (org.testng.annotations.Test)6 Resource (org.apache.tapestry5.commons.Resource)4 ComponentModel (org.apache.tapestry5.model.ComponentModel)3 Messages (org.apache.tapestry5.commons.Messages)2 File (java.io.File)1 URLClassLoader (java.net.URLClassLoader)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Location (org.apache.tapestry5.commons.Location)1 InvalidationListener (org.apache.tapestry5.commons.services.InvalidationListener)1 ComponentTemplate (org.apache.tapestry5.internal.parser.ComponentTemplate)1 PropertiesFileParserImpl (org.apache.tapestry5.internal.services.messages.PropertiesFileParserImpl)1 LocationImpl (org.apache.tapestry5.ioc.internal.util.LocationImpl)1 PersistenceUnitConfigurer (org.apache.tapestry5.jpa.PersistenceUnitConfigurer)1 TapestryPersistenceUnitInfo (org.apache.tapestry5.jpa.TapestryPersistenceUnitInfo)1 ComponentMessagesSource (org.apache.tapestry5.services.messages.ComponentMessagesSource)1 PropertiesFileParser (org.apache.tapestry5.services.messages.PropertiesFileParser)1 ComponentResourceLocator (org.apache.tapestry5.services.pageload.ComponentResourceLocator)1