本文整理汇总了Java中com.meterware.httpunit.HttpUnitOptions.setExceptionsThrownOnScriptError方法的典型用法代码示例。如果您正苦于以下问题:Java HttpUnitOptions.setExceptionsThrownOnScriptError方法的具体用法?Java HttpUnitOptions.setExceptionsThrownOnScriptError怎么用?Java HttpUnitOptions.setExceptionsThrownOnScriptError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.meterware.httpunit.HttpUnitOptions
的用法示例。
在下文中一共展示了HttpUnitOptions.setExceptionsThrownOnScriptError方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPing
import com.meterware.httpunit.HttpUnitOptions; //导入方法依赖的package包/类
/**
* Test ping().
*/
@Test
public void testPing() {
Server server = null;
String dataDir = "data-test-ping1";
try {
String host = "localhost";
int port = 18983;
// start Solr
server = SimpleAnuenueInstanceFactory.createSolrInstance(port,
dataDir, NODE_CONF_FILE);
HttpUnitOptions.setExceptionsThrownOnScriptError(false);
SolrClient client = new SolrClient(host, port);
client.ping();
} catch (Exception e) {
fail();
} finally {
AnuenueTestUtil.stopServerQuietly(server);
assertTrue(FileUtils.deleteQuietly(new File(dataDir)));
}
}
示例2: testBrowseCatalog
import com.meterware.httpunit.HttpUnitOptions; //导入方法依赖的package包/类
public void testBrowseCatalog() throws Exception {
try {
// Disable scripting support until HttpUnit has better support for AJAX, Dojo...
HttpUnitOptions.setScriptingEnabled(false);
HttpUnitOptions.setExceptionsThrownOnScriptError(false);
// Start with the home page
WebConversation wc = new WebConversation();
WebRequest req = new GetMethodWebRequest("http://" + serverHost + ":" + serverPort + "/" + context);
WebResponse resp = wc.getResponse(req);
testMainPage(wc, resp);
testSellerPage(wc, resp);
testSearchPage(wc, resp);
testCatalogPage(wc, resp);
testMapPage(wc, resp);
testTagsPage(wc, resp);
} catch (ConnectException e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
fail("Could not connect to the server. Received Exception: \n" + sw.toString());
}
}
示例3: testInvalidInput
import com.meterware.httpunit.HttpUnitOptions; //导入方法依赖的package包/类
/**
* Test of adding file including invalid line.
*/
@Test
public void testInvalidInput() {
Server server = null;
String dataDir = "data-test-invalid-input";
try {
int port = 18983;
server = SimpleAnuenueInstanceFactory.createSolrInstance(port, dataDir, NODE_CONF_FILE);
HttpUnitOptions.setExceptionsThrownOnScriptError(false);
assertSame("initial size", 0, AnuenueTestUtil.getNumberOfIndexedDocumentViaLocalhostSolr(port));
NodeDatabase database = new NodeDatabaseBuilder("resources/anuenue-nodes-single.xml").build();
AnuenueDistCommandFactory.createDistCommand("addDir", "resources/example-failure-docs", database).execute();
assertSame("addDir, before commit", 0, AnuenueTestUtil.getNumberOfIndexedDocumentViaLocalhostSolr(port));
AnuenueDistCommandFactory.createDistCommand("commit", "", database).execute();
assertSame("addDir and commit", 2, AnuenueTestUtil.getNumberOfIndexedDocumentViaLocalhostSolr(port));
} catch (Exception e) {
fail();
} finally {
AnuenueTestUtil.stopServerQuietly(server);
assertTrue(FileUtils.deleteQuietly(new File(dataDir)));
}
}
示例4: setExceptionsThrownOnScriptError
import com.meterware.httpunit.HttpUnitOptions; //导入方法依赖的package包/类
/**
* Determines whether script errors result in exceptions or warning messages.
*/
public void setExceptionsThrownOnScriptError(String throwExceptions) {
HttpUnitOptions.setExceptionsThrownOnScriptError(Boolean.getBoolean(throwExceptions));
}
示例5: testRunWithTargets
import com.meterware.httpunit.HttpUnitOptions; //导入方法依赖的package包/类
/**
* Test of Anuenue distribution command indicating target node.
*/
@Test
public void testRunWithTargets() {
Server server1 = null;
Server server2 = null;
String dataDir1 = "data-test-dist-targets1";
String dataDir2 = "data-test-dist-targets2";
try {
/** role: merger, master, slave */
int port1 = 18070;
server1 = SimpleAnuenueInstanceFactory.createSolrInstance(port1, dataDir1, NODE_CONF_FILE);
HttpUnitOptions.setExceptionsThrownOnScriptError(false);
assertSame("initial size", 0, AnuenueTestUtil.getNumberOfIndexedDocumentViaLocalhostSolr(port1));
/** role: merger, master, slave */
int port2 = 17070;
server2 = SimpleAnuenueInstanceFactory.createSolrInstance(port2, dataDir2, NODE_CONF_FILE);
HttpUnitOptions.setExceptionsThrownOnScriptError(false);
assertSame("initial size", 0, AnuenueTestUtil.getNumberOfIndexedDocumentViaLocalhostSolr(port2));
NodeDatabase database = new NodeDatabaseBuilder("resources/anuenue-nodes-disttest.xml").build();
AbstractDistCommand command = AnuenueDistCommandFactory.createDistCommand("node1", "addDir", "resources/example-docs", database);
command.setMaxLinePerFile(2);
command.execute();
assertSame("addDir, before commit", 0, AnuenueTestUtil.getNumberOfIndexedDocumentViaLocalhostSolr(port1));
assertSame("addDir, before commit. nothing changed", 0, AnuenueTestUtil.getNumberOfIndexedDocumentViaLocalhostSolr(port2));
AnuenueDistCommandFactory.createDistCommand("commit", "", database).execute();
assertSame("addDir and commit", 9, AnuenueTestUtil.getNumberOfIndexedDocumentViaLocalhostSolr(port1));
assertSame("addDir and commit. nothing changed", 0, AnuenueTestUtil.getNumberOfIndexedDocumentViaLocalhostSolr(port2));
AnuenueDistCommandFactory.createDistCommand("delete", "*:*", database).execute();
assertSame("delete, before commit", 9, AnuenueTestUtil.getNumberOfIndexedDocumentViaLocalhostSolr(port1));
assertSame("delete, before commit. nothing changed", 0, AnuenueTestUtil.getNumberOfIndexedDocumentViaLocalhostSolr(port2));
AnuenueDistCommandFactory.createDistCommand("commit", "", database).execute();
assertSame("delete and commit", 0, AnuenueTestUtil.getNumberOfIndexedDocumentViaLocalhostSolr(port1));
assertSame("delete and commit. nothing changed", 0, AnuenueTestUtil.getNumberOfIndexedDocumentViaLocalhostSolr(port2));
} catch (Exception e) {
fail();
} finally {
AnuenueTestUtil.stopServerQuietly(server1);
AnuenueTestUtil.stopServerQuietly(server2);
assertTrue(FileUtils.deleteQuietly(new File(dataDir1)));
assertTrue(FileUtils.deleteQuietly(new File(dataDir2)));
}
}
示例6: testUpdateTSVData
import com.meterware.httpunit.HttpUnitOptions; //导入方法依赖的package包/类
/**
* Test updateTsvData().
*/
@Test
public void testUpdateTSVData() {
Server server = null;
String dataDir = "data-test-updater1";
try {
String host = "localhost";
int port = 18983;
// start Solr
server = SimpleAnuenueInstanceFactory.createSolrInstance(port,
dataDir, NODE_CONF_FILE);
HttpUnitOptions.setExceptionsThrownOnScriptError(false);
assertSame(0, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
// post a TSV data
SolrClient client = new SolrClient(host, port);
client.updateTSVData("blogid\tauthor\tgenre\tcontent\n"
+ "39209\tTakahiko Ito\tHadoop\tI like Hadoop.\n"
+ "4783\tTaro Gihu\tHadoop\tI also like Hadoop.\n");
assertSame(0, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
client.updateXML(XML_COMMIT);
assertSame(2, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
client.updateTSVData("blogid\tauthor\tgenre\tcontent\n"
+ "1\tTakahiko Ito\tHad\"oop\tI like Hadoop.\n"
+ "2\tTa\"ro Gi\"hu\t\"Hadoop\"\tI also like Hado\"op.\n");
assertSame(2, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
client.updateXML(XML_COMMIT);
assertSame(4, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
} catch (Exception e) {
fail();
} finally {
AnuenueTestUtil.stopServerQuietly(server);
assertTrue(FileUtils.deleteQuietly(new File(dataDir)));
}
}
示例7: testUpdateTSVFile
import com.meterware.httpunit.HttpUnitOptions; //导入方法依赖的package包/类
/**
* Test updateTSVFile().
*/
@Test
public void testUpdateTSVFile() {
Server server = null;
String dataDir = "data-test-updater2";
try {
String host = "localhost";
int port = 18983;
// start Solr
server = SimpleAnuenueInstanceFactory.createSolrInstance(port,
dataDir, NODE_CONF_FILE);
HttpUnitOptions.setExceptionsThrownOnScriptError(false);
assertSame(0, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
// post a TSV file
SolrClient client = new SolrClient(host, port);
client.updateTSVFile(new File(
"resources/example-docs/add-sample01.txt"));
assertSame(0, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
client.updateXML(XML_COMMIT);
assertSame(3, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
// post another TSV file
client.updateTSVFile(new File(
"resources/example-docs/add-sample02.txt"));
assertSame(3, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
client.updateXML(XML_COMMIT);
assertSame(6, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
// encapsulator
client.updateTSVFile(new File(
"resources/example-encapsulator-docs/add-sample04.txt"));
assertSame(6, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
client.updateXML(XML_COMMIT);
assertSame(13, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
} catch (Exception e) {
fail();
} finally {
AnuenueTestUtil.stopServerQuietly(server);
assertTrue(FileUtils.deleteQuietly(new File(dataDir)));
}
}
示例8: testCreateCommand
import com.meterware.httpunit.HttpUnitOptions; //导入方法依赖的package包/类
/**
* Test of createCommand().
*/
@Test
public void testCreateCommand() {
/** location of anuenue-nodes.xml file for the testing. */
String clusterConfFile = "resources/anuenue-nodes-single.xml";
String dataDir = "data-test-command";
String host = "localhost";
int port = 18983;
Server server = null;
try {
// start Solr
server = SimpleAnuenueInstanceFactory.createSolrInstance(port,
dataDir, clusterConfFile);
HttpUnitOptions.setExceptionsThrownOnScriptError(false);
// create AnuenueCommands
// run commands (post file, commit, optimize)
AnuenueCommandFactory.createCommand(host, port, "addFile",
"resources/example-docs/add-sample01.txt").runCommand();
assertSame(0, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
AnuenueCommandFactory.createCommand(host, port, "commit", null)
.runCommand();
assertSame(3, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
AnuenueCommandFactory.createCommand(host, port, "addFile",
"resources/example-docs/add-sample02.txt").runCommand();
assertSame(3, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
AnuenueCommandFactory.createCommand(host, port, "softcommit", null)
.runCommand();
assertSame(6, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
AnuenueCommandFactory.createCommand(host, port, "delete",
"blogid:39209").runCommand();
assertSame(6, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
AnuenueCommandFactory.createCommand(host, port, "commit", null)
.runCommand();
assertSame(5, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
AnuenueCommandFactory.createCommand(host, port, "deleteAll", null)
.runCommand();
assertSame(5, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
AnuenueCommandFactory.createCommand(host, port, "commit", null)
.runCommand();
assertSame(0, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
AnuenueCommandFactory.createCommand(host, port, "ping", null)
.runCommand();
} catch (Exception e) {
fail();
} finally {
// stop Solr
AnuenueTestUtil.stopServerQuietly(server);
assertTrue(FileUtils.deleteQuietly(new File(dataDir)));
}
}
示例9: testCreateCommand2
import com.meterware.httpunit.HttpUnitOptions; //导入方法依赖的package包/类
/**
* Test of createCommand() part2.
*/
@Test
public void testCreateCommand2() {
/** location of anuenue-nodes.xml file for the testing. */
String clusterConfFile = "resources/anuenue-nodes-single.xml";
String dataDir = "data-test-command";
String host = "localhost";
int port = 18983;
Server server = null;
try {
// start Solr
server = SimpleAnuenueInstanceFactory.createSolrInstance(port,
dataDir, clusterConfFile);
HttpUnitOptions.setExceptionsThrownOnScriptError(false);
// create AnuenueCommands
// run commands (post file, commit, optimize)
AnuenueCommandFactory.createCommand(host, port, "addData",
FileUtils.readFileToString(new File("resources/example-docs/add-sample01.txt"))).runCommand();
assertSame(0, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
AnuenueCommandFactory.createCommand(host, port, "commit", null)
.runCommand();
assertSame(3, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
AnuenueCommandFactory.createCommand(host, port, "addData",
FileUtils.readFileToString(new File("resources/example-docs/add-sample02.txt"))).runCommand();
assertSame(3, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
AnuenueCommandFactory.createCommand(host, port, "softcommit", null)
.runCommand();
assertSame(6, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
AnuenueCommandFactory.createCommand(host, port, "delete",
"blogid:39209").runCommand();
assertSame(6, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
AnuenueCommandFactory.createCommand(host, port, "commit", null)
.runCommand();
assertSame(5, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
AnuenueCommandFactory.createCommand(host, port, "deleteAll", null)
.runCommand();
assertSame(5, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
AnuenueCommandFactory.createCommand(host, port, "commit", null)
.runCommand();
assertSame(0, AnuenueTestUtil.getNumberOfIndexedDocumentViaSolr(host, port));
AnuenueCommandFactory.createCommand(host, port, "ping", null)
.runCommand();
} catch (Exception e) {
e.printStackTrace();
fail();
} finally {
// stop Solr
AnuenueTestUtil.stopServerQuietly(server);
assertTrue(FileUtils.deleteQuietly(new File(dataDir)));
}
}