java.util.Properties Java Examples

The following examples show how to use java.util.Properties. 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: SharedProxyConfig.java    From consulo with Apache License 2.0 7 votes vote down vote up
public static boolean store(@Nonnull ProxyParameters params) {
  if (params.host != null) {
    try {
      final Properties props = new Properties();
      props.setProperty(HOST, params.host);
      props.setProperty(PORT, String.valueOf(params.port));
      if (params.login != null) {
        props.setProperty(LOGIN, params.login);
        props.setProperty(PASSWORD, new String(params.password));
      }
      ourEncryptionSupport.store(props, "Proxy Configuration", CONFIG_FILE);
      return true;
    }
    catch (Exception ignored) {
    }
  }
  else {
    FileUtil.delete(CONFIG_FILE);
  }
  return false;
}
 
Example #2
Source File: SortMergeJoinIT.java    From phoenix with Apache License 2.0 6 votes vote down vote up
@Test
public void testJoinWithDifferentNumericJoinKeyTypes() throws Exception {
    Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
    Connection conn = DriverManager.getConnection(getUrl(), props);
    String tableName1 = getTableName(conn, JOIN_ITEM_TABLE_FULL_NAME);
    String tableName4 = getTableName(conn, JOIN_ORDER_TABLE_FULL_NAME);
    String query = "SELECT /*+ USE_SORT_MERGE_JOIN*/ \"order_id\", i.name, i.price, discount2, quantity FROM " + tableName4 + " o INNER JOIN " 
        + tableName1 + " i ON o.\"item_id\" = i.\"item_id\" AND o.price = (i.price * (100 - discount2)) / 100.0 WHERE quantity < 5000";
    try {
        PreparedStatement statement = conn.prepareStatement(query);
        ResultSet rs = statement.executeQuery();
        assertTrue (rs.next());
        assertEquals(rs.getString(1), "000000000000004");
        assertEquals(rs.getString(2), "T6");
        assertEquals(rs.getInt(3), 600);
        assertEquals(rs.getInt(4), 15);
        assertEquals(rs.getInt(5), 4000);

        assertFalse(rs.next());
    } finally {
        conn.close();
    }
}
 
Example #3
Source File: EndpointListFromDirectoryProvider.java    From CostFed with GNU Affero General Public License v3.0 6 votes vote down vote up
synchronized void rebuildEndpoints() {
    endpoints.clear();
    strEndpoints.clear();
    
    File folder = new File(path);
    
    for (final File fileEntry : folder.listFiles()) {
        if (fileEntry.isDirectory()) continue;
        if (fileEntry.getName().endsWith(".temp")) continue;
        
        Properties prop = loadEndpoint(fileEntry);
        if (prop == null) continue;
        
        boolean enable = "true".equals(prop.getProperty("enable"));
        if (!enable) continue;
        
        boolean hasValidSummary = "ready".equals(prop.getProperty("summary"));
        if (!hasValidSummary) continue;
        
        String address = prop.getProperty("address");
        if (address != null) {
            strEndpoints.add(address);
        }
    }
    log.info("endpoints have been rebuilt: " + strEndpoints);
}
 
Example #4
Source File: GemFireTimeSync.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
@Override
public boolean setProperties(Properties props) {
  String str;

  super.setProperties(props);

  str=props.getProperty("clock_sync_interval");
  if (str != null) {
    clockSyncInterval = Integer.parseInt(str);
    props.remove("clock_sync_interval");
  }

  str=props.getProperty("reply_wait_interval");
  if (str != null) {
    replyWaitInterval = Integer.parseInt(str);
    props.remove("reply_wait_interval");
  }

  if (props.size() > 0) {
    // this will not normally be seen by customers, even if there are unrecognized properties, because
    // jgroups error messages aren't displayed unless the debug flag is turned on
    log.error(ExternalStrings.DEBUG, "The following GemFireTimeSync properties were not recognized: " + props);
    return false;
  }
  return true;
}
 
