Search in sources :

Example 11 with InvalidProtocolBufferException

use of com.google.protobuf.InvalidProtocolBufferException in project j2objc by google.

the class CompatibilityTest method testMergeDelimitedFromInvalidProtocolBufferException.

public void testMergeDelimitedFromInvalidProtocolBufferException() throws Exception {
    try {
        ByteArrayInputStream in = new ByteArrayInputStream(new byte[] { 0x03, 0x01, 0x02 });
        TypicalData.Builder builder = TypicalData.newBuilder();
        builder.mergeDelimitedFrom(in, ExtensionRegistry.getEmptyRegistry());
        builder.build();
        fail("Expected InvalidProtocolBufferException to be thrown.");
    } catch (InvalidProtocolBufferException e) {
    // Expected
    }
}
Also used : TypicalData(protos.TypicalData) ByteArrayInputStream(java.io.ByteArrayInputStream) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException)

Example 12 with InvalidProtocolBufferException

use of com.google.protobuf.InvalidProtocolBufferException in project j2objc by google.

the class CompatibilityTest method testParseFromInvalidProtocolBufferException.

public void testParseFromInvalidProtocolBufferException() throws Exception {
    try {
        @SuppressWarnings("unused") TypicalData output = TypicalData.parseFrom(new byte[] { 0x08 });
        fail("Expected InvalidProtocolBufferException to be thrown.");
    } catch (InvalidProtocolBufferException e) {
    // Expected
    }
}
Also used : TypicalData(protos.TypicalData) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException)

Example 13 with InvalidProtocolBufferException

use of com.google.protobuf.InvalidProtocolBufferException in project j2objc by google.

the class CompatibilityTest method testParseDelimitedFromInvalidProtocolBufferException.

public void testParseDelimitedFromInvalidProtocolBufferException() throws Exception {
    try {
        ByteArrayInputStream in = new ByteArrayInputStream(new byte[] { 0x03, 0x01, 0x02 });
        @SuppressWarnings("unused") TypicalData output = TypicalData.parseDelimitedFrom(in);
        fail("Expected InvalidProtocolBufferException to be thrown.");
    } catch (InvalidProtocolBufferException e) {
    // Expected
    }
}
Also used : TypicalData(protos.TypicalData) ByteArrayInputStream(java.io.ByteArrayInputStream) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException)

Example 14 with InvalidProtocolBufferException

use of com.google.protobuf.InvalidProtocolBufferException in project j2objc by google.

the class CompatibilityTest method testMergeFromInvalidProtocolBufferException.

public void testMergeFromInvalidProtocolBufferException() throws Exception {
    try {
        ByteArrayInputStream in = new ByteArrayInputStream(new byte[] { 0x00 });
        @SuppressWarnings("unused") TypicalData output = TypicalData.newBuilder().mergeFrom(in, ExtensionRegistry.getEmptyRegistry()).build();
        fail("Expected InvalidProtocolBufferException to be thrown.");
    } catch (InvalidProtocolBufferException e) {
    // Expected
    }
}
Also used : TypicalData(protos.TypicalData) ByteArrayInputStream(java.io.ByteArrayInputStream) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException)

Example 15 with InvalidProtocolBufferException

use of com.google.protobuf.InvalidProtocolBufferException in project grpc-java by grpc.

the class ProtoLiteUtilsTest method parseInvalid.

@Test
public void parseInvalid() throws Exception {
    InputStream is = new ByteArrayInputStream(new byte[] { -127 });
    try {
        marshaller.parse(is);
        fail("Expected exception");
    } catch (StatusRuntimeException ex) {
        assertEquals(Status.Code.INTERNAL, ex.getStatus().getCode());
        assertNotNull(((InvalidProtocolBufferException) ex.getCause()).getUnfinishedMessage());
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) StatusRuntimeException(io.grpc.StatusRuntimeException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) Test(org.junit.Test)

Aggregations

InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)87 ServerRequest (com.pokegoapi.main.ServerRequest)42 RequestFailedException (com.pokegoapi.exceptions.request.RequestFailedException)37 ByteString (com.google.protobuf.ByteString)21 IOException (java.io.IOException)12 CodedInputStream (com.google.protobuf.CodedInputStream)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 TypicalData (protos.TypicalData)4 GetPlayerMessage (POGOProtos.Networking.Requests.Messages.GetPlayerMessageOuterClass.GetPlayerMessage)3 Item (com.pokegoapi.api.inventory.Item)3 ItemBag (com.pokegoapi.api.inventory.ItemBag)3 TutorialListener (com.pokegoapi.api.listener.TutorialListener)3 BytesWritable (org.apache.hadoop.io.BytesWritable)3 Text (org.apache.hadoop.io.Text)3 FortDeployPokemonMessage (POGOProtos.Networking.Requests.Messages.FortDeployPokemonMessageOuterClass.FortDeployPokemonMessage)2 LevelUpRewardsMessage (POGOProtos.Networking.Requests.Messages.LevelUpRewardsMessageOuterClass.LevelUpRewardsMessage)2 ReleasePokemonMessage (POGOProtos.Networking.Requests.Messages.ReleasePokemonMessageOuterClass.ReleasePokemonMessage)2 UseItemEncounterMessage (POGOProtos.Networking.Requests.Messages.UseItemEncounterMessageOuterClass.UseItemEncounterMessage)2 LevelUpRewardsResponse (POGOProtos.Networking.Responses.LevelUpRewardsResponseOuterClass.LevelUpRewardsResponse)2 UseItemEncounterResponse (POGOProtos.Networking.Responses.UseItemEncounterResponseOuterClass.UseItemEncounterResponse)2