use of org.apache.commons.configuration2.Configuration in project graylog2-server by Graylog2.
the class ExposedConfigurationTest method testSerialization.
@Test
public void testSerialization() throws Exception {
final Configuration configuration = new Configuration();
final ExposedConfiguration c = ExposedConfiguration.create(configuration);
final String json = objectMapper.writeValueAsString(c);
assertThat((int) JsonPath.read(json, "$.inputbuffer_processors")).isEqualTo(c.inputBufferProcessors());
assertThat((int) JsonPath.read(json, "$.processbuffer_processors")).isEqualTo(c.processBufferProcessors());
assertThat((int) JsonPath.read(json, "$.outputbuffer_processors")).isEqualTo(c.outputBufferProcessors());
assertThat((String) JsonPath.read(json, "$.processor_wait_strategy")).isEqualTo(c.processorWaitStrategy());
assertThat((String) JsonPath.read(json, "$.inputbuffer_wait_strategy")).isEqualTo(c.inputBufferWaitStrategy());
assertThat((int) JsonPath.read(json, "$.inputbuffer_ring_size")).isEqualTo(c.inputBufferRingSize());
assertThat((int) JsonPath.read(json, "$.ring_size")).isEqualTo(c.ringSize());
assertThat((String) JsonPath.read(json, "$.plugin_dir")).isEqualTo(c.pluginDir());
assertThat((String) JsonPath.read(json, "$.node_id_file")).isEqualTo(c.nodeIdFile());
assertThat((boolean) JsonPath.read(json, "$.allow_highlighting")).isEqualTo(c.allowHighlighting());
assertThat((boolean) JsonPath.read(json, "$.allow_leading_wildcard_searches")).isEqualTo(c.allowLeadingWildcardSearches());
assertThat((int) JsonPath.read(json, "$.stream_processing_timeout")).isEqualTo((int) c.streamProcessingTimeout());
assertThat((int) JsonPath.read(json, "$.stream_processing_max_faults")).isEqualTo(c.streamProcessingMaxFaults());
assertThat((int) JsonPath.read(json, "$.output_module_timeout")).isEqualTo((int) c.outputModuleTimeout());
assertThat((int) JsonPath.read(json, "$.stale_master_timeout")).isEqualTo(c.staleMasterTimeout());
assertThat((String) JsonPath.read(json, "$.gc_warning_threshold")).isEqualTo(c.gcWarningThreshold());
}
use of org.apache.commons.configuration2.Configuration in project graylog2-server by Graylog2.
the class FieldContentValueAlertConditionTest method testCorrectUsageOfRelativeRange.
@Test
public void testCorrectUsageOfRelativeRange() throws Exception {
final Stream stream = mock(Stream.class);
final Searches searches = mock(Searches.class);
final Configuration configuration = mock(Configuration.class);
final SearchResult searchResult = mock(SearchResult.class);
final int alertCheckInterval = 42;
final RelativeRange relativeRange = RelativeRange.create(alertCheckInterval);
when(configuration.getAlertCheckInterval()).thenReturn(alertCheckInterval);
when(searches.search(anyString(), anyString(), eq(relativeRange), anyInt(), anyInt(), any(Sorting.class))).thenReturn(searchResult);
final FieldContentValueAlertCondition alertCondition = new FieldContentValueAlertCondition(searches, configuration, stream, null, DateTime.now(DateTimeZone.UTC), "mockuser", ImmutableMap.<String, Object>of("field", "test", "value", "test"), "Field Content Value Test COndition");
final AbstractAlertCondition.CheckResult result = alertCondition.runCheck();
}
use of org.apache.commons.configuration2.Configuration in project graylog2-server by Graylog2.
the class UserServiceImplTest method setUp.
@Before
public void setUp() throws Exception {
this.mongoConnection = mongoRule.getMongoConnection();
this.configuration = new Configuration();
this.userFactory = new UserImplFactory(configuration);
this.permissions = new Permissions(ImmutableSet.of(new RestPermissions()));
this.userService = new UserServiceImpl(mongoConnection, configuration, roleService, userFactory, permissionsResolver);
when(roleService.getAdminRoleObjectId()).thenReturn("deadbeef");
}
use of org.apache.commons.configuration2.Configuration in project hadoop by apache.
the class RollingFileSystemSinkTestBase method preCreateLogFile.
/**
* Create files at the target path with some known data in them. Each file
* will have the same content: "Extra stuff".
*
* If the test run is happening within 20 seconds of the top of the hour,
* this method will sleep until the top of the hour.
*
* @param path the target path under which to create the directory for the
* current hour that will contain the log files.
* @param numFiles the number of log files to create
* @throws IOException thrown if the file creation fails
* @throws InterruptedException thrown if interrupted while waiting for the
* top of the hour.
* @throws URISyntaxException thrown if the path isn't a valid URI
*/
protected void preCreateLogFile(String path, int numFiles) throws IOException, InterruptedException, URISyntaxException {
Calendar now = getNowNotTopOfHour();
FileSystem fs = FileSystem.get(new URI(path), new Configuration());
Path dir = new Path(path, DATE_FORMAT.format(now.getTime()) + "00");
fs.mkdirs(dir);
Path file = new Path(dir, getLogFilename());
// Create the log file to force the sink to append
try (FSDataOutputStream out = fs.create(file)) {
out.write("Extra stuff\n".getBytes());
out.flush();
}
if (numFiles > 1) {
int count = 1;
while (count < numFiles) {
file = new Path(dir, getLogFilename() + "." + count);
// Create the log file to force the sink to append
try (FSDataOutputStream out = fs.create(file)) {
out.write("Extra stuff\n".getBytes());
out.flush();
}
count += 1;
}
}
}
use of org.apache.commons.configuration2.Configuration in project hadoop by apache.
the class MetricsConfig method toString.
static String toString(Configuration c) {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
try {
PrintWriter pw = new PrintWriter(buffer, false);
PropertiesConfiguration tmp = new PropertiesConfiguration();
tmp.copy(c);
tmp.write(pw);
return buffer.toString("UTF-8");
} catch (Exception e) {
throw new MetricsConfigException(e);
}
}
Aggregations