You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cd...@apache.org on 2017/04/16 22:32:44 UTC
[53/72] [abbrv] flex-blazeds git commit: - Fixed a timing issue in
the AllowDocumentTypeDeclaration test
- Fixed a timing issue in the AllowDocumentTypeDeclaration test
Project: http://git-wip-us.apache.org/repos/asf/flex-blazeds/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-blazeds/commit/94728dd7
Tree: http://git-wip-us.apache.org/repos/asf/flex-blazeds/tree/94728dd7
Diff: http://git-wip-us.apache.org/repos/asf/flex-blazeds/diff/94728dd7
Branch: refs/heads/master
Commit: 94728dd74053f7ebfa6fbcb2c25f1a099172250f
Parents: 62d99f3
Author: Christofer Dutz <ch...@codecentric.de>
Authored: Fri Feb 17 10:49:38 2017 +0100
Committer: Christofer Dutz <ch...@codecentric.de>
Committed: Fri Feb 17 10:49:38 2017 +0100
----------------------------------------------------------------------
.../io/amfx/AllowDocumentTypeDeclaration.java | 44 ++++++++++----------
1 file changed, 21 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/94728dd7/core/src/test/java/flex/messaging/io/amfx/AllowDocumentTypeDeclaration.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/flex/messaging/io/amfx/AllowDocumentTypeDeclaration.java b/core/src/test/java/flex/messaging/io/amfx/AllowDocumentTypeDeclaration.java
index e1e1bb3..f90f7da 100644
--- a/core/src/test/java/flex/messaging/io/amfx/AllowDocumentTypeDeclaration.java
+++ b/core/src/test/java/flex/messaging/io/amfx/AllowDocumentTypeDeclaration.java
@@ -30,10 +30,6 @@ import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
-/**
- * Created by christoferdutz on 23.07.15.
- */
-
public class AllowDocumentTypeDeclaration extends TestCase {
public void testDoctypeEnabled() throws Exception {
@@ -41,16 +37,17 @@ public class AllowDocumentTypeDeclaration extends TestCase {
TinyServer server = new TinyServer();
server.start();
- // Sleep for half a second.
- Thread.sleep(500);
+ // Wait till the server is up.
+ while(server.port == 0) {
+ Thread.sleep(100);
+ }
try {
- StringBuffer xml = new StringBuffer(512);
- xml.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
- xml.append("<!DOCTYPE foo PUBLIC \"-//VSR//PENTEST//EN\" \"http://localhost:" + server.getPort() +
- "/service?ssrf\">");
- xml.append("<foo>Some content</foo>");
- XMLUtil.stringToDocument(xml.toString(), true, true, false);
+ String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" +
+ "<!DOCTYPE foo PUBLIC \"-//VSR//PENTEST//EN\" \"http://localhost:" +
+ server.getPort() + "/service?ssrf\">" +
+ "<foo>Some content</foo>";
+ XMLUtil.stringToDocument(xml, true, true, false);
// The server should have been contacted.
Assert.assertTrue(server.connected);
@@ -64,14 +61,16 @@ public class AllowDocumentTypeDeclaration extends TestCase {
TinyServer server = new TinyServer();
server.start();
- // Sleep for half a second.
- Thread.sleep(500);
+ // Wait till the server is up.
+ while(server.port == 0) {
+ Thread.sleep(100);
+ }
try {
- StringBuffer xml = new StringBuffer(512);
+ StringBuilder xml = new StringBuilder(512);
xml.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
- xml.append("<!DOCTYPE foo PUBLIC \"-//VSR//PENTEST//EN\" \"http://localhost:" + server.getPort() +
- "/service?ssrf\">");
+ xml.append("<!DOCTYPE foo PUBLIC \"-//VSR//PENTEST//EN\" \"http://localhost:");
+ xml.append(server.getPort()).append("/service?ssrf\">");
xml.append("<foo>Some content</foo>");
try {
XMLUtil.stringToDocument(xml.toString(), true, false, false);
@@ -115,6 +114,9 @@ public class AllowDocumentTypeDeclaration extends TestCase {
"<!ELEMENT foo>" +
"]>").getBytes());
out.flush();
+
+ // It seems we need a little sleep here or the Dom parser hangs forever.
+ Thread.sleep(100);
} catch (Exception e) {
// Ignore.
} finally {
@@ -131,7 +133,7 @@ public class AllowDocumentTypeDeclaration extends TestCase {
}
}
- public void kill() {
+ void kill() {
try {
serverSocket.close();
} catch (IOException e) {
@@ -139,13 +141,9 @@ public class AllowDocumentTypeDeclaration extends TestCase {
}
}
- public int getPort() {
+ int getPort() {
return port;
}
-
- public boolean isConnected() {
- return connected;
- }
}
}