当前位置: 首页>>代码示例>>Java>>正文


Java Strings.repeat方法代码示例

本文整理汇总了Java中com.google.common.base.Strings.repeat方法的典型用法代码示例。如果您正苦于以下问题:Java Strings.repeat方法的具体用法?Java Strings.repeat怎么用?Java Strings.repeat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.base.Strings的用法示例。


在下文中一共展示了Strings.repeat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: constructWarningMessage

import com.google.common.base.Strings; //导入方法依赖的package包/类
private static String constructWarningMessage(Host hub) {
    String separator = Strings.repeat("*", 80);
    StringBuilder msg = new StringBuilder(separator);
    GridApiAssistant assistant = new GridApiAssistant(hub);
    HubConfiguration hubConfig = assistant.getHubConfiguration();
    int timeout = hubConfig.getTimeout();
    String hubUrl = String.format("http://%s:%s/grid/console", hub.getIpAddress(), hub.getPort());
    msg.append("\nYour Hub URL is [").append(hubUrl).append("]");
    msg.append("\n1. It is configured with [").append(timeout).append(" seconds] as timeout (via -timeout parameter.)\n");
    msg.append("This means that the server automatically kills a session that hasn't had any activity in the last ");
    msg.append(timeout).append(" seconds.");
    int cleanupCycle = hubConfig.getCleanUpCycle() / 1000;
    msg.append("\n2. It is configured with [").append(cleanupCycle).append(" seconds] as cleanup cycle ");
    msg.append("(via -cleanUpCycle parameter.)");
    msg.append("\nThis means that the hub will poll for currently running sessions every [");
    msg.append(cleanupCycle).append(" seconds] to check if there are any 'hung' sessions.");
    msg.append("\nBoth these values can cause your test session to be cleaned up and cause test failures.");
    msg.append("\nSo please ensure that you set the values for both these parameters on the grid to an appropriately higher value.");
    msg.append("\n").append(separator);
    return msg.toString();
}
 
开发者ID:RationaleEmotions,项目名称:talk2grid,代码行数:22,代码来源:RemoteWebDriverEnricher.java

示例2: testPopOnly

import com.google.common.base.Strings; //导入方法依赖的package包/类
@Test
public void testPopOnly() throws Exception {
    DiskRawQueue queue = new DiskRawQueue(temp.getRoot().toPath(), 512);

    String s = Strings.repeat("a", 512);

    for (int i = 0; i < 3; i++)
        push(queue, s);

    Buffer buffer = new Buffer();

    for (int i = 0; i < 3; i++) {
        assertThat(queue.pop(buffer)).isTrue();
        assertThat(buffer.count()).isEqualTo(512);
    }
    assertThat(queue.pop(buffer)).isFalse();
}
 
开发者ID:intelie,项目名称:disq,代码行数:18,代码来源:DiskRawQueueTest.java

示例3: testWriteBigStringExact

import com.google.common.base.Strings; //导入方法依赖的package包/类
@Test
public void testWriteBigStringExact() throws Exception {
    Buffer buffer = new Buffer();

    PrintStream stream = new PrintStream(buffer.write(12));

    String s = Strings.repeat("a", 500);
    stream.print(s);

    assertThat(buffer.count()).isEqualTo(512);
    assertThat(buffer.currentCapacity()).isEqualTo(512);

    stream.write('a');
    assertThat(buffer.count()).isEqualTo(513);
    assertThat(buffer.currentCapacity()).isEqualTo(1024);
}
 
开发者ID:intelie,项目名称:disq,代码行数:17,代码来源:BufferTest.java

示例4: testWriteBigString

import com.google.common.base.Strings; //导入方法依赖的package包/类
@Test
public void testWriteBigString() throws Exception {
    Buffer buffer = new Buffer();

    PrintStream stream = new PrintStream(buffer.write());

    String s = Strings.repeat("a", 511);
    stream.print(s);

    assertThat(buffer.currentCapacity()).isEqualTo(512);

    stream.write('a');
    stream.write('a');
    assertThat(buffer.count()).isEqualTo(513);
    assertThat(buffer.currentCapacity()).isEqualTo(1024);
    assertThat(buffer.toArray()).isEqualTo((s + "aa").getBytes());
}
 
开发者ID:intelie,项目名称:disq,代码行数:18,代码来源:BufferTest.java

示例5: render

import com.google.common.base.Strings; //导入方法依赖的package包/类
private static void render(StringBuilder sb, PropertyTree map, int level) {
	String prefix=Strings.repeat(INDENT, level);
	
	Set<String> properties = map.properties();
	properties.forEach((key) -> {
		List<Either<Object, ? extends PropertyTree>> val = map.get(key);
		sb.append(prefix).append(INDENT).append(key).append("=[\n");
		val.forEach((Either<Object, ? extends PropertyTree> v) -> {
			if (v.isLeft()) {
				sb.append(prefix).append(INDENT).append(INDENT).append(v.left()).append(",\n");
			} else {
				sb.append(prefix).append(INDENT).append(INDENT).append("{\n");
				render(sb, v.right(), level+2);
				sb.append(prefix).append(INDENT).append(INDENT).append("},\n");
			}
		});
		sb.append(prefix).append(INDENT).append("],\n");
	});
}
 
