⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uurifactorytest.html

📁 一个开源的网页爬虫一个开源的网页爬虫一个开源的网页爬虫一个开源的网页爬虫一个开源的网页爬虫一个开源的网页爬虫
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<a name="406" href="#406">406</a> <em>	 * Test for [ 962892 ] UURI accepting/creating unUsable URIs (bad hosts).</em><a name="407" href="#407">407</a> <em>	 * @see &lt;a href="https://sourceforge.net/tracker/?func=detail&amp;atid=539099&amp;aid=962892&amp;group_id=73833">[ 962892 ] UURI accepting/creating unUsable URIs (bad hosts)&lt;/a></em><a name="408" href="#408">408</a> <em>	 */</em><a name="409" href="#409">409</a> 	<strong>public</strong> <strong>final</strong> <strong>void</strong> testHostWithLessThan() {<a name="410" href="#410">410</a> 		checkExceptionOnIllegalDomainlabel(<span class="string">"http://www.betamobile.com&lt;/A"</span>);<a name="411" href="#411">411</a> 		checkExceptionOnIllegalDomainlabel(<a name="412" href="#412">412</a> 		<span class="string">"http://C|/unzipped/426/spacer.gif"</span>);<a name="413" href="#413">413</a> 		checkExceptionOnIllegalDomainlabel(<span class="string">"http://www.lycos.co.uk\&quot;/l/b/\&quot;"</span>);<a name="414" href="#414">414</a> 	}    <a name="415" href="#415">415</a> 	<a name="416" href="#416">416</a> 	<em>/**<em>*</em></em><a name="417" href="#417">417</a> <em>	 * Test for [ 1012520 ] UURI.length() &amp;gt; 2k.</em><a name="418" href="#418">418</a> <em>	 * @throws URIException</em><a name="419" href="#419">419</a> <em>	 * @see &lt;a href="<a href="http://sourceforge.net/tracker/index.php?func=detail&amp;aid=1012520&amp;group_id=73833&amp;atid=539099" target="alexandria_uri">http://sourceforge.net/tracker/index.php?func=detail&amp;aid=1012520&amp;group_id=73833&amp;atid=539099</a>">[ 1012520 ] UURI.length() &amp;gt; 2k&lt;/a></em><a name="420" href="#420">420</a> <em>	 */</em><a name="421" href="#421">421</a> 	<strong>public</strong> <strong>final</strong> <strong>void</strong> test2kURI() throws URIException {<a name="422" href="#422">422</a> 		<strong>final</strong> StringBuffer buffer = <strong>new</strong> StringBuffer(<span class="string">"http://a.b"</span>);<a name="423" href="#423">423</a> 		<strong>final</strong> String subPath = <span class="string">"/123456789"</span>;<a name="424" href="#424">424</a> 		<strong>for</strong> (<strong>int</strong> i = 0; i &lt; 207; i++) {<a name="425" href="#425">425</a> 			buffer.append(subPath);<a name="426" href="#426">426</a> 		}<a name="427" href="#427">427</a> 		<em class="comment">// String should be 2080 characters long.  Legal.</em><a name="428" href="#428">428</a> 		UURIFactory.getInstance(buffer.toString());<a name="429" href="#429">429</a> 		<strong>boolean</strong> gotException = false;<a name="430" href="#430">430</a> 		<em class="comment">// Add ten more characters and make size illegal.</em><a name="431" href="#431">431</a> 		buffer.append(subPath);<a name="432" href="#432">432</a> 		<strong>try</strong> {<a name="433" href="#433">433</a> 			UURIFactory.getInstance(buffer.toString()); <a name="434" href="#434">434</a> 		} <strong>catch</strong> (URIException e) {<a name="435" href="#435">435</a> 			gotException = <strong>true</strong>;<a name="436" href="#436">436</a> 		}<a name="437" href="#437">437</a> 		assertTrue(<span class="string">"No expected exception complaining about long URI"</span>,<a name="438" href="#438">438</a> 				gotException);<a name="439" href="#439">439</a> 	} <a name="440" href="#440">440</a> 	<a name="441" href="#441">441</a> 	<strong>private</strong> <strong>void</strong> checkExceptionOnIllegalDomainlabel(String uuri) {<a name="442" href="#442">442</a> 		<strong>boolean</strong> expectedException = false;<a name="443" href="#443">443</a>         <strong>try</strong> {<a name="444" href="#444">444</a> 			UURIFactory.getInstance(uuri);<a name="445" href="#445">445</a> 		} <strong>catch</strong> (URIException e) {<a name="446" href="#446">446</a> 			<em class="comment">// Expected exception.</em><a name="447" href="#447">447</a> 			expectedException = <strong>true</strong>;<a name="448" href="#448">448</a> 		}<a name="449" href="#449">449</a> 		assertTrue(<span class="string">"Didn't get expected exception: "</span> + uuri, <a name="450" href="#450">450</a> 				expectedException); <a name="451" href="#451">451</a> 	}<a name="452" href="#452">452</a> 	<a name="453" href="#453">453</a> 	<em>/**<em>*</em></em><a name="454" href="#454">454</a> <em>	 * Test for doing separate DNS lookup for same host</em><a name="455" href="#455">455</a> <em>	 *</em><a name="456" href="#456">456</a> <em>	 * @see &lt;a href="https://sourceforge.net/tracker/?func=detail&amp;aid=788277&amp;group_id=73833&amp;atid=539099">[ 788277 ] Doing separate DNS lookup for same host&lt;/a></em><a name="457" href="#457">457</a> <em>	 * @throws URIException</em><a name="458" href="#458">458</a> <em>	 */</em><a name="459" href="#459">459</a> 	<strong>public</strong> <strong>final</strong> <strong>void</strong> testHostWithPeriod() throws URIException {<a name="460" href="#460">460</a> 		UURI uuri1 = UURIFactory.<a name="461" href="#461">461</a> 		getInstance(<span class="string">"http://www.loc.gov./index.html"</span>);<a name="462" href="#462">462</a> 		UURI uuri2 = UURIFactory.<a name="463" href="#463">463</a> 		getInstance(<span class="string">"http://www.loc.gov/index.html"</span>);<a name="464" href="#464">464</a> 		assertEquals(<span class="string">"Failed equating hosts with dot"</span>,<a name="465" href="#465">465</a> 				uuri1.getHost(), uuri2.getHost());<a name="466" href="#466">466</a> 	}<a name="467" href="#467">467</a> 	<a name="468" href="#468">468</a> 	<em>/**<em>*</em></em><a name="469" href="#469">469</a> <em>	 * Test for NPE in java.net.URI.encode</em><a name="470" href="#470">470</a> <em>	 *</em><a name="471" href="#471">471</a> <em>	 * @see &lt;a href="https://sourceforge.net/tracker/?func=detail&amp;aid=874220&amp;group_id=73833&amp;atid=539099">[ 874220 ] NPE in java.net.URI.encode&lt;/a></em><a name="472" href="#472">472</a> <em>	 * @throws URIException</em><a name="473" href="#473">473</a> <em>	 */</em><a name="474" href="#474">474</a> 	<strong>public</strong> <strong>final</strong> <strong>void</strong> testHostEncodedChars() throws URIException {<a name="475" href="#475">475</a> 		String s = <span class="string">"http://g.msn.co.kr/0nwkokr0/00/19??"</span> +<a name="476" href="#476">476</a> 		<span class="string">"PS=10274&amp;NC=10009&amp;CE=42&amp;CP=949&amp;HL="</span> +<a name="477" href="#477">477</a> 		<span class="string">"&amp;#65533;&amp;#65533;&amp;#65533;?&amp;#65533;&amp;#65533;"</span>;<a name="478" href="#478">478</a> 		assertNotNull(<span class="string">"Encoded chars "</span> + s, <a name="479" href="#479">479</a> 				UURIFactory.getInstance(s));<a name="480" href="#480">480</a> 	}<a name="481" href="#481">481</a> 	<a name="482" href="#482">482</a> 	<em>/**<em>*</em></em><a name="483" href="#483">483</a> <em>	 * Test for java.net.URI parses %20 but getHost null</em><a name="484" href="#484">484</a> <em>	 *</em><a name="485" href="#485">485</a> <em>	 * See &lt;a href="https://sourceforge.net/tracker/?func=detail&amp;aid=927940&amp;group_id=73833&amp;atid=539099">[ 927940 ] java.net.URI parses %20 but getHost null&lt;/a></em><a name="486" href="#486">486</a> <em>	 */</em><a name="487" href="#487">487</a> 	<strong>public</strong> <strong>final</strong> <strong>void</strong> testSpaceInHost() {<a name="488" href="#488">488</a> 		<strong>boolean</strong> expectedException = false;<a name="489" href="#489">489</a> 		<strong>try</strong> {<a name="490" href="#490">490</a> 			UURIFactory.getInstance(<a name="491" href="#491">491</a> 					<span class="string">"http://www.local-regions.odpm%20.gov.uk"</span> +<a name="492" href="#492">492</a> 			<span class="string">"/lpsa/challenge/pdf/propect.pdf"</span>);<a name="493" href="#493">493</a> 		} <strong>catch</strong> (URIException e) {<a name="494" href="#494">494</a> 			expectedException = <strong>true</strong>;<a name="495" href="#495">495</a> 		}<a name="496" href="#496">496</a> 		assertTrue(<span class="string">"Did not fail with escaped space."</span>, expectedException);<a name="497" href="#497">497</a> 		<a name="498" href="#498">498</a> 		expectedException = false;<a name="499" href="#499">499</a> 		<strong>try</strong> {<a name="500" href="#500">500</a> 			UURIFactory.getInstance(<a name="501" href="#501">501</a> 					<span class="string">"http://www.local-regions.odpm .gov.uk"</span> +<a name="502" href="#502">502</a> 			<span class="string">"/lpsa/challenge/pdf/propect.pdf"</span>);<a name="503" href="#503">503</a> 		} <strong>catch</strong> (URIException e) {<a name="504" href="#504">504</a> 			expectedException = <strong>true</strong>;<a name="505" href="#505">505</a> 		}<a name="506" href="#506">506</a> 		assertTrue(<span class="string">"Did not fail with real space."</span>, expectedException);<a name="507" href="#507">507</a> 	}<a name="508" href="#508">508</a> 	<a name="509" href="#509">509</a> 	<em>/**<em>*</em></em><a name="510" href="#510">510</a> <em>	 * Test for java.net.URI chokes on hosts_with_underscores.</em><a name="511" href="#511">511</a> <em>	 *</em><a name="512" href="#512">512</a> <em>	 * @see  &lt;a href="https://sourceforge.net/tracker/?func=detail&amp;aid=808270&amp;group_id=73833&amp;atid=539099">[ 808270 ] java.net.URI chokes on hosts_with_underscores&lt;/a></em><a name="513" href="#513">513</a> <em>	 * @throws URIException</em><a name="514" href="#514">514</a> <em>	 */</em><a name="515" href="#515">515</a> 	<strong>public</strong> <strong>final</strong> <strong>void</strong> testHostWithUnderscores() throws URIException {<a name="516" href="#516">516</a> 		UURI uuri = UURIFactory.getInstance(<a name="517" href="#517">517</a> 		<span class="string">"http://x_underscore_underscore.2u.com.tw/nonexistent_page.html"</span>);<a name="518" href="#518">518</a> 		assertEquals(<span class="string">"Failed get of host with underscore"</span>,<a name="519" href="#519">519</a> 				<span class="string">"x_underscore_underscore.2u.com.tw"</span>, uuri.getHost());<a name="520" href="#520">520</a> 	}<a name="521" href="#521">521</a> 	<a name="522" href="#522">522</a> 	<a name="523" href="#523">523</a> 	<em>/**<em>*</em></em><a name="524" href="#524">524</a> <em>	 * Two dots for igor.</em><a name="525" href="#525">525</a> <em>	 */</em><a name="526" href="#526">526</a> 	<strong>public</strong> <strong>final</strong> <strong>void</strong> testTwoDots() {<a name="527" href="#527">527</a> 		<strong>boolean</strong> expectedException = false;<a name="528" href="#528">528</a> 		<strong>try</strong> {<a name="529" href="#529">529</a> 			UURIFactory.getInstance(<a name="530" href="#530">530</a> 			<span class="string">"http://x_underscore_underscore..2u.com/nonexistent_page.html"</span>);<a name="531" href="#531">531</a> 		} <strong>catch</strong> (URIException e) {<a name="532" href="#532">532</a> 			expectedException = <strong>true</strong>;<a name="533" href="#533">533</a> 		}<a name="534" href="#534">534</a> 		assertTrue(<span class="string">"Two dots did not throw exception"</span>, expectedException);<a name="535" href="#535">535</a> 	}<a name="536" href="#536">536</a> 	<a name="537" href="#537">537</a> 	<em>/**<em>*</em></em><a name="538" href="#538">538</a> <em>	 * Test for java.net.URI#getHost fails when leading digit.</em><a name="539" href="#539">539</a> <em>	 *</em><a name="540" href="#540">540</a> <em>	 * @see &lt;a href="https://sourceforge.net/tracker/?func=detail&amp;aid=910120&amp;group_id=73833&amp;atid=539099">[ 910120 ] java.net.URI#getHost fails when leading digit.&lt;/a></em><a name="541" href="#541">541</a> <em>	 * @throws URIException</em><a name="542" href="#542">542</a> <em>	 */</em><a name="543" href="#543">543</a> 	<strong>public</strong> <strong>final</strong> <strong>void</strong> testHostWithDigit() throws URIException {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -