Java Code Examples for org.cache2k.Cache2kBuilder#name()

The following examples show how to use org.cache2k.Cache2kBuilder#name() . 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: CacheRule.java    From cache2k with Apache License 2.0 6 votes vote down vote up
Cache<K, V> buildCache() {
  String _name = description.getTestClass().getName();
  Cache2kBuilder b = getInitialBuilder();
  for (Specialization sp : configurationSpecialization) {
    sp.extend(b);
  }
  if (shared) {
    b.name(description.getTestClass());
    sharedCache.put(_name, _name);
  } else {
    if (sharedCache.containsKey(_name)) {
      throw new IllegalArgumentException("Shared cache usage: Method rule must be identical instance.");
    }
    b.name(description.getTestClass(), description.getMethodName());
  }
  return b.build();
}
 
Example 2
Source File: Cache2kBuilderTest.java    From cache2k with Apache License 2.0 4 votes vote down vote up
@Test
public void cacheNameUnique() {
  Cache2kBuilder _builder = Cache2kBuilder.forUnknownTypes();
  _builder.name("hello", this.getClass(), "field");
  assertEquals("hello~org.cache2k.test.core.Cache2kBuilderTest.field", _builder.toConfiguration().getName());
}
 
Example 3
Source File: Cache2kBuilderTest.java    From cache2k with Apache License 2.0 4 votes vote down vote up
@Test
public void cacheNameUniqueNull() {
  Cache2kBuilder _builder = Cache2kBuilder.forUnknownTypes();
  _builder.name(null, this.getClass(), "field");
  assertEquals("org.cache2k.test.core.Cache2kBuilderTest.field", _builder.toConfiguration().getName());
}
 
Example 4
Source File: Cache2kBuilderTest.java    From cache2k with Apache License 2.0 4 votes vote down vote up
@Test(expected = NullPointerException.class)
public void cacheNameException() {
  Cache2kBuilder _builder = Cache2kBuilder.forUnknownTypes();
  _builder.name(this.getClass(), null);
}