-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into release-history
- Loading branch information
Showing
2 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
apollo-core/src/test/java/com/ctrip/framework/foundation/internals/UtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* Copyright 2021 Apollo Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
package com.ctrip.framework.foundation.internals; | ||
|
||
import org.junit.After; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public class UtilsTest { | ||
private final String actualOsName = System.getProperty("os.name"); | ||
|
||
@After | ||
public void tearDown() { | ||
System.setProperty("os.name", actualOsName); | ||
} | ||
|
||
@Test | ||
public void isBlankTrueGivenNull() { | ||
assertTrue(Utils.isBlank(null)); | ||
} | ||
|
||
@Test | ||
public void isBlankTrueGivenEmpty() { | ||
assertTrue(Utils.isBlank("")); | ||
} | ||
|
||
@Test | ||
public void isBlankTrueGivenWhitespace() { | ||
assertTrue(Utils.isBlank(" ")); | ||
} | ||
|
||
@Test | ||
public void isBlankFalseGivenLoremIpsum() { | ||
assertFalse(Utils.isBlank("Lorem Ipsum")); | ||
} | ||
|
||
@Test | ||
public void isBlankFalseGivenWhitespacePadded() { | ||
assertFalse(Utils.isBlank(" Lorem Ipsum ")); | ||
} | ||
|
||
@Test | ||
public void isOsWindowsTrueGivenWindows10() { | ||
System.setProperty("os.name", "Windows 10"); | ||
assertTrue(Utils.isOSWindows()); | ||
} | ||
|
||
@Test | ||
public void isOSWindowsFalseGivenMacOsX() { | ||
System.setProperty("os.name", "Mac OS X"); | ||
assertFalse(Utils.isOSWindows()); | ||
} | ||
|
||
@Test | ||
public void isOSWindowsFalseGivenBlank() { | ||
System.setProperty("os.name", ""); | ||
assertFalse(Utils.isOSWindows()); | ||
} | ||
|
||
// Explicitly calling out case sensitivity; revisit if Microsoft changes naming convention | ||
@Test | ||
public void isOSWindowsFalseGivenAllUppercaseWindows() { | ||
System.setProperty("os.name", "WINDOWS 10"); | ||
assertFalse(Utils.isOSWindows()); | ||
} | ||
|
||
@Test | ||
public void isOSWindowsFalseGivenAllLowercaseWindows() { | ||
System.setProperty("os.name", "windows 10"); | ||
assertFalse(Utils.isOSWindows()); | ||
} | ||
} |