org.junit.runners.Parameterized.Parameters#java.util.Properties源码实例Demo

下面列出了org.junit.runners.Parameterized.Parameters#java.util.Properties 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: consulo   文件: SharedProxyConfig.java
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;
}
 
源代码2 项目: gemfirexd-oss   文件: GemFireTimeSync.java
@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;
}
 
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);
}
 
@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);
	
}
 
源代码5 项目: phoenix   文件: SortMergeJoinIT.java
@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();
    }
}
 
源代码6 项目: gemfirexd-oss   文件: DistributedSQLTestBase.java
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);
}
 
源代码7 项目: mariadb-connector-j   文件: MultiTest.java
@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();
  }
}
 
源代码8 项目: conductor   文件: KafkaProducerManager.java
@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;
}
 
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();
        }
    }
}
 
源代码10 项目: consultant   文件: PropertiesUtilTest.java
@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"));
}
 
源代码11 项目: sakai   文件: BaseDbFlatStorage.java
/**
 * 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);

}
 
源代码12 项目: IGUANA   文件: TriplestoreStorageTest.java
/**
 * @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());
}
 
源代码13 项目: ethsigner   文件: Runner.java
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);
  }
}
 
源代码14 项目: sherlock   文件: CLISettings.java
/**
 * Attempt to load configuration elements from a
 * file if the path to the config file has been
 * specified in the commandline settings.
 *
 * @throws IOException if an error reading/location the file occurs
 */
public void loadFromConfig() throws IOException {
    // If the config file is defined, attempt to load settings
    // from a properties file
    if (CONFIG_FILE == null) {
        log.info("No configuration file specified, using default/passed settings");
        return;
    }
    log.info("Attempting to read config file at: {}", CONFIG_FILE);
    Field[] configFields = Utils.findFields(getClass(), Parameter.class);
    Properties props = new Properties();
    InputStream is = new FileInputStream(CONFIG_FILE);
    props.load(is);
    for (Field configField : configFields) {
        String configName = configField.getName();
        Class<?> type = configField.getType();
        String configValue = props.getProperty(configName);
        if (configValue != null && configValue.length() > 0) {
            configField.setAccessible(true);
            try {
                if (type.getName().equals("int")) {
                    configField.set(null, Integer.valueOf(configValue));
                } else if (type.getName().equals("boolean")) {
                    configField.set(null, Boolean.valueOf(configValue));
                } else {
                    configField.set(null, configValue);
                }
            } catch (IllegalAccessException | IllegalArgumentException e) {
                log.error("Could not set {} to {}: {}", configName, configValue, e.toString());
                throw new IOException(String.format(
                        "Failed to set %s to value %s",
                        configName,
                        configValue
                ));
            }
        }
    }
}
 
源代码15 项目: commons-crypto   文件: AbstractCipherStreamTest.java
protected CryptoOutputStream getCryptoOutputStream(final String transformation,
        final Properties props, final ByteArrayOutputStream baos, final byte[] key,
        final AlgorithmParameterSpec param, final boolean withChannel) throws IOException {
    if (withChannel) {
        return new CryptoOutputStream(transformation, props, Channels.newChannel(baos),
                new SecretKeySpec(key, "AES"), param);
    }
    return new CryptoOutputStream(transformation, props, baos, new SecretKeySpec(key, "AES"),
            param);
}
 
源代码16 项目: quarkus   文件: CodecEndpoint.java
public static KafkaConsumer<String, Pet> createPetConsumer() {
    Properties props = new Properties();
    props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:19092");
    props.put(ConsumerConfig.GROUP_ID_CONFIG, "pet");
    props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
    props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, PetCodec.class.getName());
    props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "true");
    props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
    KafkaConsumer<String, Pet> consumer = new KafkaConsumer<>(props);
    consumer.subscribe(Collections.singletonList("pets"));
    return consumer;
}
 
