Java Code Examples for org.ehcache.config.units.MemoryUnit#B

The following examples show how to use org.ehcache.config.units.MemoryUnit#B . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultSizeOfEngineConfigurationTest.java    From ehcache3 with Apache License 2.0 5 votes vote down vote up
@Test
public void testIllegalMaxObjectSizeArgument() {
  try {
    new DefaultSizeOfEngineConfiguration(0, MemoryUnit.B, 1l);
    fail();
  } catch (Exception illegalArgument) {
    assertThat(illegalArgument, instanceOf(IllegalArgumentException.class));
    assertThat(illegalArgument.getMessage(), equalTo("ObjectGraphSize/ObjectSize can only accept positive values."));
  }
}
 
Example 2
Source File: DefaultSizeOfEngineConfigurationTest.java    From ehcache3 with Apache License 2.0 5 votes vote down vote up
@Test
public void testIllegalMaxObjectGraphSizeArgument() {
  try {
    new DefaultSizeOfEngineConfiguration(1l, MemoryUnit.B, 0);
    fail();
  } catch (Exception illegalArgument) {
    assertThat(illegalArgument, instanceOf(IllegalArgumentException.class));
    assertThat(illegalArgument.getMessage(), equalTo("ObjectGraphSize/ObjectSize can only accept positive values."));
  }
}
 
Example 3
Source File: DefaultSizeOfEngineConfigurationTest.java    From ehcache3 with Apache License 2.0 5 votes vote down vote up
@Test
public void testValidArguments() {
  DefaultSizeOfEngineConfiguration configuration = new DefaultSizeOfEngineConfiguration(10l, MemoryUnit.B, 10l);
  assertThat(configuration.getMaxObjectGraphSize(), equalTo(10l));
  assertThat(configuration.getMaxObjectSize(), equalTo(10l));
  assertThat(configuration.getUnit(), equalTo(MemoryUnit.B));
}
 
Example 4
Source File: DefaultSizeOfEngineProviderConfigurationTest.java    From ehcache3 with Apache License 2.0 5 votes vote down vote up
@Test
public void testIllegalMaxObjectSizeArgument() {
  try {
    new DefaultSizeOfEngineProviderConfiguration(0, MemoryUnit.B, 1l);
    fail();
  } catch (Exception illegalArgument) {
    assertThat(illegalArgument, instanceOf(IllegalArgumentException.class));
    assertThat(illegalArgument.getMessage(), equalTo("SizeOfEngine cannot take non-positive arguments."));
  }
}
 
Example 5
Source File: DefaultSizeOfEngineProviderConfigurationTest.java    From ehcache3 with Apache License 2.0 5 votes vote down vote up
@Test
public void testIllegalMaxObjectGraphSizeArgument() {
  try {
    new DefaultSizeOfEngineProviderConfiguration(1l, MemoryUnit.B, 0);
    fail();
  } catch (Exception illegalArgument) {
    assertThat(illegalArgument, instanceOf(IllegalArgumentException.class));
    assertThat(illegalArgument.getMessage(), equalTo("SizeOfEngine cannot take non-positive arguments."));
  }
}
 
Example 6
Source File: DefaultSizeOfEngineProviderConfigurationTest.java    From ehcache3 with Apache License 2.0 5 votes vote down vote up
@Test
public void testValidArguments() {
  DefaultSizeOfEngineProviderConfiguration configuration = new DefaultSizeOfEngineProviderConfiguration(10l, MemoryUnit.B, 10l);
  assertThat(configuration.getMaxObjectGraphSize(), equalTo(10l));
  assertThat(configuration.getMaxObjectSize(), equalTo(10l));
  assertThat(configuration.getUnit(), equalTo(MemoryUnit.B));
}
 
Example 7
Source File: DefaultSizeOfEngineProviderConfigurationTest.java    From ehcache3 with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeriveDetachesCorrectly() {
  DefaultSizeOfEngineProviderConfiguration configuration = new DefaultSizeOfEngineProviderConfiguration(42L, MemoryUnit.B, 100L);

  DefaultSizeOfEngineProviderConfiguration derived = configuration.build(configuration.derive());

  assertThat(derived, is(not(sameInstance(configuration))));
  assertThat(derived.getMaxObjectGraphSize(), is(configuration.getMaxObjectGraphSize()));
  assertThat(derived.getMaxObjectSize(), is(configuration.getMaxObjectSize()));
  assertThat(derived.getUnit(), is(configuration.getUnit()));
}