@Test void createVelocityEngine() throws Exception { assertNull(this.velocityFactory.getVelocityEngine("somekey")); assertFalse(this.velocityFactory.hasVelocityEngine("somekey")); VelocityEngine mockEngine = this.componentManager.registerMockComponent(VelocityEngine.class); Properties props = new Properties(); props.setProperty("prop1", "value1"); this.velocityFactory.createVelocityEngine("somekey", props); assertSame(mockEngine, this.velocityFactory.getVelocityEngine("somekey")); assertTrue(this.velocityFactory.hasVelocityEngine("somekey")); verify(mockEngine).initialize(props); }
@Override public VelocityEngine createVelocityEngine(String key, Properties properties) throws XWikiVelocityException { VelocityEngine engine; try { engine = this.componentManager.getInstance(VelocityEngine.class); } catch (ComponentLookupException e) { throw new XWikiVelocityException("Failed to create Velocity Engine", e); } engine.initialize(properties); this.velocityEngines.put(key, engine); return engine; }
DefaultVelocityFactory implements VelocityFactory { @Override public VelocityEngine createVelocityEngine(String key, Properties properties) throws XWikiVelocityException { VelocityEngine engine; try { engine = this.componentManager.getInstance(VelocityEngine.class); } catch (ComponentLookupException e) { throw new XWikiVelocityException("Failed to create Velocity Engine", e); } engine.initialize(properties); this.velocityEngines.put(key, engine); return engine; } }
DefaultVelocityFactory implements VelocityFactory { @Override public VelocityEngine createVelocityEngine(String key, Properties properties) throws XWikiVelocityException { VelocityEngine engine; try { engine = this.componentManager.getInstance(VelocityEngine.class); } catch (ComponentLookupException e) { throw new XWikiVelocityException("Failed to create Velocity Engine", e); } engine.initialize(properties); this.velocityEngines.put(key, engine); return engine; }  }
DefaultVelocityFactory implements VelocityFactory { @Override public VelocityEngine createVelocityEngine(String key, Properties properties) throws XWikiVelocityException { VelocityEngine engine; try { engine = this.componentManager.getInstance(VelocityEngine.class); } catch (ComponentLookupException e) { throw new XWikiVelocityException("Failed to create Velocity Engine", e); } engine.initialize(properties); this.velocityEngines.put(key, engine); return engine; }  @Override boolean hasVelocityEngine(String key); @Override VelocityEngine getVelocityEngine(String key); @Override VelocityEngine createVelocityEngine(String key, Properties properties); @Override VelocityEngine removeVelocityEngine(String key); }
DefaultVelocityFactory implements VelocityFactory { @Override public VelocityEngine createVelocityEngine(String key, Properties properties) throws XWikiVelocityException { VelocityEngine engine; try { engine = this.componentManager.getInstance(VelocityEngine.class); } catch (ComponentLookupException e) { throw new XWikiVelocityException("Failed to create Velocity Engine", e); } engine.initialize(properties); this.velocityEngines.put(key, engine); return engine; }  @Override boolean hasVelocityEngine(String key); @Override VelocityEngine getVelocityEngine(String key); @Override VelocityEngine createVelocityEngine(String key, Properties properties); @Override VelocityEngine removeVelocityEngine(String key);  }