List of usage examples for org.apache.commons.configuration Configuration setProperty
void setProperty(String key, Object value);
From source file:org.sonar.plugins.php.core.AbstractPhpPluginConfigurationTest.java
@Test public void testDynamicAnalysisProperty() { Configuration config = new BaseConfiguration(); Project project = MockUtils.createMockProject(config); FakeConfiguration conf = new FakeConfiguration(project); assertEquals(true, conf.isDynamicAnalysisEnabled()); // Set to FALSE config.setProperty("sonar.dynamicAnalysis", "false"); conf = new FakeConfiguration(project); assertEquals(false, conf.isDynamicAnalysisEnabled()); // Set to REUSE REPORTS (may be possible in Sonar, does not make sense for the moment in PHP plugin but must not break) config.setProperty("sonar.dynamicAnalysis", "reuseReports"); conf = new FakeConfiguration(project); assertEquals(true, conf.isDynamicAnalysisEnabled()); }
From source file:org.sonar.plugins.squid.SquidSensorTest.java
@Test public void testGetBytecodeFiles() { ProjectClasspath projectClasspath = mock(ProjectClasspath.class); when(projectClasspath.getElements()).thenReturn(Arrays.asList(new File("classes"))); SquidSensor sensor = new SquidSensor(null, null, projectClasspath, null, null); Configuration configuration = new BaseConfiguration(); Project project = mock(Project.class); when(project.getConfiguration()).thenReturn(configuration); configuration.setProperty(CoreProperties.DESIGN_SKIP_DESIGN_PROPERTY, true); assertThat(sensor.getBytecodeFiles(project).size(), is(0)); configuration.setProperty(CoreProperties.DESIGN_SKIP_DESIGN_PROPERTY, false); assertThat(sensor.getBytecodeFiles(project).size(), is(1)); assertThat(sensor.getBytecodeFiles(project), sameInstance((Collection<File>) projectClasspath.getElements())); }
From source file:org.sonar.plugins.twitter.TwitterPublisher.java
private void authenticate(Configuration configuration) throws TwitterException, IOException { String key = configuration.getString(USERNAME_PROPERTY); String secret = configuration.getString(PASSWORD_PROPERTY); twitter.setOAuthConsumer(key, secret); RequestToken requestToken = twitter.getOAuthRequestToken(); AccessToken accessToken = null;/* ww w . ja va 2 s . c o m*/ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); while (null == accessToken) { LOG.info("Open the following URL and grant access to your account:"); LOG.info(requestToken.getAuthorizationURL()); LOG.info("Enter the PIN(if aviailable) or just hit enter.[PIN]:"); String pin = br.readLine(); try { if (pin.length() > 0) { accessToken = twitter.getOAuthAccessToken(requestToken, pin); } else { accessToken = twitter.getOAuthAccessToken(); } } catch (TwitterException te) { if (401 == te.getStatusCode()) { LOG.error("Unable to get the access token."); } else { LOG.error("Unexpected Twitter error: " + te.getMessage(), te); } } } int id = twitter.verifyCredentials().getId(); // persist to the accessToken for future reference. storeAccessToken(configuration, id, accessToken); // unset clear password on the configuration configuration.setProperty(USERNAME_PROPERTY, null); configuration.setProperty(PASSWORD_PROPERTY, null); }
From source file:org.sonar.plugins.twitter.TwitterPublisher.java
private void storeAccessToken(Configuration configuration, int id, AccessToken accessToken) { configuration.setProperty(TWITTER_TOKEN, accessToken.getToken()); configuration.setProperty(TWITTER_TOKEN_SECRET, accessToken.getTokenSecret()); configuration.setProperty(TWITTER_TOKEN_ID, id); }
From source file:org.sonar.plugins.twitter.TwitterPublisherTest.java
@Test public void updateStatus() throws TwitterException { Configuration configuration = new BaseConfiguration(); configuration.setProperty(USERNAME_PROPERTY, "user"); configuration.setProperty(PASSWORD_PROPERTY, "pass"); configuration.setProperty(HOST_PROPERTY, HOST_DEFAULT_VALUE); when(project.getConfiguration()).thenReturn(configuration); when(project.getName()).thenReturn("SimpleProject"); doNothing().when(publisher).updateStatus(anyString()); publisher.executeOn(project, context); // verify(publisher).updateStatus(contains("SimpleProject")); }
From source file:org.springframework.data.neo4j.rest.support.SpringPluginInitializerTests.java
@Before public void setUp() throws Exception { ImpermanentGraphDatabase db = new ImpermanentGraphDatabase(); final ServerConfigurator configurator = new ServerConfigurator(db) { @Override//from ww w . ja v a 2s . c o m public List<ThirdPartyJaxRsPackage> getThirdpartyJaxRsPackages() { return Collections.singletonList( new ThirdPartyJaxRsPackage("org.springframework.data.neo4j.rest.support", "/test")); } }; final Configuration configuration = configurator.configuration(); configuration.setProperty(Configurator.WEBSERVER_PORT_PROPERTY_KEY, PORT); final WrappingNeoServerBootstrapper bootstrapper = new WrappingNeoServerBootstrapper(db, configurator); touched = 0; bootstrapper.start(); neoServer = bootstrapper.getServer(); }
From source file:org.wso2.andes.configuration.qpid.ServerConfiguration.java
private static void substituteEnvironmentVariables(org.apache.commons.configuration.Configuration conf) { for (Entry<String, String> var : envVarMap.entrySet()) { String val = System.getenv(var.getKey()); if (val != null) { conf.setProperty(var.getValue(), val); }/*from w w w. j av a 2 s .c o m*/ } }
From source file:org.wso2.andes.server.configuration.ServerConfiguration.java
private static void substituteEnvironmentVariables(Configuration conf) { for (Entry<String, String> var : envVarMap.entrySet()) { String val = System.getenv(var.getKey()); if (val != null) { conf.setProperty(var.getValue(), val); }/*from w w w . j ava 2 s . c o m*/ } }
From source file:org.zaproxy.zap.authentication.FormBasedAuthenticationMethodType.java
@Override public void exportData(Configuration config, AuthenticationMethod authMethod) { if (!(authMethod instanceof FormBasedAuthenticationMethod)) { throw new UnsupportedAuthenticationMethodException("Form based authentication type only supports: " + FormBasedAuthenticationMethod.class.getName()); }// www. java 2 s . c o m FormBasedAuthenticationMethod method = (FormBasedAuthenticationMethod) authMethod; config.setProperty(CONTEXT_CONFIG_AUTH_FORM_LOGINURL, method.loginRequestURL); config.setProperty(CONTEXT_CONFIG_AUTH_FORM_LOGINBODY, method.loginRequestBody); }
From source file:org.zaproxy.zap.extension.accessControl.ExtensionAccessControl.java
@Override public void exportContextData(Context ctx, Configuration config) { ContextAccessRulesManager contextManager = contextManagers.get(ctx.getIndex()); if (contextManager != null) { List<String> serializedRules = contextManager.exportSerializedRules(); config.setProperty(CONTEXT_CONFIG_ACCESS_RULES_RULE, serializedRules); }/*from w w w . j a v a2 s .co m*/ }