Example #5
Source File: BaseDbFlatStorage.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Replace any properties for this resource with the resource's current set of properties.
 * 
 * @param r
 *        The resource for which properties are to be written.
 */
public void writeProperties(final String table, final String idField, final Object id, final String extraIdField, final String extraId,
		final Properties props, final boolean deleteFirst)
{
	// if not properties table set, skip it
	if (table == null) return;
	if (props == null) return;

	// do this in a transaction
	m_sql.transact(new Runnable()
	{
		public void run()
		{
			writePropertiesTx(table, idField, id, extraIdField, extraId, props, deleteFirst);
		}
	}, "writeProperties:" + id);

}
 
Example #6
Source File: TriplestoreStorageTest.java    From IGUANA with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * @throws IOException
 */
@Test
public void metaTest() throws IOException{
	fastServerContainer = new ServerMock();
       fastServer = new ContainerServer(fastServerContainer);
       fastConnection = new SocketConnection(fastServer);
       SocketAddress address1 = new InetSocketAddress(FAST_SERVER_PORT);
       fastConnection.connect(address1);
       
       String host = "http://localhost:8023";
       TriplestoreStorage store = new TriplestoreStorage(host, host);
       Properties p = new Properties();
	p.put(COMMON.EXPERIMENT_TASK_ID_KEY, "1/1/1");
    p.setProperty(COMMON.EXPERIMENT_ID_KEY, "1/1");
    p.setProperty(COMMON.CONNECTION_ID_KEY, "virtuoso");
    p.setProperty(COMMON.SUITE_ID_KEY, "1");
    p.setProperty(COMMON.DATASET_ID_KEY, "dbpedia");
    p.put(COMMON.RECEIVE_DATA_START_KEY, "true");
    p.put(COMMON.EXTRA_META_KEY, new Properties());
    p.put(COMMON.NO_OF_QUERIES, 2);
       store.addMetaData(p);
       
       assertEquals(metaExp.trim(), fastServerContainer.getActualContent().trim());
}
 
Example #7
Source File: BaseTestCase.java    From arangodb-tinkerpop-provider with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {

	// host name and port see: arangodb.properties
	PropertiesConfiguration configuration = new PropertiesConfiguration();
	configuration.setProperty("arangodb.hosts", "127.0.0.1:8529");
	configuration.setProperty("arangodb.user", "gremlin");
	configuration.setProperty("arangodb.password", "gremlin");
	Properties arangoProperties = ConfigurationConverter.getProperties(configuration);
	
	client = new ArangoDBGraphClient(null, arangoProperties, "tinkerpop", 30000, true);
	
	client.deleteGraph(graphName);
	client.deleteCollection(vertices);
	client.deleteCollection(edges);
	
}
 
Example #8
Source File: PropertiesUtilTest.java    From consultant with Apache License 2.0 6 votes vote down vote up
@Test
public void verifyMerge() {
	Properties source = new Properties();
	Properties target = new Properties();

	source.setProperty("key-1", "some-value");
	source.setProperty("key-2", "other-value");

	target.setProperty("key-1", "some-other-value");
	target.setProperty("key-3", "new-value");

	PropertiesUtil.sync(source, target);

	assertEquals("some-value", target.getProperty("key-1"));
	assertEquals("other-value", target.getProperty("key-2"));
	assertNull(target.getProperty("key-3"));
}
 
Example #9
Source File: DistributedSQLTestBase.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public static void _startNetworkServer(String className, String name,
    int mcastPort, int netPort, String serverGroups, Properties extraProps, Boolean configureDefautHeap)
    throws Exception {
  final Class<?> c = Class.forName(className);

  // start a DataNode first.
  if (TestUtil.getFabricService().status() != FabricService.State.RUNNING) {
    _startNewServer(className, name, mcastPort, serverGroups, extraProps, configureDefautHeap);
  }

  DistributedSQLTestBase test = (DistributedSQLTestBase)c.getConstructor(
      String.class).newInstance(name);
  test.configureDefaultOffHeap = configureDefautHeap;
  
  final Properties props = new Properties();
  test.setCommonProperties(props, mcastPort, serverGroups, extraProps);
  TestUtil.startNetServer(netPort, props);
}
 
