org.apache.solr.SolrTestCaseJ4 Java Examples
The following examples show how to use
org.apache.solr.SolrTestCaseJ4.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImplicitSnitchTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testGetTags_withHostNameRequestedTag_ip3_returns_1_tag() throws Exception { SolrTestCaseJ4.assumeWorkingMockito(); String node = "serv01.dc01.london.uk.apache.org:8983_solr"; SnitchContext context = new ServerSnitchContext(null, node, new HashMap<>(),null); //We need mocking here otherwise, we would need proper DNS entry for this test to pass ImplicitSnitch mockedSnitch = Mockito.spy(snitch); when(mockedSnitch.getHostIp(anyString())).thenReturn("10.11.12.13"); mockedSnitch.getTags(node, Sets.newHashSet(IP_3), context); Map<String, Object> tags = context.getTags(); assertThat(tags.entrySet().size(), is(1)); assertThat(tags.get(IP_3), is("11")); }
Example #2
Source File: ImplicitSnitchTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testGetTags_withAllHostNameRequestedTags_returns_all_Tags() throws Exception { SolrTestCaseJ4.assumeWorkingMockito(); String node = "serv01.dc01.london.uk.apache.org:8983_solr"; SnitchContext context = new ServerSnitchContext(null, node, new HashMap<>(),null); //We need mocking here otherwise, we would need proper DNS entry for this test to pass ImplicitSnitch mockedSnitch = Mockito.spy(snitch); when(mockedSnitch.getHostIp(anyString())).thenReturn("10.11.12.13"); mockedSnitch.getTags(node, Sets.newHashSet(IP_1, IP_2, IP_3, IP_4), context); Map<String, Object> tags = context.getTags(); assertThat(tags.entrySet().size(), is(4)); assertThat(tags.get(IP_1), is("13")); assertThat(tags.get(IP_2), is("12")); assertThat(tags.get(IP_3), is("11")); assertThat(tags.get(IP_4), is("10")); }
Example #3
Source File: TestMiniSolrCloudClusterSSL.java From lucene-solr with Apache License 2.0 | 6 votes |
/** * General purpose cluster sanity check... * <ol> * <li>Upload a config set</li> * <li>verifies a collection can be created</li> * <li>verifies many things that should succeed/fail when communicating with the cluster according to the specified sslConfig</li> * <li>shutdown a server & startup a new one in it's place</li> * <li>repeat the verifications of ssl / no-ssl communication</li> * <li>create a second collection</li> * </ol> * @see #CONF_NAME * @see #NUM_SERVERS */ public static void checkClusterWithCollectionCreations(final MiniSolrCloudCluster cluster, final SSLTestConfig sslConfig) throws Exception { cluster.uploadConfigSet(SolrTestCaseJ4.TEST_PATH().resolve("collection1").resolve("conf"), CONF_NAME); checkCreateCollection(cluster, "first_collection"); checkClusterJettys(cluster, sslConfig); // shut down a server JettySolrRunner stoppedServer = cluster.stopJettySolrRunner(0); cluster.waitForJettyToStop(stoppedServer); assertTrue(stoppedServer.isStopped()); assertEquals(NUM_SERVERS - 1, cluster.getJettySolrRunners().size()); // create a new server JettySolrRunner startedServer = cluster.startJettySolrRunner(); cluster.waitForAllNodes(30); assertTrue(startedServer.isRunning()); assertEquals(NUM_SERVERS, cluster.getJettySolrRunners().size()); checkClusterJettys(cluster, sslConfig); checkCreateCollection(cluster, "second_collection"); }
Example #4
Source File: TestHdfsBackupRestoreCore.java From lucene-solr with Apache License 2.0 | 6 votes |
@AfterClass public static void teardownClass() throws Exception { IOUtils.closeQuietly(fs); fs = null; try { SolrTestCaseJ4.resetFactory(); } finally { try { HdfsTestUtil.teardownClass(dfsCluster); } finally { dfsCluster = null; System.clearProperty("solr.hdfs.home"); System.clearProperty("solr.hdfs.default.backup.path"); System.clearProperty("test.build.data"); System.clearProperty("test.cache.data"); } } }
Example #5
Source File: SolrCoreTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testClose() throws Exception { final CoreContainer cores = h.getCoreContainer(); SolrCore core = cores.getCore(SolrTestCaseJ4.DEFAULT_TEST_CORENAME); ClosingRequestHandler handler1 = new ClosingRequestHandler(); handler1.inform( core ); String path = "/this/is A path /that won't be registered 2!!!!!!!!!!!"; SolrRequestHandler old = core.registerRequestHandler( path, handler1 ); assertNull( old ); // should not be anything... assertEquals( core.getRequestHandlers().get( path ), handler1 ); core.close(); cores.shutdown(); assertTrue("Handler not closed", handler1.closed == true); }
Example #6
Source File: MockSolrEntityProcessor.java From lucene-solr with Apache License 2.0 | 6 votes |
private SolrDocumentList getDocs(int start, int rows) { SolrDocumentList docs = new SolrDocumentList(); docs.setNumFound(docsData.size()); docs.setStart(start); int endIndex = start + rows; int end = docsData.size() < endIndex ? docsData.size() : endIndex; for (int i = start; i < end; i++) { SolrDocument doc = new SolrDocument(); SolrTestCaseJ4.Doc testDoc = docsData.get(i); doc.addField("id", testDoc.id); doc.addField("description", testDoc.getValues("description")); docs.add(doc); } return docs; }
Example #7
Source File: TestSolrConfigHandler.java From lucene-solr with Apache License 2.0 | 6 votes |
public static void runConfigCommandExpectFailure(RestTestHarness harness, String uri, String payload, String expectedErrorMessage) throws Exception { String json = SolrTestCaseJ4.json(payload); log.info("going to send config command. path {} , payload: {}", uri, payload); String response = harness.post(uri, json); @SuppressWarnings({"rawtypes"}) Map map = (Map)Utils.fromJSONString(response); assertNotNull(response, map.get("errorMessages")); assertNotNull(response, map.get("error")); assertTrue("Expected status != 0: " + response, 0L != (Long)((Map)map.get("responseHeader")).get("status")); @SuppressWarnings({"rawtypes"}) List errorDetails = (List)((Map)map.get("error")).get("details"); @SuppressWarnings({"rawtypes"}) List errorMessages = (List)((Map)errorDetails.get(0)).get("errorMessages"); assertTrue("Expected '" + expectedErrorMessage + "': " + response, errorMessages.get(0).toString().contains(expectedErrorMessage)); }
Example #8
Source File: SentrySingletonTestInstance.java From incubator-sentry with Apache License 2.0 | 6 votes |
public void setupSentry() throws Exception { sentrySite = File.createTempFile("sentry-site", "xml"); File authProviderDir = SolrTestCaseJ4.getFile("sentry-handlers/sentry"); sentrySite.deleteOnExit(); // need to write sentry-site at execution time because we don't know // the location of sentry.solr.provider.resource beforehand StringBuilder sentrySiteData = new StringBuilder(); sentrySiteData.append("<configuration>\n"); addPropertyToSentry(sentrySiteData, "sentry.provider", "org.apache.sentry.provider.file.LocalGroupResourceAuthorizationProvider"); addPropertyToSentry(sentrySiteData, "sentry.solr.provider.resource", new File(authProviderDir.toString(), "test-authz-provider.ini").toURI().toURL().toString()); sentrySiteData.append("</configuration>\n"); FileUtils.writeStringToFile(sentrySite,sentrySiteData.toString(), Charsets.UTF_8.toString()); }
Example #9
Source File: PluginInfoTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testNameRequired() throws Exception { Node nodeWithNoName = getNode("<plugin></plugin>", "plugin"); try { SolrTestCaseJ4.ignoreException("missing mandatory attribute"); RuntimeException thrown = expectThrows(RuntimeException.class, () -> { PluginInfo pi = new PluginInfo(nodeWithNoName, "Node with No name", true, false); }); assertTrue(thrown.getMessage().contains("missing mandatory attribute")); } finally { SolrTestCaseJ4.resetExceptionIgnores(); } Node nodeWithAName = getNode("<plugin name=\"myName\" />", "plugin"); PluginInfo pi2 = new PluginInfo(nodeWithAName, "Node with a Name", true, false); assertTrue(pi2.name.equals("myName")); }
Example #10
Source File: SolrPortAwareCookieSpecTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testDomainHostPortMatch() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieOrigin origin = new CookieOrigin("myhost", 80, "/", false); final CookieAttributeHandler h = new SolrPortAwareCookieSpecFactory.PortAwareDomainHandler(); cookie.setDomain("myhost"); SolrTestCaseJ4.expectThrows(IllegalArgumentException.class, () -> h.match(cookie, null)); cookie.setDomain(null); Assert.assertFalse(h.match(cookie, origin)); cookie.setDomain("otherhost"); Assert.assertFalse(h.match(cookie, origin)); cookie.setDomain("myhost"); Assert.assertTrue(h.match(cookie, origin)); cookie.setDomain("myhost:80"); Assert.assertTrue(h.match(cookie, origin)); cookie.setDomain("myhost:8080"); Assert.assertFalse(h.match(cookie, origin)); }
Example #11
Source File: PluginInfoTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testClassRequired() throws Exception { Node nodeWithNoClass = getNode("<plugin></plugin>", "plugin"); try { SolrTestCaseJ4.ignoreException("missing mandatory attribute"); RuntimeException thrown = expectThrows(RuntimeException.class, () -> { PluginInfo pi = new PluginInfo(nodeWithNoClass, "Node with No Class", false, true); }); assertTrue(thrown.getMessage().contains("missing mandatory attribute")); } finally { SolrTestCaseJ4.resetExceptionIgnores(); } Node nodeWithAClass = getNode("<plugin class=\"myName\" />", "plugin"); PluginInfo pi2 = new PluginInfo(nodeWithAClass, "Node with a Class", false, true); assertTrue(pi2.className.equals("myName")); }
Example #12
Source File: SolrITInitializer.java From SearchServices with GNU Lesser General Public License v3.0 | 5 votes |
public static void distribSetUp(String serverName) { SolrTestCaseJ4.resetExceptionIgnores(); // ignore anything with // ignore_exception in it System.setProperty("solr.test.sys.prop1", "propone"); System.setProperty("solr.test.sys.prop2", "proptwo"); System.setProperty("solr.directoryFactory", "org.apache.solr.core.MockDirectoryFactory"); System.setProperty("solr.log.dir", testDir.toPath().resolve(serverName).toString()); }
Example #13
Source File: TestConfigSetImmutable.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test public void testSolrConfigHandlerImmutable() throws Exception { String payload = "{\n" + "'create-requesthandler' : { 'name' : '/x', 'class': 'org.apache.solr.handler.DumpRequestHandler' , 'startup' : 'lazy'}\n" + "}"; String uri = "/config"; String response = restTestHarness.post(uri, SolrTestCaseJ4.json(payload)); @SuppressWarnings({"rawtypes"}) Map map = (Map) Utils.fromJSONString(response); assertNotNull(map.get("error")); assertTrue(map.get("error").toString().contains("immutable")); }
Example #14
Source File: CoreAdminCreateDiscoverTest.java From lucene-solr with Apache License 2.0 | 5 votes |
private static void setupCore(String coreName, boolean blivet) throws IOException { File instDir = new File(solrHomeDirectory, coreName); File subHome = new File(instDir, "conf"); assertTrue("Failed to make subdirectory ", subHome.mkdirs()); // Be sure we pick up sysvars when we create this String srcDir = SolrTestCaseJ4.TEST_HOME() + "/collection1/conf"; FileUtils.copyFile(new File(srcDir, "schema-tiny.xml"), new File(subHome, "schema_ren.xml")); FileUtils.copyFile(new File(srcDir, "solrconfig-minimal.xml"), new File(subHome, "solrconfig_ren.xml")); FileUtils.copyFile(new File(srcDir, "solrconfig.snippet.randomindexconfig.xml"), new File(subHome, "solrconfig.snippet.randomindexconfig.xml")); }
Example #15
Source File: PingRequestHandlerTest.java From lucene-solr with Apache License 2.0 | 5 votes |
public void testPingInClusterWithNoHealthCheck() throws Exception { MiniSolrCloudCluster miniCluster = new MiniSolrCloudCluster(NUM_SERVERS, createTempDir(), buildJettyConfig("/solr")); final CloudSolrClient cloudSolrClient = miniCluster.getSolrClient(); try { assertNotNull(miniCluster.getZkServer()); List<JettySolrRunner> jettys = miniCluster.getJettySolrRunners(); assertEquals(NUM_SERVERS, jettys.size()); for (JettySolrRunner jetty : jettys) { assertTrue(jetty.isRunning()); } // create collection String collectionName = "testSolrCloudCollection"; String configName = "solrCloudCollectionConfig"; miniCluster.uploadConfigSet(SolrTestCaseJ4.TEST_PATH().resolve("collection1").resolve("conf"), configName); CollectionAdminRequest.createCollection(collectionName, configName, NUM_SHARDS, REPLICATION_FACTOR) .process(miniCluster.getSolrClient()); // Send distributed and non-distributed ping query SolrPingWithDistrib reqDistrib = new SolrPingWithDistrib(); reqDistrib.setDistrib(true); SolrPingResponse rsp = reqDistrib.process(cloudSolrClient, collectionName); assertEquals(0, rsp.getStatus()); assertTrue(rsp.getResponseHeader().getBooleanArg(("zkConnected"))); SolrPing reqNonDistrib = new SolrPing(); rsp = reqNonDistrib.process(cloudSolrClient, collectionName); assertEquals(0, rsp.getStatus()); assertTrue(rsp.getResponseHeader().getBooleanArg(("zkConnected"))); } finally { miniCluster.shutdown(); } }
Example #16
Source File: ResponseHeaderTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@BeforeClass public static void beforeTest() throws Exception { solrHomeDirectory = createTempDir().toFile(); setupJettyTestHome(solrHomeDirectory, "collection1"); String top = SolrTestCaseJ4.TEST_HOME() + "/collection1/conf"; FileUtils.copyFile(new File(top, "solrconfig-headers.xml"), new File(solrHomeDirectory + "/collection1/conf", "solrconfig.xml")); createAndStartJetty(solrHomeDirectory.getAbsolutePath()); }
Example #17
Source File: TestBinaryField.java From lucene-solr with Apache License 2.0 | 5 votes |
@BeforeClass public static void beforeTest() throws Exception { File homeDir = createTempDir().toFile(); File collDir = new File(homeDir, "collection1"); File dataDir = new File(collDir, "data"); File confDir = new File(collDir, "conf"); homeDir.mkdirs(); collDir.mkdirs(); dataDir.mkdirs(); confDir.mkdirs(); FileUtils.copyFile(new File(SolrTestCaseJ4.TEST_HOME(), "solr.xml"), new File(homeDir, "solr.xml")); String src_dir = TEST_HOME() + "/collection1/conf"; FileUtils.copyFile(new File(src_dir, "schema-binaryfield.xml"), new File(confDir, "schema.xml")); FileUtils.copyFile(new File(src_dir, "solrconfig-basic.xml"), new File(confDir, "solrconfig.xml")); FileUtils.copyFile(new File(src_dir, "solrconfig.snippet.randomindexconfig.xml"), new File(confDir, "solrconfig.snippet.randomindexconfig.xml")); try (Writer w = new OutputStreamWriter(Files.newOutputStream(collDir.toPath().resolve("core.properties")), StandardCharsets.UTF_8)) { Properties coreProps = new Properties(); coreProps.put("name", "collection1"); coreProps.store(w, ""); } createAndStartJetty(homeDir.getAbsolutePath()); }
Example #18
Source File: SchemaWatcherTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { SolrTestCaseJ4.assumeWorkingMockito(); mockSchemaReader = mock(ZkIndexSchemaReader.class); schemaWatcher = new SchemaWatcher(mockSchemaReader); }
Example #19
Source File: BasicHttpSolrClientTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test @SuppressWarnings({"try"}) public void testInvariantParams() throws IOException { try(HttpSolrClient createdClient = new HttpSolrClient.Builder() .withBaseSolrUrl(jetty.getBaseUrl().toString()) .withInvariantParams(SolrTestCaseJ4.params("param", "value")) .build()) { assertEquals("value", createdClient.getInvariantParams().get("param")); } try(HttpSolrClient createdClient = new HttpSolrClient.Builder() .withBaseSolrUrl(jetty.getBaseUrl().toString()) .withInvariantParams(SolrTestCaseJ4.params("fq", "fq1", "fq", "fq2")) .build()) { assertEquals(2, createdClient.getInvariantParams().getParams("fq").length); } try(HttpSolrClient createdClient = new HttpSolrClient.Builder() .withBaseSolrUrl(jetty.getBaseUrl().toString()) .withKerberosDelegationToken("mydt") .withInvariantParams(SolrTestCaseJ4.params(DelegationTokenHttpSolrClient.DELEGATION_TOKEN_PARAM, "mydt")) .build()) { fail(); } catch(Exception ex) { if (!ex.getMessage().equals("parameter "+ DelegationTokenHttpSolrClient.DELEGATION_TOKEN_PARAM +" is redefined.")) { throw ex; } } }
Example #20
Source File: TestCoreDiscovery.java From lucene-solr with Apache License 2.0 | 5 votes |
private void addConfFiles(File confDir) throws Exception { String top = SolrTestCaseJ4.TEST_HOME() + "/collection1/conf"; assertTrue("Failed to mkdirs for " + confDir.getAbsolutePath(), confDir.mkdirs()); FileUtils.copyFile(new File(top, "schema-tiny.xml"), new File(confDir, "schema-tiny.xml")); FileUtils.copyFile(new File(top, "solrconfig-minimal.xml"), new File(confDir, "solrconfig-minimal.xml")); FileUtils.copyFile(new File(top, "solrconfig.snippet.randomindexconfig.xml"), new File(confDir, "solrconfig.snippet.randomindexconfig.xml")); }
Example #21
Source File: TestReplicationHandler.java From lucene-solr with Apache License 2.0 | 5 votes |
static JettySolrRunner createAndStartJetty(SolrInstance instance) throws Exception { FileUtils.copyFile(new File(SolrTestCaseJ4.TEST_HOME(), "solr.xml"), new File(instance.getHomeDir(), "solr.xml")); Properties nodeProperties = new Properties(); nodeProperties.setProperty("solr.data.dir", instance.getDataDir()); JettyConfig jettyConfig = JettyConfig.builder().setContext("/solr").setPort(0).build(); JettySolrRunner jetty = new JettySolrRunner(instance.getHomeDir(), nodeProperties, jettyConfig); jetty.start(); return jetty; }
Example #22
Source File: TestReplicationHandlerBackup.java From lucene-solr with Apache License 2.0 | 5 votes |
private static JettySolrRunner createAndStartJetty(TestReplicationHandler.SolrInstance instance) throws Exception { FileUtils.copyFile(new File(SolrTestCaseJ4.TEST_HOME(), "solr.xml"), new File(instance.getHomeDir(), "solr.xml")); Properties nodeProperties = new Properties(); nodeProperties.setProperty("solr.data.dir", instance.getDataDir()); JettyConfig jettyConfig = JettyConfig.builder().setContext("/solr").setPort(0).build(); JettySolrRunner jetty = new JettySolrRunner(instance.getHomeDir(), nodeProperties, jettyConfig); jetty.start(); return jetty; }
Example #23
Source File: TestRestoreCore.java From lucene-solr with Apache License 2.0 | 5 votes |
private static JettySolrRunner createAndStartJetty(TestReplicationHandler.SolrInstance instance) throws Exception { FileUtils.copyFile(new File(SolrTestCaseJ4.TEST_HOME(), "solr.xml"), new File(instance.getHomeDir(), "solr.xml")); Properties nodeProperties = new Properties(); nodeProperties.setProperty("solr.data.dir", instance.getDataDir()); JettyConfig jettyConfig = JettyConfig.builder().setContext("/solr").setPort(0).build(); JettySolrRunner jetty = new JettySolrRunner(instance.getHomeDir(), nodeProperties, jettyConfig); jetty.start(); return jetty; }
Example #24
Source File: TestHttpServletCarrier.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test @SuppressWarnings({"unchecked"}) public void test() { SolrTestCaseJ4.assumeWorkingMockito(); HttpServletRequest req = mock(HttpServletRequest.class); Multimap<String, String> headers = HashMultimap.create(); headers.put("a", "a"); headers.put("a", "b"); headers.put("a", "c"); headers.put("b", "a"); headers.put("b", "b"); headers.put("c", "a"); when(req.getHeaderNames()).thenReturn(IteratorUtils.asEnumeration(headers.keySet().iterator())); when(req.getHeaders(anyString())).thenAnswer((Answer<Enumeration<String>>) inv -> { String key = inv.getArgument(0); return IteratorUtils.asEnumeration(headers.get(key).iterator()); }); HttpServletCarrier servletCarrier = new HttpServletCarrier(req); Iterator<Map.Entry<String, String>> it = servletCarrier.iterator(); Multimap<String, String> resultBack = HashMultimap.create(); while(it.hasNext()) { Map.Entry<String, String> entry = it.next(); resultBack.put(entry.getKey(), entry.getValue()); } assertEquals(headers, resultBack); }
Example #25
Source File: SolrExceptionTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test // commented out on: 24-Dec-2018 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // added 20-Sep-2018 public void testSolrException() throws Throwable { // test a connection to a solr server that probably doesn't exist // this is a very simple test and most of the test should be considered verified // if the compiler won't let you by without the try/catch boolean gotExpectedError = false; CloseableHttpClient httpClient = null; try { // switched to a local address to avoid going out on the net, ns lookup issues, etc. // set a 1ms timeout to let the connection fail faster. httpClient = HttpClientUtil.createClient(null); try (HttpSolrClient client = getHttpSolrClient("http://" + SolrTestCaseJ4.DEAD_HOST_1 + "/solr/", httpClient, 1)) { SolrQuery query = new SolrQuery("test123"); client.query(query); } httpClient.close(); } catch (SolrServerException sse) { gotExpectedError = true; /*** assertTrue(UnknownHostException.class == sse.getRootCause().getClass() //If one is using OpenDNS, then you don't get UnknownHostException, instead you get back that the query couldn't execute || (sse.getRootCause().getClass() == SolrException.class && ((SolrException) sse.getRootCause()).code() == 302 && sse.getMessage().equals("Error executing query"))); ***/ } finally { if (httpClient != null) HttpClientUtil.close(httpClient); } assertTrue(gotExpectedError); }
Example #26
Source File: ImplicitSnitchTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test public void testGetTags_withHostNameRequestedTag_ip99999_returns_nothing() throws Exception { SolrTestCaseJ4.assumeWorkingMockito(); String node = "serv01.dc01.london.uk.apache.org:8983_solr"; SnitchContext context = new ServerSnitchContext(null, node, new HashMap<>(),null); //We need mocking here otherwise, we would need proper DNS entry for this test to pass ImplicitSnitch mockedSnitch = Mockito.spy(snitch); when(mockedSnitch.getHostIp(anyString())).thenReturn("10.11.12.13"); mockedSnitch.getTags(node, Sets.newHashSet("ip_99999"), context); Map<String, Object> tags = context.getTags(); assertThat(tags.entrySet().size(), is(0)); }
Example #27
Source File: CharBufferTest.java From lucene-solr with Apache License 2.0 | 5 votes |
public void testCreate() { CharBuffer cb = new CharBuffer(); assertEquals(0, cb.length()); SolrTestCaseJ4.expectThrows(IllegalArgumentException.class, () -> new CharBuffer(0)); cb = new CharBuffer(128); assertEquals(0, cb.length()); }
Example #28
Source File: TestObjectReleaseTracker.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test public void testObjectReleaseTracker() { ObjectReleaseTracker.track(new Object()); ObjectReleaseTracker.release(new Object()); assertNotNull(SolrTestCaseJ4.clearObjectTrackerAndCheckEmpty(1)); assertNull(SolrTestCaseJ4.clearObjectTrackerAndCheckEmpty(1)); Object obj = new Object(); ObjectReleaseTracker.track(obj); ObjectReleaseTracker.release(obj); assertNull(SolrTestCaseJ4.clearObjectTrackerAndCheckEmpty(1)); Object obj1 = new Object(); ObjectReleaseTracker.track(obj1); Object obj2 = new Object(); ObjectReleaseTracker.track(obj2); Object obj3 = new Object(); ObjectReleaseTracker.track(obj3); ObjectReleaseTracker.release(obj1); ObjectReleaseTracker.release(obj2); ObjectReleaseTracker.release(obj3); assertNull(SolrTestCaseJ4.clearObjectTrackerAndCheckEmpty(1)); ObjectReleaseTracker.track(obj1); ObjectReleaseTracker.track(obj2); ObjectReleaseTracker.track(obj3); ObjectReleaseTracker.release(obj1); ObjectReleaseTracker.release(obj2); // ObjectReleaseTracker.release(obj3); assertNotNull(SolrTestCaseJ4.clearObjectTrackerAndCheckEmpty(1)); assertNull(SolrTestCaseJ4.clearObjectTrackerAndCheckEmpty(1)); }
Example #29
Source File: TestSystemIdResolver.java From lucene-solr with Apache License 2.0 | 5 votes |
public void testUnsafeResolving() throws Exception { System.setProperty("solr.allow.unsafe.resourceloading", "true"); final Path testHome = SolrTestCaseJ4.getFile("solr/collection1").getParentFile().toPath(); final ResourceLoader loader = new SolrResourceLoader(testHome.resolve("collection1"), this.getClass().getClassLoader()); final SystemIdResolver resolver = new SystemIdResolver(loader); assertEntityResolving(resolver, SystemIdResolver.createSystemIdFromResourceName(testHome+"/crazy-path-to-schema.xml"), SystemIdResolver.createSystemIdFromResourceName(testHome+"/crazy-path-to-config.xml"), "crazy-path-to-schema.xml"); }
Example #30
Source File: SolrPortAwareCookieSpecTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test public void testDomainValidate2() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false); final CookieAttributeHandler h = new SolrPortAwareCookieSpecFactory.PortAwareDomainHandler(); cookie.setDomain(".somedomain.com"); h.validate(cookie, origin); cookie.setDomain(".otherdomain.com"); SolrTestCaseJ4.expectThrows(MalformedCookieException.class, () -> h.validate(cookie, origin)); cookie.setDomain("www.otherdomain.com"); SolrTestCaseJ4.expectThrows(MalformedCookieException.class, () -> h.validate(cookie, origin)); }