Skip to content

Commit

Permalink
refs #3425 fixed chunked handling and removed connection constructor … (
Browse files Browse the repository at this point in the history
#3705)

* refs #3425 fixed chunked handling and removed connection constructor info methods in favor of connection serialization which is cleaner and easier to maintain

* refs #3425 removed tests for removed functionality
  • Loading branch information
davidnich committed Dec 28, 2019
1 parent 65151f1 commit fa46f42
Show file tree
Hide file tree
Showing 30 changed files with 27 additions and 501 deletions.
2 changes: 2 additions & 0 deletions doxygen/lang/900_release_notes.dox.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
- fixed broken @ref cast "cast<>" operator handling; in previous releases, @ref cast "cast<>" would accept and
return @ref nothing without raising an error with type specifications that did not accept or return
@ref nothing. To get the old behavior, use the @ref broken-cast "%broken-cast" parse directive.
- classes inheriting \c AbstractConneciton must be serializable; the \c AbstractConnection::getConstructorInfo()
and \c AbstractConnection::getConstructorInfoImpl() methods have been removed and are ignored in child classes

@subsection qore_094_new_features New Features in Qore
- <a href="../../modules/ConnectionProvider/html/index.html">ConnectionProvider</a> module:
Expand Down
24 changes: 1 addition & 23 deletions examples/test/qlib/AwsRestClient/AwsRestClient.qtest
Original file line number Diff line number Diff line change
Expand Up @@ -125,28 +125,6 @@ class AwsTest inherits QUnit::Test {

AwsRestClient new_client = conn.get(False);
assertEq(True, new_client instanceof AwsRestClient);

hash<ConnectionConstructorInfo> info = conn.getConstructorInfo();
assertEq("AwsRestClient", info.module);
assertEq("AwsRestClient", info.class_name);
assertEq(url, info.args[0].url);
checkPreAndPostProcessing(info);
}

private checkPreAndPostProcessing(hash<ConnectionConstructorInfo> info) {
Program program(PO_NEW_STYLE|PO_STRICT_ARGS|PO_REQUIRE_TYPES);
if (info.module)
program.loadModule(info.module);
if (info.pre_processing) {
string pre_processing = sprintf("sub pre_processing(reference<*softlist<auto>> args, bool connect, *hash rtopts) { %s }", info.pre_processing);
program.parse(pre_processing, "pre processing");
assertTrue(True, "pre processing: " + info.class_name);
}
if (info.post_processing) {
string post_processing = sprintf("sub post_processing(%s obj, bool connect, *hash rtopts) { %s }", info.class_name, info.post_processing);
program.parse(post_processing, "post processing");
assertTrue(True, "post processing: " + info.class_name);
}
}
}

Expand All @@ -158,4 +136,4 @@ class AwsRestTestClient inherits AwsRestClient {
string signed_headers;
return getSignature(meth, path, \hdr, body, gmdate, scope, \signed_headers);
}
}
}
39 changes: 1 addition & 38 deletions examples/test/qlib/ConnectionProvider/ConnectionProvider.qtest
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ public class ConnectionProviderTest inherits QUnit::Test {
# issue #3696: test connection serialization
FtpConnection conn2 = Serializable::deserialize(fc.serialize());
assertEq(fc.url, conn2.url);

hash<ConnectionConstructorInfo> info = fc.getConstructorInfo();
assertEq("FtpClient", info.class_name);
assertEq(url, info.args[0]);
checkPreAndPostProcessing(info);
}

