Java Code Examples for org.apache.solr.SolrTestCaseJ4#resetExceptionIgnores()
The following examples show how to use
org.apache.solr.SolrTestCaseJ4#resetExceptionIgnores() .
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: 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 2
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 3
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 4
Source File: TestSolrProperties.java From lucene-solr with Apache License 2.0 | 4 votes |
@Test public void testProperties() throws Exception { UpdateRequest up = new UpdateRequest(); up.setAction(ACTION.COMMIT, true, true); up.deleteByQuery("*:*"); up.process(getSolrCore0()); up.process(getSolrCore1()); up.clear(); // Add something to each core SolrInputDocument doc = new SolrInputDocument(); doc.setField("id", "AAA"); doc.setField("core0", "yup stopfra stopfrb stopena stopenb"); // Add to core0 up.add(doc); up.process(getSolrCore0()); SolrTestCaseJ4.ignoreException("unknown field"); // You can't add it to core1 expectThrows(Exception.class, () -> up.process(getSolrCore1())); // Add to core1 doc.setField("id", "BBB"); doc.setField("core1", "yup stopfra stopfrb stopena stopenb"); doc.removeField("core0"); up.add(doc); up.process(getSolrCore1()); // You can't add it to core1 SolrTestCaseJ4.ignoreException("core0"); expectThrows(Exception.class, () -> up.process(getSolrCore0())); SolrTestCaseJ4.resetExceptionIgnores(); // now Make sure AAA is in 0 and BBB in 1 SolrQuery q = new SolrQuery(); QueryRequest r = new QueryRequest(q); q.setQuery("id:AAA"); assertEquals(1, r.process(getSolrCore0()).getResults().size()); assertEquals(0, r.process(getSolrCore1()).getResults().size()); // Now test Changing the default core assertEquals(1, getSolrCore0().query(new SolrQuery("id:AAA")).getResults().size()); assertEquals(0, getSolrCore0().query(new SolrQuery("id:BBB")).getResults().size()); assertEquals(0, getSolrCore1().query(new SolrQuery("id:AAA")).getResults().size()); assertEquals(1, getSolrCore1().query(new SolrQuery("id:BBB")).getResults().size()); // Now test reloading it should have a newer open time String name = "core0"; SolrClient coreadmin = getSolrAdmin(); CoreAdminResponse mcr = CoreAdminRequest.getStatus(name, coreadmin); long before = mcr.getStartTime(name).getTime(); CoreAdminRequest.reloadCore(name, coreadmin); mcr = CoreAdminRequest.getStatus(name, coreadmin); long after = mcr.getStartTime(name).getTime(); assertTrue("should have more recent time: " + after + "," + before, after > before); }