Codota Logo
ConfigServiceImpl
Code IndexAdd Codota to your IDE (free)

How to use
ConfigServiceImpl
in
com.oculusinfo.tile.rest.config

Best Java code snippets using com.oculusinfo.tile.rest.config.ConfigServiceImpl (Showing top 9 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Dictionary d =
  • Codota Iconnew Hashtable()
  • Codota IconBundle bundle;bundle.getHeaders()
  • Codota Iconnew Properties()
  • Smart code suggestions by Codota
}
origin: unchartedsoftware/aperture-tiles

@Override
public String replaceProperties(File configFile) throws ConfigException {
  try {
    LOGGER.info("Processing configFile {}", configFile);
    Map<String, String> replacements = buildReplacements();
    String configFileContent = new String(Files.readAllBytes(Paths.get(configFile.getPath())), StandardCharsets.UTF_8);
    // Do configuration file replacements
    String replacedContent = configFileContent;
    if (replacements != null) {
      replacedContent = replaceTokens(configFileContent, replacements, PROPERTIES_FILE_REPLACEMENT_REGEX, false);
    } else {
      LOGGER.warn("No config properties found, using file as is {}", configFile.getAbsolutePath());
    }
    // Do environment variable replacements
    // Replace undefined environment variables with empty string
    // (Windows doesn't allow you to set empty environment variables - it just deletes them)
    return replaceTokens(replacedContent, System.getenv(), ENV_VAR_REPLACEMENT_REGEX, true);
  } catch (IOException e) {
    throw new ConfigException(String.format("Unable to read config file %s", configFile), e);
  }
}
origin: unchartedsoftware/aperture-tiles

@Test(expected = ConfigException.class)
public void testReplaceProperties_invalidConfigFile() throws Exception {
  File foo = new File("foo");
  _configService.replaceProperties(foo);
}
origin: unchartedsoftware/aperture-tiles

@Test
public void testReplaceTokens() {
  String text = "The ${some.animal} jumped over the ${some.object}";
  Map<String, String> replacements = new HashMap<>();
  replacements.put("some.animal", "cow");
  replacements.put("some.object", "moon");
  String replaced = _configService.replaceTokens(text, replacements, ConfigServiceImpl.PROPERTIES_FILE_REPLACEMENT_REGEX, false);
  assertEquals("The cow jumped over the moon", replaced);
}
origin: unchartedsoftware/aperture-tiles

@Test
public void testFindResourceConfig_found() throws Exception {
  File resourceConfig = _configService.findResourceConfig("test1.json");
  assertNotNull(resourceConfig);
}
origin: unchartedsoftware/aperture-tiles

@Before
public void setUp() throws Exception {
  ConfigPropertiesService configPropsService = new ConfigPropertiesServiceImpl();
  _configService = new ConfigServiceImpl( configPropsService );
}
origin: unchartedsoftware/aperture-tiles

@Test
public void testFindResourceConfig_notFound() throws Exception {
  File resourceConfig = _configService.findResourceConfig("test2.txt");
  assertNull(resourceConfig);
}
origin: unchartedsoftware/aperture-tiles

@Test(expected = ConfigException.class)
public void testReplaceProperties_invalidPathToPropertiesInEnvVar() throws Exception {
  Map<String,String> newEnv = new HashMap<>();
  newEnv.put(CONFIG_ENV_VAR, "invalid/path/to.properties");
  setEnv(newEnv);
  File configFile = new File(this.getClass().getClassLoader().getResource("config-service-unit-test.json").toURI().getPath());
  _configService.replaceProperties(configFile);
}
origin: unchartedsoftware/aperture-tiles

@Test
public void testReplaceProperties() throws Exception {
  String pathToProperties = this.getClass().getClassLoader().getResource("config-service-unit-test.properties").getPath();
  Map<String,String> newEnv = new HashMap<>();
  newEnv.put(CONFIG_ENV_VAR, pathToProperties);
  setEnv(newEnv);
  File configFile = new File(this.getClass().getClassLoader().getResource("config-service-unit-test.json").toURI().getPath());
  String replaced = _configService.replaceProperties(configFile);
  assertTrue(replaced.contains("\"foo.zookeeper.quorum\": \"bar.test.local\""));
  assertTrue(replaced.contains("\"foo.zookeeper.port\": \"2222\""));
  assertTrue(replaced.contains("\"foo.master\": \"bar.test.local:33333\""));
  assertTrue(replaced.contains("\"endpoint\": \"http://some.host/some.data/\""));
}
origin: unchartedsoftware/aperture-tiles

@Test
public void testReplaceProperties_envVarIsNull_usesDefaultReplacements() throws Exception {
  File configFile = new File(this.getClass().getClassLoader().getResource("config-service-unit-test.json").toURI().getPath());
  String replaced = _configService.replaceProperties(configFile);
  // The default properties file only has one replacement that matches a key in the test json file
  assertTrue(replaced.contains("\"endpoint\": \"http://some.endpoint/somedata\""));
  // The other keys remain templated
  assertTrue(replaced.contains("\"foo.zookeeper.quorum\": \"${foo.zookeeper.quorum}\""));
  assertTrue(replaced.contains("\"foo.zookeeper.port\": \"${foo.zookeeper.port}\""));
  assertTrue(replaced.contains("\"foo.master\": \"${foo.master}\""));
}
com.oculusinfo.tile.rest.configConfigServiceImpl

Most used methods

  • replaceTokens
  • <init>
  • buildReplacements
  • findResourceConfig
  • replaceProperties

Popular in Java

  • Reading from database using SQL prepared statement
  • requestLocationUpdates (LocationManager)
  • orElseThrow (Optional)
  • findViewById (Activity)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Path (java.nio.file)
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now