Example usage for org.apache.solr.common.cloud ZkStateReader SOLR_SECURITY_CONF_PATH

List of usage examples for org.apache.solr.common.cloud ZkStateReader SOLR_SECURITY_CONF_PATH

Introduction

In this page you can find the example usage for org.apache.solr.common.cloud ZkStateReader SOLR_SECURITY_CONF_PATH.

Prototype

String SOLR_SECURITY_CONF_PATH

To view the source code for org.apache.solr.common.cloud ZkStateReader SOLR_SECURITY_CONF_PATH.

Click Source Link

Usage

From source file:org.apache.coheigea.bigdata.solr.ranger.RangerSolrCloudTest.java

License:Apache License

@BeforeClass
public static void setUp() throws Exception {

    JettyConfig.Builder jettyConfig = JettyConfig.builder();
    jettyConfig.waitForLoadingCoresToFinish(null);

    String solrConfig = new String(Files.readAllBytes(Paths.get("target/test-classes/solrcloud/solr.xml")),
            Charset.defaultCharset());
    tempDir = Files.createTempDirectory("solrcloud");
    server = new MiniSolrCloudCluster(2, tempDir, solrConfig, jettyConfig.build());

    // Insert the RangerSolrAuthorizer + BasicAuthPlugin
    try (ZkStateReader zkStateReader = new ZkStateReader(server.getZkServer().getZkAddress(), 10000, 10000)) {
        zkStateReader.getZkClient().delete(ZkStateReader.SOLR_SECURITY_CONF_PATH, 0, true);
        String securityJson = new String(Files.readAllBytes(Paths.get("src/test/resources/security.json")),
                Charset.defaultCharset());
        zkStateReader.getZkClient().create(ZkStateReader.SOLR_SECURITY_CONF_PATH,
                securityJson.getBytes(Charset.defaultCharset()), CreateMode.PERSISTENT, true);
    }//from w  w w. jav a  2 s  . c o m

    String configName = "core1Config";
    File configDir = Paths.get("target/test-classes/solrcloud").toFile();
    server.uploadConfigDir(configDir, configName);

    Map<String, String> collectionProperties = new HashMap<>();
    collectionProperties.put("config", "solrconfig.xml");
    collectionProperties.put("schema", "schema.xml");

    server.createCollection("docs", 1, 1, configName, collectionProperties);

    JettySolrRunner startedServer = server.startJettySolrRunner();
    assertTrue(startedServer.isRunning());

}