Example #10
Source File: MultiTest.java    From mariadb-connector-j with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testInsertWithLeadingConstantValue() throws Exception {
  Properties props = new Properties();
  props.setProperty("rewriteBatchedStatements", "true");
  props.setProperty("allowMultiQueries", "true");
  try (Connection tmpConnection = openNewConnection(connUri, props)) {
    PreparedStatement insertStmt =
        tmpConnection.prepareStatement(
            "INSERT INTO MultiTesttest_table (col1, col2,"
                + " col3, col4, col5) values('some value', ?, 'other value', ?, 'third value')");
    insertStmt.setString(1, "a1");
    insertStmt.setString(2, "a2");
    insertStmt.addBatch();
    insertStmt.setString(1, "b1");
    insertStmt.setString(2, "b2");
    insertStmt.addBatch();
    insertStmt.executeBatch();
  }
}
 
Example #11
Source File: Runner.java    From ethsigner with Apache License 2.0 6 votes vote down vote up
private void writePortsToFile(final HttpServerService httpService) {
  final File portsFile = new File(dataPath.toFile(), "ethsigner.ports");
  portsFile.deleteOnExit();

  final Properties properties = new Properties();
  properties.setProperty("http-jsonrpc", String.valueOf(httpService.actualPort()));

  LOG.info(
      "Writing ethsigner.ports file: {}, with contents: {}",
      portsFile.getAbsolutePath(),
      properties);
  try (final FileOutputStream fileOutputStream = new FileOutputStream(portsFile)) {
    properties.store(
        fileOutputStream,
        "This file contains the ports used by the running instance of Web3Provider. This file will be deleted after the node is shutdown.");
  } catch (final Exception e) {
    LOG.warn("Error writing ports file", e);
  }
}
 
Example #12
Source File: KafkaProducerManager.java    From conductor with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
Properties getProducerProperties(KafkaPublishTask.Input input) {

	Properties configProperties = new Properties();
	configProperties.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, input.getBootStrapServers());

	configProperties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, input.getKeySerializer());

	String requestTimeoutMs = requestTimeoutConfig;

	if (Objects.nonNull(input.getRequestTimeoutMs())) {
		requestTimeoutMs = String.valueOf(input.getRequestTimeoutMs());
	}
	
	String maxBlockMs = maxBlockMsConfig;

	if (Objects.nonNull(input.getMaxBlockMs())) {
		maxBlockMs = String.valueOf(input.getMaxBlockMs());
	}
	
	configProperties.put(ProducerConfig.REQUEST_TIMEOUT_MS_CONFIG, requestTimeoutMs);
	configProperties.put(ProducerConfig.MAX_BLOCK_MS_CONFIG, maxBlockMs);
	configProperties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, STRING_SERIALIZER);
	return configProperties;
}
 
