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


Java ByteString.copyFromUtf8方法代码示例

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


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

示例1: processElement

import com.google.protobuf.ByteString; //导入方法依赖的package包/类
@ProcessElement
public void processElement(ProcessContext c) {
	InputContent i = c.element();
	String jobName = c.getPipelineOptions().getJobName();
	ByteString rowkey = ByteString.copyFromUtf8(jobName + "#" + i.expectedDocumentHash); 
	ByteString value = ByteString.copyFromUtf8(i.text);
	
	Iterable<Mutation> mutations =
		ImmutableList.of(Mutation.newBuilder()
			.setSetCell(
				Mutation.SetCell.newBuilder()
					.setFamilyName(IndexerPipelineUtils.DEAD_LETTER_TABLE_ERR_CF)
					.setColumnQualifier(ByteString.copyFromUtf8("text"))
					.setValue(value)
			)
               .build());
	
	c.output(KV.of(rowkey, mutations));			
}
 
开发者ID:GoogleCloudPlatform,项目名称:dataflow-opinion-analysis,代码行数:20,代码来源:FileIndexerPipeline.java

示例2: findMissingBlobs

import com.google.protobuf.ByteString; //导入方法依赖的package包/类
@Test
public void findMissingBlobs() {
  ByteString content = ByteString.copyFromUtf8("Hello, World!");
  Iterable<Digest> digests =
      Collections.singleton(Digests.computeDigest(content));
  FindMissingBlobsRequest request = FindMissingBlobsRequest.newBuilder()
      .setInstanceName("memory")
      .addAllBlobDigests(digests)
      .build();
  ContentAddressableStorageGrpc.ContentAddressableStorageBlockingStub stub =
      ContentAddressableStorageGrpc.newBlockingStub(inProcessChannel);

  FindMissingBlobsResponse response = stub.findMissingBlobs(request);

  assertThat(response.getMissingBlobDigestsList())
      .containsExactlyElementsIn(digests);
}
 
开发者ID:bazelbuild,项目名称:bazel-buildfarm,代码行数:18,代码来源:BuildFarmServerTest.java

示例3: batchUpdateBlobs

import com.google.protobuf.ByteString; //导入方法依赖的package包/类
@Test
public void batchUpdateBlobs() {
  ByteString content = ByteString.copyFromUtf8("Hello, World!");
  Digest digest = Digests.computeDigest(content);
  BatchUpdateBlobsRequest request = BatchUpdateBlobsRequest.newBuilder()
      .setInstanceName("memory")
      .addRequests(UpdateBlobRequest.newBuilder()
          .setContentDigest(digest)
          .setData(content)
          .build())
      .build();
  ContentAddressableStorageGrpc.ContentAddressableStorageBlockingStub stub =
      ContentAddressableStorageGrpc.newBlockingStub(inProcessChannel);

  BatchUpdateBlobsResponse response = stub.batchUpdateBlobs(request);

  BatchUpdateBlobsResponse.Response expected = BatchUpdateBlobsResponse.Response.newBuilder()
      .setBlobDigest(digest)
      .setStatus(com.google.rpc.Status.newBuilder()
          .setCode(com.google.rpc.Code.OK.getNumber())
          .build())
      .build();
  assertThat(response.getResponsesList())
      .containsExactlyElementsIn(Collections.singleton(expected));
}
 
开发者ID:bazelbuild,项目名称:bazel-buildfarm,代码行数:26,代码来源:BuildFarmServerTest.java

示例4: add_peer_if_not_in_list

import com.google.protobuf.ByteString; //导入方法依赖的package包/类
@Test
public void add_peer_if_not_in_list() {
    adapter.peerList = singlePeer();
    ByteString newPeer = ByteString.copyFromUtf8("new peer");
    String peerString = adapter.findInPeersOrAdd(newPeer);

    assertEquals(peerString, "peer0");
    assertTrue(adapter.peerList.containsKey(newPeer));
}
 
开发者ID:wkmeijer,项目名称:CS4160-trustchain-android,代码行数:10,代码来源:ChainExplorerAdapterTest.java

示例5: testDe

import com.google.protobuf.ByteString; //导入方法依赖的package包/类
@Test
public void testDe() {
    String msg = "brMcxcmVDxcd1IAs1z4LsXWXrZFfV+UBo37vcxL/NUY=";
    ByteString b = ByteString.copyFromUtf8(msg);
    byte[] o = b.toByteArray();
    
    byte[] r = SecurityUtils.getInstance().DecryptMsg(o);
    byte[] a =SecurityUtils.getInstance().EncryptMsg(new String(r));
    
    //System.out.println(new String(r));
    Assert.assertArrayEquals(o, a);
}
 
开发者ID:ccfish86,项目名称:sctalk,代码行数:13,代码来源:SecurityUtilsTest.java

示例6: readSingleChunk

import com.google.protobuf.ByteString; //导入方法依赖的package包/类
@Test
public void readSingleChunk() throws IOException {
  ByteString hello = ByteString.copyFromUtf8("Hello, World");
  InputStream in = new ByteStringIteratorInputStream(
      Iterators.<ByteString>singletonIterator(hello));
  byte[] data = new byte[hello.size()];

  assertThat(in.read(data)).isEqualTo(hello.size());
  assertThat(ByteString.copyFrom(data)).isEqualTo(hello);
  assertThat(in.read()).isEqualTo(-1);
}
 
开发者ID:bazelbuild,项目名称:bazel-buildfarm,代码行数:12,代码来源:ByteStringIteratorInputStreamTest.java

示例7: readSpanningChunks

