com.typesafe.config.ConfigFactory Java Examples

The following examples show how to use com.typesafe.config.ConfigFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MetadataServiceClientImplTest.java    From eagle with Apache License 2.0 6 votes vote down vote up
@Ignore
@Test
public void addScheduleState() throws Exception {
    ConfigFactory.invalidateCaches();
    System.setProperty("config.resource", "/test-application.conf");
    Config config = ConfigFactory.load("test-application.conf").getConfig("coordinator");
    MetadataServiceClientImpl client = new MetadataServiceClientImpl(config);

    ScheduleState ss = new ScheduleState();
    ss.setVersion("spec_version_1463764252582");

    client.addScheduleState(ss);

    client.close();

    ss.setVersion("spec_version_1464764252582");
    ZKConfig zkConfig = ZKConfigBuilder.getZKConfig(config);
    ConfigBusProducer producer = new ConfigBusProducer(zkConfig);
    Coordinator.postSchedule(client, ss, producer);
}
 
Example #2
Source File: TestImpalaMetadataTask.java    From envelope with Apache License 2.0 6 votes vote down vote up
@Test
public void testBuildKerberosAuthConnectionString() {
  System.setProperty("java.security.krb5.conf", ClassLoader.getSystemResource("krb5.conf").getPath());

  Map<String, Object> configMap = new HashMap<>();
  configMap.put(HOST_CONFIG, "testhost");
  configMap.put(QUERY_TYPE_CONFIG, "refresh");
  configMap.put(QUERY_TABLE_CONFIG, "testtable");
  configMap.put(AUTH_CONFIG, "kerberos");
  configMap.put(KEYTAB_CONFIG, "foo.kt");
  configMap.put(USER_PRINC_CONFIG, "user");
  Config config = ConfigFactory.parseMap(configMap);
  ImpalaMetadataTask metadataTask = new ImpalaMetadataTask();
  metadataTask.configure(config);

  String connectionString = metadataTask.buildConnectionString();
  assertEquals("jdbc:hive2://testhost:21050/;principal=impala/[email protected]" +
      ";auth=kerberos;kerberosAuthType=fromSubject", connectionString);
}
 
Example #3
Source File: SchedulerUtilsTest.java    From incubator-gobblin with Apache License 2.0 6 votes vote down vote up
@Test
public void testloadGenericJobConfig()
    throws ConfigurationException, IOException {
  Path jobConfigPath = new Path(this.subDir11.getAbsolutePath(), "test111.pull");
  Properties properties = new Properties();
  properties.setProperty(ConfigurationKeys.JOB_CONFIG_FILE_GENERAL_PATH_KEY, this.jobConfigDir.getAbsolutePath());
  Properties jobProps =
      SchedulerUtils.loadGenericJobConfig(properties, jobConfigPath, new Path(this.jobConfigDir.getAbsolutePath()),
          JobSpecResolver.builder(ConfigFactory.empty()).build());

  Assert.assertEquals(jobProps.stringPropertyNames().size(), 7);
  Assert.assertTrue(jobProps.containsKey(ConfigurationKeys.JOB_CONFIG_FILE_DIR_KEY) || jobProps.containsKey(
      ConfigurationKeys.JOB_CONFIG_FILE_GENERAL_PATH_KEY));
  Assert.assertTrue(jobProps.containsKey(ConfigurationKeys.JOB_CONFIG_FILE_PATH_KEY));
  Assert.assertEquals(jobProps.getProperty("k1"), "d1");
  Assert.assertEquals(jobProps.getProperty("k2"), "a2");
  Assert.assertEquals(jobProps.getProperty("k3"), "a3");
  Assert.assertEquals(jobProps.getProperty("k8"), "a8");
  Assert.assertEquals(jobProps.getProperty("k9"), "a8");
}
 
Example #4
Source File: TestInListDeriver.java    From envelope with Apache License 2.0 6 votes vote down vote up
@Test
public void testMissingField() throws Exception {
  Dataset<Row> source = createTestDataframe();

  List<String> inListLiteral = Arrays.asList("1", "2", "3");

  Map<String, Dataset<Row>> dependencies = new HashMap<>();
  dependencies.put("df1", source);

  Config config = ConfigFactory.empty()
      .withValue(InListDeriver.INLIST_STEP_CONFIG, ConfigValueFactory.fromAnyRef("df1"))
      .withValue(InListDeriver.INLIST_VALUES_CONFIG, ConfigValueFactory.fromIterable(inListLiteral));

  InListDeriver deriver = new InListDeriver();

  assertNoValidationFailures(deriver, config);
  deriver.configure(config);

  // Doesn't return anything because the IN values don't match the target column values
  List<Row> results = deriver.derive(dependencies).select("value").collectAsList();
  assertThat(results.size(), is(0));
}
 
Example #5
Source File: TestSystemTimeUpsertPlanner.java    From envelope with Apache License 2.0 6 votes vote down vote up
@Test
public void testLastUpdated() {
  Map<String, Object> configMap = Maps.newHashMap();
  configMap.put(SystemTimeUpsertPlanner.LAST_UPDATED_FIELD_NAME_CONFIG_NAME, "lastupdated");
  Config config = ConfigFactory.parseMap(configMap);

  SystemTimeUpsertPlanner planner = new SystemTimeUpsertPlanner();
  assertNoValidationFailures(planner, config);
  planner.configure(config);

  List<Tuple2<MutationType, Dataset<Row>>> planned = planner.planMutationsForSet(dataFrame);

  assertEquals(planned.size(), 1);

  Dataset<Row> plannedDF = planned.get(0)._2();

  assertEquals(plannedDF.count(), 1);

  Row plannedRow = plannedDF.collectAsList().get(0);
  assertEquals(plannedRow.length(), 2);
}
 
Example #6
Source File: RestliLimiterFactoryTest.java    From incubator-gobblin with Apache License 2.0 6 votes vote down vote up
@Test
public void testFactory() throws Exception {
  SharedResourcesBroker<SimpleScopeType> broker = SharedResourcesBrokerFactory.createDefaultTopLevelBroker(
      ConfigFactory.empty(), SimpleScopeType.GLOBAL.defaultScopeInstance());

  MyRequestSender requestSender = new MyRequestSender();

  broker.bindSharedResourceAtScope(new RedirectAwareRestClientRequestSender.Factory<>(),
      new SharedRestClientKey(RestliLimiterFactory.RESTLI_SERVICE_NAME), SimpleScopeType.GLOBAL, requestSender);
  RestliServiceBasedLimiter limiter =
      broker.getSharedResource(new RestliLimiterFactory<>(), new SharedLimiterKey("my/resource"));

  Assert.assertNotNull(limiter.acquirePermits(10));
  Assert.assertEquals(requestSender.requestList.size(), 1);

  broker.close();
}
 
Example #7
Source File: TestEnumRowRule.java    From envelope with Apache License 2.0 6 votes vote down vote up
@Test
public void testLongEnums() {
  Map<String, Object> configMap = new HashMap<>();
  configMap.put("fields", Lists.newArrayList("age"));
  configMap.put("fieldtype", "long");
  configMap.put("values", Lists.newArrayList(34L, 42L, 111L));
  Config config = ConfigFactory.parseMap(configMap);

  EnumRowRule rule = new EnumRowRule();
  assertNoValidationFailures(rule, config);
  rule.configure(config);
  rule.configureName("scorecheck");

  Row row1 = new RowWithSchema(SCHEMA, "Ian", "Ian", 34L, new BigDecimal("0.00"));
  assertTrue("Row should pass rule", rule.check(row1));

  Row row2 = new RowWithSchema(SCHEMA, "Webster", "Websta", 110L, new BigDecimal("450.10"));
  assertFalse("Row should not pass rule", rule.check(row2));
}
 
Example #8
Source File: VcapServicesStringParser.java    From ditto with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Config apply(final String systemVcapServices) {
    checkNotNull(systemVcapServices, "system VCAP services string");
    if (systemVcapServices.isEmpty()) {
        return ConfigFactory.empty();
    }

    final Config vcapServicesConfig = tryToParseString(systemVcapServices);
    final Set<Map.Entry<String, ConfigValue>> vcapServicesConfigEntries = vcapServicesConfig.entrySet();

    final Map<String, Object> result = new HashMap<>(vcapServicesConfigEntries.size());
    for (final Map.Entry<String, ConfigValue> serviceConfigEntry : vcapServicesConfigEntries) {
        result.put(serviceConfigEntry.getKey(), convertConfigListToConfigObject(serviceConfigEntry.getValue()));
    }
    return ConfigFactory.parseMap(result);
}
 
