Renames Message.addAttribute method to putAttribute.

This commit is contained in:
paweldomas 2014-05-27 08:48:13 +00:00
parent fa9ccc92ef
commit ec427382e9
8 changed files with 85 additions and 85 deletions

View File

@ -196,12 +196,12 @@ class ConnectivityCheckClient
localCandidate.computePriorityForType( localCandidate.computePriorityForType(
CandidateType.PEER_REFLEXIVE_CANDIDATE)); CandidateType.PEER_REFLEXIVE_CANDIDATE));
request.addAttribute(priority); request.putAttribute(priority);
//controlling controlled //controlling controlled
if (parentAgent.isControlling()) if (parentAgent.isControlling())
{ {
request.addAttribute( request.putAttribute(
AttributeFactory.createIceControllingAttribute( AttributeFactory.createIceControllingAttribute(
parentAgent.getTieBreaker())); parentAgent.getTieBreaker()));
@ -212,13 +212,13 @@ class ConnectivityCheckClient
logger.fine( logger.fine(
"Add USE-CANDIDATE in check for: " "Add USE-CANDIDATE in check for: "
+ candidatePair.toShortString()); + candidatePair.toShortString());
request.addAttribute( request.putAttribute(
AttributeFactory.createUseCandidateAttribute()); AttributeFactory.createUseCandidateAttribute());
} }
} }
else else
{ {
request.addAttribute( request.putAttribute(
AttributeFactory.createIceControlledAttribute( AttributeFactory.createIceControlledAttribute(
parentAgent.getTieBreaker())); parentAgent.getTieBreaker()));
} }
@ -235,7 +235,7 @@ class ConnectivityCheckClient
UsernameAttribute unameAttr UsernameAttribute unameAttr
= AttributeFactory.createUsernameAttribute(localUserName); = AttributeFactory.createUsernameAttribute(localUserName);
request.addAttribute(unameAttr); request.putAttribute(unameAttr);
// TODO Also implement SASL prepare // TODO Also implement SASL prepare
MessageIntegrityAttribute msgIntegrity MessageIntegrityAttribute msgIntegrity
@ -247,7 +247,7 @@ class ConnectivityCheckClient
// remote key of the current stream, that why we pass the media // remote key of the current stream, that why we pass the media
// name. // name.
msgIntegrity.setMedia(media); msgIntegrity.setMedia(media);
request.addAttribute(msgIntegrity); request.putAttribute(msgIntegrity);
TransactionID tran = TransactionID.createNewTransactionID(); TransactionID tran = TransactionID.createNewTransactionID();

View File

