/** * Shuts down the test harness, and makes the best attempt possible to delete dataDir, unless the * system property "solr.test.leavedatadir" is set. */ @Override public void tearDown() throws Exception { log.info("####TEARDOWN_START " + getTestName()); if (factoryProp == null) { System.clearProperty("solr.directoryFactory"); } if (h != null) { h.close(); } String skip = System.getProperty("solr.test.leavedatadir"); if (null != skip && 0 != skip.trim().length()) { System.err.println( "NOTE: per solr.test.leavedatadir, dataDir will not be removed: " + dataDir.getAbsolutePath()); } else { if (!recurseDelete(dataDir)) { System.err.println( "!!!! WARNING: best effort to remove " + dataDir.getAbsolutePath() + " FAILED !!!!!"); } } resetExceptionIgnores(); super.tearDown(); }
// This is in fact a DOMUtil test, but it is here for completeness @Test public void testNameRequired() throws Exception { Node nodeWithNoName = getNode("<plugin></plugin>", "plugin"); AbstractSolrTestCase.ignoreException("missing mandatory attribute"); try { PluginInfo pi = new PluginInfo(nodeWithNoName, "Node with No name", true, false); fail("Exception should have been thrown"); } catch (RuntimeException e) { assertTrue(e.getMessage().contains("missing mandatory attribute")); } finally { AbstractSolrTestCase.resetExceptionIgnores(); } Node nodeWithAName = getNode("<plugin name=\"myName\" />", "plugin"); PluginInfo pi2 = new PluginInfo(nodeWithAName, "Node with a Name", true, false); assertTrue(pi2.name.equals("myName")); }
@Test public void testClassRequired() throws Exception { Node nodeWithNoClass = getNode("<plugin></plugin>", "plugin"); AbstractSolrTestCase.ignoreException("missing mandatory attribute"); try { @SuppressWarnings("unused") PluginInfo pi = new PluginInfo(nodeWithNoClass, "Node with No Class", false, true); fail("Exception should have been thrown"); } catch (RuntimeException e) { assertTrue(e.getMessage().contains("missing mandatory attribute")); } finally { AbstractSolrTestCase.resetExceptionIgnores(); } Node nodeWithAClass = getNode("<plugin class=\"myName\" />", "plugin"); PluginInfo pi2 = new PluginInfo(nodeWithAClass, "Node with a Class", false, true); assertTrue(pi2.className.equals("myName")); }