|
| 1 | +/* |
| 2 | + * Copyright (c) 2015, salesforce.com, inc. |
| 3 | + * All rights reserved. |
| 4 | + * |
| 5 | + * Redistribution and use in source and binary forms, with or without modification, are permitted provided |
| 6 | + * that the following conditions are met: |
| 7 | + * |
| 8 | + * Redistributions of source code must retain the above copyright notice, this list of conditions and the |
| 9 | + * following disclaimer. |
| 10 | + * |
| 11 | + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and |
| 12 | + * the following disclaimer in the documentation and/or other materials provided with the distribution. |
| 13 | + * |
| 14 | + * Neither the name of salesforce.com, inc. nor the names of its contributors may be used to endorse or |
| 15 | + * promote products derived from this software without specific prior written permission. |
| 16 | + * |
| 17 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED |
| 18 | + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
| 19 | + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR |
| 20 | + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
| 21 | + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 22 | + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 23 | + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 24 | + * POSSIBILITY OF SUCH DAMAGE. |
| 25 | + */ |
| 26 | +package com.salesforce.dataloader.client; |
| 27 | + |
| 28 | +import org.junit.Test; |
| 29 | + |
| 30 | +import static org.junit.Assert.assertEquals; |
| 31 | +import static org.junit.Assert.assertNull; |
| 32 | + |
| 33 | +/** |
| 34 | + * Unit tests for LoginClient API version logic. |
| 35 | + * SOAP login is not supported in API versions >= 65; login falls back to 64.0. |
| 36 | + */ |
| 37 | +public class LoginClientTest { |
| 38 | + |
| 39 | + @Test |
| 40 | + public void getApiVersionForLogin_when65_returns64() { |
| 41 | + assertEquals("64.0", LoginClient.getApiVersionForLogin("65.0")); |
| 42 | + } |
| 43 | + |
| 44 | + @Test |
| 45 | + public void getApiVersionForLogin_when66_returns64() { |
| 46 | + assertEquals("64.0", LoginClient.getApiVersionForLogin("66.0")); |
| 47 | + } |
| 48 | + |
| 49 | + @Test |
| 50 | + public void getApiVersionForLogin_when70_returns64() { |
| 51 | + assertEquals("64.0", LoginClient.getApiVersionForLogin("70.0")); |
| 52 | + } |
| 53 | + |
| 54 | + @Test |
| 55 | + public void getApiVersionForLogin_when64_returns64() { |
| 56 | + assertEquals("64.0", LoginClient.getApiVersionForLogin("64.0")); |
| 57 | + } |
| 58 | + |
| 59 | + @Test |
| 60 | + public void getApiVersionForLogin_when63_returns63() { |
| 61 | + assertEquals("63.0", LoginClient.getApiVersionForLogin("63.0")); |
| 62 | + } |
| 63 | + |
| 64 | + @Test |
| 65 | + public void getApiVersionForLogin_when50_returns50() { |
| 66 | + assertEquals("50.0", LoginClient.getApiVersionForLogin("50.0")); |
| 67 | + } |
| 68 | + |
| 69 | + @Test |
| 70 | + public void getApiVersionForLogin_whenNull_returnsNull() { |
| 71 | + assertNull(LoginClient.getApiVersionForLogin(null)); |
| 72 | + } |
| 73 | + |
| 74 | + @Test |
| 75 | + public void getApiVersionForLogin_whenEmpty_returnsEmpty() { |
| 76 | + assertEquals("", LoginClient.getApiVersionForLogin("")); |
| 77 | + } |
| 78 | + |
| 79 | + @Test |
| 80 | + public void getServicePath_usesProvidedVersion() { |
| 81 | + assertEquals("/services/Soap/u/64.0/", LoginClient.getServicePath("64.0")); |
| 82 | + assertEquals("/services/Soap/u/65.0/", LoginClient.getServicePath("65.0")); |
| 83 | + } |
| 84 | + |
| 85 | + @Test |
| 86 | + public void getServicePath_withLoginVersion_uses64ForV65Session() { |
| 87 | + String loginVersion = LoginClient.getApiVersionForLogin("65.0"); |
| 88 | + assertEquals("/services/Soap/u/64.0/", LoginClient.getServicePath(loginVersion)); |
| 89 | + } |
| 90 | + |
| 91 | + @Test |
| 92 | + public void getServicePath_withLoginVersion_passesThrough64() { |
| 93 | + String loginVersion = LoginClient.getApiVersionForLogin("64.0"); |
| 94 | + assertEquals("/services/Soap/u/64.0/", LoginClient.getServicePath(loginVersion)); |
| 95 | + } |
| 96 | + |
| 97 | + @Test |
| 98 | + public void getServicePath_withLoginVersion_passesThrough63() { |
| 99 | + String loginVersion = LoginClient.getApiVersionForLogin("63.0"); |
| 100 | + assertEquals("/services/Soap/u/63.0/", LoginClient.getServicePath(loginVersion)); |
| 101 | + } |
| 102 | + |
| 103 | +} |
0 commit comments