@ -134,12 +134,12 @@ class ConnectivityCheckServer
*/ */
Attribute usernameAttribute = Attribute usernameAttribute =
AttributeFactory.createUsernameAttribute(uname.getUsername()); AttributeFactory.createUsernameAttribute(uname.getUsername());
response.addAttribute(usernameAttribute); response.putAttribute(usernameAttribute);
Attribute messageIntegrityAttribute = Attribute messageIntegrityAttribute =
AttributeFactory.createMessageIntegrityAttribute( AttributeFactory.createMessageIntegrityAttribute(
new String(uname.getUsername())); new String(uname.getUsername()));
response.addAttribute(messageIntegrityAttribute); response.putAttribute(messageIntegrityAttribute);
try try
{ {

View File

@ -199,10 +199,10 @@ public class StunCandidateHarvest
if (shortTermCredentialUsername != null) if (shortTermCredentialUsername != null)
{ {
request.addAttribute( request.putAttribute(
AttributeFactory.createUsernameAttribute( AttributeFactory.createUsernameAttribute(
shortTermCredentialUsername)); shortTermCredentialUsername));
request.addAttribute( request.putAttribute(
AttributeFactory.createMessageIntegrityAttribute( AttributeFactory.createMessageIntegrityAttribute(
shortTermCredentialUsername)); shortTermCredentialUsername));
return true; return true;

View File

@ -538,15 +538,15 @@ public abstract class Message
} }
/** /**
* Adds the specified attribute to this message. If an attribute with that * Puts the specified attribute into this message. If an attribute with that
* name was already added, it would be replaced. * name was already added, it would be replaced.
* *
* @param attribute the attribute to add to this message. * @param attribute the attribute to put into this message.
* *
* @throws IllegalArgumentException if the message cannot contain * @throws IllegalArgumentException if the message cannot contain
* such an attribute. * such an attribute.
*/ */
public void addAttribute(Attribute attribute) public void putAttribute(Attribute attribute)
throws IllegalArgumentException throws IllegalArgumentException
{ {
if (getAttributePresentity(attribute.getAttributeType()) == N_A) if (getAttributePresentity(attribute.getAttributeType()) == N_A)
@ -1004,14 +1004,14 @@ public abstract class Message
if (getAttribute(Attribute.SOFTWARE) == null if (getAttribute(Attribute.SOFTWARE) == null
&& software != null && software.length() > 0) && software != null && software.length() > 0)
{ {
addAttribute(AttributeFactory putAttribute(AttributeFactory
.createSoftwareAttribute(software.getBytes())); .createSoftwareAttribute(software.getBytes()));
} }
//re-add MESSAGE-INTEGRITY if there was one. //re-add MESSAGE-INTEGRITY if there was one.
if (msgIntAttr != null) if (msgIntAttr != null)
{ {
addAttribute(msgIntAttr); putAttribute(msgIntAttr);
} }
//add FINGERPRINT if there was one or if user told us to add it //add FINGERPRINT if there was one or if user told us to add it
@ -1024,7 +1024,7 @@ public abstract class Message
if (fingerprint != null) if (fingerprint != null)
{ {
addAttribute(fingerprint); putAttribute(fingerprint);
} }
} }
@ -1128,7 +1128,7 @@ public abstract class Message
performAttributeSpecificActions(att, binMessage, performAttributeSpecificActions(att, binMessage,
originalOffset, offset); originalOffset, offset);
message.addAttribute(att); message.putAttribute(att);
offset += att.getDataLength() + Attribute.HEADER_LENGTH; offset += att.getDataLength() + Attribute.HEADER_LENGTH;
//now also skip any potential padding that might have come with //now also skip any potential padding that might have come with

View File

@ -54,7 +54,7 @@ public class MessageFactory
* //add a change request attribute ChangeRequestAttribute attribute = * //add a change request attribute ChangeRequestAttribute attribute =
* AttributeFactory.createChangeRequestAttribute(); * AttributeFactory.createChangeRequestAttribute();
* *
* try { bindingRequest.addAttribute(attribute); } catch (StunException * try { bindingRequest.putAttribute(attribute); } catch (StunException
* ex) { //shouldn't happen throw new * ex) { //shouldn't happen throw new
* RuntimeException("Failed to add a change request " * RuntimeException("Failed to add a change request "
* +"attribute to a binding request!"); } * +"attribute to a binding request!"); }
@ -78,7 +78,7 @@ public class MessageFactory
PriorityAttribute attribute = AttributeFactory PriorityAttribute attribute = AttributeFactory
.createPriorityAttribute(priority); .createPriorityAttribute(priority);
bindingRequest.addAttribute(attribute); bindingRequest.putAttribute(attribute);
return bindingRequest; return bindingRequest;
} }
@ -104,18 +104,18 @@ public class MessageFactory
PriorityAttribute attribute = AttributeFactory PriorityAttribute attribute = AttributeFactory
.createPriorityAttribute(priority); .createPriorityAttribute(priority);
bindingRequest.addAttribute(attribute); bindingRequest.putAttribute(attribute);
if (controlling) if (controlling)
{ {
IceControllingAttribute iceControllingAttribute = AttributeFactory IceControllingAttribute iceControllingAttribute = AttributeFactory
.createIceControllingAttribute(tieBreaker); .createIceControllingAttribute(tieBreaker);
bindingRequest.addAttribute(iceControllingAttribute); bindingRequest.putAttribute(iceControllingAttribute);
} else } else
{ {
IceControlledAttribute iceControlledAttribute = AttributeFactory IceControlledAttribute iceControlledAttribute = AttributeFactory
.createIceControlledAttribute(tieBreaker); .createIceControlledAttribute(tieBreaker);
bindingRequest.addAttribute(iceControlledAttribute); bindingRequest.putAttribute(iceControlledAttribute);
} }
return bindingRequest; return bindingRequest;
@ -163,16 +163,16 @@ public class MessageFactory
changedAddressAttribute = AttributeFactory changedAddressAttribute = AttributeFactory
.createChangedAddressAttribute(changedAddress); .createChangedAddressAttribute(changedAddress);
bindingResponse.addAttribute(mappedAddressAttribute); bindingResponse.putAttribute(mappedAddressAttribute);
// the changed address and source address attribute were removed in // the changed address and source address attribute were removed in
// RFC 5389 so we should be prepared to go without them. // RFC 5389 so we should be prepared to go without them.
if (sourceAddressAttribute != null) if (sourceAddressAttribute != null)
bindingResponse.addAttribute(sourceAddressAttribute); bindingResponse.putAttribute(sourceAddressAttribute);
if (changedAddressAttribute != null) if (changedAddressAttribute != null)
bindingResponse.addAttribute(changedAddressAttribute); bindingResponse.putAttribute(changedAddressAttribute);
return bindingResponse; return bindingResponse;
} }
@ -201,7 +201,7 @@ public class MessageFactory
.createXorMappedAddressAttribute(mappedAddress, .createXorMappedAddressAttribute(mappedAddress,
request.getTransactionID()); request.getTransactionID());
bindingResponse.addAttribute(xorMappedAddressAttribute); bindingResponse.putAttribute(xorMappedAddressAttribute);
return bindingResponse; return bindingResponse;
} }
@ -233,7 +233,7 @@ public class MessageFactory
.createErrorCodeAttribute(errorCode, .createErrorCodeAttribute(errorCode,
reasonPhrase); reasonPhrase);
bindingErrorResponse.addAttribute(errorCodeAttribute); bindingErrorResponse.putAttribute(errorCodeAttribute);
if (unknownAttributes != null) if (unknownAttributes != null)
{ {
@ -245,7 +245,7 @@ public class MessageFactory
.addAttributeID(unknownAttributes[i]); .addAttributeID(unknownAttributes[i]);
} }
bindingErrorResponse bindingErrorResponse
.addAttribute(unknownAttributesAttribute); .putAttribute(unknownAttributesAttribute);
} }
return bindingErrorResponse; return bindingErrorResponse;
@ -375,14 +375,14 @@ public class MessageFactory
throw new StunException("Protocol not valid!"); throw new StunException("Protocol not valid!");
// REQUESTED-TRANSPORT // REQUESTED-TRANSPORT
allocateRequest.addAttribute( allocateRequest.putAttribute(
AttributeFactory.createRequestedTransportAttribute( AttributeFactory.createRequestedTransportAttribute(
protocol)); protocol));
// EVEN-PORT // EVEN-PORT
if (rFlag) if (rFlag)
{ {
allocateRequest.addAttribute( allocateRequest.putAttribute(
AttributeFactory.createEvenPortAttribute(rFlag)); AttributeFactory.createEvenPortAttribute(rFlag));
} }
} }
@ -457,7 +457,7 @@ public class MessageFactory
.createXorMappedAddressAttribute( .createXorMappedAddressAttribute(
mappedAddress, request.getTransactionID()); mappedAddress, request.getTransactionID());
allocationSuccessResponse.addAttribute(xorMappedAddressAttribute); allocationSuccessResponse.putAttribute(xorMappedAddressAttribute);
//xor relayed address //xor relayed address
XorRelayedAddressAttribute xorRelayedAddressAttribute XorRelayedAddressAttribute xorRelayedAddressAttribute
@ -465,13 +465,13 @@ public class MessageFactory
.createXorRelayedAddressAttribute(relayedAddress, .createXorRelayedAddressAttribute(relayedAddress,
request.getTransactionID()); request.getTransactionID());
allocationSuccessResponse.addAttribute(xorRelayedAddressAttribute); allocationSuccessResponse.putAttribute(xorRelayedAddressAttribute);
//lifetime //lifetime
LifetimeAttribute lifetimeAttribute LifetimeAttribute lifetimeAttribute
= AttributeFactory.createLifetimeAttribute(lifetime); = AttributeFactory.createLifetimeAttribute(lifetime);
allocationSuccessResponse.addAttribute(lifetimeAttribute); allocationSuccessResponse.putAttribute(lifetimeAttribute);
if(token != null) if(token != null)
{ {
@ -480,7 +480,7 @@ public class MessageFactory
= AttributeFactory = AttributeFactory
.createReservationTokenAttribute(token); .createReservationTokenAttribute(token);
allocationSuccessResponse.addAttribute(reservationTokenAttribute); allocationSuccessResponse.putAttribute(reservationTokenAttribute);
} }
return allocationSuccessResponse; return allocationSuccessResponse;
@ -525,7 +525,7 @@ public class MessageFactory
.createErrorCodeAttribute(errorCode, .createErrorCodeAttribute(errorCode,
reasonPhrase); reasonPhrase);
allocationErrorResponse.addAttribute(errorCodeAttribute); allocationErrorResponse.putAttribute(errorCodeAttribute);
return allocationErrorResponse; return allocationErrorResponse;
} }
@ -547,8 +547,8 @@ public class MessageFactory
allocateRequest.setMessageType(Message.ALLOCATE_REQUEST); allocateRequest.setMessageType(Message.ALLOCATE_REQUEST);
// first attribute is MAGIC-COOKIE // first attribute is MAGIC-COOKIE
allocateRequest.addAttribute(magicCookieAttr); allocateRequest.putAttribute(magicCookieAttr);
allocateRequest.addAttribute(usernameAttr); allocateRequest.putAttribute(usernameAttr);
return allocateRequest; return allocateRequest;
} }
@ -589,9 +589,9 @@ public class MessageFactory
NonceAttribute nonceAttribute NonceAttribute nonceAttribute
= AttributeFactory.createNonceAttribute(nonce); = AttributeFactory.createNonceAttribute(nonce);
request.addAttribute(usernameAttribute); request.putAttribute(usernameAttribute);
request.addAttribute(realmAttribute); request.putAttribute(realmAttribute);
request.addAttribute(nonceAttribute); request.putAttribute(nonceAttribute);
// MESSAGE-INTEGRITY // MESSAGE-INTEGRITY
MessageIntegrityAttribute messageIntegrityAttribute; MessageIntegrityAttribute messageIntegrityAttribute;
@ -611,7 +611,7 @@ public class MessageFactory
{ {
throw new StunException("username", ueex); throw new StunException("username", ueex);
} }
request.addAttribute(messageIntegrityAttribute); request.putAttribute(messageIntegrityAttribute);
} }
/** /**
@ -657,7 +657,7 @@ public class MessageFactory
/* add a LIFETIME attribute */ /* add a LIFETIME attribute */
LifetimeAttribute lifetimeReq = AttributeFactory LifetimeAttribute lifetimeReq = AttributeFactory
.createLifetimeAttribute(lifetime); .createLifetimeAttribute(lifetime);
refreshRequest.addAttribute(lifetimeReq); refreshRequest.putAttribute(lifetimeReq);
} catch (IllegalArgumentException ex) } catch (IllegalArgumentException ex)
{ {
logger.log(Level.FINE, "Failed to set message type.", ex); logger.log(Level.FINE, "Failed to set message type.", ex);
@ -685,7 +685,7 @@ public class MessageFactory
= AttributeFactory = AttributeFactory
.createLifetimeAttribute(lifetime); .createLifetimeAttribute(lifetime);
refreshSuccessResponse.addAttribute(lifetimeAttribute); refreshSuccessResponse.putAttribute(lifetimeAttribute);
} }
catch(IllegalArgumentException ex) catch(IllegalArgumentException ex)
{ {
@ -726,7 +726,7 @@ public class MessageFactory
.createErrorCodeAttribute( .createErrorCodeAttribute(
errorCode, reasonPhrase); errorCode, reasonPhrase);
refreshErrorResponse.addAttribute(errorCodeAttribute); refreshErrorResponse.putAttribute(errorCodeAttribute);
} }
catch(IllegalArgumentException ex) catch(IllegalArgumentException ex)
{ {
@ -757,14 +757,14 @@ public class MessageFactory
// add a CHANNEL-NUMBER attribute // add a CHANNEL-NUMBER attribute
ChannelNumberAttribute channelNumberAttribute = AttributeFactory ChannelNumberAttribute channelNumberAttribute = AttributeFactory
.createChannelNumberAttribute(channelNumber); .createChannelNumberAttribute(channelNumber);
channelBindRequest.addAttribute(channelNumberAttribute); channelBindRequest.putAttribute(channelNumberAttribute);
// add a XOR-PEER-ADDRESS // add a XOR-PEER-ADDRESS
XorPeerAddressAttribute peerAddressAttribute = AttributeFactory XorPeerAddressAttribute peerAddressAttribute = AttributeFactory
.createXorPeerAddressAttribute(peerAddress, .createXorPeerAddressAttribute(peerAddress,
tranID); tranID);
channelBindRequest.addAttribute(peerAddressAttribute); channelBindRequest.putAttribute(peerAddressAttribute);
} catch (IllegalArgumentException ex) } catch (IllegalArgumentException ex)
{ {
logger.log(Level.FINE, "Failed to set message type.", ex); logger.log(Level.FINE, "Failed to set message type.", ex);
@ -817,7 +817,7 @@ public class MessageFactory
= AttributeFactory = AttributeFactory
.createErrorCodeAttribute(errorCode,reasonPhrase); .createErrorCodeAttribute(errorCode,reasonPhrase);
channelBindErrorResponse.addAttribute(errorCodeAttribute); channelBindErrorResponse.putAttribute(errorCodeAttribute);
return channelBindErrorResponse; return channelBindErrorResponse;
} }
@ -849,7 +849,7 @@ public class MessageFactory
// Expected to not happen because we are the creators. // Expected to not happen because we are the creators.
logger.log(Level.FINE, "Failed to set message type.", iaex); logger.log(Level.FINE, "Failed to set message type.", iaex);
} }
createPermissionRequest.addAttribute( createPermissionRequest.putAttribute(
AttributeFactory.createXorPeerAddressAttribute( AttributeFactory.createXorPeerAddressAttribute(
peerAddress, peerAddress,
transactionID)); transactionID));
@ -903,7 +903,7 @@ public class MessageFactory
.createErrorCodeAttribute( .createErrorCodeAttribute(
errorCode,reasonPhrase); errorCode,reasonPhrase);
createPermissionErrorResponse.addAttribute(errorCodeAttribute); createPermissionErrorResponse.putAttribute(errorCodeAttribute);
return createPermissionErrorResponse; return createPermissionErrorResponse;
} }
@ -929,14 +929,14 @@ public class MessageFactory
/* add XOR-PEER-ADDRESS attribute */ /* add XOR-PEER-ADDRESS attribute */
XorPeerAddressAttribute peerAddressAttribute = AttributeFactory XorPeerAddressAttribute peerAddressAttribute = AttributeFactory
.createXorPeerAddressAttribute(peerAddress, tranID); .createXorPeerAddressAttribute(peerAddress, tranID);
sendIndication.addAttribute(peerAddressAttribute); sendIndication.putAttribute(peerAddressAttribute);
/* add DATA if data */ /* add DATA if data */
if (data != null && data.length > 0) if (data != null && data.length > 0)
{ {
DataAttribute dataAttribute = AttributeFactory DataAttribute dataAttribute = AttributeFactory
.createDataAttribute(data); .createDataAttribute(data);
sendIndication.addAttribute(dataAttribute); sendIndication.putAttribute(dataAttribute);
} }
} catch (IllegalArgumentException ex) } catch (IllegalArgumentException ex)
{ {
@ -963,24 +963,24 @@ public class MessageFactory
sendRequest.setMessageType(Message.SEND_REQUEST); sendRequest.setMessageType(Message.SEND_REQUEST);
/* add MAGIC-COOKIE attribute */ /* add MAGIC-COOKIE attribute */
sendRequest.addAttribute( sendRequest.putAttribute(
AttributeFactory.createMagicCookieAttribute()); AttributeFactory.createMagicCookieAttribute());
/* add USERNAME attribute */ /* add USERNAME attribute */
sendRequest.addAttribute( sendRequest.putAttribute(
AttributeFactory.createUsernameAttribute(username)); AttributeFactory.createUsernameAttribute(username));
/* add DESTINATION-ADDRESS attribute */ /* add DESTINATION-ADDRESS attribute */
DestinationAddressAttribute peerAddressAttribute = AttributeFactory DestinationAddressAttribute peerAddressAttribute = AttributeFactory
.createDestinationAddressAttribute(peerAddress); .createDestinationAddressAttribute(peerAddress);
sendRequest.addAttribute(peerAddressAttribute); sendRequest.putAttribute(peerAddressAttribute);
/* add DATA if data */ /* add DATA if data */
if (data != null && data.length > 0) if (data != null && data.length > 0)
{ {
DataAttribute dataAttribute = AttributeFactory DataAttribute dataAttribute = AttributeFactory
.createDataAttributeWithoutPadding(data); .createDataAttributeWithoutPadding(data);
sendRequest.addAttribute(dataAttribute); sendRequest.putAttribute(dataAttribute);
} }
} }
catch (IllegalArgumentException ex) catch (IllegalArgumentException ex)
@ -1054,7 +1054,7 @@ public class MessageFactory
.createXorPeerAddressAttribute( .createXorPeerAddressAttribute(
peerAddress, request.getTransactionID()); peerAddress, request.getTransactionID());
connectRequest.addAttribute(xorPeerAddressAttribute); connectRequest.putAttribute(xorPeerAddressAttribute);
return connectRequest; return connectRequest;
} }
@ -1082,7 +1082,7 @@ public class MessageFactory
= AttributeFactory = AttributeFactory
.createConnectionIdAttribute(connectionIdValue); .createConnectionIdAttribute(connectionIdValue);
connectSuccessResponse.addAttribute(connectionIdAttribute); connectSuccessResponse.putAttribute(connectionIdAttribute);
return connectSuccessResponse; return connectSuccessResponse;
} }
@ -1124,7 +1124,7 @@ public class MessageFactory
= AttributeFactory = AttributeFactory
.createErrorCodeAttribute(errorCode, reasonPhrase); .createErrorCodeAttribute(errorCode, reasonPhrase);
connectionErrorResponse.addAttribute(errorCodeAttribute); connectionErrorResponse.putAttribute(errorCodeAttribute);
return connectionErrorResponse; return connectionErrorResponse;
} }
@ -1152,7 +1152,7 @@ public class MessageFactory
= AttributeFactory = AttributeFactory
.createConnectionIdAttribute(connectionIdValue); .createConnectionIdAttribute(connectionIdValue);
connectionBindRequest.addAttribute(connectionIdAttribute); connectionBindRequest.putAttribute(connectionIdAttribute);
return connectionBindRequest; return connectionBindRequest;
} }
@ -1216,7 +1216,7 @@ public class MessageFactory
= AttributeFactory = AttributeFactory
.createErrorCodeAttribute(errorCode, reasonPhrase); .createErrorCodeAttribute(errorCode, reasonPhrase);
connectionBindErrorResponse.addAttribute(errorCodeAttribute); connectionBindErrorResponse.putAttribute(errorCodeAttribute);
return connectionBindErrorResponse; return connectionBindErrorResponse;
} }
@ -1247,7 +1247,7 @@ public class MessageFactory
= AttributeFactory = AttributeFactory
.createConnectionIdAttribute(connectionIdValue); .createConnectionIdAttribute(connectionIdValue);
connectionAttemptIndication.addAttribute(connectionIdAttribute); connectionAttemptIndication.putAttribute(connectionIdAttribute);
//xor peer address attribute //xor peer address attribute
XorPeerAddressAttribute xorPeerAddressAttribute XorPeerAddressAttribute xorPeerAddressAttribute
@ -1255,7 +1255,7 @@ public class MessageFactory
.createXorPeerAddressAttribute(peerAddress, .createXorPeerAddressAttribute(peerAddress,
connectionAttemptIndication.getTransactionID()); connectionAttemptIndication.getTransactionID());
connectionAttemptIndication.addAttribute(xorPeerAddressAttribute); connectionAttemptIndication.putAttribute(xorPeerAddressAttribute);
return connectionAttemptIndication; return connectionAttemptIndication;
} }

