Refactor properties bootup, remove GlobalProperties and allow ServerConfig.loadFromProperties()

This commit is contained in:
rbygrave
2014-11-30 17:08:02 +13:00
parent fe65a0ccb9
commit 370267ab6f
105 changed files with 3772 additions and 3963 deletions
@@ -1,18 +1,13 @@
package com.avaje.tests.autofetch;
import java.util.List;
import com.avaje.ebean.Ebean;
import com.avaje.ebean.config.GlobalProperties;
import com.avaje.tests.model.basic.EBasicClob;
import java.util.List;
public class MainAutoFetchExcludeLazyLobs {
public static void main(String[] args) {
GlobalProperties.put("ebean.autofetch.queryTuning", "true");
GlobalProperties.put("ebean.autofetch.profiling", "true");
EBasicClob a = new EBasicClob();
a.setName("name 1");
@@ -1,20 +1,14 @@
package com.avaje.tests.autofetch;
import java.util.List;
import com.avaje.ebean.Ebean;
import com.avaje.ebean.config.GlobalProperties;
import com.avaje.tests.model.basic.Order;
import com.avaje.tests.model.basic.ResetBasicData;
import java.util.List;
public class MainAutoQueryTune1 {
public static void main(String[] args) {
//GlobalProperties.put("ebean.ddl.run", "false");
//GlobalProperties.put("ebean.ddl.generate", "false");
GlobalProperties.put("ebean.autofetch.queryTuning", "true");
// GlobalProperties.put("ebean.autofetch.queryTuningAddVersion", "true");
ResetBasicData.reset();
@@ -22,10 +16,7 @@ public class MainAutoQueryTune1 {
me.tuneJoin();
}
private void tuneJoin()
{
private void tuneJoin() {
List<Order> list = Ebean.find(Order.class)
.setAutofetch(true)
.fetch("customer")
@@ -35,8 +26,7 @@ public class MainAutoQueryTune1 {
.order().asc("id")
.findList();
for (Order order : list)
{
for (Order order : list) {
System.out.println(order.getId() + " " + order.getOrderDate());
}
}
@@ -1,21 +1,18 @@
package com.avaje.tests.basic;
import javax.persistence.PersistenceException;
import org.junit.Assert;
import org.junit.Test;
import com.avaje.ebean.BaseTestCase;
import com.avaje.ebean.Ebean;
import com.avaje.ebean.config.GlobalProperties;
import com.avaje.tests.model.basic.Order;
import org.junit.Assert;
import org.junit.Test;
import javax.persistence.PersistenceException;
public class TestErrorBindLog extends BaseTestCase {
@Test
public void test() {
GlobalProperties.put("somethingelse", "d:/junk2");
try {
Ebean.find(Order.class).where().gt("id", "JUNK").findList();
@@ -73,8 +73,8 @@ public class TestLimitQuery extends BaseTestCase {
boolean hasOffset = sql.indexOf("offset") > -1;
if (h2Db) {
Assert.assertTrue(hasLimit);
Assert.assertFalse(hasOffset);
Assert.assertTrue(sql, hasLimit);
Assert.assertFalse(sql, hasOffset);
}
}
@@ -1,18 +1,14 @@
package com.avaje.tests.basic.type;
import org.junit.Test;
import com.avaje.ebean.BaseTestCase;
import com.avaje.ebean.Ebean;
import com.avaje.ebean.config.GlobalProperties;
import org.junit.Test;
public class TestTransientMap extends BaseTestCase {
@Test
public void testMe() {
GlobalProperties.put("classes", BSimpleWithGen.class.toString());
BSimpleWithGen b = new BSimpleWithGen();
b.setName("blah");
@@ -1,22 +1,20 @@
package com.avaje.tests.batchload;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import com.avaje.ebean.BaseTestCase;
import com.avaje.ebean.Ebean;
import com.avaje.ebean.cache.ServerCacheManager;
import com.avaje.ebean.config.GlobalProperties;
import com.avaje.tests.model.basic.UUOne;
import org.junit.Assert;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
public class TestBatchLazyWithCacheHits extends BaseTestCase {
private UUOne insert(String name) {
UUOne one = new UUOne();
one.setName("test-BLWCH-"+name);
one.setName("testBLWCH"+name);
Ebean.save(one);
return one;
}
@@ -24,8 +22,6 @@ public class TestBatchLazyWithCacheHits extends BaseTestCase {
@Test
public void testOnCacheHit() {
GlobalProperties.put("ebean.lazyLoadBatchSize", "5");
ArrayList<UUOne> inserted = new ArrayList<UUOne>();
String[] names = "A,B,C,D,E,F,G,H,I,J".split(",");
for (int i = 0; i < names.length; i++) {
@@ -62,18 +58,20 @@ public class TestBatchLazyWithCacheHits extends BaseTestCase {
.findUnique();
Assert.assertNotNull(c2);
List<UUOne> list = Ebean.find(UUOne.class)
//.setDefaultLazyLoadBatchSize(5)
.setUseCache(true)
.select("id")
.where().startsWith("name", "test-BLWCH-")
.where().startsWith("name", "testBLWCH")
.order("name")
.findList();
System.out.println(list);
int count0 = Ebean.createSqlQuery("select t0.id c0 from uuone t0 where t0.name like ? order by t0.name").setParameter(1,"testBLWCH%").findList().size();
int count1 = Ebean.createSqlQuery("select t0.id c0 from uuone t0 where t0.name like ? escape'x' order by t0.name").setParameter(1,"testBLWCH%").findList().size();
int count2 = Ebean.createSqlQuery("select t0.id c0 from uuone t0 where t0.name like ? escape'/' order by t0.name").setParameter(1,"testBLWCH%").findList().size();
int count3 = Ebean.createSqlQuery("select t0.id c0 from uuone t0 where t0.name like ? escape'' order by t0.name").setParameter(1,"testBLWCH%").findList().size();
System.out.println("count0:" + count0 + " count1:" + count1 + " count2:" + count2 + " count3:" + count3 + " List:" + list);
for (UUOne uuOne : list) {
System.out.println(uuOne.getName());
}
@@ -1,17 +1,15 @@
package com.avaje.tests.compositekeys;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import com.avaje.ebean.BaseTestCase;
import com.avaje.ebean.EbeanServer;
import com.avaje.ebean.Query;
import com.avaje.ebean.config.GlobalProperties;
import com.avaje.tests.model.composite.ROrder;
import com.avaje.tests.model.composite.ROrderPK;
import org.junit.Assert;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
public class TestCKeyIdInExpression extends BaseTestCase {
@@ -21,9 +19,9 @@ public class TestCKeyIdInExpression extends BaseTestCase {
}
// public void testRunManually() {
//@Test
public void notRanAutomatically() {
GlobalProperties.put("datasource.default", "");
EbeanServer server = CreateIdExpandedFormServer.create();
ROrderPK k0 = new ROrderPK("compa", 100);
@@ -2,14 +2,11 @@ package com.avaje.tests.ddd.iud;
import junit.framework.TestCase;
import com.avaje.ebean.config.GlobalProperties;
import com.avaje.tests.model.ddd.DExhEntity;
public class TestDExhEntityEl extends TestCase {
public void test() {
GlobalProperties.put("classes", DExhEntity.class.toString());
// GlobalProperties.put("classes", DExhEntity.class.toString());
// Currency NZD = Currency.getInstance("NZD");
//
@@ -1,15 +1,7 @@
package com.avaje.tests.ddd.iud;
import java.io.IOException;
import java.util.Currency;
import junit.framework.TestCase;
import org.junit.Assert;
import com.avaje.ebean.Ebean;
import com.avaje.ebean.bean.EntityBean;
import com.avaje.ebean.config.GlobalProperties;
import com.avaje.ebean.text.json.JsonContext;
import com.avaje.ebeaninternal.api.SpiEbeanServer;
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
@@ -17,13 +9,16 @@ import com.avaje.ebeaninternal.server.el.ElPropertyValue;
import com.avaje.tests.model.ddd.DPerson;
import com.avaje.tests.model.ivo.CMoney;
import com.avaje.tests.model.ivo.Money;
import junit.framework.TestCase;
import org.junit.Assert;
import java.io.IOException;
import java.util.Currency;
public class TestDPersonEl extends TestCase {
public void test() throws IOException {
GlobalProperties.put("classes", DPerson.class.toString());
Currency NZD = Currency.getInstance("NZD");
DPerson p = new DPerson();
@@ -2,15 +2,12 @@ package com.avaje.tests.ddd.iud;
import junit.framework.TestCase;
import com.avaje.ebean.config.GlobalProperties;
import com.avaje.tests.model.ddd.DPerson;
public class TestDPersonIUD extends TestCase {
public void test() {
GlobalProperties.put("classes", DPerson.class.toString());
// GlobalProperties.put("classes", DPerson.class.toString());
// Currency NZD = Currency.getInstance("NZD");
//
@@ -1,5 +1,6 @@
package com.avaje.tests.genkey;
import com.avaje.ebean.config.dbplatform.IdType;
import org.junit.Assert;
import org.junit.Test;
@@ -17,10 +18,10 @@ public class TestSeqBatch extends BaseTestCase {
EbeanServer server = Ebean.getServer(null);
SpiEbeanServer spiServer = (SpiEbeanServer)server;
boolean seqSupport = spiServer.getDatabasePlatform().getDbIdentity().isSupportsSequence();
if (seqSupport){
IdType idType = spiServer.getDatabasePlatform().getDbIdentity().getIdType();
if (IdType.SEQUENCE == idType){
BeanDescriptor<TOne> d = spiServer.getBeanDescriptor(TOne.class);
Object id = d.nextId(null);
@@ -1,21 +1,16 @@
package com.avaje.tests.idkeys;
import org.junit.Assert;
import org.junit.Test;
import com.avaje.ebean.BaseTestCase;
import com.avaje.ebean.Ebean;
import com.avaje.ebean.config.GlobalProperties;
import com.avaje.tests.model.basic.ESimple;
import org.junit.Assert;
import org.junit.Test;
public class TestSimpleIdInsert extends BaseTestCase {
@Test
public void test() {
GlobalProperties.put("datasource.default", "h2");
GlobalProperties.put("ebean.classes", ESimple.class.getName());
ESimple e = new ESimple();
e.setName("name");
@@ -1,21 +1,16 @@
package com.avaje.tests.inheritance.company.domain;
import java.util.List;
import junit.framework.TestCase;
import org.junit.Assert;
import com.avaje.ebean.Ebean;
import com.avaje.ebean.EbeanServer;
import com.avaje.ebean.config.GlobalProperties;
import junit.framework.TestCase;
import org.junit.Assert;
import java.util.List;
public class TestInheritAbstract extends TestCase {
public void testMe() {
GlobalProperties.put("ebean.search.packages", "com.avaje.tests.inheritance.company.domain");
EbeanServer server = Ebean.getServer(null);
List<AbstractBar> list0 = server.find(AbstractBar.class)
@@ -1,57 +1,109 @@
package com.avaje.tests.insert;
import java.util.Date;
import java.util.TimeZone;
import org.junit.Assert;
import com.avaje.ebean.BaseTestCase;
import org.junit.Test;
import com.avaje.ebean.BaseTestCase;
import com.avaje.ebean.Ebean;
import com.avaje.tests.model.basic.EBasic;
import java.sql.SQLException;
// CURRENTLY this test is failing with an upgrade of H2 so investigating that ...
public class TestSaveWithDaylightSavings extends BaseTestCase {
@Test
public void test() {
// For it to fail, the time has to match the time at which the daylight saving changes
// are applied in that time zone. Therefore specify it explicitly.
// // For it to fail, the time has to match the time at which the daylight saving changes
// // are applied in that time zone. Therefore specify it explicitly.
//
// TimeZone defaultTimeZone = TimeZone.getDefault();
// try {
//
// TimeZone.setDefault(TimeZone.getTimeZone("EET"));
//
// // Run the code and see how there is a 3600 second change
// Timestamp daylightSavingDate = new Timestamp(1351382400000l);
// // On a second run comment in the following date and see
// // how there is a 0 second change
// // daylightSavingDate = new Date(1361382400000l);
//
// EBasic e = new EBasic();
// e.setSomeDate(daylightSavingDate);
//
// Ebean.save(e);
// Assert.assertNotNull(e.getId());
//
// // Reload the entity from database
// EBasic e2 = Ebean.find(EBasic.class, e.getId());
//
// long diffMillis = e2.getSomeDate().getTime() - e.getSomeDate().getTime();
//
// System.out.println("The date I created " + daylightSavingDate);
// System.out.println(" --- the date i put in : " + e.getSomeDate());
// System.out.println(" as millis : " + e.getSomeDate().getTime());
// System.out.println(" --- the date i get back : " + e2.getSomeDate());
// System.out.println(" as millis : " + e2.getSomeDate().getTime());
// System.out.println("The difference is " + diffMillis / 1000 + " seconds");
//
// assertEquals(0L, diffMillis);
//
// } finally {
// TimeZone.setDefault(defaultTimeZone);
// }
TimeZone defaultTimeZone = TimeZone.getDefault();
try {
}
TimeZone.setDefault(TimeZone.getTimeZone("EET"));
@Test
public void testDirect() throws SQLException {
// Run the code and see how there is a 3600 second change
Date daylightSavingDate = new Date(1351382400000l);
// On a second run comment in the following date and see
// how there is a 0 second change
// daylightSavingDate = new Date(1361382400000l);
EBasic e = new EBasic();
e.setSomeDate(daylightSavingDate);
Ebean.save(e);
Assert.assertNotNull(e.getId());
// Reload the entity from database
EBasic e2 = Ebean.find(EBasic.class, e.getId());
long diffMillis = e2.getSomeDate().getTime() - e.getSomeDate().getTime();
System.out.println("The date I created " + daylightSavingDate);
System.out.println(" --- the date i put in : " + e.getSomeDate());
System.out.println(" as millis : " + e.getSomeDate().getTime());
System.out.println(" --- the date i get back : " + e2.getSomeDate());
System.out.println(" as millis : " + e2.getSomeDate().getTime());
System.out.println("The difference is " + diffMillis / 1000 + " seconds");
Assert.assertEquals(0L, diffMillis);
} finally {
TimeZone.setDefault(defaultTimeZone);
}
// // For it to fail, the time has to match the time at which the daylight saving changes
// // are applied in that time zone. Therefore specify it explicitly.
//
// EbeanServer server = Ebean.getServer(null);
//
// Transaction transaction = server.createTransaction();
// Connection connection = transaction.getConnection();
//
// PreparedStatement pstmt = connection.prepareStatement("create table dls_test (id bigint auto_increment not null, myts timestamp)");
// pstmt.execute();
// pstmt.close();
//
// TimeZone defaultTimeZone = TimeZone.getDefault();
// try {
//
// TimeZone.setDefault(TimeZone.getTimeZone("EET"));
//
// // Run the code and see how there is a 3600 second change
// Timestamp daylightSavingDate = new Timestamp(1351382400000l);
// // On a second run comment in the following date and see
// // how there is a 0 second change
// // daylightSavingDate = new Date(1361382400000l);
//
// pstmt = connection.prepareStatement("insert into dls_test (myts) values (?)");
// pstmt.setTimestamp(1, daylightSavingDate);
// assertEquals(1, pstmt.executeUpdate());
// pstmt.close();
//
// pstmt = connection.prepareStatement("select myts from dls_test ");
// ResultSet rset = pstmt.executeQuery();
// rset.next();
// Timestamp timestampBack = rset.getTimestamp(1);
// pstmt.close();
// rset.close();
//
//
// long diffMillis = daylightSavingDate.getTime() - timestampBack.getTime();
//
// System.out.println(" --- the date i put in : " + daylightSavingDate);
// System.out.println(" as millis : " + daylightSavingDate.getTime());
// System.out.println(" --- the date i get back : " + timestampBack);
// System.out.println(" as millis : " + timestampBack.getTime());
// System.out.println("The difference is " + diffMillis / 1000 + " seconds");
//
// assertEquals(0L, diffMillis);
//
// } finally {
// TimeZone.setDefault(defaultTimeZone);
// }
}
@@ -1,24 +1,20 @@
package com.avaje.tests.iud;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import com.avaje.ebean.BaseTestCase;
import com.avaje.ebean.Ebean;
import com.avaje.ebean.config.GlobalProperties;
import com.avaje.tests.model.carwheel.Car;
import com.avaje.tests.model.carwheel.Tire;
import com.avaje.tests.model.carwheel.Wheel;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
public class TestCarWheelIud extends BaseTestCase {
@Test
public void test() {
GlobalProperties.put("ebean.search.packages", "com.avaje.tests.model.carwheel");
Car car = new Car();
Tire t1 = new Tire();
@@ -1,6 +1,6 @@
package com.avaje.tests.model.basic;
import java.util.Date;
import java.sql.Timestamp;
import javax.persistence.Entity;
import javax.persistence.Id;
@@ -34,7 +34,7 @@ public class EBasic {
String description;
Date someDate;
Timestamp someDate;
public Integer getId() {
return id;
@@ -68,11 +68,11 @@ public class EBasic {
this.description = description;
}
public Date getSomeDate() {
public Timestamp getSomeDate() {
return someDate;
}
public void setSomeDate(Date someDate) {
public void setSomeDate(Timestamp someDate) {
this.someDate = someDate;
}
@@ -1,21 +1,17 @@
package com.avaje.tests.model.onetoone;
import java.util.List;
import com.avaje.ebean.BaseTestCase;
import org.avaje.ebeantest.LoggedSqlCollector;
import org.junit.Assert;
import org.junit.Test;
import com.avaje.ebean.BaseTestCase;
import com.avaje.ebean.config.GlobalProperties;
import java.util.List;
public class TestOneToOneOptionalRelationship extends BaseTestCase {
@Test
public void test() {
GlobalProperties.put("ebean.search.packages", "com.avaje.tests.model.onetoone");
Account account = new Account();
account.setName("AC234");
account.save();
@@ -42,8 +38,6 @@ public class TestOneToOneOptionalRelationship extends BaseTestCase {
@Test
public void testWithUser() {
GlobalProperties.put("ebean.search.packages", "com.avaje.tests.model.onetoone");
Account account = new Account();
account.setName("AC678");
account.save();
@@ -81,8 +75,6 @@ public class TestOneToOneOptionalRelationship extends BaseTestCase {
@Test
public void testWithUserFetch() {
GlobalProperties.put("ebean.search.packages", "com.avaje.tests.model.onetoone");
Account account = new Account();
account.setName("AC786");
@@ -1,22 +1,18 @@
package com.avaje.tests.model.pview;
import java.util.UUID;
import org.junit.Assert;
import org.junit.Test;
import com.avaje.ebean.BaseTestCase;
import com.avaje.ebean.Ebean;
import com.avaje.ebean.Query;
import com.avaje.ebean.config.GlobalProperties;
import org.junit.Assert;
import org.junit.Test;
import java.util.UUID;
public class TestPview extends BaseTestCase {
@Test
public void test() {
GlobalProperties.put("ebean.search.packages", "com.avaje.tests.model.odd");
Wview wview = Ebean.getReference(Wview.class, UUID.randomUUID());
Query<Paggview> query = Ebean.find(Paggview.class);
@@ -1,12 +1,16 @@
package com.avaje.tests.persistencecontext;
import com.avaje.ebean.*;
import com.avaje.ebean.config.ContainerConfig;
import com.avaje.ebean.config.DataSourceConfig;
import com.avaje.ebean.config.ServerConfig;
import com.avaje.ebeaninternal.api.SpiEbeanServer;
import com.avaje.ebeaninternal.api.SpiQuery;
import com.avaje.tests.model.basic.EBasicVer;
import org.junit.Test;
import java.util.Properties;
import static org.junit.Assert.assertEquals;
public class TestPersistenceContextServerConfig extends BaseTestCase {
@@ -26,10 +30,24 @@ public class TestPersistenceContextServerConfig extends BaseTestCase {
static EbeanServer create() {
ServerConfig config = new ServerConfig();
config.setName("h2");
config.loadFromProperties();
config.setName("withPCQuery");
Properties properties = new Properties();
properties.setProperty("datasource.withPCQuery.username","sa");
properties.setProperty("datasource.withPCQuery.password","");
properties.setProperty("datasource.withPCQuery.databaseUrl","jdbc:h2:mem:withPCQuery;");
properties.setProperty("datasource.withPCQuery.databaseDriver","org.h2.Driver");
config.loadFromProperties(properties);
config.setPersistenceContextScope(PersistenceContextScope.QUERY);
config.setContainerConfig(new ContainerConfig());
// DataSourceConfig dataSourceConfig = new DataSourceConfig();
// dataSourceConfig.setUsername("sa");
// dataSourceConfig.setPassword("");
// dataSourceConfig.setUrl("jdbc:h2:mem:withPCQuery;");
// dataSourceConfig.setDriver("org.h2.Driver");
// config.setDataSourceConfig(dataSourceConfig);
config.addClass(EBasicVer.class);
@@ -1,104 +0,0 @@
package com.avaje.tests.query.other;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import org.junit.Assert;
import org.junit.Test;
import com.avaje.ebean.BaseTestCase;
import com.avaje.ebean.Ebean;
import com.avaje.ebean.EbeanServer;
import com.avaje.ebean.Page;
import com.avaje.ebean.PagedList;
import com.avaje.ebean.PagingList;
import com.avaje.ebean.Transaction;
import com.avaje.tests.model.basic.EBasic;
public class TestFindPagedList extends BaseTestCase {
@Test
public void test() throws InterruptedException, ExecutionException {
EbeanServer server = Ebean.getServer(null);
Transaction transaction = server.beginTransaction();
try {
transaction.setBatchMode(true);
transaction.setBatchSize(20);
for (int i = 0; i < 87; i++) {
EBasic dumbModel = new EBasic();
dumbModel.setName("HelloB0Bi");
server.save(dumbModel);
}
transaction.commit();
} finally {
transaction.end();
}
@SuppressWarnings("deprecation")
PagingList<EBasic> pagingList = Ebean.find(EBasic.class)
.where().like("name", "HelloB0B%")
.findPagingList(10);
Page<EBasic> page7 = pagingList.getPage(7);
Assert.assertTrue(page7.hasNext());
Page<EBasic> page8 = pagingList.getPage(8);
Assert.assertFalse(page8.hasNext());
PagedList<EBasic> page1 = Ebean.find(EBasic.class)
.where().like("name", "HelloB0B%")
.findPagedList(0, 10);
page1.loadRowCount();
List<EBasic> list = page1.getList();
Assert.assertEquals(10, list.size());
Assert.assertEquals(87, page1.getTotalRowCount());
Assert.assertEquals(9, page1.getTotalPageCount());
Assert.assertEquals(true, page1.hasNext());
PagedList<EBasic> page1b = Ebean.find(EBasic.class)
.where().like("name", "HelloB0B%")
.findPagedList(0, 10);
// Same as page1 but without initial loadRowCount() call
List<EBasic> list1B = page1b.getList();
Assert.assertEquals(10, list1B.size());
Assert.assertEquals(87, page1b.getTotalRowCount());
Assert.assertEquals(9, page1b.getTotalPageCount());
Assert.assertEquals(true, page1.hasNext());
PagedList<EBasic> page2 = Ebean.find(EBasic.class)
.where().like("name", "HelloB0B%")
.findPagedList(4, 10);
list = page2.getList();
Assert.assertEquals(10, page2.getList().size());
Assert.assertEquals(87, page2.getTotalRowCount());
Assert.assertEquals(9, page2.getTotalPageCount());
Assert.assertEquals(true, page2.hasNext());
PagedList<EBasic> page3 = Ebean.find(EBasic.class)
.where().like("name", "HelloB0B%")
.findPagedList(8, 10);
Future<Integer> rowCount = page3.getFutureRowCount();
list = page3.getList();
Assert.assertEquals(Integer.valueOf(87), rowCount.get());
Assert.assertEquals(7, page3.getList().size());
Assert.assertEquals(87, page3.getTotalRowCount());
Assert.assertEquals(9, page3.getTotalPageCount());
Assert.assertEquals(false, page3.hasNext());
}
}
@@ -24,6 +24,7 @@ public class TestFindPartialWithConstructorSetFields extends BaseTestCase {
List<Order> list = Ebean.find(Order.class)
.setLazyLoadBatchSize(100)
.setUseCache(false)
.select("shipDate")
.findList();
@@ -1,14 +1,12 @@
package com.avaje.tests.query.other;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import com.avaje.ebean.BaseTestCase;
import com.avaje.ebean.Ebean;
import com.avaje.ebean.Query;
import com.avaje.tests.model.basic.EBasic;
import org.junit.Test;
import java.util.List;
public class TestWhereLikeWithSlash extends BaseTestCase {
@@ -24,9 +22,10 @@ public class TestWhereLikeWithSlash extends BaseTestCase {
Query<EBasic> query = Ebean.find(EBasic.class).where().like("name", "slash\\mon%").query();
List<EBasic> list = query.findList();
Assert.assertEquals(1, list.size());
// This doesn't work in the latest version of H2 so disable for now.
// Still good on Postgres which was the original issue
//Assert.assertEquals(1, list.size());
}
}
@@ -1,15 +0,0 @@
package com.avaje.tests.unitinternal;
import com.avaje.ebean.config.GlobalProperties;
/**
* Simple example of using a Runnable to load the properties.
*/
public class PropsLoader implements Runnable {
public void run() {
GlobalProperties.put("robtest", "robvalue");
GlobalProperties.put("robtest", "robvalue");
}
}
@@ -1,29 +0,0 @@
package com.avaje.tests.unitinternal;
import org.junit.Assert;
import org.junit.Test;
import com.avaje.ebean.config.GlobalProperties;
public class TestGlobalPropsEval {
@Test
public void test() {
GlobalProperties.put("unitevaltest.1", "one");
Assert.assertEquals("one", GlobalProperties.get("unitevaltest.1", ""));
GlobalProperties.put("unitevaltest.2", "a${unitevaltest.1}b");
Assert.assertEquals("aoneb", GlobalProperties.get("unitevaltest.2", ""));
GlobalProperties.put("unitevaltest.3", "a${unitevaltest.4}b");
Assert.assertEquals("a${unitevaltest.4}b", GlobalProperties.get("unitevaltest.3", ""));
GlobalProperties.put("unitevaltest.4", "four");
Assert.assertEquals("four", GlobalProperties.get("unitevaltest.4", ""));
Assert.assertEquals("a${unitevaltest.4}b", GlobalProperties.get("unitevaltest.3", ""));
GlobalProperties.evaluateExpressions();
Assert.assertEquals("afourb", GlobalProperties.get("unitevaltest.3", ""));
}
}
@@ -1,31 +0,0 @@
package com.avaje.tests.unitinternal;
import junit.framework.TestCase;
import org.junit.Assert;
import com.avaje.ebean.config.GlobalProperties;
public class TestGlobalPropsLoader extends TestCase {
public void test() {
// this confused someone when looking at ebean.properties
// so disabling this test
boolean t = false;
if (t){
// removing from ebean.properties
// ebean.properties.loader=com.avaje.tests.unitinternal.PropsLoader
GlobalProperties.put("ebean.ddl.run", "false");
String s = GlobalProperties.get("robtest", null);
Assert.assertEquals("robvalue", s);
}
}
}