com.google.protobuf.TextFormat.ParseException Java Examples
The following examples show how to use
com.google.protobuf.TextFormat.ParseException.
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: AdminServiceTest.java From kafka-pubsub-emulator with Apache License 2.0 | 6 votes |
@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())); }
Example #2
Source File: ProtoAssertTestBase.java From curiostack with MIT License | 5 votes |
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); } }
Example #3
Source File: ProtoAssertTestBase.java From curiostack with MIT License | 5 votes |
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); } }
Example #4
Source File: TestConfig.java From api-compiler with Apache License 2.0 | 5 votes |
/** 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(); }
Example #5
Source File: JsonKeyFinder.java From attic-apex-malhar with Apache License 2.0 | 5 votes |
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; }
Example #6
Source File: EventSendIT.java From esj with GNU Lesser General Public License v3.0 | 5 votes |
@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); }
Example #7
Source File: Writer.java From esj with GNU Lesser General Public License v3.0 | 5 votes |
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); }
Example #8
Source File: PlatformUtils.java From bazel with Apache License 2.0 | 4 votes |
@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(); }
Example #9
Source File: CppActionConfigs.java From bazel with Apache License 2.0 | 4 votes |
private static CToolchain.ActionConfig getActionConfig(String protoText) throws ParseException { CToolchain.ActionConfig.Builder actionConfig = CToolchain.ActionConfig.newBuilder(); TextFormat.merge(protoText, actionConfig); return actionConfig.build(); }
Example #10
Source File: CppActionConfigs.java From bazel with Apache License 2.0 | 4 votes |
private static CToolchain.Feature getFeature(String protoText) throws ParseException { CToolchain.Feature.Builder feature = CToolchain.Feature.newBuilder(); TextFormat.merge(protoText, feature); return feature.build(); }
Example #11
Source File: JsonKeyFinder.java From attic-apex-malhar with Apache License 2.0 | 4 votes |
public boolean endObjectEntry() throws ParseException, IOException { return true; }
Example #12
Source File: JsonKeyFinder.java From attic-apex-malhar with Apache License 2.0 | 4 votes |
public boolean endObject() throws ParseException, IOException { return true; }
Example #13
Source File: JsonKeyFinder.java From attic-apex-malhar with Apache License 2.0 | 4 votes |
public boolean endArray() throws ParseException, IOException { return false; }
Example #14
Source File: JsonKeyFinder.java From attic-apex-malhar with Apache License 2.0 | 4 votes |
public boolean startObjectEntry(String key) throws ParseException, IOException { this.key = key; return true; }
Example #15
Source File: JsonKeyFinder.java From attic-apex-malhar with Apache License 2.0 | 4 votes |
public boolean startObject() throws ParseException, IOException { return true; }
Example #16
Source File: JsonKeyFinder.java From attic-apex-malhar with Apache License 2.0 | 4 votes |
public boolean startArray() throws ParseException, IOException { return true; }
Example #17
Source File: JsonKeyFinder.java From attic-apex-malhar with Apache License 2.0 | 4 votes |
public void endJSON() throws ParseException, IOException { end = true; }
Example #18
Source File: JsonKeyFinder.java From attic-apex-malhar with Apache License 2.0 | 4 votes |
public void startJSON() throws ParseException, IOException { found = false; end = false; }