ftpConnectionTestDeprecated() {
Expand All @@ -66,29 +61,6 @@ public class ConnectionProviderTest inherits QUnit::Test {
FtpConnection fc("name", "desc", url, True, NOTHING, urlh);
assertEq(True, fc.enabled, "connection is enabled by default");
assertEq(False, fc.locked, "connection is unlocked by default");

hash<ConnectionConstructorInfo> info = fc.getConstructorInfo();
assertEq("FtpClient", info.class_name);
assertEq(url, info.args[0]);
checkPreAndPostProcessing(info);
}

private checkPreAndPostProcessing(hash<ConnectionConstructorInfo> info) {
Program p(PO_NEW_STYLE | PO_STRICT_ARGS | PO_REQUIRE_TYPES);
if (info.module)
p.loadModule(info.module);
if (info.pre_processing) {
string pre_processing = sprintf("sub pre_processing(reference<*softlist<auto>> args, bool connect, *hash<auto> rtopts) { %s }", info.pre_processing);
# ensure that the pre processing code can be parsed
p.parse(pre_processing, "pre processing");
assertTrue(True, "pre processing: " + info.class_name);
}
if (info.post_processing) {
string post_processing = sprintf("sub post_processing(%s obj, bool connect, *hash<auto> rtopts) { %s }", info.class_name, info.post_processing);
# ensure that the post processing code can be parsed
p.parse(post_processing, "post processing");
assertTrue(True, "post processing: " + info.class_name);
}
}

httpConnectionTest() {
Expand Down Expand Up @@ -124,13 +96,6 @@ public class ConnectionProviderTest inherits QUnit::Test {
HTTPClient client = hc.get();
assertEq("X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT", server.wait());

hash<ConnectionConstructorInfo> info = hc.getConstructorInfo();
assertEq("HTTPClient", info.class_name);
assertEq(45s, info.args[0].timeout);
assertEq(45s, info.args[0].connect_timeout);
assertEq("password", info.args[0].ssl_key_password);
checkPreAndPostProcessing(info);

# turn on certificate verification in the server
server.acceptAllCertificates(False);
assertEq(False, server.getAcceptAllCertificates());
Expand Down Expand Up @@ -275,9 +240,7 @@ class MyConnection inherits AbstractConnection {
string getType() {
return "sql";
}
hash<ConnectionConstructorInfo> getConstructorInfoImpl() {
return hash<ConnectionConstructorInfo>{};
}

object getImpl(bool _ = True, *hash<auto> __) {
return new Dir(); # just a silence the missing abtsract method. No use for Dir at all
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,6 @@ class TestConnection inherits AbstractConnection {
private TestConn getImpl(bool connect = True, *hash rtopts) {
return new TestConn();
}

private hash<ConnectionConstructorInfo> getConstructorInfoImpl() {
return new hash<ConnectionConstructorInfo>({
"module": "TestConnection",
"class_name": "TestConn",
});
}
}

public namespace TestConnectionProvider {
Expand Down
27 changes: 0 additions & 27 deletions examples/test/qlib/Pop3Client/Pop3Client.qtest
Original file line number Diff line number Diff line change
Expand Up @@ -50,32 +50,5 @@ public class Pop3ClientTest inherits QUnit::Test {
conn = new Pop3Connection("test", "test", url, {"monitor": False});
client = conn.get(False);
assertEq("localhost:8099", client.getTarget());

hash<ConnectionConstructorInfo> info = conn.getConstructorInfo();
assertEq("Pop3Client", info.module);
assertEq("Pop3Client", info.class_name);
assertEq(url, info.args[0]);
checkPreAndPostProcessing(info);
}

private checkPreAndPostProcessing(hash<ConnectionConstructorInfo> info) {
if (info.pre_processing) {
Program p(PO_NEW_STYLE | PO_STRICT_ARGS | PO_REQUIRE_TYPES);
if (info.module)
p.loadModule(info.module);
string pre_processing = sprintf("sub pre_processing(reference<*softlist<auto>> args, bool connect, *hash rtopts) { %s }", info.pre_processing);
# ensure that the pre processing code can be parsed
p.parse(pre_processing, "pre processing");
assertTrue(True, "pre processing: " + info.class_name);
}
if (info.post_processing) {
Program p(PO_NEW_STYLE | PO_STRICT_ARGS | PO_REQUIRE_TYPES);
if (info.module)
p.loadModule(info.module);
string post_processing = sprintf("sub post_processing(%s obj, bool connect, *hash rtopts) { %s }", info.class_name, info.post_processing);
# ensure that the post processing code can be parsed
p.parse(post_processing, "post processing");
assertTrue(True, "post processing: " + info.class_name);
}
}
}
24 changes: 0 additions & 24 deletions examples/test/qlib/RestClient/RestClient.qtest
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,6 @@ public class Main inherits QUnit::Test {
assertEq(False, conn.monitor);
assertEq(True, conn.enabled);

hash<ConnectionConstructorInfo> info = conn.getConstructorInfo();
assertEq("RestClient", info.module);
assertEq("RestClient", info.class_name);
assertEq(url, info.args[0].url);
checkPreAndPostProcessing(info);

conn = new RestConnection("test", "test", url, {"monitor": False}, {"headers": "X-Test=" + val});
client = conn.get(False);
assertEq(hdr, client.getDefaultHeaders(){"X-Test",});
Expand All @@ -262,22 +256,4 @@ public class Main inherits QUnit::Test {
new RestConnection("test", "test", url, {"monitor": False}, {"headers": "1"});
});
}

private checkPreAndPostProcessing(hash<ConnectionConstructorInfo> info) {
Program p(PO_NEW_STYLE | PO_STRICT_ARGS | PO_REQUIRE_TYPES);
if (info.module)
p.loadModule(info.module);
if (info.pre_processing) {
string pre_processing = sprintf("sub pre_processing(reference<*softlist<auto>> args, bool connect, *hash rtopts) { %s }", info.pre_processing);
# ensure that the pre processing code can be parsed
p.parse(pre_processing, "pre processing");
assertTrue(True, "pre processing: " + info.class_name);
}
if (info.post_processing) {
string post_processing = sprintf("sub post_processing(%s obj, bool connect, *hash rtopts) { %s }", info.class_name, info.post_processing);
# ensure that the post processing code can be parsed
p.parse(post_processing, "post processing");
assertTrue(True, "post processing: " + info.class_name);
}
}
} # class Main
27 changes: 0 additions & 27 deletions examples/test/qlib/SalesforceRestClient/SalesforceRestClient.qtest
Original file line number Diff line number Diff line change
Expand Up @@ -127,32 +127,5 @@ class SalesforceTest inherits QUnit::Test {
# issue #3321: check default timeouts
assertEq(45000, client.getTimeout());
assertEq(45000, client.getConnectTimeout());

hash<ConnectionConstructorInfo> info = swsc.getConstructorInfo();
assertEq("SalesforceRestClient", info.module);
assertEq("SalesforceRestClient", info.class_name);
assertEq(url, info.args[0].url);
checkPreAndPostProcessing(info);

# issue #3346: the Salesforce rest connection returns 'rest' type instead of 'sfrests'
assertEq("sfrests", swsc.getType());
}

private checkPreAndPostProcessing(hash<ConnectionConstructorInfo> info) {
Program p(PO_NEW_STYLE | PO_STRICT_ARGS | PO_REQUIRE_TYPES);
if (info.module)
p.loadModule(info.module);
if (info.pre_processing) {
string pre_processing = sprintf("sub pre_processing(reference<*softlist<auto>> args, bool connect, *hash rtopts) { %s }", info.pre_processing);
# ensure that the pre processing code can be parsed
p.parse(pre_processing, "pre processing");
assertTrue(True, "pre processing: " + info.class_name);
}
if (info.post_processing) {
string post_processing = sprintf("sub post_processing(%s obj, bool connect, *hash rtopts) { %s }", info.class_name, info.post_processing);
# ensure that the post processing code can be parsed
p.parse(post_processing, "post processing");
assertTrue(True, "post processing: " + info.class_name);
}
}
}
24 changes: 0 additions & 24 deletions examples/test/qlib/Sap4HanaRestClient/Sap4HanaRestClient.qtest
Original file line number Diff line number Diff line change
Expand Up @@ -122,29 +122,5 @@ public class Main inherits QUnit::Test {
# issue #3321: check default timeouts
assertEq(45000, client.getTimeout());
assertEq(45000, client.getConnectTimeout());

hash<ConnectionConstructorInfo> info = swsc.getConstructorInfo();
assertEq("Sap4HanaRestClient", info.module);
assertEq("Sap4HanaRestClient", info.class_name);
assertEq(url, info.args[0].url);
checkPreAndPostProcessing(info);
}

private checkPreAndPostProcessing(hash<ConnectionConstructorInfo> info) {
Program p(PO_NEW_STYLE | PO_STRICT_ARGS | PO_REQUIRE_TYPES);
if (info.module)
p.loadModule(info.module);
if (info.pre_processing) {
string pre_processing = sprintf("sub pre_processing(reference<*softlist<auto>> args, bool connect, *hash rtopts) { %s }", info.pre_processing);
# ensure that the pre processing code can be parsed
p.parse(pre_processing, "pre processing");
assertTrue(True, "pre processing: " + info.class_name);
}
if (info.post_processing) {
string post_processing = sprintf("sub post_processing(%s obj, bool connect, *hash rtopts) { %s }", info.class_name, info.post_processing);
# ensure that the post processing code can be parsed
p.parse(post_processing, "post processing");
assertTrue(True, "post processing: " + info.class_name);
}
}
} # class Main
24 changes: 0 additions & 24 deletions examples/test/qlib/SewioRestClient/SewioRestClient.qtest
Original file line number Diff line number Diff line change
Expand Up @@ -123,29 +123,5 @@ public class Main inherits QUnit::Test {
# issue #3321: check default timeouts
assertEq(45000, client.getTimeout());
assertEq(45000, client.getConnectTimeout());

hash<ConnectionConstructorInfo> info = swsc.getConstructorInfo();
assertEq("SewioRestClient", info.module);
assertEq("SewioRestClient", info.class_name);
assertEq(url, info.args[0].url);
checkPreAndPostProcessing(info);
}

private checkPreAndPostProcessing(hash<ConnectionConstructorInfo> info) {
Program p(PO_NEW_STYLE | PO_STRICT_ARGS | PO_REQUIRE_TYPES);
if (info.module)
p.loadModule(info.module);
if (info.pre_processing) {
string pre_processing = sprintf("sub pre_processing(reference<*softlist<auto>> args, bool connect, *hash rtopts) { %s }", info.pre_processing);
# ensure that the pre processing code can be parsed
p.parse(pre_processing, "pre processing");
assertTrue(True, "pre processing: " + info.class_name);
}
if (info.post_processing) {
string post_processing = sprintf("sub post_processing(%s obj, bool connect, *hash rtopts) { %s }", info.class_name, info.post_processing);
# ensure that the post processing code can be parsed
p.parse(post_processing, "post processing");
assertTrue(True, "post processing: " + info.class_name);
}
}
} # class Main
27 changes: 0 additions & 27 deletions examples/test/qlib/SmtpClient/SmtpClient.qtest
Original file line number Diff line number Diff line change
Expand Up @@ -50,32 +50,5 @@ public class SmtpClientTest inherits QUnit::Test {
conn = new SmtpConnection("test", "test", url, {"monitor": False});
client = conn.get(False);
assertEq("localhost:8099", client.getTarget());

hash<ConnectionConstructorInfo> info = conn.getConstructorInfo();
assertEq("SmtpClient", info.module);
assertEq("SmtpClient", info.class_name);
assertEq(url, info.args[0]);
checkPreAndPostProcessing(info);
}