源代码17 项目: jaybird   文件: MessageLoader.java
private Properties loadProperties(String resource) throws IOException {
    Properties properties = new Properties();
    // Load from property files
    try (InputStream in = getResourceAsStream("/" + resource + ".properties")) {
        if (in != null) {
            properties.load(in);
        } else {
            log.warn("Unable to load resource; resource " + resource + " is not found");
        }
    } catch (IOException ioex) {
        log.error("Unable to load resource " + resource, ioex);
        throw ioex;
    }
    return properties;
}
 
源代码18 项目: micro-integrator   文件: TConnectionFactory.java
public static Connection createConnection(String type, Properties props) throws SQLException {
    type = type.toUpperCase();
    if (Constants.EXCEL.equals(type)) {
        return new TExcelConnection(props);
    } else if (Constants.GSPREAD.equals(type)) {
        return new TGSpreadConnection(props);
    } else if (Constants.CUSTOM.equals(type)) {
        return new TCustomConnection(props);
    } else {
        throw new SQLException("Unsupported datasource type");
    }

}
 
@Override
protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props) throws BeansException {
    super.processProperties(beanFactoryToProcess, props);
    propertyMap = new HashMap<String, String>();
    for (Object key : props.keySet()) {
        String keyStr = key.toString();
        String value = props.getProperty(keyStr);
        propertyMap.put(keyStr, value);
    }
}
 
private void strip(Properties props) 
{
    for (Enumeration<Object> keys = props.keys(); keys.hasMoreElements();) 
    {
        String key = (String) keys.nextElement();
        String val = StringUtils.trimTrailingWhitespace(props.getProperty(key));
        if (logger.isTraceEnabled()) 
        {
            logger.trace("Trimmed trailing whitespace for property " + key + " = " + val);
        }
        props.setProperty(key, val);
    }
}
 
源代码21 项目: jdk8u_jdk   文件: StartManagementAgent.java
private static void basicTests(VirtualMachine vm) throws Exception {

        // Try calling with null argument
        boolean exception = false;
        try {
            vm.startManagementAgent(null);
        } catch (NullPointerException e) {
            exception = true;
        }
        if (!exception) {
            throw new Exception("startManagementAgent(null) should throw NPE");
        }

        // Try calling with a property value with a space in it
        Properties p = new Properties();
        File f = new File("file with space");
        try (FileWriter fw = new FileWriter(f)) {
            fw.write("com.sun.management.jmxremote.port=apa");
        }
        p.put("com.sun.management.config.file", f.getAbsolutePath());
        try {
            vm.startManagementAgent(p);
        } catch(AttachOperationFailedException ex) {
            // We expect parsing of "apa" above to fail, but if the file path
            // can't be read we get a different exception message
            if (!ex.getMessage().contains("NumberFormatException: For input string: \"apa\"")) {
                throw ex;
            }
        }
    }
 
源代码22 项目: component-runtime   文件: Carpates.java
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);
    }
}
 
源代码23 项目: QuickProject   文件: XMLConfigBuilder.java
private TransactionFactory transactionManagerElement(XNode context) throws Exception {
  if (context != null) {
    String type = context.getStringAttribute("type");
    Properties props = context.getChildrenAsProperties();
    TransactionFactory factory = (TransactionFactory) resolveClass(type).newInstance();
    factory.setProperties(props);
    return factory;
  }
  throw new BuilderException("Environment declaration requires a TransactionFactory.");
}
 
@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"));
}
 
源代码25 项目: keycloak   文件: ProfileTest.java
@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();
}
 
源代码26 项目: lams   文件: TimeUtil.java
/**
 * 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);
        }
    }
}
 
源代码27 项目: flink   文件: FlinkKafkaProducer.java
private static Properties getPropertiesFromBrokerList(String brokerList) {
	String[] elements = brokerList.split(",");

	// validate the broker addresses
	for (String broker: elements) {
		NetUtils.getCorrectHostnamePort(broker);
	}

	Properties props = new Properties();
	props.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, brokerList);
	return props;
}
 
源代码28 项目: javers   文件: PropertiesUtil.java
/**
 * @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);
    }
}
 
源代码29 项目: gemfirexd-oss   文件: PerfTicketDUnit.java
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 ............");
}
 
源代码30 项目: tmxeditor8   文件: TMDatabaseImpl.java
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);
}