-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
122 additions
and
83 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
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
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
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
42 changes: 42 additions & 0 deletions
42
atum/src/main/scala/za/co/absa/atum/utils/OperatingSystem.scala
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,42 @@ | ||
/* | ||
* Copyright 2018 ABSA Group Limited | ||
* | ||
* 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 za.co.absa.atum.utils | ||
|
||
|
||
object OperatingSystem { | ||
|
||
// adapted from https://stackoverflow.com/a/31547504/1773349 | ||
|
||
object OperatingSystems extends Enumeration { | ||
val WINDOWS, LINUX, MAC, SOLARIS, OTHER = Value | ||
} | ||
|
||
def getOsByOsName(osName: String): OperatingSystems.Value = { | ||
import za.co.absa.atum.utils.OperatingSystem.OperatingSystems._ | ||
osName.toLowerCase match { | ||
case os if os.contains("win") => WINDOWS | ||
case os if os.contains("nix") || os.contains("nux") || os.contains("aix") => LINUX | ||
case os if os.contains("mac") => MAC | ||
case os if os.contains("sunos") => SOLARIS | ||
case _ => OTHER | ||
} | ||
} | ||
|
||
def getCurrentOs: OperatingSystems.Value = { | ||
getOsByOsName(System.getProperty("os.name")) | ||
} | ||
|
||
} |
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
32 changes: 0 additions & 32 deletions
32
atum/src/test/scala/za/co/absa/atum/utils/MiniDfsClusterBase.scala
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
atum/src/test/scala/za/co/absa/atum/utils/OperatingSystemSuite.scala
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,32 @@ | ||
/* | ||
* Copyright 2018 ABSA Group Limited | ||
* | ||
* 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 za.co.absa.atum.utils | ||
|
||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.should.Matchers | ||
import za.co.absa.atum.utils.OperatingSystem.OperatingSystems | ||
|
||
class OperatingSystemSuite extends AnyFlatSpec with Matchers { | ||
|
||
"OperatingSystem util" should "correctly find out OS" in { | ||
OperatingSystem.getOsByOsName("Windows 10") shouldBe OperatingSystems.WINDOWS | ||
OperatingSystem.getOsByOsName("Linux") shouldBe OperatingSystems.LINUX | ||
OperatingSystem.getOsByOsName("Mac OS X") shouldBe OperatingSystems.MAC | ||
OperatingSystem.getOsByOsName("SunOs") shouldBe OperatingSystems.SOLARIS | ||
|
||
OperatingSystem.getOsByOsName("my own special os") shouldBe OperatingSystems.OTHER | ||
} | ||
} |
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
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
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
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
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
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