Exemplo n.º 1
0
 // 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"));
 }
Exemplo n.º 2
0
 @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"));
 }
Exemplo n.º 3
0
  /**
   * Initializes things your test might need
   *
   * <ul>
   *   <li>Creates a dataDir in the "java.io.tmpdir"
   *   <li>initializes the TestHarness h using this data directory, and getSchemaPath()
   *   <li>initializes the LocalRequestFactory lrf using sensible defaults.
   * </ul>
   */
  @Override
  public void setUp() throws Exception {
    super.setUp();
    log.info("####SETUP_START " + getTestName());
    ignoreException("ignore_exception");
    factoryProp = System.getProperty("solr.directoryFactory");
    if (factoryProp == null) {
      System.setProperty("solr.directoryFactory", "solr.RAMDirectoryFactory");
    }
    dataDir = new File(TEMP_DIR, getClass().getName() + "-" + System.currentTimeMillis());
    dataDir.mkdirs();
    String configFile = getSolrConfigFile();
    System.setProperty("solr.solr.home", getSolrHome());
    if (configFile != null) {

      solrConfig = TestHarness.createConfig(getSolrConfigFile());
      h = new TestHarness(dataDir.getAbsolutePath(), solrConfig, getSchemaFile());
      lrf = h.getRequestFactory("standard", 0, 20, CommonParams.VERSION, "2.2");
    }
    log.info("####SETUP_END " + getTestName());
  }
Exemplo n.º 4
0
 public static void resetExceptionIgnores() {
   SolrException.ignorePatterns = null;
   ignoreException("ignore_exception"); // always ignore "ignore_exception"
 }