Index: solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestContentStreamDataSource.java =================================================================== --- solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestContentStreamDataSource.java (revision 1566863) +++ solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestContentStreamDataSource.java (working copy) @@ -69,8 +69,7 @@ params.set("command", "full-import"); params.set("clean", "false"); req.setParams(params); - String url = "http" + (isSSLMode() ? "s" : "") + "://127.0.0.1:" + jetty.getLocalPort() + "/solr"; - HttpSolrServer solrServer = new HttpSolrServer(url); + HttpSolrServer solrServer = new HttpSolrServer(buildUrl(jetty.getLocalPort(), "/solr")); solrServer.request(req); ModifiableSolrParams qparams = new ModifiableSolrParams(); qparams.add("q", "*:*"); @@ -89,8 +88,7 @@ "clean", "false", UpdateParams.COMMIT, "false", UpdateParams.COMMIT_WITHIN, "1000"); req.setParams(params); - String url = "http" + (isSSLMode() ? "s" : "") + "://127.0.0.1:" + jetty.getLocalPort() + "/solr"; - HttpSolrServer solrServer = new HttpSolrServer(url); + HttpSolrServer solrServer = new HttpSolrServer(buildUrl(jetty.getLocalPort(), "/solr")); solrServer.request(req); Thread.sleep(100); ModifiableSolrParams queryAll = params("q", "*"); Index: solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestSolrEntityProcessorEndToEnd.java =================================================================== --- solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestSolrEntityProcessorEndToEnd.java (revision 1566863) +++ solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestSolrEntityProcessorEndToEnd.java (working copy) @@ -95,7 +95,7 @@ } private String getSourceUrl() { - return "http" + (isSSLMode() ? "s" : "") +"://127.0.0.1:" + jetty.getLocalPort() + "/solr"; + return buildUrl(jetty.getLocalPort(), "/solr"); } //TODO: fix this test to close its directories Index: solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java =================================================================== --- solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java (revision 1566863) +++ solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java (working copy) @@ -138,7 +138,7 @@ query.set("collection", "testalias"); JettySolrRunner jetty = jettys.get(random().nextInt(jettys.size())); int port = jetty.getLocalPort(); - HttpSolrServer server = new HttpSolrServer(getBaseUrl() + port + context + "/testalias"); + HttpSolrServer server = new HttpSolrServer(buildUrl(port) + "/testalias"); res = server.query(query); assertEquals(3, res.getResults().getNumFound()); @@ -146,7 +146,7 @@ query = new SolrQuery("*:*"); jetty = jettys.get(random().nextInt(jettys.size())); port = jetty.getLocalPort(); - server = new HttpSolrServer(getBaseUrl() + port + context + "/testalias"); + server = new HttpSolrServer(buildUrl(port) + "/testalias"); res = server.query(query); assertEquals(3, res.getResults().getNumFound()); @@ -173,7 +173,7 @@ query.set("collection", "testalias"); jetty = jettys.get(random().nextInt(jettys.size())); port = jetty.getLocalPort(); - server = new HttpSolrServer(getBaseUrl() + port + context + "/testalias"); + server = new HttpSolrServer(buildUrl(port) + "/testalias"); res = server.query(query); assertEquals(5, res.getResults().getNumFound()); @@ -181,7 +181,7 @@ query = new SolrQuery("*:*"); jetty = jettys.get(random().nextInt(jettys.size())); port = jetty.getLocalPort(); - server = new HttpSolrServer(getBaseUrl() + port + context + "/testalias"); + server = new HttpSolrServer(buildUrl(port) + "/testalias"); res = server.query(query); assertEquals(5, res.getResults().getNumFound()); @@ -243,10 +243,6 @@ assertTrue(sawException); } - private String getBaseUrl() { - return (isSSLMode() ? "https" : "http") + "://127.0.0.1:"; - } - private void createAlias(String alias, String collections) throws SolrServerException, IOException { if (random().nextBoolean()) { Index: solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java =================================================================== --- solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java (revision 1567399) +++ solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java (working copy) @@ -56,13 +56,6 @@ private static final String SHARD1 = "shard1"; private static final String ONE_NODE_COLLECTION = "onenodecollection"; - static { - if (Constants.MAC_OS_X) { - // disable while we look into mac test fail - ALLOW_SSL = false; - } - } - public BasicDistributedZk2Test() { super(); fixShardCount = true; Index: solr/core/src/test/org/apache/solr/core/OpenCloseCoreStressTest.java =================================================================== --- solr/core/src/test/org/apache/solr/core/OpenCloseCoreStressTest.java (revision 1566863) +++ solr/core/src/test/org/apache/solr/core/OpenCloseCoreStressTest.java (working copy) @@ -135,7 +135,7 @@ private void getServers() throws Exception { jetty.start(); - url = "http" + (isSSLMode() ? "s" : "") + "://127.0.0.1:" + jetty.getLocalPort() + "/solr/"; + url = buildUrl(jetty.getLocalPort(), "/solr/"); // Mostly to keep annoying logging messages from being sent out all the time. Index: solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java =================================================================== --- solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java (revision 1566863) +++ solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java (working copy) @@ -161,8 +161,7 @@ private static SolrServer createNewSolrServer(int port) { try { // setup the server... - String url = "http://127.0.0.1:" + port + context; - HttpSolrServer s = new HttpSolrServer(url); + HttpSolrServer s = new HttpSolrServer(buildUrl(port)); s.setConnectionTimeout(15000); s.setSoTimeout(60000); s.setDefaultMaxConnectionsPerHost(100); @@ -495,7 +494,7 @@ //jetty servers. private void invokeReplicationCommand(int pJettyPort, String pCommand) throws IOException { - String masterUrl = "http://127.0.0.1:" + pJettyPort + "/solr/replication?command=" + pCommand; + String masterUrl = buildUrl(pJettyPort) + "/replication?command=" + pCommand; try { URL u = new URL(masterUrl); InputStream stream = u.openStream(); @@ -648,7 +647,7 @@ // todo: make SolrJ easier to pass arbitrary params to // TODO: precommit WILL screw with the rest of this test - String masterUrl = "http://127.0.0.1:" + masterJetty.getLocalPort() + "/solr/update?prepareCommit=true"; + String masterUrl = buildUrl(masterJetty.getLocalPort()) + "/update?prepareCommit=true"; URL url = new URL(masterUrl); // InputStream stream = url.openStream(); // try { @@ -664,8 +663,8 @@ assertEquals(nDocs, masterQueryResult.getNumFound()); // snappull - masterUrl = "http://127.0.0.1:" + slaveJetty.getLocalPort() + "/solr/replication?command=fetchindex&masterUrl="; - masterUrl += "http://127.0.0.1:" + masterJetty.getLocalPort() + "/solr/replication"; + masterUrl = buildUrl(slaveJetty.getLocalPort()) + "/replication?command=fetchindex&masterUrl="; + masterUrl += buildUrl(masterJetty.getLocalPort()) + "/replication"; url = new URL(masterUrl); InputStream stream = url.openStream(); try { @@ -1012,10 +1011,9 @@ String masterUrl; URL url; InputStream stream; - masterUrl = "http://127.0.0.1:" + to.getLocalPort() - + "/solr/replication?wait=true&command=fetchindex&masterUrl="; - masterUrl += "http://127.0.0.1:" + from.getLocalPort() - + "/solr/replication"; + masterUrl = buildUrl(to.getLocalPort()) + + "/replication?wait=true&command=fetchindex&masterUrl=" + + buildUrl(from.getLocalPort()) + "/replication"; url = new URL(masterUrl); stream = url.openStream(); try { @@ -1329,7 +1327,7 @@ @Override public void run() { String masterUrl = - "http://127.0.0.1:" + masterJetty.getLocalPort() + "/solr/replication?command=" + ReplicationHandler.CMD_BACKUP + + buildUrl(masterJetty.getLocalPort()) + "/replication?command=" + ReplicationHandler.CMD_BACKUP + (addNumberToKeepInRequest ? "&" + backupKeepParamName + "=1" : ""); URL url; InputStream stream = null; @@ -1359,7 +1357,7 @@ } @Override public void run() { - String masterUrl = "http://127.0.0.1:" + masterJetty.getLocalPort() + "/solr/replication?command=" + ReplicationHandler.CMD_DETAILS; + String masterUrl = buildUrl(masterJetty.getLocalPort()) + "/replication?command=" + ReplicationHandler.CMD_DETAILS; URL url; InputStream stream = null; try { @@ -1525,6 +1523,10 @@ fail("timed out waiting for collection1 startAt time to exceed: " + min); return min; // compilation neccessity } + + private static String buildUrl(int port) { + return buildUrl(port, context); + } private static class SolrInstance { Index: solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java =================================================================== --- solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java (revision 1566863) +++ solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java (working copy) @@ -60,11 +60,6 @@ private AtomicInteger id = new AtomicInteger(); - static { - // no ssl currently because distrib updates read scheme from zk and no zk in this test - ALLOW_SSL = false; - } - @BeforeClass public static void beforeClass() throws Exception { // we can't use the Randomized merge policy because the test depends on @@ -122,7 +117,7 @@ getSchemaFile()); jettys.add(j); clients.add(createNewSolrServer(j.getLocalPort())); - String shardStr = "127.0.0.1:" + j.getLocalPort() + context; + String shardStr = buildUrl(j.getLocalPort()); shardsArr[i] = shardStr; sb.append(shardStr); } Index: solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java =================================================================== --- solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java (revision 1566863) +++ solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java (working copy) @@ -259,7 +259,7 @@ } public String getUrl() { - return "http" + (isSSLMode() ? "s" : "") + "://127.0.0.1:" + port + "/solr"; + return buildUrl(port, "/solr"); } public String getSchemaFile() { Index: solr/solrj/src/test/org/apache/solr/client/solrj/embedded/MultiCoreExampleJettyTest.java =================================================================== --- solr/solrj/src/test/org/apache/solr/client/solrj/embedded/MultiCoreExampleJettyTest.java (revision 1566863) +++ solr/solrj/src/test/org/apache/solr/client/solrj/embedded/MultiCoreExampleJettyTest.java (working copy) @@ -93,7 +93,7 @@ { try { // setup the server... - String url = "http" + (isSSLMode() ? "s" : "") + "://127.0.0.1:"+port+context+"/"+name; + String url = buildUrl(port, context) + "/" + name; HttpSolrServer s = new HttpSolrServer( url ); s.setConnectionTimeout(SolrTestCaseJ4.DEFAULT_CONNECTION_TIMEOUT); s.setDefaultMaxConnectionsPerHost(100); @@ -138,7 +138,7 @@ assertEquals( 1, r.process( getSolrCore1() ).getResults().size() ); // Distributed - String baseURL = "127.0.0.1:"+port+context+"/"; + String baseURL = buildUrl(port, context) + "/"; q = new SolrQuery( "*:*" ); q.set( ShardParams.SHARDS, baseURL+"core0,"+baseURL+"core1" ); q.set( "fl", "id,s:[shard]" ); Index: solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrServerTest.java =================================================================== --- solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrServerTest.java (revision 1566863) +++ solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrServerTest.java (working copy) @@ -147,8 +147,7 @@ public void testConnectionRefused() throws MalformedURLException { int unusedPort = findUnusedPort(); // XXX even if fwe found an unused port // it might not be unused anymore - HttpSolrServer server = new HttpSolrServer("http" + (isSSLMode() ? "s" : "") + "://127.0.0.1:" + unusedPort - + "/solr"); + HttpSolrServer server = new HttpSolrServer(buildUrl(unusedPort, "/solr")); server.setConnectionTimeout(500); SolrQuery q = new SolrQuery("*:*"); try { Index: solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java =================================================================== --- solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java (revision 1566863) +++ solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java (working copy) @@ -307,7 +307,7 @@ getSchemaFile()); jettys.add(j); clients.add(createNewSolrServer(j.getLocalPort())); - String shardStr = "127.0.0.1:" + j.getLocalPort() + context; + String shardStr = buildUrl(j.getLocalPort()); shardsArr[i] = shardStr; sb.append(shardStr); } @@ -393,9 +393,7 @@ protected SolrServer createNewSolrServer(int port) { try { // setup the server... - String urlScheme = isSSLMode() ? "https" : "http"; - String url = urlScheme + "://127.0.0.1:" + port + context; - HttpSolrServer s = new HttpSolrServer(url); + HttpSolrServer s = new HttpSolrServer(buildUrl(port)); s.setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT); s.setSoTimeout(60000); s.setDefaultMaxConnectionsPerHost(100); @@ -406,6 +404,10 @@ throw new RuntimeException(ex); } } + + protected String buildUrl(int port) { + return buildUrl(port, context); + } protected void addFields(SolrInputDocument doc, Object... fields) { for (int i = 0; i < fields.length; i += 2) { Index: solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java =================================================================== --- solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java (revision 1566883) +++ solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java (working copy) @@ -45,6 +45,7 @@ import org.apache.lucene.analysis.MockAnalyzer; import org.apache.lucene.analysis.MockTokenizer; import org.apache.lucene.index.IndexWriterConfig; +import org.apache.lucene.util.Constants; import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.QuickPatchThreadsFilter; @@ -213,7 +214,10 @@ } final boolean trySsl = random().nextBoolean(); - final boolean trySslClientAuth = random().nextBoolean(); + boolean trySslClientAuth = random().nextBoolean(); + if (Constants.MAC_OS_X) { + trySslClientAuth = false; + } log.info("Randomized ssl ({}) and clientAuth ({})", trySsl, trySslClientAuth); @@ -220,6 +224,10 @@ return new SSLTestConfig(trySsl, trySslClientAuth); } + + protected static String buildUrl(final int port, final String context) { + return (isSSLMode() ? "https" : "http") + "://127.0.0.1:" + port + context; + } protected static MockTokenizer whitespaceMockTokenizer(Reader input) throws IOException { MockTokenizer mockTokenizer = new MockTokenizer(MockTokenizer.WHITESPACE, false); Index: solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java =================================================================== --- solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java (revision 1566863) +++ solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java (working copy) @@ -107,7 +107,7 @@ JettySolrRunner j = createJetty(jettyHome, null, "shard" + (i + 2)); jettys.add(j); clients.add(createNewSolrServer(j.getLocalPort())); - sb.append("127.0.0.1:").append(j.getLocalPort()).append(context); + sb.append(buildUrl(j.getLocalPort())); } shards = sb.toString(); Index: solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java =================================================================== --- solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java (revision 1566863) +++ solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java (working copy) @@ -407,8 +407,8 @@ JettySolrRunner j = this.jettys.get(i); JettySolrRunner j2 = this.jettys.get(i + (numJettys / 2 - 1)); if (sb.length() > 0) sb.append(','); - sb.append("127.0.0.1:").append(j.getLocalPort()).append(context); - sb.append("|127.0.0.1:").append(j2.getLocalPort()).append(context); + sb.append(buildUrl(j.getLocalPort())); + sb.append("|").append(buildUrl(j2.getLocalPort())); } shards = sb.toString(); @@ -1674,9 +1674,8 @@ protected SolrServer createNewSolrServer(int port) { try { // setup the server... - String urlScheme = isSSLMode() ? "https" : "http"; - String url = urlScheme + "://127.0.0.1:" + port + context + - (context.endsWith("/") ? "" : "/") + DEFAULT_COLLECTION; + String baseUrl = buildUrl(port); + String url = baseUrl + (baseUrl.endsWith("/") ? "" : "/") + DEFAULT_COLLECTION; HttpSolrServer s = new HttpSolrServer(url); s.setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT); s.setSoTimeout(60000);