Skip to content
This repository was archived by the owner on Jun 18, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,7 @@ private void loadEntry(EwsServiceXmlReader reader) throws Exception {

String nil = reader.readAttributeValue(XmlNamespace.XmlSchemaInstance,
XmlAttributeNames.Nil);
boolean hasValue = (nil == null)
|| (!nil.getClass().equals(Boolean.TYPE));
boolean hasValue = (nil == null);
if (hasValue) {
value = this.getDictionaryObject(reader);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package microsoft.exchange.webservices.data.core.request;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add the license header to all new files.


import microsoft.exchange.webservices.base.BaseTest;
import microsoft.exchange.webservices.data.core.EwsServiceXmlReader;
import microsoft.exchange.webservices.data.core.enumeration.service.ServiceResult;
import microsoft.exchange.webservices.data.core.response.GetUserConfigurationResponse;
import microsoft.exchange.webservices.data.core.response.ServiceResponseCollection;
import microsoft.exchange.webservices.data.misc.OutParam;
import microsoft.exchange.webservices.data.property.complex.UserConfigurationDictionary;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import java.io.InputStream;

@RunWith(JUnit4.class)
public class UserConfigurationTest extends BaseTest {

@Test
public void testNilDictionaryEntry() throws Exception {
GetUserConfigurationRequest request = new GetUserConfigurationRequest(exchangeServiceMock);
request.setName("Calendar");

InputStream inputStream = getClass().getResourceAsStream("/nil.xml");
EwsServiceXmlReader ewsXmlReader = new EwsServiceXmlReader(inputStream, exchangeServiceMock);
ServiceResponseCollection<GetUserConfigurationResponse> responses = request.readResponse(ewsXmlReader);

Assert.assertEquals(ServiceResult.Success, responses.getOverallResult());
Assert.assertNull(getDictionaryEntryValue(responses, "RequestInPolicy"));
}

private Object getDictionaryEntryValue(ServiceResponseCollection<GetUserConfigurationResponse> responses,
String requestInPolicy) {
UserConfigurationDictionary dictionary = responses.iterator().next().getUserConfiguration().getDictionary();
OutParam<Object> value = new OutParam<Object>();
dictionary.tryGetValue(requestInPolicy, value);
return value.getParam();
}

}
51 changes: 51 additions & 0 deletions src/test/resources/nil.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add the license header to all new files.

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
MajorVersion="14" MinorVersion="3" MajorBuildNumber="266" MinorBuildNumber="1"
Version="Exchange2010_SP2"/>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<m:GetUserConfigurationResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<m:ResponseMessages>
<m:GetUserConfigurationResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:UserConfiguration>
<t:UserConfigurationName Name="Calendar">
<t:DistinguishedFolderId Id="calendar">
<t:Mailbox>
<t:EmailAddress>room@company.com</t:EmailAddress>
</t:Mailbox>
</t:DistinguishedFolderId>
</t:UserConfigurationName>
<t:ItemId
Id="AAMkADM1ZTI1ZDFkLTVhYzAtNGM1OS1hNWU0LTRkYWMyN2IxY2NhYgBGAAAAAABpRr8ivxS3SpNwMWdbqv/CBwBC8RoCDnbYSbjqYWwdG9viAKfx+eOZAABC8RoCDnbYSbjqYWwdG9viAKfx+6f2AAA="
ChangeKey="CQAAABYAAADXBP/PKsWQRKG/Fv+wtIlbAAASQjNo"/>
<t:Dictionary>
<t:DictionaryEntry>
<t:DictionaryKey>
<t:Type>String</t:Type>
<t:Value>RequestInPolicy</t:Value>
</t:DictionaryKey>
<t:DictionaryValue xsi:nil="true"/>
</t:DictionaryEntry>
<t:DictionaryEntry>
<t:DictionaryKey>
<t:Type>String</t:Type>
<t:Value>RemovePrivateProperty</t:Value>
</t:DictionaryKey>
<t:DictionaryValue>
<t:Type>Boolean</t:Type>
<t:Value>true</t:Value>
</t:DictionaryValue>
</t:DictionaryEntry>
</t:Dictionary>
</m:UserConfiguration>
</m:GetUserConfigurationResponseMessage>
</m:ResponseMessages>
</m:GetUserConfigurationResponse>
</s:Body>
</s:Envelope>