summaryrefslogtreecommitdiff
path: root/java/common
diff options
context:
space:
mode:
authorKeith Wall <kwall@apache.org>2014-01-17 13:05:23 +0000
committerKeith Wall <kwall@apache.org>2014-01-17 13:05:23 +0000
commitd74602ef8790144bfacf7bcd6f313164e931e827 (patch)
treebfd47bc08591971fbba8980de50332ea0755f24f /java/common
parent88a8ed7c656e5863c638b2189294e19a22a6118c (diff)
downloadqpid-python-d74602ef8790144bfacf7bcd6f313164e931e827.tar.gz
QPID-5065: modifications to get more tests running on windows (both ant and maven).
Also - Fixed the jca/rar pom module name, it should be qpid-ra not qpid-rar. - Added project details such as Website, Mailing List, SCM. Patch submitted by Andrew MacBean <andymacbean@gmail.com> git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1559096 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/common')
-rw-r--r--java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java7
-rw-r--r--java/common/src/main/java/org/apache/qpid/transport/network/io/IoReceiver.java4
-rw-r--r--java/common/src/main/java/org/apache/qpid/util/FileUtils.java5
-rw-r--r--java/common/src/main/java/org/apache/qpid/util/SystemUtils.java81
4 files changed, 90 insertions, 7 deletions
diff --git a/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java b/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java
index 6f9d872f98..b2bcc1836e 100644
--- a/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java
+++ b/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java
@@ -24,6 +24,7 @@ import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import org.apache.qpid.transport.util.Logger;
+import org.apache.qpid.util.SystemUtils;
/**
* Constants for the various properties clients can
@@ -88,11 +89,11 @@ public class ConnectionStartProperties
fullSystemInfo.append(", ");
fullSystemInfo.append(System.getProperty("java.vendor"));
fullSystemInfo.append(", ");
- fullSystemInfo.append(System.getProperty("os.arch"));
+ fullSystemInfo.append(SystemUtils.getOSArch());
fullSystemInfo.append(", ");
- fullSystemInfo.append(System.getProperty("os.name"));
+ fullSystemInfo.append(SystemUtils.getOSName());
fullSystemInfo.append(", ");
- fullSystemInfo.append(System.getProperty("os.version"));
+ fullSystemInfo.append(SystemUtils.getOSVersion());
fullSystemInfo.append(", ");
fullSystemInfo.append(System.getProperty("sun.os.patch.level"));
diff --git a/java/common/src/main/java/org/apache/qpid/transport/network/io/IoReceiver.java b/java/common/src/main/java/org/apache/qpid/transport/network/io/IoReceiver.java
index 06a43e21c6..0ab195ced8 100644
--- a/java/common/src/main/java/org/apache/qpid/transport/network/io/IoReceiver.java
+++ b/java/common/src/main/java/org/apache/qpid/transport/network/io/IoReceiver.java
@@ -26,6 +26,7 @@ import org.apache.qpid.transport.Receiver;
import org.apache.qpid.transport.TransportException;
import org.apache.qpid.transport.network.Ticker;
import org.apache.qpid.transport.util.Logger;
+import org.apache.qpid.util.SystemUtils;
import javax.net.ssl.SSLSocket;
import java.io.IOException;
@@ -57,8 +58,7 @@ final class IoReceiver implements Runnable, Closeable
private Ticker _ticker;
static
{
- String osName = System.getProperty("os.name");
- shutdownBroken = osName == null ? false : osName.matches("(?i).*windows.*");
+ shutdownBroken = SystemUtils.isWindows();
}
public IoReceiver(Socket socket, Receiver<ByteBuffer> receiver, int bufferSize, long timeout)
diff --git a/java/common/src/main/java/org/apache/qpid/util/FileUtils.java b/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
index 7362099070..f48103c650 100644
--- a/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
+++ b/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
@@ -129,7 +129,6 @@ public class FileUtils
StringBuffer inBuffer = new StringBuffer();
- String line;
int read;
while ((read = is.read(data)) != -1)
@@ -157,6 +156,7 @@ public class FileUtils
*
* @return An input stream for the file or resource, or null if one could not be opened.
*/
+ @SuppressWarnings("resource")
public static InputStream openFileOrDefaultResource(String filename, String defaultResource, ClassLoader cl)
{
InputStream is = null;
@@ -173,7 +173,6 @@ public class FileUtils
{
is = null;
}
-
if (is == null)
{
// failed on filesystem, so try on classpath
@@ -332,6 +331,8 @@ public class FileUtils
public static class UnableToCopyException extends Exception
{
+ private static final long serialVersionUID = 956249157141857044L;
+
UnableToCopyException(String msg)
{
super(msg);
diff --git a/java/common/src/main/java/org/apache/qpid/util/SystemUtils.java b/java/common/src/main/java/org/apache/qpid/util/SystemUtils.java
new file mode 100644
index 0000000000..55c7ae9b96
--- /dev/null
+++ b/java/common/src/main/java/org/apache/qpid/util/SystemUtils.java
@@ -0,0 +1,81 @@
+/*
+ *
+ * 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.qpid.util;
+
+/**
+ * SystemUtils provides some simple helper methods for working with the current
+ * Operating System.
+ *
+ * It follows the convention of wrapping all checked exceptions as runtimes, so
+ * code using these methods is free of try-catch blocks but does not expect to
+ * recover from errors.
+ */
+public class SystemUtils
+{
+
+ public static final String UNKNOWN_OS = "unknown";
+ public static final String UNKNOWN_VERSION = "na";
+ public static final String UNKNOWN_ARCH = "unknown";
+
+ private static final String _osName = System.getProperty("os.name", UNKNOWN_OS);
+ private static final String _osVersion = System.getProperty("os.version", UNKNOWN_VERSION);
+ private static final String _osArch = System.getProperty("os.arch", UNKNOWN_ARCH);
+
+ private static final boolean _isWindows = _osName.toLowerCase().contains("windows");
+
+ private SystemUtils()
+ {
+ }
+
+ public final static String getOSName()
+ {
+ return _osName;
+ }
+
+ public final static String getOSVersion()
+ {
+ return _osVersion;
+ }
+
+ public final static String getOSArch()
+ {
+ return _osArch;
+ }
+
+ public final static boolean isWindows()
+ {
+ return _isWindows;
+ }
+
+ public final static String getOSConfigSuffix()
+ {
+ if (_osName.contains(" "))
+ {
+ return _osName.substring(0, _osName.indexOf(' ')).toLowerCase();
+ }
+ return _osName;
+ }
+
+ public final static String getOSString()
+ {
+ return _osName + " " + _osVersion + " " + _osArch;
+ }
+}