import com.google.protobuf.ByteString; //导入方法依赖的package包/类
@Test
public void readSpanningChunks() throws IOException {
  ByteString hello = ByteString.copyFromUtf8("Hello, ");
  ByteString world = ByteString.copyFromUtf8("World");
  InputStream in = new ByteStringIteratorInputStream(
      ImmutableList.<ByteString>of(hello, world).iterator());
  ByteString helloWorld = hello.concat(world);
  byte[] data = new byte[helloWorld.size()];

  assertThat(in.read(data)).isEqualTo(helloWorld.size());
  assertThat(ByteString.copyFrom(data)).isEqualTo(helloWorld);
  assertThat(in.read()).isEqualTo(-1);
}
 
开发者ID:bazelbuild,项目名称:bazel-buildfarm,代码行数:14,代码来源:ByteStringIteratorInputStreamTest.java

示例8: readSpanningChunksWithEmptyChunk

import com.google.protobuf.ByteString; //导入方法依赖的package包/类
@Test
public void readSpanningChunksWithEmptyChunk() throws IOException {
  ByteString hello = ByteString.copyFromUtf8("Hello, ");
  ByteString world = ByteString.copyFromUtf8("World");
  InputStream in = new ByteStringIteratorInputStream(
      ImmutableList.<ByteString>of(hello, ByteString.EMPTY, world).iterator());
  ByteString helloWorld = hello.concat(world);
  byte[] data = new byte[helloWorld.size()];

  assertThat(in.read(data)).isEqualTo(helloWorld.size());
  assertThat(ByteString.copyFrom(data)).isEqualTo(helloWorld);
  assertThat(in.read()).isEqualTo(-1);
}
 
开发者ID:bazelbuild,项目名称:bazel-buildfarm,代码行数:14,代码来源:ByteStringIteratorInputStreamTest.java

示例9: getADependent

import com.google.protobuf.ByteString; //导入方法依赖的package包/类
public ChartOuterClass.Chart getADependent(){
	
	  MetadataOuterClass.Metadata metadata = MetadataOuterClass.Metadata.newBuilder()
        		.setApiVersion("V1")
        		.setDescription("tiger test by helm sdk dependent")
        		.setName("tomcat")
        		.setVersion("8")
        		.build();
        
        ByteString byteString = ByteString.copyFromUtf8(
        		"apiVersion: extensions/v1beta1 \n"
        	  + "kind: Deployment\n"
        	  + "metadata:\n"
        	  + "  name: {{ template \"fullname\" . }}\n"
        	  + "  labels:\n"
        	  + "    chart: \"{{ .Chart.Name }}-{{ .Chart.Version | replace \"+\" \"_\" }}\"\n"
        	  + "spec:\n"
        	  + "  replicas: {{ .Values.replicaCount }}\n"
        	  + "  template:\n"
        	  + "    metadata:\n"
        	  + "      labels:\n"
        	  + "        app: {{ template \"fullname\" . }}\n"
        	  + "    spec:\n"
        	  + "      containers:\n"
        	  + "      - name: {{ .Chart.Name }}\n"
        	  + "        image: \"{{ .Values.image }}:{{ .Values.tag }}\"\n"
        	  + "        imagePullPolicy: {{ .Values.image.pullPolicy }}\n"
        	  + "        ports:\n"
        	  + "        - containerPort: {{ .Values.service.internalPort }}\n");
        
        TemplateOuterClass.Template template = TemplateOuterClass.Template.newBuilder()
        		.setName("templates/deployment.yaml")
        		.setData(byteString)
        		.build();
       
        
        ByteString byteString2 = ByteString.copyFromUtf8("{{/* vim: set filetype=mustache: */}}\n{{/*\nExpand the name of the chart.\n*/}}\n{{- define \"name\" -}}\n{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix \"-\" -}}\n{{- end -}}\n\n{{/*\nCreate a default fully qualified app name.\nWe truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).\n*/}}\n{{- define \"fullname\" -}}\n{{- $name := default .Chart.Name .Values.nameOverride -}}\n{{- printf \"%s-%s\" .Release.Name $name | trunc 63 | trimSuffix \"-\" -}}\n{{- end -}}\n");
        TemplateOuterClass.Template template2 = TemplateOuterClass.Template.newBuilder()
        		.setName("templates/_helpers.tpl")
        		.setData(byteString2)
        		.build();
        
        ByteString byteString3 = ByteString.copyFromUtf8(
        		"oapiVersion: v1\n"
        	  + "kind: Service\n"
        	  + "metadata:\n"
        	  + "  name: {{ template \"fullname\" . }}\n"
        	  + "  labels:\n"
        	  + "    chart: \"{{ .Chart.Name }}-{{ .Chart.Version | replace \"+\" \"_\" }}\"\n"
        	  + "spec:\n"
        	  + "  type: {{ .Values.service.type }}\n"
        	  + "  ports:\n"
        	  + "  - port: {{ .Values.service.externalPort }}\n"
        	  + "    targetPort: {{ .Values.service.internalPort }}\n"
        	  + "    nodePort: {{ .Values.service.nodePort }}\n"
        	  + "    protocol: TCP\n"
        	  + "    name: {{ .Values.service.name }}\n"
        	  + "  selector:\n"
        	  + "    app: {{ template \"fullname\" . }}\n");
        
        TemplateOuterClass.Template template3 = TemplateOuterClass.Template.newBuilder()
        		.setName("templates/service.yaml")
        		.setData(byteString3)
        		.build();
	
        ChartOuterClass.Chart cc = ChartOuterClass.Chart.newBuilder()
        		/*.setValues(config)*/
        		.setMetadata(metadata)
        		.addTemplates(template)
        		.addTemplates(template2)
        		.addTemplates(template3)
        		.build();
	
	return cc;
}
 
开发者ID:breakEval13,项目名称:Helm-SDK,代码行数:76,代码来源:HelmDependent.java


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