use of org.broadleafcommerce.common.config.domain.SystemPropertyImpl in project BroadleafCommerce by BroadleafCommerce.
the class SystemPropertiesTest method testOverridesPropertyFiles.
@Test
@Transactional
public void testOverridesPropertyFiles() {
String propertyFileResolved = env.getProperty("property.file.override.test", String.class);
Assert.assertEquals(propertyFileResolved, "propertyfile");
clearSystemPropertiesCache();
SystemProperty prop = new SystemPropertyImpl();
prop.setName("property.file.override.test");
prop.setValue("testngtest");
prop = propsDao.saveSystemProperty(prop);
String resolvedProperty = env.getProperty(prop.getName(), String.class);
Assert.assertEquals(resolvedProperty, prop.getValue());
propsDao.deleteSystemProperty(prop);
clearSystemPropertiesCache();
String fromPropertiesFile = propsSvc.resolveSystemProperty("property.file.override.test");
Assert.assertEquals(fromPropertiesFile, "propertyfile");
}
use of org.broadleafcommerce.common.config.domain.SystemPropertyImpl in project BroadleafCommerce by BroadleafCommerce.
the class SystemPropertiesTest method testEnvironmentResolvedFromDatabase.
@Test
@Transactional
public void testEnvironmentResolvedFromDatabase() {
SystemProperty prop = new SystemPropertyImpl();
prop.setName("test.property.with.environment");
prop.setValue("database");
propsDao.saveSystemProperty(prop);
String resolvedProperty = env.getProperty(prop.getName(), String.class);
Assert.assertEquals(resolvedProperty, prop.getValue());
}
use of org.broadleafcommerce.common.config.domain.SystemPropertyImpl in project BroadleafCommerce by BroadleafCommerce.
the class SystemPropertiesDaoImpl method readAllSystemProperties.
@Override
public List<SystemProperty> readAllSystemProperties() {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<SystemProperty> criteria = builder.createQuery(SystemProperty.class);
Root<SystemPropertyImpl> handler = criteria.from(SystemPropertyImpl.class);
criteria.select(handler);
List<Predicate> restrictions = new ArrayList<Predicate>();
List<Order> sorts = new ArrayList<Order>();
try {
if (queryExtensionManager != null) {
queryExtensionManager.getProxy().setup(SystemPropertyImpl.class, null);
queryExtensionManager.getProxy().refineRetrieve(SystemPropertyImpl.class, null, builder, criteria, handler, restrictions);
queryExtensionManager.getProxy().refineOrder(SystemPropertyImpl.class, null, builder, criteria, handler, sorts);
}
criteria.where(restrictions.toArray(new Predicate[restrictions.size()]));
return em.createQuery(criteria).getResultList();
} catch (NoResultException e) {
LOG.error(e);
return new ArrayList<SystemProperty>();
} finally {
if (queryExtensionManager != null) {
queryExtensionManager.getProxy().breakdown(SystemPropertyImpl.class, null);
}
}
}
Aggregations