private checkPreAndPostProcessing(hash<ConnectionConstructorInfo> info) {
if (info.pre_processing) {
Program p(PO_NEW_STYLE | PO_STRICT_ARGS | PO_REQUIRE_TYPES);
if (info.module)
p.loadModule(info.module);
string pre_processing = sprintf("sub pre_processing(reference<*softlist<auto>> args, bool connect, *hash rtopts) { %s }", info.pre_processing);
# ensure that the pre processing code can be parsed
p.parse(pre_processing, "pre processing");
assertTrue(True, "pre processing: " + info.class_name);
}
if (info.post_processing) {
Program p(PO_NEW_STYLE | PO_STRICT_ARGS | PO_REQUIRE_TYPES);
if (info.module)
p.loadModule(info.module);
string post_processing = sprintf("sub post_processing(%s obj, bool connect, *hash rtopts) { %s }", info.class_name, info.post_processing);
# ensure that the post processing code can be parsed
p.parse(post_processing, "post processing");
assertTrue(True, "post processing: " + info.class_name);
}
}
}
27 changes: 0 additions & 27 deletions examples/test/qlib/TelnetClient/TelnetClient.qtest
Original file line number Diff line number Diff line change
Expand Up @@ -43,32 +43,5 @@ public class TelnetClientTest inherits QUnit::Test {
conn = new TelnetConnection("test", "test", url, {"monitor": False});
client = conn.get(False);
assertEq("localhost:8099", client.getTarget());

hash<ConnectionConstructorInfo> info = conn.getConstructorInfo();
assertEq("TelnetClient", info.module);
assertEq("TelnetClient", info.class_name);
assertEq(url, info.args[0]);
checkPreAndPostProcessing(info);
}

