类com.google.protobuf.TextFormat.ParseException源码实例Demo

下面列出了怎么用com.google.protobuf.TextFormat.ParseException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: kafka-pubsub-emulator   文件: AdminServiceTest.java
@Test
public void statistics() throws ParseException {
  when(statisticsManager.getPublishInformationByTopic())
      .thenReturn(
          ImmutableMap.of(
              TestHelpers.PROJECT1_TOPIC1,
              givenStatisticsInformation(1, 10L, 55L, 500L, 59L, 19L, 10L, 11L, 1L, 91L, 5L),
              TestHelpers.PROJECT1_TOPIC2,
              givenStatisticsInformation(0, 90L, 90L),
              TestHelpers.PROJECT2_TOPIC1,
              givenStatisticsInformation(1, 10L, 55L, 500L, 59L, 19L, 10L, 11L, 1L, 91L, 5L),
              TestHelpers.PROJECT2_TOPIC2,
              givenStatisticsInformation(0, 90L, 90L)));
  when(statisticsManager.getSubscriberInformationByTopic())
      .thenReturn(
          new ImmutableMap.Builder<String, StatisticsInformation>()
              .put(TestHelpers.PROJECT1_TOPIC1, givenStatisticsInformation(0, 200L, 50L, 100L))
              .put(TestHelpers.PROJECT1_TOPIC2, new StatisticsInformation())
              .put(TestHelpers.PROJECT2_TOPIC1, givenStatisticsInformation(0, 200L, 50L, 100L))
              .put(TestHelpers.PROJECT2_TOPIC2, new StatisticsInformation())
              .build());

  StatisticsResponse statisticsResponse =
      blockingStub.statistics(StatisticsRequest.newBuilder().build());
  assertThat(statisticsResponse, Matchers.equalTo(getExpectedResponse()));
}
 
源代码2 项目: curiostack   文件: ProtoAssertTestBase.java
protected Message parse(String textProto) {
  try {
    Message.Builder builder = defaultInstance.toBuilder();
    PARSER.merge(textProto, builder);
    return builder.build();
  } catch (ParseException e) {
    throw new RuntimeException(e);
  }
}
 
源代码3 项目: curiostack   文件: ProtoAssertTestBase.java
protected final Message parsePartial(String textProto) {
  try {
    Message.Builder builder = defaultInstance.toBuilder();
    PARSER.merge(textProto, builder);
    return builder.buildPartial();
  } catch (ParseException e) {
    throw new RuntimeException(e);
  }
}
 
源代码4 项目: api-compiler   文件: TestConfig.java
/** Parses the config file, in proto text format, and returns it. */
public Service getApiProtoConfig(String configFileName) throws ParseException {
  String content = readTestData(configFileName);
  Service.Builder builder = Service.newBuilder();
  TextFormat.merge(content, builder);
  return builder.build();
}
 
源代码5 项目: attic-apex-malhar   文件: JsonKeyFinder.java
public boolean primitive(Object value) throws ParseException, IOException
{
  if (getMatchKeyList().contains(key)) {
    found = true;
    this.value = value;
    keyValMap.put(key, value);
    key = null;
    keyCount++;
    return false;
  }
  return true;
}
 
源代码6 项目: esj   文件: Writer.java
public void writeMultipleEvents() throws Exception, ParseException {
    final int TOTAL_WRITES = 100000;
    final long startTime = System.currentTimeMillis();
    successes = 0;
    fails = 0;

    for (int z = 0; z < TOTAL_WRITES; z++) {
        es.appendToStream(STREAM_NAME, new ResponseReceiver() {

            @Override
            public void onResponseReturn(Message msg) {
                // log.debug("Response returned="+i);
                successes++;
                if ((successes + fails) == (TOTAL_WRITES)) {
                    processing.release();
                }
            }

            @Override
            public void onErrorReturn(Exception ex) {
                fails++;
                if ((successes + fails) == TOTAL_WRITES) {
                    processing.release();
                }
            }
        }, generateEvents());
    }

    processing.acquire();
    long endTime = System.currentTimeMillis();
    long duration = endTime - startTime;
    log.debug("Writing finished. Number of writes={} ({} successful, {} failed), duration={}",
                    TOTAL_WRITES, successes, fails, duration);
}
 