开发者ID:flapdoodle-oss,项目名称:de.flapdoodle.solid,代码行数:20,代码来源:PropertyTreePrinter.java

示例6: testDeleteAllFiles

import com.google.common.base.Strings; //导入方法依赖的package包/类
@Test
public void testDeleteAllFiles() throws Exception {
    DiskRawQueue queue = new DiskRawQueue(temp.getRoot().toPath(), 512);

    String s = Strings.repeat("a", 512);

    for (int i = 0; i < 5; i++)
        push(queue, s);

    for (int i = 0; i < 5; i++)
        assertThat(new File(temp.getRoot(), "data0" + i).length()).isEqualTo(516);

    queue.clear();

    assertBytesAndCount(queue, 0, 0);
    assertThat(temp.getRoot().list()).containsOnly("state");

    for (int i = 0; i < 5; i++)
        push(queue, s);
    for (int i = 0; i < 5; i++)
        assertThat(new File(temp.getRoot(), "data0" + i).length()).isEqualTo(516);
    assertBytesAndCount(queue, 5 * 516, 5);
}
 
开发者ID:intelie,项目名称:disq,代码行数:24,代码来源:DiskRawQueueTest.java

示例7: getProgessBar

import com.google.common.base.Strings; //导入方法依赖的package包/类
public static String getProgessBar(int current, int maximum, int total, char symbol, ChatColor completed, ChatColor uncompleted) {
    float percent = current / maximum;
    int progress = (int) (total * percent);

    return Strings.repeat("" + completed + symbol, progress)
            + Strings.repeat("" + uncompleted + symbol, total - progress);
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:8,代码来源:Util.java

示例8: testMaxBufferSize

import com.google.common.base.Strings; //导入方法依赖的package包/类
@Test
public void testMaxBufferSize() throws Exception {
    String s = Strings.repeat("a", 1001);

    PersistentQueue<Object> queue = Disq.builder()
            .setInitialBufferCapacity(100)
            .setMaxBufferCapacity(1000)
            .buildPersistentQueue();

    assertThatThrownBy(() -> queue.push(s))
            .isInstanceOf(IllegalStateException.class)
            .hasMessageContaining("Buffer overflowed")
            .hasMessageContaining("1008/1000");
}
 
开发者ID:intelie,项目名称:disq,代码行数:15,代码来源:DisqTest.java

示例9: testExpandWithoutPreserving

import com.google.common.base.Strings; //导入方法依赖的package包/类
@Test
public void testExpandWithoutPreserving() throws Exception {
    Buffer buffer = new Buffer();
    PrintStream stream = new PrintStream(buffer.write());
    String s = Strings.repeat("a", 32);
    stream.print(s);

    assertThat(buffer.buf()[0]).isEqualTo((byte) 'a');

    buffer.setCountAtLeast(100, false);

    assertThat(buffer.count()).isEqualTo(100);
    assertThat(buffer.currentCapacity()).isEqualTo(128);
    assertThat(buffer.buf()[0]).isEqualTo((byte) 0);
}
 
开发者ID:intelie,项目名称:disq,代码行数:16,代码来源:BufferTest.java

示例10: testBlockingTimeout

import com.google.common.base.Strings; //导入方法依赖的package包/类
@Test(timeout = 3000)
public void testBlockingTimeout() throws Exception {
    DiskRawQueue bq = new DiskRawQueue(temp.getRoot().toPath(), 1000, true, true, false);
    PersistentQueue<Object> queue = new PersistentQueue<>(bq, GsonSerializer.make(), 32, 1 << 16);

    String s = Strings.repeat("a", 506);

    for (int i = 0; i < 121; i++)
        assertThat(queue.blockingPush(s, 10, TimeUnit.MILLISECONDS)).isTrue();
    assertThat(queue.blockingPush(s, 10, TimeUnit.MILLISECONDS)).isFalse();

    for (int i = 0; i < 121; i++)
        assertThat(queue.blockingPop(10, TimeUnit.MILLISECONDS)).isEqualTo(s);
    assertThat(queue.blockingPop(10, TimeUnit.MILLISECONDS)).isEqualTo(null);
}
 
开发者ID:intelie,项目名称:disq,代码行数:16,代码来源:PersistentQueueTest.java

示例11: testBlockingBoth

import com.google.common.base.Strings; //导入方法依赖的package包/类
@Test(timeout = 3000)
public void testBlockingBoth() throws Throwable {
    DiskRawQueue bq = new DiskRawQueue(temp.getRoot().toPath(), 1000, true, true, false);
    PersistentQueue<Object> queue = new PersistentQueue<>(bq, GsonSerializer.make(), 32, 1 << 16);
    queue.setPopPaused(true);
    queue.setPushPaused(true);

    String s = Strings.repeat("a", 502);

    ReaderThread t2 = new ReaderThread(queue, s);
    t2.start();

    WriterThread t1 = new WriterThread(queue, s);
    t1.start();

    while (t1.getState() != Thread.State.TIMED_WAITING)
        Thread.sleep(10);
    while (t2.getState() != Thread.State.TIMED_WAITING)
        Thread.sleep(10);

    assertThat(queue.count()).isEqualTo(0);
    queue.setPushPaused(false);
    while (queue.count() < 121)
        Thread.sleep(10);

    queue.setPopPaused(false);
    while (queue.count() > 0)
        Thread.sleep(10);

    t1.waitFinish();
    t2.waitFinish();
}
 
开发者ID:intelie,项目名称:disq,代码行数:33,代码来源:PersistentQueueTest.java

示例12: testLimitByNumberOfFiles

import com.google.common.base.Strings; //导入方法依赖的package包/类
@Test
public void testLimitByNumberOfFiles() throws Exception {
    DiskRawQueue queue = new DiskRawQueue(temp.getRoot().toPath(), 512 * 121);

    String s1 = Strings.repeat("a", 508);
    for (int i = 0; i < 110; i++)
        push(queue, s1);

    queue.close();
    queue = new DiskRawQueue(temp.getRoot().toPath(), 1024 * 121);

    String s2 = Strings.repeat("a", 1020);
    for (int i = 0; i < 11; i++)
        push(queue, s2);

    assertThat(queue.files()).isEqualTo(121);
    assertThat(queue.count()).isEqualTo(121);
    assertThat(queue.bytes()).isEqualTo(512 * 110 + 1024 * 11);

    push(queue, s2);
    queue.reopen();

    assertThat(queue.files()).isEqualTo(121);
    assertThat(queue.count()).isEqualTo(121);
    assertThat(queue.bytes()).isEqualTo(512 * 109 + 1024 * 12);

    for (int i = 0; i < 109; i++)
        assertThat(pop(queue)).isEqualTo(s1);
    for (int i = 0; i < 12; i++)
        assertThat(pop(queue)).isEqualTo(s2);
    assertThat(pop(queue)).isEqualTo(null);
}
 
开发者ID:intelie,项目名称:disq,代码行数:33,代码来源:DiskRawQueueTest.java

示例13: getServers

import com.google.common.base.Strings; //导入方法依赖的package包/类
/**
 * Retrieve all servers of the given types
 * @param serverTypes list of allowed server types
 * @return
 */
private JSONArray getServers(String[] serverTypes) {
    //empty
    if (serverTypes.length == 0) {
        return new JSONArray();
    }

    final String serverTypesClause = "server_type = ?" + Strings.repeat(" OR server_type = ? ", serverTypes.length - 1);

    final String sql = "SELECT * FROM test_server WHERE active AND selectable AND (" + serverTypesClause + ")";
    final JSONArray result = new JSONArray();
    try {
        PreparedStatement ps = conn.prepareStatement(sql);
        int i = 1;
        for (String serverType : serverTypes) {
            ps.setString(i++, serverType);
        }

        ResultSet rs = ps.executeQuery();

        while (rs.next()) {
            final JSONObject obj = new JSONObject();

            obj.put("name", rs.getString("name"));
            obj.put("uuid", rs.getString("uuid"));

            result.put(obj);
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return result;
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:38,代码来源:SettingsResource.java

示例14: testPeek

import com.google.common.base.Strings; //导入方法依赖的package包/类
@Test
public void testPeek() throws Exception {
    DiskRawQueue queue = new DiskRawQueue(temp.getRoot().toPath(), 512 * 121);

    String s = Strings.repeat("a", 512);
    push(queue, s);

    assertThat(peek(queue)).isEqualTo(s);
    assertThat(peek(queue)).isEqualTo(s);

    assertThat(pop(queue)).isEqualTo(s);

    assertThat(peek(queue)).isEqualTo(null);
}
 
开发者ID:intelie,项目名称:disq,代码行数:15,代码来源:DiskRawQueueTest.java

示例15: indent

import com.google.common.base.Strings; //导入方法依赖的package包/类
private static String indent(ImmutableList<String> parentKey, int skipIndent) {
	return Strings.repeat("\t", parentKey.size()-skipIndent);
}
 
开发者ID:flapdoodle-oss,项目名称:de.flapdoodle.solid,代码行数:4,代码来源:PropertyTreeAsText.java


注:本文中的com.google.common.base.Strings.repeat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。