Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New URLConnection test for exception thrown on connect #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ CLASSES += src/malva/java/lang/reflect/FieldTest.class
CLASSES += src/malva/java/math/BigDecimalTest.class
CLASSES += src/malva/java/net/InetAddressTest.class
CLASSES += src/malva/java/net/NetworkInterfaceTest.class
CLASSES += src/malva/java/net/URLConnectionTest.class
CLASSES += src/malva/java/nio/DirectByteBufferTest.class
CLASSES += src/malva/java/text/DecimalFormatTest.class
CLASSES += src/malva/java/text/SimpleDateFormatTest.class
Expand Down
26 changes: 26 additions & 0 deletions src/malva/java/net/URLConnectionTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package malva.java.net;

import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;

import malva.TestCase;

public class URLConnectionTest extends TestCase {
private static void testConnect() throws Exception {
// Connect with unresolvable hostname
URL url = new URL("http", "anunresolvablehost", 80, "index.html");
final URLConnection connection = url.openConnection();
connection.setUseCaches(false);
assertThrows(new Block() {
@Override
public void run() throws Throwable {
connection.connect();
}
}, IOException.class);
}

public static void main(String[] args) throws Exception {
testConnect();
}
}