Example #13
Source File: Chapter5.java    From Natural-Language-Processing-with-Java-Second-Edition with MIT License 6 votes vote down vote up
private static void usingStanfordPOSTagger() {
    Properties props = new Properties();
    props.put("annotators", "tokenize, ssplit, pos");
    props.put("pos.model", "C:\\Current Books in Progress\\NLP and Java\\Models\\english-caseless-left3words-distsim.tagger");
    props.put("pos.maxlen", 10);
    StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
    Annotation document = new Annotation(theSentence);
    pipeline.annotate(document);

    List<CoreMap> sentences = document.get(SentencesAnnotation.class);
    for (CoreMap sentence : sentences) {
        for (CoreLabel token : sentence.get(TokensAnnotation.class)) {
            String word = token.get(TextAnnotation.class);
            String pos = token.get(PartOfSpeechAnnotation.class);
            System.out.print(word + "/" + pos + " ");
        }
        System.out.println();

        try {
            pipeline.xmlPrint(document, System.out);
            pipeline.prettyPrint(document, System.out);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}
 
Example #14
Source File: TombstoneCreationJUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void testDestroyCreatesTombstone() throws Exception {
  String name = getName();
  Properties props = new Properties();
  props.put(DistributionConfig.LOCATORS_NAME, "");
  props.put(DistributionConfig.MCAST_PORT_NAME, "0");
  props.put(DistributionConfig.LOG_LEVEL_NAME, "config");
  GemFireCacheImpl cache = (GemFireCacheImpl)CacheFactory.create(DistributedSystem.connect(props));
  RegionFactory f = cache.createRegionFactory(RegionShortcut.REPLICATE);
  DistributedRegion region = (DistributedRegion)f.create(name);
  
  EntryEventImpl ev = EntryEventImpl.create(region,
      Operation.DESTROY, "myDestroyedKey", null, null, true, new InternalDistributedMember(InetAddress.getLocalHost(), 1234));
   VersionTag tag = VersionTag.create((InternalDistributedMember)ev.getDistributedMember());
   tag.setIsRemoteForTesting();
   tag.setEntryVersion(2);
   tag.setRegionVersion(12345);
   tag.setVersionTimeStamp(System.currentTimeMillis());
   tag.setDistributedSystemId(1);
   ev.setVersionTag(tag);
   cache.getLogger().info("destroyThread is trying to destroy the entry: " + region.getRegionEntry("myDestroyedKey"));
   region.basicDestroy(ev,
       false,
       null); // expectedOldValue not supported on
   RegionEntry entry = region.getRegionEntry("myDestroyedKey");
   Assert.assertTrue(entry != null, "expected to find a region entry for myDestroyedKey");
   Assert.assertTrue(entry.isTombstone(), "expected entry to be found and be a tombstone but it is " + entry);
   
}
 
Example #15
Source File: MemDocBundleUpdateTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testBug() throws IOException, ResourceException, InterruptedException {
  final Properties p1 = new Properties();
  p1.setProperty( "key", "value1" );

  final MemoryDocumentBundle bundle = new MemoryDocumentBundle();
  bundle.getWriteableDocumentMetaData().setBundleType( "text/plain" );
  final OutputStream outputStream = bundle.createEntry( "test.properties", "text/plain" );
  p1.store( outputStream, "run 1" );
  outputStream.close();

  final ResourceManager resourceManager = bundle.getResourceManager();
  final ResourceKey key = resourceManager.deriveKey( bundle.getBundleMainKey(), "test.properties" );
  final Resource res1 = resourceManager.create( key, null, Properties.class );
  assertEquals( p1, res1.getResource() );

  bundle.removeEntry( "test.properties" );

  final Properties p2 = new Properties();
  p2.setProperty( "key", "value2" );

  final OutputStream outputStream2 = bundle.createEntry( "test.properties", "text/plain" );
  p2.store( outputStream2, "run 2" );
  outputStream2.close();

  final Resource res2 = resourceManager.create( key, null, Properties.class );
  assertEquals( p2, res2.getResource() );
}
 
Example #16
Source File: OortConfiguration.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Write the given {@link OortConfiguration} into the file as properties.
 * 
 * @param file target file
 * @param config
 * @throws IOException
 */
public static void writeConfig(File file, OortConfiguration config) throws IOException {
	Properties properties = createProperties(config);
	Writer writer = null;
	try {
		writer = new FileWriter(file);
		properties.store(writer , null);
	} finally {
		IOUtils.closeQuietly(writer);
	}
}
 
Example #17
Source File: PasswordConverter.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
String process(final String value) {
  if ((value != null) && !"".equals(value.trim())) {
    if (value.indexOf(SEPARATOR) != -1) {
      String propertyFilePath = value.split(SEPARATOR)[0];
      String propertyKey = value.split(SEPARATOR)[1];
      if ((propertyFilePath != null) && !"".equals(propertyFilePath.trim())) {
        propertyFilePath = propertyFilePath.trim();
        final File propsFile = new File(propertyFilePath);
        if ((propsFile != null) && propsFile.exists()) {
          final Properties properties = PropertiesUtils.fromFile(propsFile);
          if ((propertyKey != null) && !"".equals(propertyKey.trim())) {
            propertyKey = propertyKey.trim();
          }
          if ((properties != null) && properties.containsKey(propertyKey)) {
            return properties.getProperty(propertyKey);
          }
        } else {
          try {
            throw new ParameterException(
                new FileNotFoundException(
                    propsFile != null
                        ? "Properties file not found at path: " + propsFile.getCanonicalPath()
                        : "No properties file specified"));
          } catch (final IOException e) {
            throw new ParameterException(e);
          }
        }
      } else {
        throw new ParameterException("No properties file path specified");
      }
    } else {
      throw new ParameterException(
          "Property File values are expected in input format <property file path>::<property key>");
    }
  } else {
    throw new ParameterException(new Exception("No properties file specified"));
  }
  return value;
}
 
Example #18
Source File: TMDatabaseImpl.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public void start() throws SQLException, ClassNotFoundException {
	String driver = dbConfig.getDriver();
	Class.forName(driver);
	String url = Utils.replaceParams(dbConfig.getDbURL(), metaData);
	Properties prop = Utils.replaceParams(dbConfig.getConfigProperty(), metaData);
	conn = DriverManager.getConnection(url, prop);
	// 在 PostgreSQL 中如果使用事务,那么在事务中创建表格会抛出异常。
	conn.setAutoCommit(false);
}
 
Example #19
Source File: PropertiesUtil.java    From javers with Apache License 2.0 5 votes vote down vote up
/**
 * @throws JaversException UNDEFINED_PROPERTY
 * @throws JaversException MALFORMED_PROPERTY
 */
public static <T extends Enum<T>> T getEnumProperty(Properties properties, String propertyKey, Class<T> enumType) {
    String enumName = getStringProperty(properties,propertyKey);
    Validate.argumentIsNotNull(enumType);

    try {
        return Enum.valueOf(enumType, enumName);
    } catch (IllegalArgumentException e) {
        throw new JaversException(MALFORMED_PROPERTY, enumName, propertyKey);
    }
}
 
Example #20
Source File: PerfTicketDUnit.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void __testuseCase4_3networkServer() throws Exception {
  getLogWriter().info("Testing with 3 n/w server ............");
  
  // start a locator
  final InetAddress localHost = SocketCreator.getLocalHost();
  final Properties locProps = new Properties();
  setCommonTestProperties(locProps);
  setCommonProperties(locProps, 0, null, null);
  locProps.remove("locators");
  netPort = AvailablePort
      .getRandomAvailablePort(AvailablePort.SOCKET);
  // also start a network server
  int locPort = TestUtil.startLocator(localHost.getHostAddress(), netPort,
      locProps);

  final Properties serverProps = new Properties();
  serverProps.setProperty("locators", localHost.getHostName() + '[' + locPort
      + ']');
  setCommonTestProperties(serverProps);
  startServerVMs(3, 0, null, serverProps);
  startNetworkServer(3, null, null);
  startNetworkServer(2, null, null);
  startNetworkServer(1, null, null);
  
  Connection conn = TestUtil.getNetConnection(netPort, null, null);
  
  Thread.sleep(2000);
  profileuseCase4Queries(conn);
  
  conn.close();
  getLogWriter().info("Done with 3 n/w server ............");
}
 
Example #21
Source File: TemplatesImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Overrides the default readObject implementation since we decided
 *  it would be cleaner not to serialize the entire tranformer
 *  factory.  [ ref bugzilla 12317 ]
 *  We need to check if the user defined class for URIResolver also
 *  implemented Serializable
 *  if yes then we need to deserialize the URIResolver
 *  Fix for bugzilla bug 22438
 */
@SuppressWarnings("unchecked")
private void  readObject(ObjectInputStream is)
  throws IOException, ClassNotFoundException
{
    SecurityManager security = System.getSecurityManager();
    if (security != null){
        String temp = SecuritySupport.getSystemProperty(DESERIALIZE_TRANSLET);
        if (temp == null || !(temp.length()==0 || temp.equalsIgnoreCase("true"))) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.DESERIALIZE_TRANSLET_ERR);
            throw new UnsupportedOperationException(err.toString());
        }
    }

    // We have to read serialized fields first.
    ObjectInputStream.GetField gf = is.readFields();
    _name = (String)gf.get("_name", null);
    _bytecodes = (byte[][])gf.get("_bytecodes", null);
    _class = (Class[])gf.get("_class", null);
    _transletIndex = gf.get("_transletIndex", -1);

    _outputProperties = (Properties)gf.get("_outputProperties", null);
    _indentNumber = gf.get("_indentNumber", 0);

    if (is.readBoolean()) {
        _uriResolver = (URIResolver) is.readObject();
    }

    _tfactory = new TransformerFactoryImpl();
}
 
