本文整理了Java中org.infinispan.commons.util.Util.getResourceAsString()
方法的一些代码示例,展示了Util.getResourceAsString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.getResourceAsString()
方法的具体详情如下:
包路径:org.infinispan.commons.util.Util
类名称:Util
方法名:getResourceAsString
暂无
代码示例来源:origin: org.infinispan/infinispan-server-rest
@BeforeClass
public void setUp() throws Exception {
IntStream.range(0, getNumNodes()).forEach(n -> {
RestServerHelper restServer = new RestServerHelper(cacheManagers.get(n));
restServer.start(TestResourceTracker.getCurrentTestShortName());
restServers.add(restServer);
});
client = new HttpClient();
client.start();
String protoFile = Util.getResourceAsString(PROTO_FILE_NAME, getClass().getClassLoader());
registerProtobuf(PROTO_FILE_NAME, protoFile);
populateData();
}
代码示例来源:origin: org.infinispan.server/infinispan-server-testsuite
private void registerProtoOnServer1() throws Exception {
String[] fileNames = {"sample_bank_account/bank.proto"};
String[] fileContents = {Util.getResourceAsString("/sample_bank_account/bank.proto", getClass().getClassLoader())};
invoke(getJmxConnection(server1), "registerProtofiles", fileNames, fileContents);
Object errors = getAttribute(getJmxConnection(server1), "filesWithErrors");
assertNull(errors);
Object protofileNames = getAttribute(getJmxConnection(server1), "protofileNames");
assertTrue(protofileNames instanceof String[]);
assertTrue(Arrays.asList((String[]) protofileNames).contains("sample_bank_account/bank.proto"));
}
代码示例来源:origin: org.infinispan.server/infinispan-server-testsuite
@BeforeClass
public static void deploy() throws IOException {
String protoFile = Util.getResourceAsString("/sample_bank_account/bank.proto", HotRodCustomMarshallerIteratorIT.class.getClassLoader());
JavaArchive archive = ShrinkWrap.create(JavaArchive.class, FILTER_MARSHALLER_DEPLOYMENT_JAR)
// Add custom marshaller classes
.addClasses(HotRodClientException.class, UserMarshaller.class, GenderMarshaller.class, User.class, Address.class)
// Add marshaller dependencies
.add(new StringAsset(protoFile), "/sample_bank_account/bank.proto")
.add(new StringAsset("Dependencies: org.infinispan.protostream, org.infinispan.remote-query.client"), "META-INF/MANIFEST.MF")
.addClass(ServerCtxInitializer.class)
.addAsServiceProvider(ProtostreamSerializationContextInitializer.class, ServerCtxInitializer.class)
// Add custom filterConverter classes
.addClasses(CustomFilterFactory.class, CustomFilterFactory.CustomFilter.class, ParamCustomFilterFactory.class,
ParamCustomFilterFactory.ParamCustomFilter.class)
// Register custom filterConverterFactories
.addAsServiceProviderAndClasses(KeyValueFilterConverterFactory.class, ParamCustomFilterFactory.class, CustomFilterFactory.class);
File deployment = new File(System.getProperty("server1.dist"), "/standalone/deployments/" + FILTER_MARSHALLER_DEPLOYMENT_JAR);
archive.as(ZipExporter.class).exportTo(deployment, true);
}
代码示例来源:origin: org.infinispan.server/infinispan-server-testsuite
@Before
public void setUp() throws Exception {
rcmFactory = new RemoteCacheManagerFactory();
remoteCacheManagers.put(ADMIN_LOGIN, rcmFactory.createManager(getClientConfigBuilderForUser(ADMIN_LOGIN, ADMIN_PASSWD)));
remoteCacheManagers.put(WRITER_LOGIN, rcmFactory.createManager(getClientConfigBuilderForUser(WRITER_LOGIN, WRITER_PASSWD)));
remoteCacheManagers.put(READER_LOGIN, rcmFactory.createManager(getClientConfigBuilderForUser(READER_LOGIN, READER_PASSWD)));
remoteCacheManagers.put(SUPERVISOR_LOGIN, rcmFactory.createManager(getClientConfigBuilderForUser(SUPERVISOR_LOGIN, SUPERVISOR_PASSWD)));
//initialize server-side serialization context
RemoteCache<String, String> metadataCache = remoteCacheManagers.get(ADMIN_LOGIN).getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME);
String proto = Util.getResourceAsString("/sample_bank_account/bank.proto", getClass().getClassLoader());
metadataCache.put("sample_bank_account/bank.proto", proto);
assertFalse(metadataCache.containsKey(ProtobufMetadataManagerConstants.ERRORS_KEY_SUFFIX));
//initialize client-side serialization context
MarshallerRegistration.registerMarshallers(ProtoStreamMarshaller.getSerializationContext(remoteCacheManagers.get(ADMIN_LOGIN)));
MarshallerRegistration.registerMarshallers(ProtoStreamMarshaller.getSerializationContext(remoteCacheManagers.get(READER_LOGIN)));
MarshallerRegistration.registerMarshallers(ProtoStreamMarshaller.getSerializationContext(remoteCacheManagers.get(WRITER_LOGIN)));
MarshallerRegistration.registerMarshallers(ProtoStreamMarshaller.getSerializationContext(remoteCacheManagers.get(SUPERVISOR_LOGIN)));
User user = new User();
user.setId(1);
user.setName("Tom");
user.setSurname("Cat");
user.setGender(User.Gender.MALE);
user.setAccountIds(Collections.singleton(12));
remoteCacheManagers.get(ADMIN_LOGIN).getCache(TEST_CACHE_INDEXED).put(1, user);
remoteCacheManagers.get(ADMIN_LOGIN).getCache(TEST_CACHE_NOT_INDEXED).put(1, user);
}
代码示例来源:origin: org.infinispan/infinispan-server-rest
@Test
public void testCompression() throws Exception {
String payload = getResourceAsString("person.proto", getClass().getClassLoader());
putStringValueInCache("default", "k", payload);
HttpClient uncompressingClient = new HttpClient();
uncompressingClient.start();
uncompressingClient.getContentDecoderFactories().clear();
ContentResponse response = uncompressingClient
.newRequest(String.format("http://localhost:%d/rest/%s/%s", restServer().getPort(), "default", "k"))
.header(HttpHeader.ACCEPT, "text/plain")
.send();
assertThat(response).hasNoContentEncoding();
assertThat(response).hasContentLength(payload.getBytes().length);
client.getContentDecoderFactories().clear();
response = uncompressingClient
.newRequest(String.format("http://localhost:%d/rest/%s/%s", restServer().getPort(), "default", "k"))
.header(HttpHeader.ACCEPT, "text/plain")
.header(ACCEPT_ENCODING, "gzip")
.send();
assertThat(response).hasGzipContentEncoding();
assertEquals(decompress(response.getContent()), payload);
}
代码示例来源:origin: org.infinispan.server/infinispan-server-testsuite
@Before
public void setUp() throws Exception {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.addServer().host("127.0.0.1")
.marshaller(new ProtoStreamMarshaller())
.nearCache().mode(NearCacheMode.INVALIDATED).cacheNamePattern("indexed").maxEntries(10);
RemoteCacheManager remoteCacheManager = new RemoteCacheManager(builder.build());
remoteCache = remoteCacheManager.getCache("indexed");
//initialize server-side serialization context
RemoteCache<String, String> metadataCache = remoteCacheManager.getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME);
metadataCache.put("sample_bank_account/bank.proto", Util.getResourceAsString("/sample_bank_account/bank.proto", getClass().getClassLoader()));
assertFalse(metadataCache.containsKey(ProtobufMetadataManagerConstants.ERRORS_KEY_SUFFIX));
//initialize client-side serialization context
MarshallerRegistration.registerMarshallers(ProtoStreamMarshaller.getSerializationContext(remoteCacheManager));
}
代码示例来源:origin: org.infinispan.server/infinispan-server-testsuite
@Before
public void setUp() throws Exception {
rcmFactory = new RemoteCacheManagerFactory();
ConfigurationBuilder clientBuilder = new ConfigurationBuilder();
clientBuilder.addServer()
.host(getServer().getHotrodEndpoint().getInetAddress().getHostName())
.port(getServer().getHotrodEndpoint().getPort())
.marshaller(new ProtoStreamMarshaller());
remoteCacheManager = rcmFactory.createManager(clientBuilder);
remoteCache = remoteCacheManager.getCache(cacheName);
//initialize server-side serialization context
RemoteCache<String, String> metadataCache = remoteCacheManager.getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME);
metadataCache.put("sample_bank_account/bank.proto", Util.getResourceAsString("/sample_bank_account/bank.proto", getClass().getClassLoader()));
assertFalse(metadataCache.containsKey(ProtobufMetadataManagerConstants.ERRORS_KEY_SUFFIX));
//initialize client-side serialization context
MarshallerRegistration.registerMarshallers(ProtoStreamMarshaller.getSerializationContext(remoteCacheManager));
}
代码示例来源:origin: org.infinispan.server/infinispan-server-testsuite
@Test
@WithRunningServer(@RunningServer(name = "query-programmatic-search-mapping-provider"))
public void testFullTextTermRightOperandAnalyzed() throws Exception {
ConfigurationBuilder clientBuilder = new ConfigurationBuilder();
clientBuilder.addServer()
.host(server.getHotrodEndpoint().getInetAddress().getHostName())
.port(server.getHotrodEndpoint().getPort())
.marshaller(new ProtoStreamMarshaller());
remoteCacheManager = new RemoteCacheManager(clientBuilder.build());
//initialize server-side serialization context
RemoteCache<String, String> metadataCache = remoteCacheManager.getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME);
metadataCache.put("sample_bank_account/bank.proto", Util.getResourceAsString("/sample_bank_account/bank.proto", getClass().getClassLoader()));
assertFalse(metadataCache.containsKey(ProtobufMetadataManagerConstants.ERRORS_KEY_SUFFIX));
//initialize client-side serialization context
MarshallerRegistration.registerMarshallers(ProtoStreamMarshaller.getSerializationContext(remoteCacheManager));
RemoteCache<Integer, Transaction> remoteCache = remoteCacheManager.getCache();
remoteCache.clear();
remoteCache.put(1, createTransaction1());
QueryFactory qf = Search.getQueryFactory(remoteCache);
Query q = qf.create("from sample_bank_account.Transaction where longDescription:'RENT'");
List<Transaction> list = q.list();
assertNotNull(list);
assertEquals(1, list.size());
assertEquals(Transaction.class, list.get(0).getClass());
assertTransaction1(list.get(0));
}
内容来源于网络,如有侵权,请联系作者删除!