Skip to content
This repository was archived by the owner on Jun 18, 2024. It is now read-only.

Fix failing test case in TimeZoneUtilsTest#393

Closed
cfraser wants to merge 1 commit intoOfficeDev:masterfrom
cfraser:bug/TimeZoneUtilTest
Closed

Fix failing test case in TimeZoneUtilsTest#393
cfraser wants to merge 1 commit intoOfficeDev:masterfrom
cfraser:bug/TimeZoneUtilTest

Conversation

@cfraser
Copy link
Copy Markdown

@cfraser cfraser commented Aug 6, 2015

  • added test to verify that getMicrosoftTimeZoneName returns null when passed a case insensitive timezone id.

* added test to verify that ```getMicrosoftTimeZoneName``` returns null when passed an case insensitive timezone id.
@azurecla
Copy link
Copy Markdown

azurecla commented Aug 6, 2015

Hi @cfraser, I'm your friendly neighborhood Azure Pull Request Bot (You can call me AZPRBOT). Thanks for your contribution!

This seems like a small (but important) contribution, so no contribution license agreement is required at this point. Real humans will now evaluate your PR.

TTYL, AZPRBOT;

@serious6
Copy link
Copy Markdown
Member

serious6 commented Aug 6, 2015

this might be a duplicate of #392 ?

@cfraser
Copy link
Copy Markdown
Author

cfraser commented Aug 6, 2015

#392 appears to just wrap the underlying issue in a try/catch. While that will mitigate the Assert, it doesn't test that the expected value is returned.

@cfraser
Copy link
Copy Markdown
Author

cfraser commented Aug 6, 2015

I don't understand why the test is failing on TravisCI.

The string "africa/abidjan" does not exist in the map in TimeZoneUtils so it's not possible for it to return "UTC" as is occurring on Travis.

Am I missing some environment variables, or some other patch that is not part of the master branch? Is it possible something was put in place to pass this test previously given it was not passing a fresh clone, There's no record of the TravisCI automation result when the test was added in #348 that I can see in the history.

Please excuse all the questions, this is my first submission to any OSS project. I am planning on submitting some Calendar fixes with tests shortly.

@cfraser
Copy link
Copy Markdown
Author

cfraser commented Aug 6, 2015

It looks like #348 failed Travis build 584 with the Assert exception I was seeing. The subsequent build 585 was successful, but it's not obvious to me what changed in the test code.

@serious6
Copy link
Copy Markdown
Member

serious6 commented Aug 6, 2015

this is really strange. I will try to solve this later on.

@serious6
Copy link
Copy Markdown
Member

serious6 commented Aug 6, 2015

can you try run that build on your local machine? mvn clean install

@cfraser
Copy link
Copy Markdown
Author

cfraser commented Aug 6, 2015

