@Override
  protected void createCacheManagers() throws Throwable {
    // todo [anistor] initializing the server-side context in this way is a hack. normally this
    // should use the protobuf metadata registry
    MarshallerRegistration.registerMarshallers(
        SerializationContextHolder.getSerializationContext());

    // initialize client-side serialization context
    MarshallerRegistration.registerMarshallers(ProtoStreamMarshaller.getSerializationContext());

    ConfigurationBuilder builder =
        hotRodCacheConfiguration(getDefaultClusteredCacheConfig(CacheMode.REPL_SYNC, false));
    builder
        .transaction()
        .indexing()
        .enable()
        .indexLocalOnly(false)
        .addProperty(
            "default.directory_provider", "ram") // todo test with  "infinispan" provider too
        .addProperty("lucene_version", "LUCENE_CURRENT");

    builder.dataContainer().valueEquivalence(AnyEquivalence.getInstance()); // TODO [anistor] hacks!

    createHotRodServers(2, builder);
  }
  @Override
  protected EmbeddedCacheManager createCacheManager() throws Exception {
    cacheManager = TestCacheManagerFactory.createCacheManager(hotRodCacheConfiguration());
    cache = cacheManager.getCache();

    hotRodServer = TestHelper.startHotRodServer(cacheManager);

    ConfigurationBuilder clientBuilder = new ConfigurationBuilder();
    clientBuilder.addServer().host("127.0.0.1").port(hotRodServer.getPort());
    clientBuilder.marshaller(new ProtoStreamMarshaller());
    remoteCacheManager = new RemoteCacheManager(clientBuilder.build());

    remoteCache = remoteCacheManager.getCache();

    // initialize client-side serialization context
    MarshallerRegistration.registerMarshallers(
        ProtoStreamMarshaller.getSerializationContext(remoteCacheManager));

    return cacheManager;
  }
  public void testIndexingWithWrapper() throws Exception {
    MarshallerRegistration.registerMarshallers(
        ProtobufMetadataManagerImpl.getSerializationContext(cacheManager));

    // Store some test data:
    ProtobufValueWrapper wrapper1 =
        new ProtobufValueWrapper(createMarshalledUser("Adrian", "Nistor"));
    ProtobufValueWrapper wrapper2 =
        new ProtobufValueWrapper(createMarshalledUser("John", "Batman"));

    cache.put(1, wrapper1); // todo how do we index if the key is a byte array?
    cache.put(2, wrapper2);

    SearchManager sm = Search.getSearchManager(cache);

    SearchIntegrator searchFactory = sm.unwrap(SearchIntegrator.class);
    assertNotNull(searchFactory.getIndexManager(ProtobufValueWrapper.class.getName()));

    Query luceneQuery =
        sm.buildQueryBuilderForClass(ProtobufValueWrapper.class)
            .get()
            .keyword()
            .onField("name")
            .ignoreFieldBridge()
            .ignoreAnalyzer()
            .matching("Adrian")
            .createQuery();

    List<ProtobufValueWrapper> list = sm.<ProtobufValueWrapper>getQuery(luceneQuery).list();
    assertEquals(1, list.size());
    ProtobufValueWrapper pvw = list.get(0);
    User unwrapped =
        (User)
            ProtobufUtil.fromWrappedByteArray(
                ProtobufMetadataManagerImpl.getSerializationContextInternal(cacheManager),
                pvw.getBinary());
    assertEquals("Adrian", unwrapped.getName());

    // an alternative approach ...

    Query luceneQuery2 =
        searchFactory
            .buildQueryBuilder()
            .forEntity(ProtobufValueWrapper.class)
            .get()
            .keyword()
            .onField("name")
            .ignoreFieldBridge()
            .ignoreAnalyzer()
            .matching("Adrian")
            .createQuery();

    List<EntityInfo> queryEntityInfos =
        searchFactory
            .createHSQuery(luceneQuery2, ProtobufValueWrapper.class)
            .projection("surname")
            .queryEntityInfos();

    assertEquals(1, queryEntityInfos.size());
    EntityInfo entityInfo = queryEntityInfos.get(0);
    assertEquals("Nistor", entityInfo.getProjection()[0]);
  }