Example #9
Source File: TestHashDeriver.java    From envelope with Apache License 2.0 6 votes vote down vote up
@Test
public void testCustomNullStringHash() {
  Map<String, Dataset<Row>> dependencies = Maps.newHashMap();
  dependencies.put("dep1", testDataFrame());

  Map<String, Object> configMap = Maps.newHashMap();
  configMap.put(HashDeriver.NULL_STRING_CONFIG, "");
  Config config = ConfigFactory.parseMap(configMap);

  HashDeriver d = new HashDeriver();
  assertNoValidationFailures(d, config);
  d.configure(config);

  Dataset<Row> derived = d.derive(dependencies);

  assertEquals(1, derived.count());
  assertEquals(testDataFrame().schema().size() + 1, derived.schema().size());
  assertTrue(Lists.newArrayList(derived.schema().fieldNames()).contains(HashDeriver.DEFAULT_HASH_FIELD_NAME));
  assertEquals(
      "862ff0dc2acce97b6f8bd6c369df2668",
      derived.collectAsList().get(0).get(derived.schema().size() - 1));
}
 
Example #10
Source File: HttpDatasetDescriptorTest.java    From incubator-gobblin with Apache License 2.0 6 votes vote down vote up
@Test
public void testContains() throws IOException {
  Config config1 = ConfigFactory.empty()
      .withValue(DatasetDescriptorConfigKeys.PLATFORM_KEY, ConfigValueFactory.fromAnyRef("https"))
      .withValue(DatasetDescriptorConfigKeys.PATH_KEY, ConfigValueFactory.fromAnyRef("https://a.com/b"));
  HttpDatasetDescriptor descriptor1 = new HttpDatasetDescriptor(config1);

  // Verify that same path points to same dataset
  Config config2 = ConfigFactory.empty()
      .withValue(DatasetDescriptorConfigKeys.PLATFORM_KEY, ConfigValueFactory.fromAnyRef("https"))
      .withValue(DatasetDescriptorConfigKeys.PATH_KEY, ConfigValueFactory.fromAnyRef("https://a.com/b"));
  HttpDatasetDescriptor descriptor2 = new HttpDatasetDescriptor(config2);
  Assert.assertTrue(descriptor2.contains(descriptor1));

  // Verify that same path but different platform points to different dataset
  Config config3 = ConfigFactory.empty()
      .withValue(DatasetDescriptorConfigKeys.PLATFORM_KEY, ConfigValueFactory.fromAnyRef("http"))
      .withValue(DatasetDescriptorConfigKeys.PATH_KEY, ConfigValueFactory.fromAnyRef("https://a.com/b"));
  HttpDatasetDescriptor descriptor3 = new HttpDatasetDescriptor(config3);
  Assert.assertFalse(descriptor3.contains(descriptor1));

}
 
Example #11
Source File: TestStreamDefinitionDAOImpl.java    From Eagle with Apache License 2.0 6 votes vote down vote up
@Test
public void test() throws Exception{
       Config config = ConfigFactory.load();
	AlertStreamSchemaDAO dao = new AlertStreamSchemaDAOImpl(null, null) {
		public List<AlertStreamSchemaEntity> findAlertStreamSchemaByDataSource(String dataSource) throws Exception {
			List<AlertStreamSchemaEntity> list = new ArrayList<AlertStreamSchemaEntity>();
			String programId = "UnitTest";
			list.add(buildTestStreamDefEntity(programId, "TestStream", "Attr1"));
			list.add(buildTestStreamDefEntity(programId, "TestStream", "Attr2"));
			list.add(buildTestStreamDefEntity(programId, "TestStream", "Attr3"));
			list.add(buildTestStreamDefEntity(programId, "TestStream", "Attr4"));
			return list;
		}
	};

	StreamMetadataManager.getInstance().init(config, dao);
	Map<String, List<AlertStreamSchemaEntity>> retMap = StreamMetadataManager.getInstance().getMetadataEntitiesForAllStreams();
	Assert.assertTrue(retMap.get("TestStream").size() == 4);
	StreamMetadataManager.getInstance().reset();
}
 
Example #12
Source File: LimiterServerResourceTest.java    From incubator-gobblin with Apache License 2.0 6 votes vote down vote up
@Test
public void testMetrics() throws Exception {
  ThrottlingGuiceServletConfig guiceServletConfig = new ThrottlingGuiceServletConfig();
  guiceServletConfig.initialize(ConfigFactory.empty());
  Injector injector = guiceServletConfig.getInjector();

  LimiterServerResource limiterServer = injector.getInstance(LimiterServerResource.class);

  PermitRequest request = new PermitRequest();
  request.setPermits(10);
  request.setResource("myResource");

  limiterServer.getSync(new ComplexResourceKey<>(request, new EmptyRecord()));
  limiterServer.getSync(new ComplexResourceKey<>(request, new EmptyRecord()));
  limiterServer.getSync(new ComplexResourceKey<>(request, new EmptyRecord()));

  MetricContext metricContext = limiterServer.metricContext;
  Timer timer = metricContext.timer(LimiterServerResource.REQUEST_TIMER_NAME);

  Assert.assertEquals(timer.getCount(), 3);
}
 
Example #13
Source File: JobSpecResolverTest.java    From incubator-gobblin with Apache License 2.0 6 votes vote down vote up
@Test
public void test() throws Exception {

	Config sysConfig = ConfigFactory.empty();

	JobTemplate jobTemplate = Mockito.mock(JobTemplate.class);
	Mockito.when(jobTemplate.getResolvedConfig(Mockito.any(Config.class))).thenAnswer(i -> {
		Config userConfig = (Config) i.getArguments()[0];
		return ConfigFactory.parseMap(ImmutableMap.of("template.value", "foo")).withFallback(userConfig);
	});

	JobCatalogWithTemplates catalog = Mockito.mock(JobCatalogWithTemplates.class);
	Mockito.when(catalog.getTemplate(Mockito.eq(URI.create("my://template")))).thenReturn(jobTemplate);

	JobSpecResolver resolver = JobSpecResolver.builder(sysConfig).jobCatalog(catalog).build();
	JobSpec jobSpec = JobSpec.builder()
			.withConfig(ConfigFactory.parseMap(ImmutableMap.of("key", "value")))
			.withTemplate(URI.create("my://template")).build();
	ResolvedJobSpec resolvedJobSpec = resolver.resolveJobSpec(jobSpec);

	Assert.assertEquals(resolvedJobSpec.getOriginalJobSpec(), jobSpec);
	Assert.assertEquals(resolvedJobSpec.getConfig().entrySet().size(), 2);
	Assert.assertEquals(resolvedJobSpec.getConfig().getString("key"), "value");
	Assert.assertEquals(resolvedJobSpec.getConfig().getString("template.value"), "foo");
}
 
Example #14
Source File: StaticJobTemplateTest.java    From incubator-gobblin with Apache License 2.0 6 votes vote down vote up
@Test
public void testSecure() throws Exception {
  Map<String, Object> confMap = Maps.newHashMap();
  confMap.put("nonOverridableKey", "value1");
  confMap.put("overridableKey", "value1");
  confMap.put(StaticJobTemplate.IS_SECURE_KEY, true);
  confMap.put(StaticJobTemplate.SECURE_OVERRIDABLE_PROPERTIES_KEYS, "overridableKey, overridableKey2");

  StaticJobTemplate template = new StaticJobTemplate(URI.create("my://template"), "1", "desc", ConfigFactory.parseMap(confMap), (JobCatalogWithTemplates) null);

  Config userConfig = ConfigFactory.parseMap(ImmutableMap.of(
      "overridableKey", "override",
      "overridableKey2", "override2",
      "nonOverridableKey", "override",
      "somethingElse", "override"));
  Config resolved = template.getResolvedConfig(userConfig);

  Assert.assertEquals(resolved.entrySet().size(), 5);
  Assert.assertEquals(resolved.getString("nonOverridableKey"), "value1");
  Assert.assertEquals(resolved.getString("overridableKey"), "override");
  Assert.assertEquals(resolved.getString("overridableKey2"), "override2");
  Assert.assertFalse(resolved.hasPath("somethingElse"));

}
 
Example #15
Source File: HeliosSoloDeploymentTest.java    From helios with Apache License 2.0 5 votes vote down vote up
@Test
public void testConfigHasGoogleContainerRegistryCredentials() throws Exception {
  // generate a file that we will pretend contains GCR credentials, in order to verify that
  // HeliosSoloDeployment sets up the expected environment variables and volume binds
  // when this config value exists (and is a real file)
  final File credentialsFile = temporaryFolder.newFile("fake-credentials");
  final String credentialsPath = credentialsFile.getPath();

  final String image = "helios-test";

  final Config config = ConfigFactory.empty()
      .withValue("helios.solo.profile", ConfigValueFactory.fromAnyRef("test"))
      .withValue("helios.solo.profiles.test.image", ConfigValueFactory.fromAnyRef(image))
      .withValue("helios.solo.profiles.test.google-container-registry.credentials",
          ConfigValueFactory.fromAnyRef(credentialsPath)
      );

  buildHeliosSoloDeployment(new HeliosSoloDeployment.Builder(null, config));

  ContainerConfig soloContainerConfig = null;
  for (final ContainerConfig cc : containerConfig.getAllValues()) {
    if (cc.image().contains(image)) {
      soloContainerConfig = cc;
    }
  }

  assertNotNull("Could not find helios-solo container creation", soloContainerConfig);

  assertThat(soloContainerConfig.env(),
      hasItem("HELIOS_AGENT_OPTS=--docker-gcp-account-credentials=" + credentialsPath));

  final String credentialsParentPath = credentialsFile.getParent();
  assertThat(soloContainerConfig.hostConfig().binds(),
      hasItem(credentialsParentPath + ":" + credentialsParentPath + ":ro"));
}
 
Example #16
Source File: ConfigWithFallbackTest.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void tryToGetInstanceWithConfigWithWrongTypeAtConfigPath() {
    final Config config = ConfigFactory.parseMap(Collections.singletonMap(KNOWN_CONFIG_PATH, "bar"));

    assertThatExceptionOfType(DittoConfigError.class)
            .isThrownBy(() -> ConfigWithFallback.newInstance(config, KNOWN_CONFIG_PATH, new KnownConfigValue[0]))
            .withMessage("Failed to get nested Config at <%s>!", KNOWN_CONFIG_PATH)
            .withCauseInstanceOf(ConfigException.WrongType.class);
}
 
Example #17
Source File: RedisPersistenceStore.java    From ari-proxy with GNU Affero General Public License v3.0 5 votes vote down vote up
public static RedisPersistenceStore create() {

		final Config cfg = ConfigFactory.load().getConfig(SERVICE).getConfig(REDIS);
		final String host = cfg.getString(HOST);
		final int port = cfg.getInt(PORT);
		final int db = cfg.getInt(DB);

		return create(RedisClient.create(RedisURI.Builder
				.redis(host)
				.withPort(port)
				.withSsl(false)
				.withDatabase(db)
				.build()));
	}
 
Example #18
Source File: PersistenceActorTestBase.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
protected void setup(final Config customConfig) {
    requireNonNull(customConfig, "Consider to use ConfigFactory.empty()");
    final Config config = customConfig.withFallback(ConfigFactory.load("test"));

    actorSystem = ActorSystem.create("AkkaTestSystem", config);
    pubSubTestProbe = TestProbe.apply("mock-pubSub-mediator", actorSystem);
    pubSubMediator = pubSubTestProbe.ref();

    dittoHeadersV1 = createDittoHeadersMock(JsonSchemaVersion.V_1, "test:" + AUTH_SUBJECT);
    dittoHeadersV2 = createDittoHeadersMock(JsonSchemaVersion.V_2, "test:" + AUTH_SUBJECT);
}
 
Example #19
Source File: TokenStoreListener.java    From envelope with Apache License 2.0 5 votes vote down vote up
public synchronized static TokenStoreListener get() {
  if (INSTANCE == null) {
    LOG.trace("SparkConf: " + SparkEnv.get().conf().toDebugString());
    Config config = ConfigFactory.parseString(SparkEnv.get().conf().get(ENVELOPE_CONFIGURATION_SPARK));
    INSTANCE = new TokenStoreListener(ConfigUtils.getOrElse(config, SECURITY_PREFIX, ConfigFactory.empty()));
  }
  return INSTANCE;
}
 
Example #20
Source File: TestLoopStep.java    From envelope with Apache License 2.0 5 votes vote down vote up
@Test
public void testListIntegerValues() {
  Set<Step> steps = Sets.newHashSet();

  Map<String, Object> loopStepConfigMap = Maps.newHashMap();
  loopStepConfigMap.put(LoopStep.MODE_PROPERTY, LoopStep.MODE_PARALLEL);
  loopStepConfigMap.put(LoopStep.SOURCE_PROPERTY, LoopStep.SOURCE_LIST);
  loopStepConfigMap.put(LoopStep.LIST_PROPERTY, Lists.newArrayList(1, 10, 100));
  Config loopStepConfig = ConfigFactory.parseMap(loopStepConfigMap);
  RefactorStep loopStep = new LoopStep("loop_step");
  loopStep.configure(loopStepConfig);
  steps.add(loopStep);

  Map<String, Object> step1ConfigMap = Maps.newHashMap();
  step1ConfigMap.put(Step.DEPENDENCIES_CONFIG, Lists.newArrayList("loop_step"));
  Config step1Config = ConfigFactory.parseMap(step1ConfigMap);
  Step step1 = new BatchStep("step1");
  step1.configure(step1Config);
  steps.add(step1);

  Set<Step> unrolled = loopStep.refactor(steps);

  assertEquals(unrolled.size(), 4);

  assertEquals(StepUtils.getStepForName("loop_step", unrolled).get().getDependencyNames(), Sets.newHashSet());
  assertEquals(StepUtils.getStepForName("step1_1", unrolled).get().getDependencyNames(), Sets.newHashSet("loop_step"));
  assertEquals(StepUtils.getStepForName("step1_10", unrolled).get().getDependencyNames(), Sets.newHashSet("loop_step"));
  assertEquals(StepUtils.getStepForName("step1_100", unrolled).get().getDependencyNames(), Sets.newHashSet("loop_step"));
}
 
Example #21
Source File: OnlinePredictor.java    From ytk-learn with MIT License 5 votes vote down vote up
public OnlinePredictor(Reader configReader) throws Exception {
    config = ConfigFactory.parseReader(configReader);

    LOG.info("load config from reader!");
    String uri = config.getString("fs_scheme");
    fs = FileSystemFactory.createFileSystem(new URI(uri));
}
 
Example #22
Source File: PatternMetricFilterTest.java    From kite with Apache License 2.0 5 votes vote down vote up
@Test
public void testEmpty() throws Exception {
  String str = "{ metricFilter : {} }";
  Config config = ConfigFactory.parseString(str);
  MetricFilter filter = PatternMetricFilter.parse(new Configs(), config);
  assertNotSame(filter, MetricFilter.ALL);
  assertTrue(filter.matches("foo", new Counter()));
  assertTrue(filter.toString().length() > 0);
}
 
Example #23
Source File: MongoDbUriSupplierTest.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void extraParametersAreAppended() {
    final Config options = ConfigFactory.parseString("hello=world");
    final Config config = ConfigFactory.parseString(
            String.format("%s=\"%s\"\n%s=%s", KEY_URI, SOURCE_URI, KEY_OPTIONS, options.root().render()));
    final MongoDbUriSupplier underTest = MongoDbUriSupplier.of(config);

    final String targetUri = underTest.get();

    assertThat(targetUri).isEqualTo(SOURCE_URI + "&hello=world");
}
 
Example #24
Source File: SprinklrProfilesIT.java    From streams with Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void setup() throws Exception {
  File conf = new File(configfile);
  Assert.assertTrue(conf.exists());
  Assert.assertTrue(conf.canRead());
  Assert.assertTrue(conf.isFile());
  Config parsedConfig = ConfigFactory.parseFileAnySyntax(conf);
  StreamsConfigurator.addConfig(parsedConfig);
  config = new ComponentConfigurator<>(SprinklrConfiguration.class).detectConfiguration();
  testsconfig = StreamsConfigurator.getConfig().getConfig("org.apache.streams.sprinklr.config.SprinklrConfiguration");
}
 
