Search in sources :

Example 36 with ByteString

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

the class ProtoReflectionServiceTest method fileContainingExtension.

@Test
public void fileContainingExtension() throws Exception {
    ServerReflectionRequest request = ServerReflectionRequest.newBuilder().setHost(TEST_HOST).setFileContainingExtension(ExtensionRequest.newBuilder().setContainingType("grpc.reflection.testing.ThirdLevelType").setExtensionNumber(100).build()).build();
    List<ByteString> goldenResponse = Arrays.asList(ReflectionTestProto.getDescriptor().toProto().toByteString(), ReflectionTestDepthTwoProto.getDescriptor().toProto().toByteString(), ReflectionTestDepthTwoAlternateProto.getDescriptor().toProto().toByteString(), ReflectionTestDepthThreeProto.getDescriptor().toProto().toByteString());
    StreamRecorder<ServerReflectionResponse> responseObserver = StreamRecorder.create();
    StreamObserver<ServerReflectionRequest> requestObserver = stub.serverReflectionInfo(responseObserver);
    requestObserver.onNext(request);
    requestObserver.onCompleted();
    List<ByteString> response = responseObserver.firstValue().get().getFileDescriptorResponse().getFileDescriptorProtoList();
    assertEquals(goldenResponse.size(), response.size());
    assertEquals(new HashSet<ByteString>(goldenResponse), new HashSet<ByteString>(response));
}
Also used : ByteString(com.google.protobuf.ByteString) ServerReflectionRequest(io.grpc.reflection.v1alpha.ServerReflectionRequest) ServerReflectionResponse(io.grpc.reflection.v1alpha.ServerReflectionResponse) Test(org.junit.Test)

Example 37 with ByteString

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

the class ProtoReflectionServiceTest method fileContainingSymbol.

@Test
public void fileContainingSymbol() throws Exception {
    ServerReflectionRequest request = ServerReflectionRequest.newBuilder().setHost(TEST_HOST).setFileContainingSymbol("grpc.reflection.testing.ReflectableService.Method").build();
    List<ByteString> goldenResponse = Arrays.asList(ReflectionTestProto.getDescriptor().toProto().toByteString(), ReflectionTestDepthTwoProto.getDescriptor().toProto().toByteString(), ReflectionTestDepthTwoAlternateProto.getDescriptor().toProto().toByteString(), ReflectionTestDepthThreeProto.getDescriptor().toProto().toByteString());
    StreamRecorder<ServerReflectionResponse> responseObserver = StreamRecorder.create();
    StreamObserver<ServerReflectionRequest> requestObserver = stub.serverReflectionInfo(responseObserver);
    requestObserver.onNext(request);
    requestObserver.onCompleted();
    List<ByteString> response = responseObserver.firstValue().get().getFileDescriptorResponse().getFileDescriptorProtoList();
    assertEquals(goldenResponse.size(), response.size());
    assertEquals(new HashSet<ByteString>(goldenResponse), new HashSet<ByteString>(response));
}
Also used : ByteString(com.google.protobuf.ByteString) ServerReflectionRequest(io.grpc.reflection.v1alpha.ServerReflectionRequest) ServerReflectionResponse(io.grpc.reflection.v1alpha.ServerReflectionResponse) Test(org.junit.Test)

Example 38 with ByteString

use of com.google.protobuf.ByteString in project pulsar by yahoo.

the class ByteBufCodedInputStream method readBytes.

/** Read a {@code bytes} field value from the stream. */
public ByteString readBytes() throws IOException {
    final int size = readRawVarint32();
    if (size == 0) {
        return ByteString.EMPTY;
    } else {
        RecyclableHeapByteBuf heapBuf = RecyclableHeapByteBuf.get();
        if (size > heapBuf.writableBytes()) {
            heapBuf.capacity(size);
        }
        heapBuf.writeBytes(buf, size);
        ByteString res = ByteString.copyFrom(heapBuf.array(), heapBuf.arrayOffset(), heapBuf.readableBytes());
        heapBuf.recycle();
        return res;
    }
}
Also used : RecyclableHeapByteBuf(com.yahoo.pulsar.common.api.Commands.RecyclableHeapByteBuf) ByteString(com.google.protobuf.ByteString)

Example 39 with ByteString

use of com.google.protobuf.ByteString in project core-java by SpineEventEngine.

the class ChangesShould method create_byte_string_value_change.

@Test
public void create_byte_string_value_change() {
    final ByteString previousValue = ByteString.copyFromUtf8(randomUuid());
    final ByteString newValue = ByteString.copyFromUtf8(randomUuid());
    final BytesChange result = Changes.of(previousValue, newValue);
    assertEquals(previousValue, result.getPreviousValue());
    assertEquals(newValue, result.getNewValue());
}
Also used : BytesChange(io.spine.change.BytesChange) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 40 with ByteString

use of com.google.protobuf.ByteString in project PokeGOAPI-Java by Grover-c13.

the class PokemonGo method initialize.