源代码7 项目: esj   文件: EventSendIT.java
@Test
public void writeMultipleEvents() throws Exception, ParseException {
    final int TOTAL_WRITES = 100000;
    final long startTime = System.currentTimeMillis();
    successes = 0;
    fails = 0;

    for (int z = 0; z < TOTAL_WRITES; z++) {
        es.appendToStream(STREAM_NAME, new ResponseReceiver() {

            @Override
            public void onResponseReturn(Message msg) {
                // log.debug("Response returned="+i);
                successes++;
                if ((successes + fails) == (TOTAL_WRITES)) {
                    processing.release();
                }
            }

            @Override
            public void onErrorReturn(Exception ex) {
                fails++;
                if ((successes + fails) == TOTAL_WRITES) {
                    processing.release();
                }
            }
        }, generateEvents());
    }

    processing.acquire();
    long endTime = System.currentTimeMillis();
    long duration = endTime - startTime;
    log.debug("Writing finished. Number of writes={} ({} successful, {} failed), duration={}",
                    TOTAL_WRITES, successes, fails, duration);
}
 
源代码8 项目: attic-apex-malhar   文件: JsonKeyFinder.java
public void startJSON() throws ParseException, IOException
{
  found = false;
  end = false;
}
 
源代码9 项目: attic-apex-malhar   文件: JsonKeyFinder.java
public void endJSON() throws ParseException, IOException
{
  end = true;
}
 
源代码10 项目: attic-apex-malhar   文件: JsonKeyFinder.java
public boolean startArray() throws ParseException, IOException
{
  return true;
}
 
源代码11 项目: attic-apex-malhar   文件: JsonKeyFinder.java
public boolean startObject() throws ParseException, IOException
{
  return true;
}
 
源代码12 项目: attic-apex-malhar   文件: JsonKeyFinder.java
public boolean startObjectEntry(String key) throws ParseException, IOException
{
  this.key = key;
  return true;
}
 
源代码13 项目: attic-apex-malhar   文件: JsonKeyFinder.java
public boolean endArray() throws ParseException, IOException
{
  return false;
}
 
源代码14 项目: attic-apex-malhar   文件: JsonKeyFinder.java
public boolean endObject() throws ParseException, IOException
{
  return true;
}
 
源代码15 项目: attic-apex-malhar   文件: JsonKeyFinder.java
public boolean endObjectEntry() throws ParseException, IOException
{
  return true;
}
 
源代码16 项目: bazel   文件: CppActionConfigs.java
private static CToolchain.Feature getFeature(String protoText) throws ParseException {
  CToolchain.Feature.Builder feature = CToolchain.Feature.newBuilder();
  TextFormat.merge(protoText, feature);
  return feature.build();
}
 
源代码17 项目: bazel   文件: CppActionConfigs.java
private static CToolchain.ActionConfig getActionConfig(String protoText) throws ParseException {
  CToolchain.ActionConfig.Builder actionConfig = CToolchain.ActionConfig.newBuilder();
  TextFormat.merge(protoText, actionConfig);
  return actionConfig.build();
}
 
源代码18 项目: bazel   文件: PlatformUtils.java
@Nullable
public static Platform getPlatformProto(Spawn spawn, @Nullable RemoteOptions remoteOptions)
    throws UserExecException {
  SortedMap<String, String> defaultExecProperties =
      remoteOptions != null
          ? remoteOptions.getRemoteDefaultExecProperties()
          : ImmutableSortedMap.of();

  if (spawn.getExecutionPlatform() == null
      && spawn.getCombinedExecProperties().isEmpty()
      && defaultExecProperties.isEmpty()) {
    return null;
  }

  Platform.Builder platformBuilder = Platform.newBuilder();

  if (!spawn.getCombinedExecProperties().isEmpty()) {
    for (Map.Entry<String, String> entry : spawn.getCombinedExecProperties().entrySet()) {
      platformBuilder.addPropertiesBuilder().setName(entry.getKey()).setValue(entry.getValue());
    }
  } else if (spawn.getExecutionPlatform() != null
      && !Strings.isNullOrEmpty(spawn.getExecutionPlatform().remoteExecutionProperties())) {
    // Try and get the platform info from the execution properties.
    try {
      TextFormat.getParser()
          .merge(spawn.getExecutionPlatform().remoteExecutionProperties(), platformBuilder);
    } catch (ParseException e) {
      String message =
          String.format(
              "Failed to parse remote_execution_properties from platform %s",
              spawn.getExecutionPlatform().label());
      throw new UserExecException(
          e, createFailureDetail(message, Code.INVALID_REMOTE_EXECUTION_PROPERTIES));
    }
  } else {
    for (Map.Entry<String, String> property : defaultExecProperties.entrySet()) {
      platformBuilder.addProperties(
          Property.newBuilder().setName(property.getKey()).setValue(property.getValue()).build());
    }
  }

  sortPlatformProperties(platformBuilder);
  return platformBuilder.build();
}
 
 类所在包
 同包方法