You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by st...@apache.org on 2014/08/22 19:55:00 UTC
[04/11] git commit: SLIDER-352 some tests
SLIDER-352 some tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/83665f61
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/83665f61
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/83665f61
Branch: refs/heads/develop
Commit: 83665f617025fea9f8f7e5462e30d66caab025d0
Parents: b3a835d
Author: Steve Loughran <st...@apache.org>
Authored: Fri Aug 22 16:08:24 2014 +0100
Committer: Steve Loughran <st...@apache.org>
Committed: Fri Aug 22 16:08:24 2014 +0100
----------------------------------------------------------------------
.../common/tools/TestWindowsSupport.groovy | 78 ++++++++++++++++++++
1 file changed, 78 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/83665f61/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy b/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy
new file mode 100644
index 0000000..4da42f2
--- /dev/null
+++ b/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.slider.common.tools
+
+import groovy.transform.CompileStatic
+import groovy.util.logging.Slf4j
+import org.apache.hadoop.conf.Configuration
+import org.apache.hadoop.fs.ChecksumFileSystem
+import org.apache.hadoop.fs.Path
+import org.apache.hadoop.fs.FileSystem as HadoopFS
+import org.junit.Test
+
+import java.util.regex.Pattern
+
+@CompileStatic
+@Slf4j
+class TestWindowsSupport {
+
+ private static final Pattern hasDriveLetterSpecifier =
+ Pattern.compile("^/?[a-zA-Z]:");
+ public static
+ final String windowsFile = "C:\\Users\\Administrator\\AppData\\Local\\Temp\\junit3180177850133852404\\testpkg\\appdef_1.zip"
+
+
+ private static boolean hasWindowsDrive(String path) {
+ return hasDriveLetterSpecifier.matcher(path).find();
+ }
+
+ private static int startPositionWithoutWindowsDrive(String path) {
+ if (hasWindowsDrive(path)) {
+ return path.charAt(0) == '/' ? 3 : 2;
+ } else {
+ return 0;
+ }
+ }
+
+ @Test
+ public void testHasWindowsDrive() throws Throwable {
+ assert hasWindowsDrive(windowsFile)
+ }
+
+ @Test
+ public void testStartPosition() throws Throwable {
+ assert 2 == startPositionWithoutWindowsDrive(windowsFile)
+ }
+
+ @Test
+ public void testPathHandling() throws Throwable {
+ System.setProperty("os.name", "Windows/286")
+ Path path = new Path(windowsFile);
+ def uri = path.toUri()
+// assert "file" == uri.scheme
+ assert uri.authority == null;
+
+
+
+ Configuration conf = new Configuration()
+
+ def localfs = HadoopFS.get(uri, conf)
+ assert localfs instanceof ChecksumFileSystem
+ }
+}