@Test public void testB() { assertEquals("testB", name.getMethodName()); } }
public void assertSingleLiveBeansViewMbean(String applicationName) throws MalformedObjectNameException { Set<ObjectName> objectNames = searchLiveBeansViewMeans(); assertEquals(1, objectNames.size()); assertEquals("Wrong MBean name", String.format("%s:application=%s", this.name.getMethodName(), applicationName), objectNames.iterator().next().getCanonicalName()); }
@Test public void sameInstanceEquals() { Method m = ReflectionUtils.findMethod(getClass(), name.getMethodName()); AnnotatedElementKey instance = new AnnotatedElementKey(m, getClass()); assertKeyEquals(instance, instance); }
@Test(expected=IllegalArgumentException.class) public void testModifyInexistentFamily() { HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(name.getMethodName())); byte[] familyName = Bytes.toBytes("cf"); HColumnDescriptor hcd = new HColumnDescriptor(familyName); htd.modifyFamily(hcd); }
@Test public void removeAll() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(name.getMethodName()); cache.put(key, new Object()); service.removeAll(); assertTrue(isEmpty(cache)); }
@Test public void testA() { assertEquals("testA", name.getMethodName()); }
@Test public void earlyRemoveAll() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(name.getMethodName()); cache.put(key, new Object()); service.earlyRemoveAll(); assertTrue(isEmpty(cache)); }
@Test public void equals() { Method m = ReflectionUtils.findMethod(getClass(), name.getMethodName()); AnnotatedElementKey first = new AnnotatedElementKey(m, getClass()); AnnotatedElementKey second = new AnnotatedElementKey(m, getClass()); assertKeyEquals(first, second); }
@Test public void registerUnregisterSingleContext() throws MalformedObjectNameException { this.environment.setProperty(LiveBeansView.MBEAN_DOMAIN_PROPERTY_NAME, this.name.getMethodName()); ConfigurableApplicationContext context = createApplicationContext("app"); assertEquals(0, searchLiveBeansViewMeans().size()); LiveBeansView.registerApplicationContext(context); assertSingleLiveBeansViewMbean("app"); LiveBeansView.unregisterApplicationContext(context); assertEquals(0, searchLiveBeansViewMeans().size()); }
@Test public void getTransactionalOnNewCache() { String cacheName = name.getMethodName(); T cacheManager = getCacheManager(true); assertFalse(cacheManager.getCacheNames().contains(cacheName)); addNativeCache(cacheName); try { assertThat(cacheManager.getCache(cacheName), is(instanceOf(TransactionAwareCacheDecorator.class))); assertTrue(cacheManager.getCacheNames().contains(cacheName)); } finally { removeNativeCache(cacheName); } }
@Test public void multiAnnotations() { thrown.expect(IllegalStateException.class); getCacheOperation(InvalidCases.class, name.getMethodName()); }
@Test public void testSimpleLoadWithFileCopy() throws Exception { String testName = tn.getMethodName(); final byte[] TABLE_NAME = Bytes.toBytes("mytable_" + testName); runTest(testName, buildHTD(TableName.valueOf(TABLE_NAME), BloomType.NONE), false, null, new byte[][][] { new byte[][] { Bytes.toBytes("aaaa"), Bytes.toBytes("cccc") }, new byte[][] { Bytes.toBytes("ddd"), Bytes.toBytes("ooo") }, }, false, true, 2); }
@Test public void customCacheResolver() { CacheResultOperation operation = getCacheOperation(CacheResultOperation.class, CustomService.class, name.getMethodName(), Long.class); assertJCacheResolver(operation.getCacheResolver(), TestableCacheResolver.class); assertJCacheResolver(operation.getExceptionCacheResolver(), null); assertEquals(KeyGeneratorAdapter.class, operation.getKeyGenerator().getClass()); assertEquals(defaultKeyGenerator, ((KeyGeneratorAdapter) operation.getKeyGenerator()).getTarget()); }
@Test public void removeAllWithException() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(name.getMethodName()); cache.put(key, new Object()); try { service.removeAllWithException(true); fail("Should have thrown an exception"); } catch (UnsupportedOperationException e) { // This is what we expect } assertTrue(isEmpty(cache)); }
@Test public void noTargetClassNotEquals() { Method m = ReflectionUtils.findMethod(getClass(), name.getMethodName()); AnnotatedElementKey first = new AnnotatedElementKey(m, getClass()); AnnotatedElementKey second = new AnnotatedElementKey(m, null); assertFalse(first.equals(second)); }
@Test public void testPriority() { HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(name.getMethodName())); htd.setPriority(42); assertEquals(42, htd.getPriority()); } }
@Test public void customKeyGenerator() { CacheResultOperation operation = getCacheOperation(CacheResultOperation.class, CustomService.class, name.getMethodName(), Long.class); assertEquals(defaultCacheResolver, operation.getCacheResolver()); assertNull(operation.getExceptionCacheResolver()); assertCacheKeyGenerator(operation.getKeyGenerator(), TestableCacheKeyGenerator.class); }
@Test public void earlyRemoveAllWithException() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(name.getMethodName()); cache.put(key, new Object()); try { service.earlyRemoveAllWithException(true); fail("Should have thrown an exception"); } catch (UnsupportedOperationException e) { // This is what we expect } assertTrue(isEmpty(cache)); }