Skip to content

Commit

Permalink
ATLAS-4967: atlas-testtools module: update for code readability impro…
Browse files Browse the repository at this point in the history
…vements
  • Loading branch information
jayendrap committed Feb 18, 2025
1 parent 0635755 commit 7c5d18c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 30 deletions.
5 changes: 5 additions & 0 deletions test-tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@

<name>Apache Atlas Test Utility Tools</name>

<properties>
<checkstyle.failOnViolation>true</checkstyle.failOnViolation>
<checkstyle.skip>false</checkstyle.skip>
</properties>

<dependencies>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
*/
// Copyright 2017 JanusGraph Authors
//
// Licensed 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 org.apache.atlas.runner;

import org.apache.atlas.ApplicationProperties;
Expand Down Expand Up @@ -44,14 +41,12 @@ public class LocalSolrRunner {
private static final Logger LOG = LoggerFactory.getLogger(LocalSolrRunner.class);

// from org.apache.atlas.repository.graphdb.janus.AtlasJanusGraphDatabase
public static final String SOLR_ZOOKEEPER_URL = "atlas.graph.index.search.solr.zookeeper-url";

protected static final String[] COLLECTIONS = readCollections();

private static final String TARGET_DIRECTORY = System.getProperty("embedded.solr.directory");
private static final String COLLECTIONS_FILE = "collections.txt";
private static final String SOLR_XML = "solr.xml";
private static final String TEMPLATE_DIRECTORY = "core-template";
public static final String SOLR_ZOOKEEPER_URL = "atlas.graph.index.search.solr.zookeeper-url";
protected static final String[] COLLECTIONS = readCollections();
private static final String TARGET_DIRECTORY = System.getProperty("embedded.solr.directory");
private static final String COLLECTIONS_FILE = "collections.txt";
private static final String SOLR_XML = "solr.xml";
private static final String TEMPLATE_DIRECTORY = "core-template";

private static MiniSolrCloudCluster miniSolrCloudCluster;

Expand All @@ -72,7 +67,7 @@ public static void start() throws Exception {

miniSolrCloudCluster = new MiniSolrCloudCluster(1, null, temp.toPath(), readSolrXml(), null, null);

LOG.info("Started local solr server at: {}", getZookeeperUrls());
LOG.info("Started local solr server at: " + getZookeeperUrls());

for (String coreName : COLLECTIONS) {
File coreDirectory = new File(temp.getAbsolutePath() + File.separator + coreName);
Expand Down Expand Up @@ -104,7 +99,6 @@ public static void stop() throws Exception {
if (!isLocalSolrRunning()) {
return;
}

System.clearProperty("solr.solrxml.location");
System.clearProperty("zkHost");

Expand Down Expand Up @@ -151,12 +145,10 @@ private static String[] readCollections() {
// For the classloader you need the following path: "/solr/collections.txt";
// Use explicit '/' separators (not File.separator) because even on Windows you want '/'
String resName = "/solr/" + COLLECTIONS_FILE;

try {
InputStream inputStream = LocalSolrRunner.class.getResourceAsStream(resName);
InputStreamReader isr = new InputStreamReader(inputStream);
BufferedReader buffer = new BufferedReader(isr);

return Pattern.compile("\\s+").split(buffer.lines().collect(Collectors.joining("\n")));
} catch (Exception e) {
throw new RuntimeException("Unable to read collections file", e);
Expand All @@ -167,7 +159,6 @@ private static String readSolrXml() throws IOException {
// For the classloader you need the following path: "/solr/solr.xml";
// Use explicit '/' separators (not File.separator) because even on Windows you want '/'
String resName = "/solr/" + SOLR_XML;

// Use the local classloader rather than the system classloader - i.e. avoid using
// Thread.currentThread().getContextClassLoader().getResourceAsStream(resName);
InputStream inputStream = LocalSolrRunner.class.getResourceAsStream(resName);
Expand Down

0 comments on commit 7c5d18c

Please sign in to comment.