Example #22
Source File: Carpates.java    From component-runtime with Apache License 2.0 5 votes vote down vote up
private static String loadComponentGav(final Path archive) {
    try (final JarFile file = new JarFile(archive.toFile());
            final InputStream stream = file.getInputStream(file.getEntry("TALEND-INF/metadata.properties"))) {
        final Properties properties = new Properties();
        properties.load(stream);
        return requireNonNull(properties.getProperty("component_coordinates"),
                "no component_coordinates in '" + archive + "'");
    } catch (final IOException e) {
        throw new IllegalStateException(e);
    }
}
 
Example #23
Source File: LongTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * java.lang.Long#getLong(java.lang.String, long)
 */
public void test_getLongLjava_lang_StringJ() {
    // Test for method java.lang.Long
    // java.lang.Long.getLong(java.lang.String, long)
    Properties tProps = new Properties();
    tProps.put("testLong", "99");
    System.setProperties(tProps);
    assertTrue("returned incorrect Long", Long.getLong("testLong", 4L)
            .equals(new Long(99)));
    assertTrue("returned incorrect default Long", Long.getLong("ff", 4L)
            .equals(new Long(4)));
}
 
Example #24
Source File: TimeUtil.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Loads a properties file that contains all kinds of time zone mappings.
 * 
 * @param exceptionInterceptor
 *            exception interceptor
 */
