// Path: vertx-web-sstore-infinispan/src/main/java/io/vertx/ext/web/sstore/infinispan/InfinispanSessionStore.java
// @VertxGen
// public interface InfinispanSessionStore extends SessionStore {
// 
//   /**
//    * Create a new {@link InfinispanSessionStore} for the given configuration.
//    *
//    * @param vertx   vertx instance
//    * @param options the configuration
//    * @return the new instance
//    */
//   static InfinispanSessionStore create(Vertx vertx, JsonObject options) {
//     InfinispanSessionStoreImpl store = new InfinispanSessionStoreImpl();
//     store.init(vertx, options);
//     return store;
//   }
// 
//   /**
//    * Like {@link #create(Vertx, JsonObject)} but with a pre-configured Infinispan Client.
//    *
//    * @param vertx              vertx instance
//    * @param options            the configuration
//    * @param remoteCacheManager pre-configured Infinispan Client
//    * @return the new instance
//    */
//   @GenIgnore(PERMITTED_TYPE)
//   static InfinispanSessionStore create(Vertx vertx, JsonObject options, RemoteCacheManager remoteCacheManager) {
//     InfinispanSessionStoreImpl store = new InfinispanSessionStoreImpl();
//     store.init(vertx, options, Objects.requireNonNull(remoteCacheManager, "remoteCacheManager is required"));
//     return store;
//   }
// }


import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.handler.SessionHandlerTestBase;
import io.vertx.ext.web.sstore.infinispan.InfinispanSessionStore;
import org.junit.ClassRule;
import org.testcontainers.containers.BindMode;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
import static org.infinispan.client.hotrod.impl.ConfigurationProperties.DEFAULT_HOTROD_PORT;
/*
 * Copyright 2021 Red Hat, Inc.
 *
 * Red Hat licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package io.vertx.ext.web.sstore.infinispan.impl;



public class InfinispanSessionHandlerTest extends SessionHandlerTestBase {

  private static final String IDENTITIES_PATH = "/user-config/identities.yaml";
  private static final String USER = "foo";
  private static final String PASS = "bar";

  @ClassRule
  public static GenericContainer<?> container =
    new GenericContainer<>("infinispan/server:12.1")
      .withExposedPorts(DEFAULT_HOTROD_PORT)
      .withClasspathResourceMapping("identities.yaml", "/user-config/identities.yaml", BindMode.READ_ONLY)
      .withEnv("IDENTITIES_PATH", IDENTITIES_PATH)
      .waitingFor(new LogMessageWaitStrategy().withRegEx(".*Infinispan Server.*started in.*\\s"));

  @Override
  public void setUp() throws Exception {
    super.setUp();
    JsonObject config = new JsonObject()
      .put("servers", new JsonArray().add(new JsonObject()
        .put("host", container.getHost())
        .put("port", container.getMappedPort(DEFAULT_HOTROD_PORT))
        .put("username", USER)
        .put("password", PASS)
      ));
// Path: vertx-web-sstore-infinispan/src/main/java/io/vertx/ext/web/sstore/infinispan/InfinispanSessionStore.java
// @VertxGen
// public interface InfinispanSessionStore extends SessionStore {
// 
//   /**
//    * Create a new {@link InfinispanSessionStore} for the given configuration.
//    *
//    * @param vertx   vertx instance
//    * @param options the configuration
//    * @return the new instance
//    */
//   static InfinispanSessionStore create(Vertx vertx, JsonObject options) {
//     InfinispanSessionStoreImpl store = new InfinispanSessionStoreImpl();
//     store.init(vertx, options);
//     return store;
//   }
// 
//   /**
//    * Like {@link #create(Vertx, JsonObject)} but with a pre-configured Infinispan Client.
//    *
//    * @param vertx              vertx instance
//    * @param options            the configuration
//    * @param remoteCacheManager pre-configured Infinispan Client
//    * @return the new instance
//    */
//   @GenIgnore(PERMITTED_TYPE)
//   static InfinispanSessionStore create(Vertx vertx, JsonObject options, RemoteCacheManager remoteCacheManager) {
//     InfinispanSessionStoreImpl store = new InfinispanSessionStoreImpl();
//     store.init(vertx, options, Objects.requireNonNull(remoteCacheManager, "remoteCacheManager is required"));
//     return store;
//   }
// }


// Path: vertx-web-sstore-infinispan/src/test/java/io/vertx/ext/web/sstore/infinispan/impl/InfinispanSessionHandlerTest.java
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.handler.SessionHandlerTestBase;
import io.vertx.ext.web.sstore.infinispan.InfinispanSessionStore;
import org.junit.ClassRule;
import org.testcontainers.containers.BindMode;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
import static org.infinispan.client.hotrod.impl.ConfigurationProperties.DEFAULT_HOTROD_PORT;

/*
 * Copyright 2021 Red Hat, Inc.
 *
 * Red Hat licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package io.vertx.ext.web.sstore.infinispan.impl;



public class InfinispanSessionHandlerTest extends SessionHandlerTestBase {

  private static final String IDENTITIES_PATH = "/user-config/identities.yaml";
  private static final String USER = "foo";
  private static final String PASS = "bar";

  @ClassRule
  public static GenericContainer<?> container =
    new GenericContainer<>("infinispan/server:12.1")
      .withExposedPorts(DEFAULT_HOTROD_PORT)
      .withClasspathResourceMapping("identities.yaml", "/user-config/identities.yaml", BindMode.READ_ONLY)
      .withEnv("IDENTITIES_PATH", IDENTITIES_PATH)
      .waitingFor(new LogMessageWaitStrategy().withRegEx(".*Infinispan Server.*started in.*\\s"));

  @Override
  public void setUp() throws Exception {
    super.setUp();
    JsonObject config = new JsonObject()
      .put("servers", new JsonArray().add(new JsonObject()
        .put("host", container.getHost())
        .put("port", container.getMappedPort(DEFAULT_HOTROD_PORT))
        .put("username", USER)
        .put("password", PASS)
      ));
    store = InfinispanSessionStore.create(vertx, config);