private checkPreAndPostProcessing(hash<ConnectionConstructorInfo> info) {
if (info.pre_processing) {
Program p(PO_NEW_STYLE | PO_STRICT_ARGS | PO_REQUIRE_TYPES);
if (info.module)
p.loadModule(info.module);
string pre_processing = sprintf("sub pre_processing(reference<*softlist<auto>> args, bool connect, *hash rtopts) { %s }", info.pre_processing);
# ensure that the pre processing code can be parsed
p.parse(pre_processing, "pre processing");
assertTrue(True, "pre processing: " + info.class_name);
}
if (info.post_processing) {
Program p(PO_NEW_STYLE | PO_STRICT_ARGS | PO_REQUIRE_TYPES);
if (info.module)
p.loadModule(info.module);
string post_processing = sprintf("sub post_processing(%s obj, bool connect, *hash rtopts) { %s }", info.class_name, info.post_processing);
# ensure that the post processing code can be parsed
p.parse(post_processing, "post processing");
assertTrue(True, "post processing: " + info.class_name);
}
}
}
29 changes: 0 additions & 29 deletions examples/test/qlib/WebSocketClient/WebSocketClient.qtest
Original file line number Diff line number Diff line change
Expand Up @@ -103,35 +103,6 @@ class WebSocketClientTest inherits QUnit::Test {
conn = new WebSocketConnectionObject("test", "test", url, {"monitor": False});
client = conn.get(False);
assertEq(url, client.getUrl());

hash<ConnectionConstructorInfo> info = conn.getConstructorInfo();
assertEq("WebSocketClient", info.module);
assertEq("WebSocketClient", info.class_name);
assertEq(url, info.args[0].url);
assertEq(45s, info.args[0].timeout);
assertEq(45s, info.args[0].connect_timeout);
checkPreAndPostProcessing(info);
}

private checkPreAndPostProcessing(hash<ConnectionConstructorInfo> info) {
if (info.pre_processing) {
Program p(PO_NEW_STYLE | PO_STRICT_ARGS | PO_REQUIRE_TYPES);
if (info.module)
p.loadModule(info.module);
string pre_processing = sprintf("sub pre_processing(reference<*softlist<auto>> args, bool connect, *hash rtopts) { %s }", info.pre_processing);
# ensure that the pre processing code can be parsed
p.parse(pre_processing, "pre processing");
assertTrue(True, "pre processing: " + info.class_name);
}
if (info.post_processing) {
Program p(PO_NEW_STYLE | PO_STRICT_ARGS | PO_REQUIRE_TYPES);
if (info.module)
p.loadModule(info.module);
string post_processing = sprintf("sub post_processing(%s obj, bool connect, *hash rtopts) { %s }", info.class_name, info.post_processing);
# ensure that the post processing code can be parsed
p.parse(post_processing, "post processing");
assertTrue(True, "post processing: " + info.class_name);
}
}

private log(string str) {
Expand Down
Loading

0 comments on commit fa46f42

Please sign in to comment.