private static void loadTimeZoneMappings(ExceptionInterceptor exceptionInterceptor) {
    timeZoneMappings = new Properties();
    try {
        timeZoneMappings.load(TimeUtil.class.getResourceAsStream(TIME_ZONE_MAPPINGS_RESOURCE));
    } catch (IOException e) {
        throw ExceptionFactory.createException(Messages.getString("TimeUtil.LoadTimeZoneMappingError"), exceptionInterceptor);
    }
    // bridge all Time Zone ids known by Java
    for (String tz : TimeZone.getAvailableIDs()) {
        if (!timeZoneMappings.containsKey(tz)) {
            timeZoneMappings.put(tz, tz);
        }
    }
}
 
Example #25
Source File: ProcessedOffsetManager.java    From kafka-spark-consumer with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
public static void persists(JavaPairDStream<String, Iterable<Long>> partitonOffset, Properties props) {
  partitonOffset.foreachRDD(new VoidFunction<JavaPairRDD<String,Iterable<Long>>>() {
    @Override
    public void call(JavaPairRDD<String, Iterable<Long>> po) throws Exception {
      List<Tuple2<String, Iterable<Long>>> poList = po.collect();
      doPersists(poList, props);
    }
  });
}
 
Example #26
Source File: ProfileTest.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Test
public void configWithPropertiesFile() throws IOException {
    Assert.assertEquals("community", Profile.getName());
    Assert.assertFalse(Profile.isFeatureEnabled(Profile.Feature.DOCKER));
    Assert.assertTrue(Profile.isFeatureEnabled(Profile.Feature.IMPERSONATION));
    Assert.assertFalse(Profile.isFeatureEnabled(Profile.Feature.UPLOAD_SCRIPTS));

    File d = temporaryFolder.newFolder();
    File f = new File(d, "profile.properties");

    Properties p = new Properties();
    p.setProperty("profile", "preview");
    p.setProperty("feature.docker", "enabled");
    p.setProperty("feature.impersonation", "disabled");
    p.setProperty("feature.upload_scripts", "enabled");
    PrintWriter pw = new PrintWriter(f);
    p.list(pw);
    pw.close();

    System.setProperty("jboss.server.config.dir", d.getAbsolutePath());

    Profile.init();

    Assert.assertEquals("preview", Profile.getName());
    Assert.assertTrue(Profile.isFeatureEnabled(Profile.Feature.DOCKER));
    Assert.assertTrue(Profile.isFeatureEnabled(Profile.Feature.OPENSHIFT_INTEGRATION));
    Assert.assertFalse(Profile.isFeatureEnabled(Profile.Feature.IMPERSONATION));
    Assert.assertTrue(Profile.isFeatureEnabled(Profile.Feature.UPLOAD_SCRIPTS));

    System.getProperties().remove("jboss.server.config.dir");

    Profile.init();
}
 