View File

@ -321,7 +321,7 @@ public class NetworkConfigurationDiscoveryProcess
= AttributeFactory.createChangeRequestAttribute(); = AttributeFactory.createChangeRequestAttribute();
changeRequest.setChangeIpFlag(false); changeRequest.setChangeIpFlag(false);
changeRequest.setChangePortFlag(false); changeRequest.setChangePortFlag(false);
request.addAttribute(changeRequest); request.putAttribute(changeRequest);
StunMessageEvent evt = null; StunMessageEvent evt = null;
try try
@ -369,7 +369,7 @@ public class NetworkConfigurationDiscoveryProcess
ChangeRequestAttribute changeRequest = AttributeFactory.createChangeRequestAttribute(); ChangeRequestAttribute changeRequest = AttributeFactory.createChangeRequestAttribute();
changeRequest.setChangeIpFlag(true); changeRequest.setChangeIpFlag(true);
changeRequest.setChangePortFlag(true); changeRequest.setChangePortFlag(true);
request.addAttribute(changeRequest); request.putAttribute(changeRequest);
StunMessageEvent evt StunMessageEvent evt
= requestSender.sendRequestAndWaitForResponse(request, = requestSender.sendRequestAndWaitForResponse(request,
@ -403,7 +403,7 @@ public class NetworkConfigurationDiscoveryProcess
ChangeRequestAttribute changeRequest = AttributeFactory.createChangeRequestAttribute(); ChangeRequestAttribute changeRequest = AttributeFactory.createChangeRequestAttribute();
changeRequest.setChangeIpFlag(false); changeRequest.setChangeIpFlag(false);
changeRequest.setChangePortFlag(true); changeRequest.setChangePortFlag(true);
request.addAttribute(changeRequest); request.putAttribute(changeRequest);
StunMessageEvent evt = requestSender.sendRequestAndWaitForResponse( StunMessageEvent evt = requestSender.sendRequestAndWaitForResponse(
request, serverAddress); request, serverAddress);

View File

@ -45,7 +45,7 @@ public class MessageFactoryTest extends TestCase
Attribute errorCodeAtt Attribute errorCodeAtt
= AttributeFactory.createErrorCodeAttribute(errorCode); = AttributeFactory.createErrorCodeAttribute(errorCode);
expectedReturn.addAttribute(errorCodeAtt); expectedReturn.putAttribute(errorCodeAtt);
Message actualReturn Message actualReturn
= MessageFactory.createBindingErrorResponse(errorCode); = MessageFactory.createBindingErrorResponse(errorCode);
@ -62,7 +62,7 @@ public class MessageFactoryTest extends TestCase
Attribute errorCodeAtt = AttributeFactory Attribute errorCodeAtt = AttributeFactory
.createErrorCodeAttribute(errorCode, reasonPhrase); .createErrorCodeAttribute(errorCode, reasonPhrase);
expectedReturn.addAttribute(errorCodeAtt); expectedReturn.putAttribute(errorCodeAtt);
Message actualReturn = MessageFactory Message actualReturn = MessageFactory
.createBindingErrorResponse(errorCode, reasonPhrase); .createBindingErrorResponse(errorCode, reasonPhrase);
@ -84,7 +84,7 @@ public class MessageFactoryTest extends TestCase
.createErrorCodeAttribute(errorCode); .createErrorCodeAttribute(errorCode);
((ErrorCodeAttribute)errorCodeAtt).setReasonPhrase( ((ErrorCodeAttribute)errorCodeAtt).setReasonPhrase(
ErrorCodeAttribute.getDefaultReasonPhrase(errorCode)); ErrorCodeAttribute.getDefaultReasonPhrase(errorCode));
expectedReturn.addAttribute(errorCodeAtt); expectedReturn.putAttribute(errorCodeAtt);
UnknownAttributesAttribute unknownAtts = UnknownAttributesAttribute unknownAtts =
AttributeFactory.createUnknownAttributesAttribute(); AttributeFactory.createUnknownAttributesAttribute();
@ -92,7 +92,7 @@ public class MessageFactoryTest extends TestCase
for (int i = 0; i < unknownAttributes.length; i++) { for (int i = 0; i < unknownAttributes.length; i++) {
unknownAtts.addAttributeID(unknownAttributes[i]); unknownAtts.addAttributeID(unknownAttributes[i]);
} }
expectedReturn.addAttribute(unknownAtts); expectedReturn.putAttribute(unknownAtts);
//create the same message using the factory //create the same message using the factory
Message actualReturn = MessageFactory Message actualReturn = MessageFactory
@ -113,7 +113,7 @@ public class MessageFactoryTest extends TestCase
Attribute errorCodeAtt = AttributeFactory.createErrorCodeAttribute( Attribute errorCodeAtt = AttributeFactory.createErrorCodeAttribute(
errorCode, reasonPhrase); errorCode, reasonPhrase);
expectedReturn.addAttribute(errorCodeAtt); expectedReturn.putAttribute(errorCodeAtt);
UnknownAttributesAttribute unknownAtts = UnknownAttributesAttribute unknownAtts =
AttributeFactory.createUnknownAttributesAttribute(); AttributeFactory.createUnknownAttributesAttribute();
@ -122,7 +122,7 @@ public class MessageFactoryTest extends TestCase
{ {
unknownAtts.addAttributeID(unknownAttributes[i]); unknownAtts.addAttributeID(unknownAttributes[i]);
} }
expectedReturn.addAttribute(unknownAtts); expectedReturn.putAttribute(unknownAtts);
Message actualReturn = MessageFactory Message actualReturn = MessageFactory
.createBindingErrorResponseUnknownAttributes( .createBindingErrorResponseUnknownAttributes(
@ -138,7 +138,7 @@ public class MessageFactoryTest extends TestCase
/* /*
Attribute changeRequest = AttributeFactory.createChangeRequestAttribute( Attribute changeRequest = AttributeFactory.createChangeRequestAttribute(
msgFixture.CHANGE_IP_FLAG_1, msgFixture.CHANGE_PORT_FLAG_1); msgFixture.CHANGE_IP_FLAG_1, msgFixture.CHANGE_PORT_FLAG_1);
bindingRequest.addAttribute(changeRequest); bindingRequest.putAttribute(changeRequest);
*/ */
Request actualReturn = MessageFactory.createBindingRequest(); Request actualReturn = MessageFactory.createBindingRequest();
assertEquals("return value", expectedReturn, actualReturn); assertEquals("return value", expectedReturn, actualReturn);
@ -155,14 +155,14 @@ public class MessageFactoryTest extends TestCase
MsgFixture.ADDRESS_ATTRIBUTE_PORT, MsgFixture.ADDRESS_ATTRIBUTE_PORT,
Transport.UDP)); Transport.UDP));
bindingResponse.addAttribute(mappedAddress); bindingResponse.putAttribute(mappedAddress);
Attribute sourceAddress = AttributeFactory.createSourceAddressAttribute( Attribute sourceAddress = AttributeFactory.createSourceAddressAttribute(
new TransportAddress( MsgFixture.ADDRESS_ATTRIBUTE_ADDRESS_2, new TransportAddress( MsgFixture.ADDRESS_ATTRIBUTE_ADDRESS_2,
MsgFixture.ADDRESS_ATTRIBUTE_PORT_2, MsgFixture.ADDRESS_ATTRIBUTE_PORT_2,
Transport.UDP)); Transport.UDP));
bindingResponse.addAttribute(sourceAddress); bindingResponse.putAttribute(sourceAddress);
Attribute changedAddress = AttributeFactory. Attribute changedAddress = AttributeFactory.
createChangedAddressAttribute( createChangedAddressAttribute(
@ -170,7 +170,7 @@ public class MessageFactoryTest extends TestCase
MsgFixture.ADDRESS_ATTRIBUTE_PORT_3, MsgFixture.ADDRESS_ATTRIBUTE_PORT_3,
Transport.UDP)); Transport.UDP));
bindingResponse.addAttribute(changedAddress); bindingResponse.putAttribute(changedAddress);
Message expectedReturn = bindingResponse; Message expectedReturn = bindingResponse;
Message actualReturn = MessageFactory.create3489BindingResponse( Message actualReturn = MessageFactory.create3489BindingResponse(

View File

@ -47,7 +47,7 @@ public class MessageTest extends TestCase
changeRequest = AttributeFactory.createChangeRequestAttribute( changeRequest = AttributeFactory.createChangeRequestAttribute(
MsgFixture.CHANGE_IP_FLAG_1, MsgFixture.CHANGE_PORT_FLAG_1); MsgFixture.CHANGE_IP_FLAG_1, MsgFixture.CHANGE_PORT_FLAG_1);
bindingRequest.addAttribute(changeRequest); bindingRequest.putAttribute(changeRequest);
bindingRequest.setTransactionID(MsgFixture.TRANSACTION_ID); bindingRequest.setTransactionID(MsgFixture.TRANSACTION_ID);
//binding response //binding response
@ -60,7 +60,7 @@ public class MessageTest extends TestCase
MsgFixture.ADDRESS_ATTRIBUTE_PORT, MsgFixture.ADDRESS_ATTRIBUTE_PORT,
Transport.UDP)); Transport.UDP));
bindingResponse.addAttribute(mappedAddress); bindingResponse.putAttribute(mappedAddress);
sourceAddress = AttributeFactory.createSourceAddressAttribute( sourceAddress = AttributeFactory.createSourceAddressAttribute(
new TransportAddress( new TransportAddress(
@ -68,13 +68,13 @@ public class MessageTest extends TestCase
MsgFixture.ADDRESS_ATTRIBUTE_PORT_2, MsgFixture.ADDRESS_ATTRIBUTE_PORT_2,
Transport.UDP)); Transport.UDP));
bindingResponse.addAttribute(sourceAddress); bindingResponse.putAttribute(sourceAddress);
changedAddress = AttributeFactory.createChangedAddressAttribute( changedAddress = AttributeFactory.createChangedAddressAttribute(
new TransportAddress( MsgFixture.ADDRESS_ATTRIBUTE_ADDRESS_3, new TransportAddress( MsgFixture.ADDRESS_ATTRIBUTE_ADDRESS_3,
MsgFixture.ADDRESS_ATTRIBUTE_PORT_3, Transport.UDP)); MsgFixture.ADDRESS_ATTRIBUTE_PORT_3, Transport.UDP));
bindingResponse.addAttribute(changedAddress); bindingResponse.putAttribute(changedAddress);
bindingResponse.setTransactionID(MsgFixture.TRANSACTION_ID); bindingResponse.setTransactionID(MsgFixture.TRANSACTION_ID);
} }
@ -108,7 +108,7 @@ public class MessageTest extends TestCase
Response message = new Response(); Response message = new Response();
message.setMessageType(Message.BINDING_SUCCESS_RESPONSE); message.setMessageType(Message.BINDING_SUCCESS_RESPONSE);
message.addAttribute(mappedAddress); message.putAttribute(mappedAddress);
Attribute getResult = null; Attribute getResult = null;
@ -120,7 +120,7 @@ public class MessageTest extends TestCase
getResult); getResult);
//do it again //do it again
message.addAttribute(sourceAddress); message.putAttribute(sourceAddress);
getResult = message.getAttribute(sourceAddress.getAttributeType()); getResult = message.getAttribute(sourceAddress.getAttributeType());
@ -220,7 +220,7 @@ public class MessageTest extends TestCase
//this.bindingRequest //this.bindingRequest
Request binReqTarget = new Request(); Request binReqTarget = new Request();
binReqTarget.setMessageType(Message.BINDING_REQUEST); binReqTarget.setMessageType(Message.BINDING_REQUEST);
binReqTarget.addAttribute(changeRequest); binReqTarget.putAttribute(changeRequest);
actualReturn = bindingRequest.equals(binReqTarget); actualReturn = bindingRequest.equals(binReqTarget);
assertEquals("Equals failed against an equal target", assertEquals("Equals failed against an equal target",
expectedReturn, actualReturn); expectedReturn, actualReturn);
@ -229,9 +229,9 @@ public class MessageTest extends TestCase
//this.bindingRequest //this.bindingRequest
Response binResTarget = new Response(); Response binResTarget = new Response();
binResTarget.setMessageType(Message.BINDING_SUCCESS_RESPONSE); binResTarget.setMessageType(Message.BINDING_SUCCESS_RESPONSE);
binResTarget.addAttribute(mappedAddress); binResTarget.putAttribute(mappedAddress);
binResTarget.addAttribute(sourceAddress); binResTarget.putAttribute(sourceAddress);
binResTarget.addAttribute(changedAddress); binResTarget.putAttribute(changedAddress);
actualReturn = bindingResponse.equals(binResTarget); actualReturn = bindingResponse.equals(binResTarget);
assertEquals("Equals failed against a different target", assertEquals("Equals failed against a different target",
expectedReturn, actualReturn); expectedReturn, actualReturn);