Question
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.
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started