mirror of https://github.com/apache/jclouds.git
Merge identical tests
This commit is contained in:
parent
a10bf3e9c5
commit
f236e046e3
|
@ -20,8 +20,6 @@ import static org.easymock.EasyMock.createMock;
|
|||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
import static org.jclouds.utils.TestUtils.NO_INVOCATIONS;
|
||||
import static org.jclouds.utils.TestUtils.SINGLE_NO_ARG_INVOCATION;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -30,8 +28,6 @@ import java.util.concurrent.TimeoutException;
|
|||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.utils.TestUtils;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
import org.xml.sax.Locator;
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
@ -53,16 +49,6 @@ public class ParseSaxTest extends BaseHandlerTest {
|
|||
return factory.create(injector.getInstance(TestHandler.class));
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] runUnderJava7() {
|
||||
return TestUtils.isJava7() ? SINGLE_NO_ARG_INVOCATION : NO_INVOCATIONS;
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] runUnderJava8() {
|
||||
return TestUtils.isJava8() ? SINGLE_NO_ARG_INVOCATION : NO_INVOCATIONS;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddDetailsAndPropagateOkWhenRequestWithNoDataAndRuntimeExceptionThrowsOriginalException()
|
||||
throws ExecutionException, InterruptedException, TimeoutException, IOException {
|
||||
|
@ -127,34 +113,8 @@ public class ParseSaxTest extends BaseHandlerTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "runUnderJava7")
|
||||
public void testAddDetailsAndPropagateOkWithValidRequestResponseWithSAXParseException_java7() throws ExecutionException,
|
||||
InterruptedException, TimeoutException, IOException {
|
||||
|
||||
ParseSax<String> parser = createParser();
|
||||
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://foohost").build();
|
||||
HttpResponse response = HttpResponse.builder().statusCode(304).message("Not Modified").build();
|
||||
Locator locator = createMock(Locator.class);
|
||||
expect(locator.getColumnNumber()).andReturn(1);
|
||||
expect(locator.getLineNumber()).andReturn(1);
|
||||
expect(locator.getPublicId()).andReturn("publicId");
|
||||
expect(locator.getSystemId()).andReturn("systemId");
|
||||
replay(locator);
|
||||
Exception input = new SAXParseException("foo", locator);
|
||||
verify(locator);
|
||||
|
||||
try {
|
||||
parser.setContext(request);
|
||||
parser.addDetailsAndPropagate(response, input);
|
||||
} catch (RuntimeException e) {
|
||||
assertEquals(e.getMessage(),
|
||||
"request: GET http://foohost HTTP/1.1; response: HTTP/1.1 304 Not Modified; error at 1:1 in document systemId; cause: org.xml.sax.SAXParseExceptionpublicId: publicId; systemId: systemId; lineNumber: 1; columnNumber: 1; foo");
|
||||
assertEquals(e.getCause(), input);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "runUnderJava8")
|
||||
public void testAddDetailsAndPropagateOkWithValidRequestResponseWithSAXParseException_java8() throws ExecutionException,
|
||||
@Test
|
||||
public void testAddDetailsAndPropagateOkWithValidRequestResponseWithSAXParseException() throws ExecutionException,
|
||||
InterruptedException, TimeoutException, IOException {
|
||||
|
||||
ParseSax<String> parser = createParser();
|
||||
|
|
|
@ -29,16 +29,6 @@ public class TestUtils {
|
|||
public static final Object[][] NO_INVOCATIONS = new Object[0][0];
|
||||
public static final Object[][] SINGLE_NO_ARG_INVOCATION = { new Object[0] };
|
||||
|
||||
public static boolean isJava7() {
|
||||
System.out.println(System.getProperty("java.version", "None??"));
|
||||
return System.getProperty("java.version", "").contains("1.7.");
|
||||
}
|
||||
|
||||
public static boolean isJava8() {
|
||||
System.out.println(System.getProperty("java.version", "None??"));
|
||||
return System.getProperty("java.version", "").contains("1.8.");
|
||||
}
|
||||
|
||||
public static ByteSource randomByteSource() {
|
||||
return randomByteSource(0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue