/** * <p> * Sets the current configuration.</p> * <p> * <b>Warning: </b> this will ignore any defined ConfigurationLoaders</p> * * @param configuration the configuration to set. */ public static synchronized void setConfiguration(final Configuration configuration) { Config.configuration = configuration; notifyListeners(); }
/** * Resets the configuration back to the default internal configuration. All configuration changes which have been * made will be lost. This method is primarily intended for unit testing. */ public static synchronized void reset() { configuration = loadConfiguration(); notifyListeners(); }
/** * {@inheritDoc} */ public void refresh() { synchronized (lockObject) { // Now reset this object back to its initial state. initialiseInstanceVariables(); // Load all the parameters from scratch. load(); // Finally, notify all the listeners that have registered with this object that a change in properties has // occurred. Config.notifyListeners(); } }
@Test public void testInterceptorDisabled() throws XpathException, SAXException, IOException { Config.getInstance().setProperty(ConfigurationProperties.DEVELOPER_DEBUG_ENABLED, "false"); Config.notifyListeners(); // No debug info should be rendered String xml = doRequest(); assertXpathEvaluatesTo("0", "count(//ui:debug/ui:debugInfo)", xml); }
@Test public void testInterceptor() throws XpathException, SAXException, IOException { Config.getInstance().setProperty(ConfigurationProperties.DEVELOPER_DEBUG_ENABLED, "true"); Config.notifyListeners(); MyApp app = new MyApp(); app.setLocked(true); // Only the label should have debug info rendered String xml = doAjaxRequest(app); assertXpathEvaluatesTo("1", "count(//ui:debug/ui:debugInfo)", xml); assertXpathEvaluatesTo(app.target.getId(), "//ui:debug/ui:debugInfo/@for", xml); assertXpathEvaluatesTo(app.target.getClass().getName(), "//ui:debug/ui:debugInfo/@class", xml); assertXpathEvaluatesTo(app.target.getClass().getName(), "//ui:debug/ui:debugInfo/@type", xml); assertXpathEvaluatesTo("true", "//ui:debug/ui:debugInfo/ui:debugDetail[@key='defaultState']/@value", xml); }
@Test public void testInterceptor() throws XpathException, SAXException, IOException { Config.getInstance().setProperty(ConfigurationProperties.DEVELOPER_DEBUG_ENABLED, "true"); Config.notifyListeners(); // Only the label should have debug info rendered String xml = doRequest(); assertXpathEvaluatesTo("1", "count(//ui:debug/ui:debugInfo)", xml); assertXpathEvaluatesTo(new WApplication().getId(), "//ui:debugInfo/@for", xml); assertXpathEvaluatesTo(WApplication.class.getName(), "//ui:debug/ui:debugInfo/@class", xml); assertXpathEvaluatesTo(WApplication.class.getName(), "//ui:debug/ui:debugInfo/@type", xml); assertXpathEvaluatesTo("false", "//ui:debug/ui:debugInfo/ui:debugDetail[@key='defaultState']/@value", xml); }
@Test public void testInterceptorDisabled() throws XpathException, SAXException, IOException { Config.getInstance().setProperty(ConfigurationProperties.DEVELOPER_DEBUG_ENABLED, "false"); Config.notifyListeners(); MyApp app = new MyApp(); app.setLocked(true); // No debug info should be rendered String xml = doAjaxRequest(app); assertXpathEvaluatesTo("0", "count(//ui:debug)", xml); }