You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2021/09/15 22:50:29 UTC

[qpid-protonj2] branch main updated: PROTON-2393 Fix test driver some API naming and clean up internals

This is an automated email from the ASF dual-hosted git repository.

tabish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-protonj2.git


The following commit(s) were added to refs/heads/main by this push:
     new 6d44c11  PROTON-2393 Fix test driver some API naming and clean up internals
6d44c11 is described below

commit 6d44c11eebfae6f9f731acce7b465177ae01eac0
Author: Timothy Bish <ta...@gmail.com>
AuthorDate: Wed Sep 15 18:50:18 2021 -0400

    PROTON-2393 Fix test driver some API naming and clean up internals
---
 .../qpid/protonj2/client/impl/ConnectionTest.java  |   2 +-
 .../qpid/protonj2/client/impl/SenderTest.java      |   4 +-
 .../qpid/protonj2/test/driver/ScriptWriter.java    |  14 +-
 .../driver/expectations/AMQPHeaderExpectation.java |   2 +-
 .../driver/expectations/AttachExpectation.java     |  12 +-
 .../driver/matchers/messaging/OpenMatcher.java     | 179 ---------------------
 .../engine/impl/sasl/ProtonSaslClientTest.java     |   8 +-
 7 files changed, 20 insertions(+), 201 deletions(-)

