Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Explain testIsValid Function 2. Give how many total number of the URLs it is testing. Also, explain how it is building all the URLs.

1. Explain testIsValid Function

2. Give how many total number of the URLs it is testing. Also, explain how it is building all the URLs.

3. Give an example of valid URL being tested and an invalid URL being tested by testIsValid() method.

* @param testObjects Used to create a url.

*/

public void testIsValid(Object[] testObjects, long allowAllSchemes) {

UrlValidator urlVal = new UrlValidator(null, null, allowAllSchemes);

//UlValidator urlVal = new UrlValidator(null, allowAllSchemes);

assertTrue(urlVal.isValid(\"http://www.google.com/\"));

int statusPerLine = 60;

int printed = 0;

if (printIndex) {

statusPerLine = 6;

}

do {

StringBuilder testBuffer = new StringBuilder();

boolean expected = true;

for (int testPartsIndexIndex = 0; testPartsIndexIndex

int index = testPartsIndex[testPartsIndexIndex];

ResultPair[] part = (ResultPair[]) testObjects[testPartsIndexIndex];

testBuffer.append(part[index].item);

expected &= part[index].valid;

}

String url = testBuffer.toString();

boolean result = urlVal.isValid(url);

if(result == true)

System.out.println(url);

assertEquals(url, expected, result);

if (printStatus) {

if (printIndex) {

System.out.print(testPartsIndextoString());

} else {

if (result == expected) {

System.out.print('.');

} else {

System.out.print('X');

}

}

printed++;

if (printed == statusPerLine) {

System.out.println();

printed = 0;

}

}

} while (incrementTestPartsIndex(testPartsIndex, testObjects));

if (printStatus) {

System.out.println();

}

}

public void testIsValid(Object[] testObjects, long allowAllSchemes) {

UrlValidator urlVal = new UrlValidator(null, null, allowAllSchemes);

//UrlValidator urlVal = new UrlValidator(null, allowAllSchemes);

assertTrue(urlVal.isValid(\"http://www.google.com\"));

assertTrue(urlVal.isValid(\"http://www.google.com/\"));

int statusPerLine = 60;

int printed = 0;

if (printIndex) {

statusPerLine = 6;

}

do {

StringBuilder testBuffer = new StringBuilder();

boolean expected = true;

for (int testPartsIndexIndex = 0; testPartsIndexIndex

int index = testPartsIndex[testPartsIndexIndex];

ResultPair[] part = (ResultPair[]) testObjects[testPartsIndexIndex];

testBuffer.append(part[index].item);

expected &= part[index].valid;

}

String url = testBuffer.toString();

boolean result = urlVal.isValid(url);

if(result == true)

System.out.println(url);

assertEquals(url, expected, result);

if (printStatus) {

if (printIndex) {

System.out.print(testPartsIndextoString());

} else {

if (result == expected) {

System.out.print('.');

} else {

System.out.print('X');

}

}

printed++;

if (printed == statusPerLine) {

System.out.println();

printed = 0;

}

}

} while (incrementTestPartsIndex(testPartsIndex, testObjects));

if (printStatus) {

System.out.println();

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

Why is failing to reject ????0 often an unreliable decision?

Answered: 1 week ago