LruCacheProvider createProvider(final String name, final String capacity, int defaultCapacity) { Module module = new AbstractModule() { @Override public void configure() { binder().bindConstant() .annotatedWith(Names.named("shindig.cache.lru." + name + ".capacity")) .to(capacity); } }; Injector injector = Guice.createInjector(module); return new LruCacheProvider(injector, defaultCapacity); }
LruCacheProvider createProvider(final String name, final String capacity, int defaultCapacity) { Module module = new AbstractModule() { @Override public void configure() { binder().bindConstant() .annotatedWith(Names.named("shindig.cache.lru." + name + ".capacity")) .to(capacity); } }; Injector injector = Guice.createInjector(module); return new LruCacheProvider(injector, defaultCapacity); }
LruCacheProvider createProvider(final String name, final String capacity, int defaultCapacity) { Module module = new AbstractModule() { @Override public void configure() { binder().bindConstant() .annotatedWith(Names.named("shindig.cache.lru." + name + ".capacity")) .to(capacity); } }; Injector injector = Guice.createInjector(module); return new LruCacheProvider(injector, defaultCapacity); }
LruCacheProvider createProvider(final String name, final String capacity, int defaultCapacity) { Module module = new AbstractModule() { @Override public void configure() { binder().bindConstant() .annotatedWith(Names.named("shindig.cache.lru." + name + ".capacity")) .to(capacity); } }; Injector injector = Guice.createInjector(module); return new LruCacheProvider(injector, defaultCapacity); }
LruCacheProvider createProvider(final String name, final String capacity, int defaultCapacity) { Module module = new AbstractModule() { @Override public void configure() { binder().bindConstant() .annotatedWith(Names.named("shindig.cache.lru." + name + ".capacity")) .to(capacity); } }; Injector injector = Guice.createInjector(module); return new LruCacheProvider(injector, defaultCapacity); }
@Test public void defaultCapacityForNamedCache() throws Exception { LruCacheProvider provider = new LruCacheProvider(10); assertEquals(10, getCache(provider, "foo").capacity); }
@Before public void setUp() throws Exception { cajaCssParser = new CajaCssParser(); cajaCssParser.setCacheProvider(new LruCacheProvider(10)); }
@Before public void setUp() throws Exception { cajaCssParser = new CajaCssParser(); cajaCssParser.setCacheProvider(new LruCacheProvider(10)); }
@Test public void defaultCapacityForNamedCache() throws Exception { LruCacheProvider provider = new LruCacheProvider(10); assertEquals(10, getCache(provider, "foo").capacity); }
@Test public void defaultCapacityForNamedCache() throws Exception { LruCacheProvider provider = new LruCacheProvider(10); assertEquals(10, getCache(provider, "foo").capacity); }
@Test public void defaultCapacityForNamedCache() throws Exception { LruCacheProvider provider = new LruCacheProvider(10); assertEquals(10, getCache(provider, "foo").capacity); }
@Test public void defaultCapacityForNamedCache() throws Exception { LruCacheProvider provider = new LruCacheProvider(10); assertEquals(10, getCache(provider, "foo").capacity); }
@Before public void setUp() throws Exception { cajaCssParser = new CajaCssParser(); cajaCssParser.setCacheProvider(new LruCacheProvider(10)); }
@Test public void testCache() throws Exception { cajaCssParser.setCacheProvider(new LruCacheProvider(100)); // Ensure that we return cloned instances and not the original out of the cache. Cloned // instances intentionally do not compare equal but should produce the same output List<Object> styleSheet = cajaCssParser.parse(CSS); List<Object> styleSheet2 = cajaCssParser.parse(CSS); assertFalse(styleSheet.equals(styleSheet2)); assertEquals(cajaCssParser.serialize(styleSheet), cajaCssParser.serialize(styleSheet2)); } }
@Test public void testCache() throws Exception { cajaCssParser.setCacheProvider(new LruCacheProvider(100)); // Ensure that we return cloned instances and not the original out of the cache. Cloned // instances intentionally do not compare equal but should produce the same output List<Object> styleSheet = cajaCssParser.parse(CSS); List<Object> styleSheet2 = cajaCssParser.parse(CSS); assertFalse(styleSheet.equals(styleSheet2)); assertEquals(cajaCssParser.serialize(styleSheet), cajaCssParser.serialize(styleSheet2)); } }
@Test public void testCache() throws Exception { cajaCssParser.setCacheProvider(new LruCacheProvider(100)); // Ensure that we return cloned instances and not the original out of the cache. Cloned // instances intentionally do not compare equal but should produce the same output List<Object> styleSheet = cajaCssParser.parse(CSS); List<Object> styleSheet2 = cajaCssParser.parse(CSS); assertFalse(styleSheet.equals(styleSheet2)); assertEquals(cajaCssParser.serialize(styleSheet), cajaCssParser.serialize(styleSheet2)); } }
@Test public void testClone() throws Exception { // Set the cache so we force cloning cajaCssParser.setCacheProvider(new LruCacheProvider(100)); // Compare the raw parsed structure to a cloned one List<Object> styleSheet = cajaCssParser.parseImpl(CSS); List<Object> styleSheet2 = cajaCssParser.parse(CSS); assertEquals(cajaCssParser.serialize(styleSheet), cajaCssParser.serialize(styleSheet2)); }
@Test public void testClone() throws Exception { // Set the cache so we force cloning cajaCssParser.setCacheProvider(new LruCacheProvider(100)); // Compare the raw parsed structure to a cloned one List<Object> styleSheet = cajaCssParser.parseImpl(CSS); List<Object> styleSheet2 = cajaCssParser.parse(CSS); assertEquals(cajaCssParser.serialize(styleSheet), cajaCssParser.serialize(styleSheet2)); }
@Test public void testClone() throws Exception { // Set the cache so we force cloning cajaCssParser.setCacheProvider(new LruCacheProvider(100)); // Compare the raw parsed structure to a cloned one List<Object> styleSheet = cajaCssParser.parseImpl(CSS); List<Object> styleSheet2 = cajaCssParser.parse(CSS); assertEquals(cajaCssParser.serialize(styleSheet), cajaCssParser.serialize(styleSheet2)); }
public void testIncludedURLRequestMarkedInternal() throws Exception { CacheProvider lru = new LruCacheProvider(3); DefaultHtmlSerializer defaultSerializer = new DefaultHtmlSerializer(); CapturingPipeline pipeline = new CapturingPipeline(); rewriter = new CajaContentRewriter(lru, pipeline, defaultSerializer, proxyUriManager) { @Override protected PluginCompiler makePluginCompiler(PluginMeta m, MessageQueue q) { BuildInfo bi = EasyMock.createNiceMock(BuildInfo.class); expect(bi.getBuildInfo()).andReturn("bi").anyTimes(); expect(bi.getBuildTimestamp()).andReturn("0").anyTimes(); expect(bi.getBuildVersion()).andReturn("0").anyTimes(); expect(bi.getCurrentTime()).andReturn(0L).anyTimes(); replay(bi); return new PluginCompiler(bi, m, q); } }; // we don't really care what the result looks like, we just want to check the issued request String markup = "<script type=\"text/javascript\" src=\"http://www.example.com/scripts/scriptFile.js\"></script>"; String expected = ""; testMarkup( markup, expected ); assertNotNull( pipeline.request ); assertTrue( pipeline.request.isInternalRequest() ); }