diff --git a/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/ConnectionTest.java b/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/ConnectionTest.java
index 4d21679..3c57622 100644
--- a/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/ConnectionTest.java
+++ b/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/ConnectionTest.java
@@ -384,7 +384,7 @@ public class ConnectionTest extends ImperativeClientTestCase {
     @Test
     public void testCreateConnectionWithSASLDisabledToSASLEnabledHost() throws Exception {
         try (ProtonTestServer peer = new ProtonTestServer(testServerOptions())) {
-            peer.expectAMQPHeader().respondWithSASLPHeader();
+            peer.expectAMQPHeader().respondWithSASLHeader();
             peer.start();
 
             URI remoteURI = peer.getServerURI();
diff --git a/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/SenderTest.java b/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/SenderTest.java
index 29f394c..d9ebdbd 100644
--- a/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/SenderTest.java
+++ b/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/SenderTest.java
@@ -940,7 +940,7 @@ public class SenderTest extends ImperativeClientTestCase {
             peer.expectBegin().respond();
             peer.expectAttach().ofSender()
                                .withSenderSettleModeSettled()
-                               .withReceivervSettlesFirst()
+                               .withReceiverSettlesFirst()
                                .respond()
                                .withSenderSettleModeSettled()
                                .withReceivervSettlesFirst();
@@ -1163,7 +1163,7 @@ public class SenderTest extends ImperativeClientTestCase {
             peer.expectOpen().respond().withOfferedCapabilities("ANONYMOUS-RELAY");
             peer.expectBegin().respond();
             peer.expectAttach().ofSender().withSenderSettleModeSettled()
-                                          .withReceivervSettlesFirst()
+                                          .withReceiverSettlesFirst()
                                           .withTarget().withAddress(Matchers.nullValue()).and().respond();
             peer.expectClose().respond();
             peer.start();
diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/ScriptWriter.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/ScriptWriter.java
index 698c5a4..38d3a01 100644
--- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/ScriptWriter.java
+++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/ScriptWriter.java
@@ -330,7 +330,7 @@ public abstract class ScriptWriter {
      * header to arrive and a header response will be sent.
      */
     public void expectSASLAnonymousConnect() {
-        expectSASLHeader().respondWithSASLPHeader();
+        expectSASLHeader().respondWithSASLHeader();
         remoteSaslMechanisms().withMechanisms("ANONYMOUS").queue();
         expectSaslInit().withMechanism("ANONYMOUS");
         remoteSaslOutcome().withCode(SaslCode.OK).queue();
@@ -354,7 +354,7 @@ public abstract class ScriptWriter {
      *      The password that is expected in the SASL Plain initial response.
      */
     public void expectSASLPlainConnect(String username, String password) {
-        expectSASLHeader().respondWithSASLPHeader();
+        expectSASLHeader().respondWithSASLHeader();
         remoteSaslMechanisms().withMechanisms("PLAIN").queue();
         expectSaslInit().withMechanism("PLAIN").withInitialResponse(saslPlainInitialResponse(username, password));
         remoteSaslOutcome().withCode(SaslCode.OK).queue();
@@ -378,7 +378,7 @@ public abstract class ScriptWriter {
      *      The password that is expected in the SASL initial response.
      */
     public void expectSaslXOauth2Connect(String username, String password) {
-        expectSASLHeader().respondWithSASLPHeader();
+        expectSASLHeader().respondWithSASLHeader();
         remoteSaslMechanisms().withMechanisms("XOAUTH2").queue();
         expectSaslInit().withMechanism("XOAUTH2").withInitialResponse(saslXOauth2InitialResponse(username, password));
         remoteSaslOutcome().withCode(SaslCode.OK).queue();
@@ -422,7 +422,7 @@ public abstract class ScriptWriter {
             throw new AssertionError("Expected offered mechanisms that contains the PLAIN mechanism");
         }
 
-        expectSASLHeader().respondWithSASLPHeader();
+        expectSASLHeader().respondWithSASLHeader();
         remoteSaslMechanisms().withMechanisms(offeredMechanisms).queue();
         expectSaslInit().withMechanism("PLAIN");
 
@@ -445,7 +445,7 @@ public abstract class ScriptWriter {
      * header to arrive and a header response will be sent.
      */
     public void expectSaslExternalConnect() {
-        expectSASLHeader().respondWithSASLPHeader();
+        expectSASLHeader().respondWithSASLHeader();
         remoteSaslMechanisms().withMechanisms("EXTERNAL").queue();
         expectSaslInit().withMechanism("EXTERNAL").withInitialResponse(new byte[0]);
         remoteSaslOutcome().withCode(SaslCode.OK).queue();
@@ -461,7 +461,7 @@ public abstract class ScriptWriter {
      *      The set of SASL Mechanisms to advertise as available on the peer.
      */
     public void expectSaslMechanismNegotiationFailure(String... offeredMechanisms) {
-        expectSASLHeader().respondWithSASLPHeader();
+        expectSASLHeader().respondWithSASLHeader();
         remoteSaslMechanisms().withMechanisms(offeredMechanisms).queue();
     }
 
@@ -476,7 +476,7 @@ public abstract class ScriptWriter {
      *      The SASL Mechanism that the client should select and respond with.
      */
     public void expectSaslConnectThatAlwaysFailsAuthentication(String[] offeredMechanisms, String chosenMechanism) {
-        expectSASLHeader().respondWithSASLPHeader();
+        expectSASLHeader().respondWithSASLHeader();
         remoteSaslMechanisms().withMechanisms(offeredMechanisms).queue();
         expectSaslInit().withMechanism(chosenMechanism);
         remoteSaslOutcome().withCode(SaslCode.AUTH).queue();
diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/expectations/AMQPHeaderExpectation.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/expectations/AMQPHeaderExpectation.java
index 3251600..b00dd2c 100644
--- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/expectations/AMQPHeaderExpectation.java
+++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/expectations/AMQPHeaderExpectation.java
@@ -47,7 +47,7 @@ public class AMQPHeaderExpectation implements ScriptedExpectation {
         return response;
     }
 
-    public AMQPHeaderInjectAction respondWithSASLPHeader() {
+    public AMQPHeaderInjectAction respondWithSASLHeader() {
         AMQPHeaderInjectAction response = new AMQPHeaderInjectAction(driver, AMQPHeader.getSASLHeader());
         driver.addScriptedElement(response);
         return response;
diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/expectations/AttachExpectation.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/expectations/AttachExpectation.java
index 15b9c8f..02b1c6b 100644
--- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/expectations/AttachExpectation.java
+++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/expectations/AttachExpectation.java
@@ -161,16 +161,14 @@ public class AttachExpectation extends AbstractExpectation<Attach> {
 
             if (response.getPerformative().getTarget() == null && !response.isNullTargetRequired()) {
                 if (attach.getTarget() != null) {
-                    if (attach.getTarget() instanceof org.apache.qpid.protonj2.test.driver.codec.messaging.Target) {
-                        org.apache.qpid.protonj2.test.driver.codec.messaging.Target target =
-                            (org.apache.qpid.protonj2.test.driver.codec.messaging.Target) attach.getTarget();
+                    if (attach.getTarget() instanceof Target) {
+                        Target target = (Target) attach.getTarget();
                         response.withTarget(target);
                         if (target != null && Boolean.TRUE.equals(target.getDynamic())) {
                             target.setAddress(UUID.randomUUID().toString());
                         }
                     } else {
-                        org.apache.qpid.protonj2.test.driver.codec.transactions.Coordinator coordinator =
-                            (org.apache.qpid.protonj2.test.driver.codec.transactions.Coordinator) attach.getTarget();
+                        Coordinator coordinator = (Coordinator) attach.getTarget();
                         response.withTarget(coordinator);
                     }
                 }
@@ -261,11 +259,11 @@ public class AttachExpectation extends AbstractExpectation<Attach> {
         return withRcvSettleMode(rcvSettleMode == null ? nullValue() : equalTo(rcvSettleMode.getValue()));
     }
 
-    public AttachExpectation withReceivervSettlesFirst() {
+    public AttachExpectation withReceiverSettlesFirst() {
         return withRcvSettleMode(equalTo(ReceiverSettleMode.FIRST.getValue()));
     }
 
-    public AttachExpectation withReceivervSettlesSecond() {
+    public AttachExpectation withReceiverSettlesSecond() {
         return withRcvSettleMode(equalTo(ReceiverSettleMode.SECOND.getValue()));
     }
 
diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/matchers/messaging/OpenMatcher.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/matchers/messaging/OpenMatcher.java
deleted file mode 100644
index 7f18174..0000000
--- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/matchers/messaging/OpenMatcher.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.qpid.protonj2.test.driver.matchers.messaging;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-
-import java.util.Map;
-
-import org.apache.qpid.protonj2.test.driver.codec.primitives.Symbol;
-import org.apache.qpid.protonj2.test.driver.codec.primitives.UnsignedInteger;
-import org.apache.qpid.protonj2.test.driver.codec.primitives.UnsignedShort;
-import org.apache.qpid.protonj2.test.driver.codec.transport.Open;
-import org.apache.qpid.protonj2.test.driver.codec.util.TypeMapper;
-import org.apache.qpid.protonj2.test.driver.matchers.ListDescribedTypeMatcher;
-import org.hamcrest.Matcher;
-
-public class OpenMatcher extends ListDescribedTypeMatcher {
-
-    public OpenMatcher() {
-        super(Open.Field.values().length, Open.DESCRIPTOR_CODE, Open.DESCRIPTOR_SYMBOL);
-    }
-
-    @Override
-    protected Class<?> getDescribedTypeClass() {
-        return Open.class;
-    }
-
-    //----- Type specific with methods that perform simple equals checks
-
-    public OpenMatcher withContainerId(String container) {
-        return withContainerId(equalTo(container));
-    }
-
-    public OpenMatcher withHostname(String hostname) {
-        return withHostname(equalTo(hostname));
-    }
-
-    public OpenMatcher withMaxFrameSize(int maxFrameSize) {
-        return withMaxFrameSize(equalTo(UnsignedInteger.valueOf(maxFrameSize)));
-    }
-
-    public OpenMatcher withMaxFrameSize(long maxFrameSize) {
-        return withMaxFrameSize(equalTo(UnsignedInteger.valueOf(maxFrameSize)));
-    }
-
-    public OpenMatcher withMaxFrameSize(UnsignedInteger maxFrameSize) {
-        return withMaxFrameSize(equalTo(maxFrameSize));
-    }
-
-    public OpenMatcher withChannelMax(short channelMax) {
-        return withChannelMax(equalTo(UnsignedShort.valueOf(channelMax)));
-    }
-
-    public OpenMatcher withChannelMax(int channelMax) {
-        return withChannelMax(equalTo(UnsignedShort.valueOf(channelMax)));
-    }
-
-    public OpenMatcher withChannelMax(UnsignedShort channelMax) {
-        return withChannelMax(equalTo(channelMax));
-    }
-
-    public OpenMatcher withIdleTimeOut(int idleTimeout) {
-        return withIdleTimeOut(equalTo(UnsignedInteger.valueOf(idleTimeout)));
-    }
-
-    public OpenMatcher withIdleTimeOut(long idleTimeout) {
-        return withIdleTimeOut(equalTo(UnsignedInteger.valueOf(idleTimeout)));
-    }
-
-    public OpenMatcher withIdleTimeOut(UnsignedInteger idleTimeout) {
-        return withIdleTimeOut(equalTo(idleTimeout));
-    }
-
-    public OpenMatcher withOutgoingLocales(String... outgoingLocales) {
-        return withOutgoingLocales(equalTo(TypeMapper.toSymbolArray(outgoingLocales)));
-    }
-
-    public OpenMatcher withOutgoingLocales(Symbol... outgoingLocales) {
-        return withOutgoingLocales(equalTo(outgoingLocales));
-    }
-
-    public OpenMatcher withIncomingLocales(String... incomingLocales) {
-        return withIncomingLocales(equalTo(TypeMapper.toSymbolArray(incomingLocales)));
-    }
-
-    public OpenMatcher withIncomingLocales(Symbol... incomingLocales) {
-        return withIncomingLocales(equalTo(incomingLocales));
-    }
-
-    public OpenMatcher withOfferedCapabilities(String... offeredCapabilities) {
-        return withOfferedCapabilities(equalTo(TypeMapper.toSymbolArray(offeredCapabilities)));
-    }
-
-    public OpenMatcher withOfferedCapabilities(Symbol... offeredCapabilities) {
-        return withOfferedCapabilities(equalTo(offeredCapabilities));
-    }
-
-    public OpenMatcher withDesiredCapabilities(String... desiredCapabilities) {
-        return withDesiredCapabilities(equalTo(TypeMapper.toSymbolArray(desiredCapabilities)));
-    }
-
-    public OpenMatcher withDesiredCapabilities(Symbol... desiredCapabilities) {
-        return withDesiredCapabilities(equalTo(desiredCapabilities));
-    }
-
-    public OpenMatcher withPropertiesMap(Map<Symbol, Object> properties) {
-        return withProperties(equalTo(properties));
-    }
-
-    public OpenMatcher withProperties(Map<String, Object> properties) {
-        return withProperties(equalTo(TypeMapper.toSymbolKeyedMap(properties)));
-    }
-
-    //----- Matcher based with methods for more complex validation
-
-    public OpenMatcher withContainerId(Matcher<?> m) {
-        addFieldMatcher(Open.Field.CONTAINER_ID, m);
-        return this;
-    }
-
-    public OpenMatcher withHostname(Matcher<?> m) {
-        addFieldMatcher(Open.Field.HOSTNAME, m);
-        return this;
-    }
-
-    public OpenMatcher withMaxFrameSize(Matcher<?> m) {
-        addFieldMatcher(Open.Field.MAX_FRAME_SIZE, m);
-        return this;
-    }
-
-    public OpenMatcher withChannelMax(Matcher<?> m) {
-        addFieldMatcher(Open.Field.CHANNEL_MAX, m);
-        return this;
-    }
-
-    public OpenMatcher withIdleTimeOut(Matcher<?> m) {
-        addFieldMatcher(Open.Field.IDLE_TIME_OUT, m);
-        return this;
-    }
-
-    public OpenMatcher withOutgoingLocales(Matcher<?> m) {
-        addFieldMatcher(Open.Field.OUTGOING_LOCALES, m);
-        return this;
-    }
-
-    public OpenMatcher withIncomingLocales(Matcher<?> m) {
-        addFieldMatcher(Open.Field.INCOMING_LOCALES, m);
-        return this;
-    }
-
-    public OpenMatcher withOfferedCapabilities(Matcher<?> m) {
-        addFieldMatcher(Open.Field.OFFERED_CAPABILITIES, m);
-        return this;
-    }
-
-    public OpenMatcher withDesiredCapabilities(Matcher<?> m) {
-        addFieldMatcher(Open.Field.DESIRED_CAPABILITIES, m);
-        return this;
-    }
-
-    public OpenMatcher withProperties(Matcher<?> m) {
-        addFieldMatcher(Open.Field.PROPERTIES, m);
-        return this;
-    }
-}
diff --git a/protonj2/src/test/java/org/apache/qpid/protonj2/engine/impl/sasl/ProtonSaslClientTest.java b/protonj2/src/test/java/org/apache/qpid/protonj2/engine/impl/sasl/ProtonSaslClientTest.java
index 79f082c..9434d81 100644
--- a/protonj2/src/test/java/org/apache/qpid/protonj2/engine/impl/sasl/ProtonSaslClientTest.java
+++ b/protonj2/src/test/java/org/apache/qpid/protonj2/engine/impl/sasl/ProtonSaslClientTest.java
@@ -96,7 +96,7 @@ public class ProtonSaslClientTest extends ProtonEngineTestSupport {
         engine.errorHandler(result -> failure = result.failureCause());
         ProtonTestConnector peer = createTestPeer(engine);
 
-        peer.expectSASLHeader().respondWithSASLPHeader();
+        peer.expectSASLHeader().respondWithSASLHeader();
         peer.remoteSaslMechanisms().withMechanisms("PLAIN", "ANONYMOUS").queue();
         peer.expectSaslInit().withMechanism("ANONYMOUS");
         peer.remoteSaslOutcome().withCode(SaslCode.OK.byteValue()).queue();
@@ -150,7 +150,7 @@ public class ProtonSaslClientTest extends ProtonEngineTestSupport {
         String user = "user";
         String pass = "qwerty123456";
 
-        peer.expectSASLHeader().respondWithSASLPHeader();
+        peer.expectSASLHeader().respondWithSASLHeader();
         peer.remoteSaslMechanisms().withMechanisms("UNKNOWN", "PLAIN", "ANONYMOUS").queue();
         peer.expectSaslInit().withMechanism("PLAIN").withInitialResponse(peer.saslPlainInitialResponse(user, pass));
         peer.remoteSaslOutcome().withCode(SaslCode.OK.byteValue()).queue();
@@ -176,7 +176,7 @@ public class ProtonSaslClientTest extends ProtonEngineTestSupport {
         engine.errorHandler(result -> failure = result.failureCause());
         ProtonTestConnector peer = createTestPeer(engine);
 
-        peer.expectSASLHeader().respondWithSASLPHeader();
+        peer.expectSASLHeader().respondWithSASLHeader();
         peer.remoteSaslMechanisms().withMechanisms("PLAIN").queue();
 
         // Default client only know about ANONYMOUS
@@ -235,7 +235,7 @@ public class ProtonSaslClientTest extends ProtonEngineTestSupport {
         engine.errorHandler(result -> failure = result.failureCause());
         ProtonTestConnector peer = createTestPeer(engine);
 
-        peer.expectSASLHeader().respondWithSASLPHeader();
+        peer.expectSASLHeader().respondWithSASLHeader();
         peer.remoteSaslMechanisms().withMechanisms("PLAIN", "ANONYMOUS").queue();
         peer.expectSaslInit().withMechanism("PLAIN");
         peer.remoteSaslOutcome().withCode(saslFailureCode.byteValue()).queue();

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org