mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-22 15:10:02 +00:00
Merge branch 'master' into wip/EntityBeanIntercept-interface
This commit is contained in:
commit
d1b5400f2c
138 files changed
+1249
-2851
No files matched your search
+24
-13
@@ -6,8 +6,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class DefaultServerCacheConfigTest {
|
||||
|
||||
class DefaultServerCacheConfigTest {
|
||||
|
||||
private DefaultServerCacheConfig create(int maxSize, int maxIdleSecs, int maxSecsToLive, int trimFreq) {
|
||||
ServerCacheOptions options = new ServerCacheOptions();
|
||||
@@ -20,33 +19,45 @@ public class DefaultServerCacheConfigTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void trimFreq_halfIdle() {
|
||||
|
||||
void trimFreq_halfIdle() {
|
||||
assertEquals(create(10000,10,20, 0).determineTrimFrequency(), 4);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void trimFreq_halfIdle_withRounding() {
|
||||
|
||||
void trimFreq_halfIdle_withRounding() {
|
||||
assertEquals(create(10000,11,20, 0).determineTrimFrequency(), 4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void trimFreq_halfTTL() {
|
||||
|
||||
void trimFreq_halfTTL() {
|
||||
assertEquals(create(10000,0,20, 0).determineTrimFrequency(), 9);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void trimFreq_halfTTL_withRounding() {
|
||||
|
||||
void trimFreq_halfTTL_withRounding() {
|
||||
assertEquals(create(10000,0,21, 0).determineTrimFrequency(), 9);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void trimFreq_explicit() {
|
||||
|
||||
void trimFreq_explicit() {
|
||||
assertEquals(create(10000,10,20, 42).determineTrimFrequency(), 42);
|
||||
}
|
||||
|
||||
@Test
|
||||
void trimOnPut_default() {
|
||||
assertEquals(create(0,0,0, 0).determineTrimOnPut(), 1_000);
|
||||
}
|
||||
|
||||
@Test
|
||||
void trimOnPut_tenPercent() {
|
||||
assertEquals(create(10_000,0,0, 0).determineTrimOnPut(), 1_000);
|
||||
assertEquals(create(9_000,0,0, 0).determineTrimOnPut(), 900);
|
||||
assertEquals(create(100,0,0, 0).determineTrimOnPut(), 10);
|
||||
}
|
||||
|
||||
@Test
|
||||
void trimOnPut_roundDown() {
|
||||
assertEquals(create(9010,0,0, 0).determineTrimOnPut(), 901);
|
||||
assertEquals(create(9009,0,0, 0).determineTrimOnPut(), 900);
|
||||
}
|
||||
}
|
||||
Vendored
+6
-11
@@ -10,16 +10,14 @@ import org.junit.jupiter.api.Test;
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
public class DefaultServerCache_RunEvictionTest {
|
||||
|
||||
class DefaultServerCache_RunEvictionTest {
|
||||
|
||||
private DefaultServerCache createCache() {
|
||||
|
||||
ServerCacheOptions cacheOptions = new ServerCacheOptions();
|
||||
cacheOptions.setMaxSize(10000);
|
||||
cacheOptions.setMaxSize(300);
|
||||
cacheOptions.setMaxIdleSecs(1);
|
||||
cacheOptions.setMaxSecsToLive(2);
|
||||
cacheOptions.setTrimFrequency(1);
|
||||
cacheOptions.setTrimFrequency(5);
|
||||
|
||||
ServerCacheConfig con = new ServerCacheConfig(ServerCacheType.BEAN, "foo", "foo", cacheOptions, null, null);
|
||||
return new DefaultServerCache(new DefaultServerCacheConfig(con));
|
||||
@@ -35,8 +33,7 @@ public class DefaultServerCache_RunEvictionTest {
|
||||
|
||||
@Disabled("test takes long time")
|
||||
@Test
|
||||
public void runEvict() throws InterruptedException {
|
||||
|
||||
void runEvict() throws InterruptedException {
|
||||
for (int i = 0; i < 15; i++) {
|
||||
doStuff();
|
||||
cache.runEviction();
|
||||
@@ -47,12 +44,10 @@ public class DefaultServerCache_RunEvictionTest {
|
||||
}
|
||||
|
||||
private void doStuff() {
|
||||
|
||||
for (int i = 0; i < 500; i++) {
|
||||
for (int i = 0; i < 5000; i++) {
|
||||
String key = "" + random.nextInt(20000);
|
||||
|
||||
int mode = random.nextInt(10);
|
||||
if (mode < 8) {
|
||||
if (mode < 7) {
|
||||
cache.get(key);
|
||||
} else {
|
||||
cache.put(key, key + "-" + System.currentTimeMillis());
|
||||
|
||||
@@ -3,7 +3,7 @@ package io.ebeaninternal.server.core;
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
import io.ebean.datasource.DataSourceAlert;
|
||||
import io.ebean.datasource.DataSourceConfig;
|
||||
import io.ebean.datasource.pool.ConnectionPool;
|
||||
import io.ebean.datasource.DataSourcePool;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
@@ -137,7 +137,7 @@ public class InitDataSourceTest {
|
||||
config.getDataSourceConfig().setUrl("jdbc:h2:mem:dsTestOnline");
|
||||
config.getDataSourceConfig().setDriver("org.h2.Driver");
|
||||
InitDataSource.init(config);
|
||||
ConnectionPool pool = (ConnectionPool) config.getDataSource();
|
||||
DataSourcePool pool = (DataSourcePool) config.getDataSource();
|
||||
assertThat(pool.isDataSourceUp()).isTrue();
|
||||
pool.shutdown();
|
||||
}
|
||||
@@ -174,7 +174,7 @@ public class InitDataSourceTest {
|
||||
config.getDataSourceConfig().setAlert(alert);
|
||||
config.setDatabasePlatformName("h2");
|
||||
InitDataSource.init(config);
|
||||
ConnectionPool pool = (ConnectionPool) config.getDataSource();
|
||||
DataSourcePool pool = (DataSourcePool) config.getDataSource();
|
||||
assertThat(pool).isNotNull();
|
||||
// make some additional tests with the pool
|
||||
assertThat(pool.isDataSourceUp()).isFalse();
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package io.ebeaninternal.server.deploy.parse;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class DeployInheritInfoTest {
|
||||
|
||||
@Test
|
||||
void addChild_when_DiscriminatorValueIsNull() {
|
||||
DeployInheritInfo root = new DeployInheritInfo(Object.class);
|
||||
root.addChild(new DeployInheritInfo(Integer.class)); // DiscriminatorValue is null
|
||||
root.addChild(new DeployInheritInfo(Short.class)); // DiscriminatorValue is null
|
||||
|
||||
DeployInheritInfo c2 = new DeployInheritInfo(Long.class);
|
||||
c2.setDiscriminatorValue("c2");
|
||||
root.addChild(c2);
|
||||
|
||||
assertThat(root.children()).hasSize(3);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package io.ebeaninternal.server.expression;
|
||||
|
||||
import io.ebean.EbeanServer;
|
||||
import io.ebean.Database;
|
||||
import io.ebean.Query;
|
||||
import io.ebean.Transaction;
|
||||
import io.ebean.event.BeanQueryRequest;
|
||||
@@ -62,7 +62,7 @@ public abstract class BaseExpressionTest extends BaseTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EbeanServer getEbeanServer() {
|
||||
public Database database() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user