Example #27
Source File: CuratorZookeeperCenterRepositoryTest.java    From shardingsphere with Apache License 2.0 5 votes vote down vote up
@Test
public void assertBuildCuratorClientWithOperationTimeoutMillisecondsEqualsZero() {
    final CuratorZookeeperCenterRepository customCenterRepository = new CuratorZookeeperCenterRepository();
    Properties props = new Properties();
    props.setProperty(ZookeeperPropertyKey.OPERATION_TIMEOUT_MILLISECONDS.getKey(), "0");
    CenterConfiguration configuration = new CenterConfiguration(customCenterRepository.getType(), new Properties());
    configuration.setServerLists(serverLists);
    customCenterRepository.setProps(props);
    customCenterRepository.init(configuration);
    assertThat(customCenterRepository.getProps().getProperty(ZookeeperPropertyKey.OPERATION_TIMEOUT_MILLISECONDS.getKey()), is("0"));
    customCenterRepository.persist("/test/children/build/3", "value1");
    assertThat(customCenterRepository.get("/test/children/build/3"), is("value1"));
}
 
Example #28
Source File: MethodExclusionMBeanInfoAssemblerComboTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected MBeanInfoAssembler getAssembler() throws Exception {
	MethodExclusionMBeanInfoAssembler assembler = new MethodExclusionMBeanInfoAssembler();
	Properties props = new Properties();
	props.setProperty(OBJECT_NAME, "setAge,isSuperman,setSuperman,dontExposeMe");
	assembler.setIgnoredMethodMappings(props);
	assembler.setIgnoredMethods(new String[] {"someMethod"});
	return assembler;
}
 
Example #29
Source File: TranslationDevManager.java    From olat with Apache License 2.0 5 votes vote down vote up
protected void deleteKey(Locale locale, String bundleName, String key) {
    Properties tempProp = i18nMgr.getPropertiesWithoutResolvingRecursively(locale, bundleName);
    tempProp.remove(key);
    i18nMgr.saveOrUpdateProperties(tempProp, locale, bundleName);

    checkForEmptyPropertyAndDelete(locale, bundleName);
    checkForEmptyBundleAndDelete(bundleName);
}
 
Example #30
Source File: TestPublishAndSubscribeMqttIntegration.java    From nifi with Apache License 2.0 5 votes vote down vote up
private void startServer() throws IOException {
    MQTT_server = new Server();
    final Properties configProps = new Properties();
    configProps.put(BrokerConstants.WEB_SOCKET_PORT_PROPERTY_NAME, "1884");
    configProps.setProperty(PERSISTENT_STORE_PROPERTY_NAME,"./target/moquette_store.mapdb");
    IConfig server_config = new MemoryConfig(configProps);
    MQTT_server.startServer(server_config);
}