private void initialize() throws RequestFailedException {
    if (getRequestHandler() != null) {
        getRequestHandler().exit();
    }
    requestHandler = new RequestHandler(this, client);
    getRequestHandler().sendServerRequests(ServerRequestEnvelope.create());
    playerProfile.updateProfile();
    ServerRequest downloadConfigRequest = new ServerRequest(RequestType.DOWNLOAD_REMOTE_CONFIG_VERSION, CommonRequests.getDownloadRemoteConfigVersionMessageRequest(this));
    getRequestHandler().sendServerRequests(downloadConfigRequest, true, RequestType.GET_BUDDY_WALKED, RequestType.GET_INCENSE_POKEMON);
    getAssetDigest();
    try {
        ByteString configVersionData = downloadConfigRequest.getData();
        if (PokemonMeta.checkVersion(DownloadRemoteConfigVersionResponse.parseFrom(configVersionData))) {
            DownloadItemTemplatesMessage message = CommonRequests.getDownloadItemTemplatesRequest();
            ServerRequest request = new ServerRequest(RequestType.DOWNLOAD_ITEM_TEMPLATES, message);
            PokemonMeta.update(getRequestHandler().sendServerRequests(request, true), true);
        }
    } catch (InvalidProtocolBufferException e) {
        throw new RequestFailedException(e);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    playerProfile.getProfile();
    try {
        LevelUpRewardsMessage rewardsMessage = LevelUpRewardsMessage.newBuilder().setLevel(playerProfile.getLevel()).build();
        ServerRequestEnvelope envelope = ServerRequestEnvelope.createCommons();
        ServerRequest request = envelope.add(RequestType.LEVEL_UP_REWARDS, rewardsMessage);
        getRequestHandler().sendServerRequests(envelope);
        LevelUpRewardsResponse levelUpRewardsResponse = LevelUpRewardsResponse.parseFrom(request.getData());
        if (levelUpRewardsResponse.getResult() == Result.SUCCESS) {
            inventories.getItemBag().addAwardedItems(levelUpRewardsResponse);
        }
    } catch (InvalidProtocolBufferException e) {
        throw new RequestFailedException(e);
    }
    List<LoginListener> loginListeners = getListeners(LoginListener.class);
    for (LoginListener listener : loginListeners) {
        listener.onLogin(this);
    }
    loggingIn = false;
    active = true;
    // From now one we will start to check our accounts is ready to fire requests.
    // Actually, we can receive valid responses even with this first check,
    // that mark the tutorial state into LEGAL_SCREEN.
    // Following, we are going to check if the account binded to this session
    // have an avatar, a nickname, and all the other things that are usually filled
    // on the official client BEFORE sending any requests such as the getMapObject etc.
    ArrayList<TutorialState> tutorialStates = playerProfile.getTutorialState().getTutorialStates();
    if (tutorialStates.isEmpty()) {
        playerProfile.activateAccount();
    }
    if (!tutorialStates.contains(TutorialState.AVATAR_SELECTION)) {
        playerProfile.setupAvatar();
    }
    heartbeat.start();
    if (!tutorialStates.contains(TutorialState.POKEMON_CAPTURE)) {
        playerProfile.encounterTutorialComplete();
    }
    int remainingCodenameClaims = getPlayerProfile().getPlayerData().getRemainingCodenameClaims();
    if (!tutorialStates.contains(TutorialState.NAME_SELECTION) && remainingCodenameClaims > 0) {
        playerProfile.claimCodeName();
    }
    if (!tutorialStates.contains(TutorialState.FIRST_TIME_EXPERIENCE_COMPLETE)) {
        playerProfile.firstTimeExperienceComplete();
    }
}
Also used : LevelUpRewardsMessage(POGOProtos.Networking.Requests.Messages.LevelUpRewardsMessageOuterClass.LevelUpRewardsMessage) ByteString(com.google.protobuf.ByteString) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) IOException(java.io.IOException) Point(com.pokegoapi.api.map.Point) ServerRequestEnvelope(com.pokegoapi.main.ServerRequestEnvelope) LoginListener(com.pokegoapi.api.listener.LoginListener) RequestHandler(com.pokegoapi.main.RequestHandler) RequestFailedException(com.pokegoapi.exceptions.request.RequestFailedException) DownloadItemTemplatesMessage(POGOProtos.Networking.Requests.Messages.DownloadItemTemplatesMessageOuterClass.DownloadItemTemplatesMessage) ServerRequest(com.pokegoapi.main.ServerRequest) LevelUpRewardsResponse(POGOProtos.Networking.Responses.LevelUpRewardsResponseOuterClass.LevelUpRewardsResponse) TutorialState(POGOProtos.Enums.TutorialStateOuterClass.TutorialState)

Aggregations

ByteString (com.google.protobuf.ByteString)151 Test (org.junit.Test)35 ArrayList (java.util.ArrayList)30 IOException (java.io.IOException)27 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)18 ServerRequest (com.pokegoapi.main.ServerRequest)13 RequestFailedException (com.pokegoapi.exceptions.request.RequestFailedException)10 Map (java.util.Map)10 HashMap (java.util.HashMap)9 List (java.util.List)9 AggregateResponse (org.apache.hadoop.hbase.protobuf.generated.AggregateProtos.AggregateResponse)9 BeforeTest (org.testng.annotations.BeforeTest)9 Test (org.testng.annotations.Test)9 Connection (org.apache.hadoop.hbase.client.Connection)8 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)7 Scan (org.apache.hadoop.hbase.client.Scan)7 DeleteRangeResponse (com.coreos.jetcd.api.DeleteRangeResponse)6 RangeResponse (com.coreos.jetcd.api.RangeResponse)6 RpcCallback (com.google.protobuf.RpcCallback)6 RpcController (com.google.protobuf.RpcController)6