Example #25
Source File: AppTest.java    From freeacs with MIT License 5 votes vote down vote up
@BeforeClass
public static void setUp() throws SQLException {
  ValueInsertHelper.insert(dataSource);
  Config baseConfig = ConfigFactory.load("application.conf");
  WebProperties properties = new WebProperties(baseConfig);
  Configuration configuration = Freemarker.initFreemarker();
  ObjectMapper objectMapper = new ObjectMapper();
  App.routes(dataSource, properties, configuration, objectMapper);
  Spark.awaitInitialization();
  seleniumTest =
      new SeleniumTest(
          "http://localhost:" + properties.getServerPort() + properties.getContextPath());
}
 
Example #26
Source File: TestTokenStoreManager.java    From envelope with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateAndInitialize() {
  Config config = ConfigUtils.configFromResource("/security/security_manager_basic.conf");
  Contexts.initialize(config, Contexts.ExecutionMode.UNIT_TEST);
  TokenStoreManager manager = new TokenStoreManager(ConfigUtils.getOrElse(config,
      APPLICATION_SECTION_PREFIX + "." + SECURITY_PREFIX, ConfigFactory.empty()));

  assertNotNull(manager);
}
 
Example #27
Source File: Configuration.java    From gsc-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static void resolveConfigFile(String fileName, File confFile) {
    if (confFile.exists()) {
        config = ConfigFactory.parseFile(confFile);
    } else if (Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName)
            != null) {
        config = ConfigFactory.load(fileName);
    } else {
        throw new IllegalArgumentException(
                "Configuration path is required! No Such file " + fileName);
    }
}
 
Example #28
Source File: KickTest.java    From freeacs with MIT License 5 votes vote down vote up
@Test
public void testPublicIpCheckDisabled() throws MalformedURLException {
  // When:
  Properties properties =
      new Properties(
          ConfigFactory.empty()
              .withValue("kick.check-public-ip", ConfigValueFactory.fromAnyRef(false)));
  String ip = "http://192.168.0.1";
  // When:
  boolean isPublic = new Kick().checkIfPublicIP(ip, properties);
  // Then:
  assertTrue(isPublic);
}
 
Example #29
Source File: GrpcServer.java    From xio with Apache License 2.0 5 votes vote down vote up
private void start(int port) throws IOException {
  server =
      NettyServerBuilder.forPort(port)
          .sslContext(
              SslContextFactory.buildServerContext(
                  TlsConfig.builderFrom(
                          ConfigFactory.load().getConfig("xio.testServer.settings.tls"))
                      .build()))
          .addService(new GreeterImpl())
          .build()
          .start();
}
 
Example #30
Source File: GobblinClusterKillTest.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
@BeforeMethod
public void setUp() throws Exception {
  // Use a random ZK port
  _testingZKServer = new TestingServer(-1);
  LOG.info("Testing ZK Server listening on: " + _testingZKServer.getConnectString());

  URL url = GobblinClusterKillTest.class.getClassLoader().getResource(
      GobblinClusterKillTest.class.getSimpleName() + ".conf");
  Assert.assertNotNull(url, "Could not find resource " + url);

  _config = ConfigFactory.parseURL(url)
      .withValue("gobblin.cluster.zk.connection.string",
                 ConfigValueFactory.fromAnyRef(_testingZKServer.getConnectString()))
      .withValue("gobblin.cluster.jobconf.fullyQualifiedPath",
          ConfigValueFactory.fromAnyRef("/tmp/gobblinClusterKillTest/job-conf"))
      .resolve();

  String zkConnectionString = _config.getString(GobblinClusterConfigurationKeys.ZK_CONNECTION_STRING_KEY);
  HelixUtils.createGobblinHelixCluster(zkConnectionString,
      _config.getString(GobblinClusterConfigurationKeys.HELIX_CLUSTER_NAME_KEY));

  setupTestDir();

  _clusterManagers = new GobblinClusterManager[NUM_MANAGERS];
  _clusterWorkers = new GobblinTaskRunner[NUM_WORKERS];
  _workerStartThreads = new Thread[NUM_WORKERS];

  for (int i = 0; i < NUM_MANAGERS; i++) {
    setupManager(i);
  }

  for (int i = 0; i < NUM_WORKERS; i++) {
    setupWorker(i);
  }
}