iprithv commented on code in PR #4775: URL: https://github.com/apache/solr/pull/4775#discussion_r3864191626
########## solr/core/src/test/org/apache/solr/handler/admin/api/GetNodePropertiesTest.java: ########## @@ -0,0 +1,107 @@ +/* + * 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 + * + * 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.solr.handler.admin.api; + +import org.apache.solr.SolrTestCase; +import org.apache.solr.client.api.model.NodePropertiesResponse; +import org.apache.solr.client.solrj.RemoteSolrException; +import org.apache.solr.client.solrj.request.NodeApi; +import org.apache.solr.core.NodeConfig; +import org.apache.solr.util.SolrJettyTestRule; +import org.junit.After; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Test; + +/** + * HTTP tests for {@code GET /api/node/properties} and {@code GET + * /api/node/properties/{propertyName}} via the generated SolrJ client classes. + */ +public class GetNodePropertiesTest extends SolrTestCase { + + private static final String VISIBLE_PROP = "GetNodePropertiesTest.visible"; + private static final String SECRET_PROP = "GetNodePropertiesTest.password"; + private static final String PASSWORD = "secret123"; + + @ClassRule public static final SolrJettyTestRule solrTestRule = new SolrJettyTestRule(); + + @BeforeClass + public static void setupSolr() throws Exception { + solrTestRule.startSolr(createTempDir()); + } + + @After + public void clearTestProperties() { + System.clearProperty(VISIBLE_PROP); + System.clearProperty(SECRET_PROP); + } + + @Test + public void testNamedProperty() throws Exception { + var req = new NodeApi.GetNodeProperty("java.version"); + var rsp = req.process(solrTestRule.getAdminClient()); + + assertNotNull(rsp); + assertNull(rsp.error); + assertEquals(1, rsp.systemProperties.size()); + assertEquals(System.getProperty("java.version"), rsp.systemProperties.get("java.version")); + } + + @Test + public void testAllProperties() throws Exception { + System.setProperty(VISIBLE_PROP, "hello"); + + NodePropertiesResponse rsp = fetchProperties(null); + + assertTrue("expected more than one system property", rsp.systemProperties.size() > 1); Review Comment: switched it to assertEquals on the property count :) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