[ cfraser bean ~/code/ews-java-api ] git reset --hard bba52a86f72015994893d9fc949597bff70c8daf
HEAD is now at bba52a8 Fix failing test case in TimeZoneUtilsTest
[ cfraser bean ~/code/ews-java-api ] mvn clean install
[INFO] Scanning for projects...
[INFO] Inspecting build with total of 1 modules...
[INFO] Installing Nexus Staging features:
[INFO]   ... total of 1 executions of maven-deploy-plugin replaced with nexus-staging-maven-plugin
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Exchange Web Services Java API 2.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ ews-java-api ---
[INFO] Deleting /Users/cfraser/code/ews-java-api/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ ews-java-api ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/cfraser/code/ews-java-api/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ ews-java-api ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 588 source files to /Users/cfraser/code/ews-java-api/target/classes
[INFO] /Users/cfraser/code/ews-java-api/src/main/java/microsoft/exchange/webservices/data/core/ExchangeService.java: Some input files use unchecked or unsafe operations.
[INFO] /Users/cfraser/code/ews-java-api/src/main/java/microsoft/exchange/webservices/data/core/ExchangeService.java: Recompile with -Xlint:unchecked for details.
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ ews-java-api ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ ews-java-api ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 24 source files to /Users/cfraser/code/ews-java-api/target/test-classes
[INFO] /Users/cfraser/code/ews-java-api/src/test/java/microsoft/exchange/webservices/data/credential/WSSecurityBasedCredentialsTest.java: Some input files use unchecked or unsafe operations.
[INFO] /Users/cfraser/code/ews-java-api/src/test/java/microsoft/exchange/webservices/data/credential/WSSecurityBasedCredentialsTest.java: Recompile with -Xlint:unchecked for details.
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ ews-java-api ---
[INFO] Surefire report directory: /Users/cfraser/code/ews-java-api/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running microsoft.exchange.webservices.data.autodiscover.request.GetUserSettingsRequestTest
11:35:42,998 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
11:35:42,998 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback-test.xml] at [file:/Users/cfraser/code/ews-java-api/target/test-classes/logback-test.xml]
11:35:43,086 |-INFO in ReconfigureOnChangeFilter{invocationCounter=0} - Will scan for changes in [[/Users/cfraser/code/ews-java-api/target/test-classes/logback-test.xml]] every 60 seconds. 
11:35:43,086 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Adding ReconfigureOnChangeFilter as a turbo filter
11:35:43,091 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
11:35:43,094 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
11:35:43,142 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG
11:35:43,142 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
11:35:43,143 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
11:35:43,143 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@50d68561 - Registering current configuration as safe fallback point
Tests run: 12, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.558 sec
Running microsoft.exchange.webservices.data.core.EwsUtilitiesTest
Tests run: 15, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.017 sec
Running microsoft.exchange.webservices.data.core.EwsXmlReaderTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.158 sec
Running microsoft.exchange.webservices.data.core.LazyMemberTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.01 sec
Running microsoft.exchange.webservices.data.core.PropertyBagTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.04 sec
Running microsoft.exchange.webservices.data.core.service.items.TaskTest
Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.015 sec
Running microsoft.exchange.webservices.data.credential.WSSecurityBasedCredentialsTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 sec
Running microsoft.exchange.webservices.data.exception.InvalidOrUnsupportedTimeZoneDefinitionExceptionTest
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec
Running microsoft.exchange.webservices.data.exception.MaximumRedirectionHopsExceededExceptionTest
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec
Running microsoft.exchange.webservices.data.misc.IFunctionsTest
Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec
Running microsoft.exchange.webservices.data.misc.TimeSpanTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.007 sec
Running microsoft.exchange.webservices.data.property.complex.ComplexPropertyCollectionTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec
Running microsoft.exchange.webservices.data.property.complex.EmailAddressTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec
Running microsoft.exchange.webservices.data.property.complex.ExtendedPropertyCollectionTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec
Running microsoft.exchange.webservices.data.property.complex.OlsonTimeZoneTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.019 sec
Running microsoft.exchange.webservices.data.property.complex.TimeZoneTransitionCompareTest
Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.06 sec
Running microsoft.exchange.webservices.data.property.complex.UniqueBodyTest
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec
Running microsoft.exchange.webservices.data.property.complex.UserConfigurationDictionaryTest
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.008 sec
Running microsoft.exchange.webservices.data.property.definition.ByteArrayPropertyDefinitionTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec
Running microsoft.exchange.webservices.data.sync.ChangeCollectionTest
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.021 sec
Running microsoft.exchange.webservices.data.util.DateTimeUtilsTest
Tests run: 18, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.052 sec
Running microsoft.exchange.webservices.data.util.TimeZoneUtilsTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec

Results :

Tests run: 107, Failures: 0, Errors: 0, Skipped: 0

@cfraser
Copy link
Copy Markdown
Author

cfraser commented Aug 6, 2015

Sorry for all the back and forth on this. It appeared trivial last night.

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.

I actually dont see what this test is about? Do you want to test TimeZone.getTimeZone(...) ? Since this is a java.util and no ews-java-api class testing if it will return null on case-insensitive is not related to our project. This test should be removed.

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.

btw this test also fails when I execute it with intelliJ on the local repo.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

To be honest, this isn't much of a test. It should probably just be removed from the test class. All it does is validate that the string isn't a key in TimeZoneUtils.createOlsonTimeZoneToMsMap(). It should return null since it's not in the map, but don't have a good explaination for why that is not the case on the build machine, and on your local system.

Unfortunately I can't reproduce the failure so I guess I'm going to withdraw the PR. It's strange to me that #392 is also"fixing" this issue and it also can't be reproduced by the Travis build.

C'est la vie.

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.

I am using jdk 1.8.0_51

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.

Ok. Nevertheless thanks for your contribution.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'll try with Java 8. I'm using 7.

I apologize for all the back on forth on this very trivial commit. I don't want to be wasting your time.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'll keep trying to contribute. 👍

I just have to get a senior director to sign the CLA, and the other PR should be unblocked.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I am able to reproduce this test failing when I use Java 8. It appears that TimeZone defaults to UTC when the time zone id cannot be resolved as documented in the javadocs of getTimeZone(String ID)

/**
     * Gets the <code>TimeZone</code> for the given ID.
     *
     * @param ID the ID for a <code>TimeZone</code>, either an abbreviation
     * such as "PST", a full name such as "America/Los_Angeles", or a custom
     * ID such as "GMT-8:00". Note that the support of abbreviations is
     * for JDK 1.1.x compatibility only and full names should be used.
     *
     * @return the specified <code>TimeZone</code>, or the GMT zone if the given ID
     * cannot be understood.
     */
    public static synchronized TimeZone getTimeZone(String ID) {
        return getTimeZone(ID, true);
    }
.
.
.
    private static TimeZone getTimeZone(String ID, boolean fallback) {
        TimeZone tz = ZoneInfo.getTimeZone(ID);
        if (tz == null) {
            tz = parseCustomTimeZone(ID);
            if (tz == null && fallback) {
                tz = new ZoneInfo(GMT_ID, 0);
            }
        }
        return tz;
    }

It's worth documenting in case someone else runs into this in the future.

@serious6
Copy link
Copy Markdown
Member

@cfraser please fix the build errors.

@cfraser cfraser closed this Aug 14, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants