Title: [2071] trunk/xstream/src: Test for presence of Sun's StAX implementation.
Revision
2071
Author
joehni
Date
2013-06-20 16:15:43 -0500 (Thu, 20 Jun 2013)

Log Message

Test for presence of Sun's StAX implementation.

Modified Paths


Diff

Modified: trunk/xstream/src/java/com/thoughtworks/xstream/core/JVM.java (2070 => 2071)


--- trunk/xstream/src/java/com/thoughtworks/xstream/core/JVM.java	2013-06-14 19:12:44 UTC (rev 2070)
+++ trunk/xstream/src/java/com/thoughtworks/xstream/core/JVM.java	2013-06-20 21:15:43 UTC (rev 2071)
@@ -39,6 +39,7 @@
     private final boolean supportsAWT = loadClass("java.awt.Color", false) != null;
     private final boolean supportsSwing = loadClass("javax.swing.LookAndFeel", false) != null;
     private final boolean supportsSQL = loadClass("java.sql.Date") != null;
+    private final boolean supportsSunStAX = loadClass("com.sun.xml.internal.stream.XMLInputFactoryImpl") != null;
     
     private static final boolean canAllocateWithUnsafe;
     private static final boolean optimizedTreeSetAddAll;
@@ -242,6 +243,15 @@
     public boolean supportsSQL() {
         return this.supportsSQL;
     }
+
+    /**
+     * Checks if the jvm supports StAX implementation by Sun.
+     * 
+     * @since upcoiming
+     */
+    public boolean supportsSunStAX() {
+        return this.supportsSunStAX;
+    }
     
     /**
      * Checks if TreeSet.addAll is optimized for SortedSet argument.
@@ -305,7 +315,7 @@
         System.out.println("XStream support for enhanced Mode: " + jvm.canUseSun14ReflectionProvider());
         System.out.println("Supports AWT: " + jvm.supportsAWT());
         System.out.println("Supports Swing: " + jvm.supportsSwing());
-        System.out.println("Supports SQL: " + jvm.supportsSQL());
+        System.out.println("Supports SQL: " + jvm.supportsSunStAX());
         System.out.println("Optimized TreeSet.addAll: " + hasOptimizedTreeSetAddAll());
         System.out.println("Optimized TreeMap.putAll: " + hasOptimizedTreeMapPutAll());
         System.out.println("Can parse UTC date format: " + canParseUTCDateFormat());

Modified: trunk/xstream/src/test/com/thoughtworks/xstream/io/DriverEndToEndTestSuite.java (2070 => 2071)


--- trunk/xstream/src/test/com/thoughtworks/xstream/io/DriverEndToEndTestSuite.java	2013-06-14 19:12:44 UTC (rev 2070)
+++ trunk/xstream/src/test/com/thoughtworks/xstream/io/DriverEndToEndTestSuite.java	2013-06-20 21:15:43 UTC (rev 2071)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2005 Joe Walnes.
- * Copyright (C) 2006, 2007, 2011 XStream Committers.
+ * Copyright (C) 2006, 2007, 2011, 2013 XStream Committers.
  * All rights reserved.
  *
  * The software in this package is published under the terms of the BSD
@@ -59,13 +59,15 @@
         addDriverTest(new StaxDriver());
         if (JVM.is16()) {
             JVM jvm = new JVM();
-            Class driverType = jvm.loadClass("com.thoughtworks.xstream.io.xml.SjsxpDriver");
-            try {
-                addDriverTest((HierarchicalStreamDriver)driverType.newInstance());
-            } catch (InstantiationException e) {
-                throw new AssertionFailedError("Cannot instantiate " + driverType.getName());
-            } catch (IllegalAccessException e) {
-                throw new AssertionFailedError("Cannot access default constructor of " + driverType.getName());
+            if (jvm.supportsSunStAX()) {
+                Class driverType = jvm.loadClass("com.thoughtworks.xstream.io.xml.SjsxpDriver");
+                try {
+                    addDriverTest((HierarchicalStreamDriver)driverType.newInstance());
+                } catch (InstantiationException e) {
+                    throw new AssertionFailedError("Cannot instantiate " + driverType.getName());
+                } catch (IllegalAccessException e) {
+                    throw new AssertionFailedError("Cannot access default constructor of " + driverType.getName());
+                }
             }
         }
         addDriverTest(new WstxDriver());

To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to