Java Code Examples for com.helger.commons.mock.CommonsTestHelper#testInParallel()
The following examples show how to use
com.helger.commons.mock.CommonsTestHelper#testInParallel() .
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: CollatorHelperTest.java From ph-commons with Apache License 2.0 | 6 votes |
@Test public void testGetCollatorSpaceBeforeDot () { final Collator c = CollatorHelper.getCollatorSpaceBeforeDot (L_DE); assertNotNull (c); final Collator c2 = CollatorHelper.getCollatorSpaceBeforeDot (L_DE); assertNotNull (c2); assertNotSame (c, c2); CommonsTestHelper.testDefaultImplementationWithEqualContentObject (c, c2); // Unknown locale assertNotNull (CollatorHelper.getCollatorSpaceBeforeDot (new Locale ("xy", "87"))); final List <Collator> res = new CommonsVector <> (); final int nMax = 100; CommonsTestHelper.testInParallel (nMax, () -> res.add (CollatorHelper.getCollatorSpaceBeforeDot (L_EN))); assertEquals (nMax, res.size ()); for (int i = 1; i < nMax; ++i) CommonsTestHelper.testDefaultImplementationWithEqualContentObject (res.get (0), res.get (i)); }
Example 2
Source File: SAXReaderTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testMultithreadedSAX_CachingSAXInputSource () { CommonsTestHelper.testInParallel (1000, (IThrowingRunnable <SAXException>) () -> assertTrue (SAXReader.readXMLSAX (new CachingSAXInputSource (new ClassPathResource ("xml/buildinfo.xml")), new SAXReaderSettings ().setContentHandler (new DefaultHandler ())) .isSuccess ())); }
Example 3
Source File: SAXReaderTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testMultithreadedSAX_ReadableResourceSAXInputSource () { CommonsTestHelper.testInParallel (1000, (IThrowingRunnable <SAXException>) () -> assertTrue (SAXReader.readXMLSAX (new ClassPathResource ("xml/buildinfo.xml"), new SAXReaderSettings ().setContentHandler (new DefaultHandler ())) .isSuccess ())); }
Example 4
Source File: CollatorHelperTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testSort () { final int nMax = 10000; CommonsTestHelper.testInParallel (nMax, () -> { Collator c = CollatorHelper.getCollatorSpaceBeforeDot (L_DE); assertEquals (-1, CompareHelper.compare ("1.1 a", "1.1.1 a", c)); c = CollatorHelper.getCollatorSpaceBeforeDot (L_EN); assertEquals (-1, CompareHelper.compare ("1.1 a", "1.1.1 a", c)); }); }
Example 5
Source File: XMLWriterTest.java From ph-commons with Apache License 2.0 | 4 votes |
@Test public void testWriteXMLMultiThreaded () { final String sSPACER = " "; final String sINDENT = XMLWriterSettings.DEFAULT_INDENTATION_STRING; final String sTAGNAME = "notext"; CommonsTestHelper.testInParallel (1000, () -> { // Java 1.6 JAXP handles things differently final String sSerTagName = "<" + sTAGNAME + "></" + sTAGNAME + ">"; final Document doc = XMLFactory.newDocument ("html", DOCTYPE_XHTML10_QNAME, DOCTYPE_XHTML10_URI); final Element aHead = (Element) doc.getDocumentElement () .appendChild (doc.createElementNS (DOCTYPE_XHTML10_URI, "head")); aHead.appendChild (doc.createTextNode ("Hallo")); final Element aNoText = (Element) doc.getDocumentElement () .appendChild (doc.createElementNS (DOCTYPE_XHTML10_URI, sTAGNAME)); aNoText.appendChild (doc.createTextNode ("")); // test including doc type final String sResult = XMLWriter.getNodeAsString (doc, XMLWriterSettings.createForXHTML ()); assertEquals ("<!DOCTYPE html PUBLIC \"" + DOCTYPE_XHTML10_QNAME + "\"" + sSPACER + "\"" + DOCTYPE_XHTML10_URI + "\">" + CRLF + "<html xmlns=\"" + DOCTYPE_XHTML10_URI + "\">" + CRLF + sINDENT + "<head>Hallo</head>" + CRLF + sINDENT + sSerTagName + CRLF + "</html>" + CRLF, sResult); assertEquals (sResult, XMLWriter.getNodeAsString (doc, XMLWriterSettings.createForXHTML ())); }); }
Example 6
Source File: DOMReaderTest.java From ph-commons with Apache License 2.0 | 4 votes |
@Test public void testMultithreadedDOM () { CommonsTestHelper.testInParallel (100, (IThrowingRunnable <SAXException>) () -> assertNotNull (DOMReader.readXMLDOM (new ClassPathResource ("xml/buildinfo.xml")))); }