From 0fadd07b64d8c494f67b9a29a5919850b349cc8f Mon Sep 17 00:00:00 2001 From: "sergiu.indrie" Date: Tue, 10 May 2016 12:10:42 +0300 Subject: [PATCH 1/3] Allow UserConfiguration dictionary entry to have null value --- .../complex/UserConfigurationDictionary.java | 3 +- .../core/request/UserConfigurationTest.java | 41 +++++++++++++++ src/test/resources/nil.xml | 51 +++++++++++++++++++ 3 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 src/test/java/microsoft/exchange/webservices/data/core/request/UserConfigurationTest.java create mode 100644 src/test/resources/nil.xml diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/UserConfigurationDictionary.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/UserConfigurationDictionary.java index 6eaee6997..2717092c3 100644 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/UserConfigurationDictionary.java +++ b/src/main/java/microsoft/exchange/webservices/data/property/complex/UserConfigurationDictionary.java @@ -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); } diff --git a/src/test/java/microsoft/exchange/webservices/data/core/request/UserConfigurationTest.java b/src/test/java/microsoft/exchange/webservices/data/core/request/UserConfigurationTest.java new file mode 100644 index 000000000..2201a48f5 --- /dev/null +++ b/src/test/java/microsoft/exchange/webservices/data/core/request/UserConfigurationTest.java @@ -0,0 +1,41 @@ +package microsoft.exchange.webservices.data.core.request; + +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 responses = request.readResponse(ewsXmlReader); + + Assert.assertEquals(ServiceResult.Success, responses.getOverallResult()); + Assert.assertNull(getDictionaryEntryValue(responses, "RequestInPolicy")); + } + + private Object getDictionaryEntryValue(ServiceResponseCollection responses, + String requestInPolicy) { + UserConfigurationDictionary dictionary = responses.iterator().next().getUserConfiguration().getDictionary(); + OutParam value = new OutParam(); + dictionary.tryGetValue(requestInPolicy, value); + return value.getParam(); + } + +} diff --git a/src/test/resources/nil.xml b/src/test/resources/nil.xml new file mode 100644 index 000000000..dd39ca6dd --- /dev/null +++ b/src/test/resources/nil.xml @@ -0,0 +1,51 @@ + + + + + + + + + + NoError + + + + + room@company.com + + + + + + + + String + RequestInPolicy + + + + + + String + RemovePrivateProperty + + + Boolean + true + + + + + + + + + \ No newline at end of file From 5cb27c3c35c264db9535bc970fbe4295f22a18e6 Mon Sep 17 00:00:00 2001 From: "sergiu.indrie" Date: Thu, 2 Jun 2016 10:20:55 +0300 Subject: [PATCH 2/3] Added license header to new files --- .../core/request/UserConfigurationTest.java | 23 ++++++++++++++++++ src/test/resources/nil.xml | 24 +++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/src/test/java/microsoft/exchange/webservices/data/core/request/UserConfigurationTest.java b/src/test/java/microsoft/exchange/webservices/data/core/request/UserConfigurationTest.java index 2201a48f5..4bb6f96e9 100644 --- a/src/test/java/microsoft/exchange/webservices/data/core/request/UserConfigurationTest.java +++ b/src/test/java/microsoft/exchange/webservices/data/core/request/UserConfigurationTest.java @@ -1,3 +1,26 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + package microsoft.exchange.webservices.data.core.request; import microsoft.exchange.webservices.base.BaseTest; diff --git a/src/test/resources/nil.xml b/src/test/resources/nil.xml index dd39ca6dd..51bc92835 100644 --- a/src/test/resources/nil.xml +++ b/src/test/resources/nil.xml @@ -1,5 +1,29 @@ + Date: Thu, 2 Jun 2016 10:30:41 +0300 Subject: [PATCH 3/3] Removed license header from test XML file (fix failing test) --- src/test/resources/nil.xml | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/src/test/resources/nil.xml b/src/test/resources/nil.xml index 51bc92835..dd39ca6dd 100644 --- a/src/test/resources/nil.xml +++ b/src/test/resources/nil.xml @@ -1,29 +1,5 @@ -