[jboss-cvs] JBossAS SVN: r71434 - in projects/vfs/trunk/src/test/java/org/jboss/test/virtual: test and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Mar 29 15:31:30 EDT 2008


Author: alesj
Date: 2008-03-29 15:31:30 -0400 (Sat, 29 Mar 2008)
New Revision: 71434

Added:
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/support/OperatingSystem.java
Modified:
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/OSAwareVFSTest.java
Log:
OS hack, still need to fix JARCacheUnitTestCase.

Added: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/support/OperatingSystem.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/support/OperatingSystem.java	                        (rev 0)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/support/OperatingSystem.java	2008-03-29 19:31:30 UTC (rev 71434)
@@ -0,0 +1,55 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.virtual.support;
+
+/**
+ * OS.
+ *
+ * TODO - remove together with OSAwareTest
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public enum OperatingSystem
+{
+   LINUX("linux"),
+   MAC("mac"),
+   WINDOWS("windows"),
+   OTHER(null);
+
+   private String name;
+
+   OperatingSystem(String name)
+   {
+      this.name = name;
+   }
+
+   public static OperatingSystem matchOS(String osName)
+   {
+      OperatingSystem[] systems = values();
+      for(int i = 0; i < systems.length - 1; i++)
+      {
+         if (osName.toLowerCase().contains(systems[i].name))
+            return systems[i];
+      }
+      return OTHER;
+   }
+}

Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/OSAwareVFSTest.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/OSAwareVFSTest.java	2008-03-29 18:46:54 UTC (rev 71433)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/OSAwareVFSTest.java	2008-03-29 19:31:30 UTC (rev 71434)
@@ -25,6 +25,7 @@
 import java.security.PrivilegedAction;
 
 import org.jboss.test.BaseTestCase;
+import org.jboss.test.virtual.support.OperatingSystem;
 
 /**
  * OS aware test, temp hack.
@@ -35,7 +36,7 @@
  */
 public abstract class OSAwareVFSTest extends BaseTestCase
 {
-   private Boolean isWindows;
+   private OperatingSystem os;
 
    protected OSAwareVFSTest(String name)
    {
@@ -49,20 +50,25 @@
     */
    protected boolean isWindowsOS()
    {
-      if (isWindows == null)
+      return OperatingSystem.WINDOWS == getOS();
+   }
+
+   protected OperatingSystem getOS()
+   {
+      if (os == null)
       {
          SecurityManager sm = suspendSecurity();
          try
          {
             String osName = System.getProperty("os.name");
-            isWindows = osName != null && osName.contains("Windows");
+            os = OperatingSystem.matchOS(osName);
          }
          finally
          {
             resumeSecurity(sm);
          }
       }
-      return isWindows;
+      return os;
    }
 
    /**




More information about the jboss-cvs-commits mailing list