[jbosscache-commits] JBoss Cache SVN: r6058 - in core/trunk/src: test/java/org/jboss/cache/config and 1 other directory.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Thu Jun 26 11:44:26 EDT 2008


Author: mircea.markus
Date: 2008-06-26 11:44:26 -0400 (Thu, 26 Jun 2008)
New Revision: 6058

Removed:
   core/trunk/src/main/etc/META-INF/config2to3.xslt
Modified:
   core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTransformerTest.java
Log:
updated ut to use relative path to the xslt. Also moved the xslt so that it is grabbed in the class path

Deleted: core/trunk/src/main/etc/META-INF/config2to3.xslt
===================================================================
--- core/trunk/src/main/etc/META-INF/config2to3.xslt	2008-06-26 14:57:18 UTC (rev 6057)
+++ core/trunk/src/main/etc/META-INF/config2to3.xslt	2008-06-26 15:44:26 UTC (rev 6058)
@@ -1,425 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-   <xsl:output method="xml" indent="yes"/>
-
-   <xsl:template match="/">
-      <xsl:element name="jbosscache">
-         <xsl:call-template name="locking"/>
-         <xsl:call-template name="transaction"/>
-         <xsl:call-template name="serialization"/>
-         <xsl:call-template name="startup"/>
-         <xsl:call-template name="transport"/>
-         <xsl:apply-templates select="//attribute"/>
-         <!--<xsl:call-template name="invalidation"/>         -->
-      </xsl:element>
-   </xsl:template>
-
-   <xsl:template match="//attribute"/>
-
-   <xsl:template name="locking">
-      <xsl:if
-            test="//attribute[@name='IsolationLevel'] | //attribute[@name='LockAcquisitionTimeout'] | //attribute[@name='LockParentForChildInsertRemove']">
-         <xsl:element name="locking">
-            <xsl:if test="//attribute[@name='IsolationLevel']">
-               <xsl:attribute name="isolationLevel">
-                  <xsl:value-of select="normalize-space(//attribute[@name='IsolationLevel'])"/>
-               </xsl:attribute>
-            </xsl:if>
-            <xsl:if test="//attribute[@name='LockAcquisitionTimeout']">
-               <xsl:attribute name="lockAcquisitionTimeout">
-                  <xsl:value-of select="normalize-space(//attribute[@name='LockAcquisitionTimeout'])"/>
-               </xsl:attribute>
-            </xsl:if>
-            <xsl:if test="//attribute[@name='LockParentForChildInsertRemove']">
-               <xsl:attribute name="lockParentForChildInsertRemove">
-                  <xsl:value-of select="normalize-space(//attribute[@name='LockParentForChildInsertRemove'])"/>
-               </xsl:attribute>
-            </xsl:if>
-            <xsl:if test="//attribute[@name='NodeLockingScheme']">
-               <xsl:attribute name="optimistic">
-                  <xsl:value-of select="normalize-space(//attribute[@name='NodeLockingScheme'])"/>
-               </xsl:attribute>
-            </xsl:if>
-         </xsl:element>
-      </xsl:if>
-   </xsl:template>
-
-   <xsl:template name="transaction">
-      <xsl:if
-            test="//attribute[@name='TransactionManagerLookupClass'] | //attribute[@name='SyncRollbackPhase'] | //attribute[@name='SyncCommitPhase']">
-         <xsl:element name="transaction">
-            <xsl:if test="//attribute[@name='TransactionManagerLookupClass']">
-               <xsl:attribute name="transactionManagerLookupClass">
-                  <xsl:value-of select="normalize-space(//attribute[@name='TransactionManagerLookupClass'])"/>
-               </xsl:attribute>
-            </xsl:if>
-            <xsl:if test="//attribute[@name='SyncCommitPhase']">
-               <xsl:attribute name="syncCommitPhase">
-                  <xsl:value-of select="normalize-space(//attribute[@name='SyncCommitPhase'])"/>
-               </xsl:attribute>
-            </xsl:if>
-            <xsl:if test="//attribute[@name='SyncRollbackPhase']">
-               <xsl:attribute name="syncRollbackPhase">
-                  <xsl:value-of select="normalize-space(//attribute[@name='SyncRollbackPhase'])"/>
-               </xsl:attribute>
-            </xsl:if>
-         </xsl:element>
-      </xsl:if>
-   </xsl:template>
-
-   <xsl:template name="serialization">
-      <xsl:if
-            test="//attribute[@name='ObjectInputStreamPoolSize'] | //attribute[@name='ObjectOutputStreamPoolSize'] | //attribute[@name='ReplicationVersion'] | //attribute[@name='MarshallerClass'] | //attribute[@name='UseLazyDeserialization'] | //attribute[@name='UseRegionBasedMarshalling']">
-         <serialization>
-            <xsl:if test="//attribute[@name='ObjectInputStreamPoolSize']">
-               <xsl:attribute name="objectInputStreamPoolSize">
-                  <xsl:value-of select="normalize-space(//attribute[@name='ObjectInputStreamPoolSize'])"/>
-               </xsl:attribute>
-            </xsl:if>
-            <xsl:if test="//attribute[@name='ObjectOutputStreamPoolSize']">
-               <xsl:attribute name="objectOutputStreamPoolSize">
-                  <xsl:value-of select="normalize-space(//attribute[@name='ObjectOutputStreamPoolSize'])"/>
-               </xsl:attribute>
-            </xsl:if>
-            <xsl:if test="//attribute[@name='ReplicationVersion']">
-               <xsl:attribute name="version">
-                  <xsl:value-of select="normalize-space(//attribute[@name='ReplicationVersion'])"/>
-               </xsl:attribute>
-            </xsl:if>
-            <xsl:if test="//attribute[@name='MarshallerClass']">
-               <xsl:attribute name="marshallerClass">
-                  <xsl:value-of select="normalize-space(//attribute[@name='MarshallerClass'])"/>
-               </xsl:attribute>
-            </xsl:if>
-            <xsl:if test="//attribute[@name='UseLazyDeserialization']">
-               <xsl:attribute name="useLazyDeserialization">
-                  <xsl:value-of select="normalize-space(//attribute[@name='UseLazyDeserialization'])"/>
-               </xsl:attribute>
-            </xsl:if>
-
-            <xsl:if test="//attribute[@name='UseRegionBasedMarshalling']">
-               <xsl:attribute name="useRegionBasedMarshalling">
-                  <xsl:value-of select="normalize-space(//attribute[@name='UseRegionBasedMarshalling'])"/>
-               </xsl:attribute>
-            </xsl:if>
-         </serialization>
-      </xsl:if>
-   </xsl:template>
-
-   <xsl:template match="//attribute[@name='CacheMode']">
-      <xsl:if test="(normalize-space(.) = 'INVALIDATION_ASYNC') or (normalize-space(.) = 'INVALIDATION_SYNC')">
-         <invalidation>
-            <xsl:if test="(normalize-space(.) = 'INVALIDATION_ASYNC')">
-               <xsl:element name="async">
-                  <xsl:call-template name="asyncAttributes"/>
-               </xsl:element>
-            </xsl:if>
-            <xsl:if test="(normalize-space(.) = 'INVALIDATION_SYNC')">
-               <xsl:element name="sync">
-                  <xsl:call-template name="syncAttributes"/>
-               </xsl:element>
-            </xsl:if>
-         </invalidation>
-      </xsl:if>
-      <xsl:if test="(normalize-space(.) = 'REPL_ASYNC') or (normalize-space(.) = 'REPL_SYNC')">
-         <replication>
-            <xsl:if test="(normalize-space(.) = 'REPL_ASYNC')">
-               <xsl:element name="async">
-                  <xsl:call-template name="asyncAttributes"/>
-               </xsl:element>
-            </xsl:if>
-            <xsl:if test="(normalize-space(.) = 'REPL_SYNC')">
-               <xsl:element name="sync">
-                  <xsl:call-template name="syncAttributes"/>
-               </xsl:element>
-            </xsl:if>
-            <xsl:call-template name="buddy"/>
-         </replication>
-      </xsl:if>
-   </xsl:template>
-
-   <xsl:template name="buddy">
-      <xsl:if test="//attribute[@name='BuddyReplicationConfig']">
-         <buddy>
-            <xsl:if test="//buddyReplicationEnabled">
-               <xsl:attribute name="enabled">
-                  <xsl:value-of select="//buddyReplicationEnabled"/>
-               </xsl:attribute>
-            </xsl:if>
-            <xsl:if test="//buddyPoolName">
-               <xsl:attribute name="poolName">
-                  <xsl:value-of select="//buddyPoolName"/>
-               </xsl:attribute>
-            </xsl:if>
-            <xsl:if test="//buddyCommunicationTimeout">
-               <xsl:attribute name="communicationTimeout">
-                  <xsl:value-of select="//buddyCommunicationTimeout"/>
-               </xsl:attribute>
-            </xsl:if>
-            <xsl:if test="//autoDataGravitation | //dataGravitationRemoveOnFind | //dataGravitationSearchBackupTrees">
-               <dataGravitation>
-                  <xsl:if test="//autoDataGravitation">
-                     <xsl:attribute name="auto">
-                        <xsl:value-of select="//autoDataGravitation"/>
-                     </xsl:attribute>
-                  </xsl:if>
-                  <xsl:if test="//dataGravitationRemoveOnFind">
-                     <xsl:attribute name="removeOnFind">
-                        <xsl:value-of select="//dataGravitationRemoveOnFind"/>
-                     </xsl:attribute>
-                  </xsl:if>
-                  <xsl:if test="//dataGravitationSearchBackupTrees">
-                     <xsl:attribute name="searchBackupTrees">
-                        <xsl:value-of select="//dataGravitationSearchBackupTrees"/>
-                     </xsl:attribute>
-                  </xsl:if>
-               </dataGravitation>
-            </xsl:if>
-            <xsl:if test="//buddyLocatorProperties">
-               <locator>
-                  <xsl:if test="//buddyLocatorClass">
-                     <xsl:attribute name="class">
-                        <xsl:value-of select="//buddyLocatorClass"/>
-                     </xsl:attribute>
-                  </xsl:if>
-                  <xsl:if test="//buddyLocatorProperties">
-                     <properties>
-                        <xsl:value-of select="//buddyLocatorProperties"/>
-                     </properties>
-                  </xsl:if>
-               </locator>
-            </xsl:if>
-         </buddy>
-      </xsl:if>
-   </xsl:template>
-
-   <xsl:template name="asyncAttributes">
-      <xsl:if test="//attribute[@name='UseReplQueue']">
-         <xsl:attribute name="useReplQueue">
-            <xsl:value-of select="//attribute[@name='UseReplQueue']"/>
-         </xsl:attribute>
-      </xsl:if>
-      <xsl:if test="//attribute[@name='ReplQueueInterval']">
-         <xsl:attribute name="replQueueInterval">
-            <xsl:value-of select="//attribute[@name='ReplQueueInterval']"/>
-         </xsl:attribute>
-      </xsl:if>
-      <xsl:if test="//attribute[@name='ReplQueueMaxElements']">
-         <xsl:attribute name="replQueueMaxElements">
-            <xsl:value-of select="//attribute[@name='ReplQueueMaxElements']"/>
-         </xsl:attribute>
-      </xsl:if>
-   </xsl:template>
-
-   <xsl:template name="syncAttributes">
-      <xsl:if test="//attribute[@name='SyncReplTimeout']">
-         <xsl:attribute name="replTimeout">
-            <xsl:value-of select="//attribute[@name='SyncReplTimeout']"/>
-         </xsl:attribute>
-      </xsl:if>
-   </xsl:template>
-
-   <xsl:template name="startup">
-      <xsl:if
-            test="//attribute[@name='FetchInMemoryState'] | //attribute[@name='StateRetrievalTimeout'] | //attribute[@name='InactiveOnStartup']">
-         <xsl:element name="startup">
-            <xsl:if test="//attribute[@name='FetchInMemoryState']">
-               <xsl:attribute name="fetchInMemoryState">
-                  <xsl:value-of select="normalize-space(//attribute[@name='FetchInMemoryState'])"/>
-               </xsl:attribute>
-            </xsl:if>
-            <xsl:if test="//attribute[@name='StateRetrievalTimeout']">
-               <xsl:attribute name="stateRetrievalTimeout">
-                  <xsl:value-of select="normalize-space(//attribute[@name='StateRetrievalTimeout'])"/>
-               </xsl:attribute>
-            </xsl:if>
-            <xsl:if test="//attribute[@name='InactiveOnStartup']">
-               <xsl:attribute name="inactiveOnStartup">
-                  <xsl:value-of select="normalize-space(//attribute[@name='InactiveOnStartup'])"/>
-               </xsl:attribute>
-            </xsl:if>
-         </xsl:element>
-      </xsl:if>
-   </xsl:template>
-
-   <xsl:template match="//attribute[@name='ShutdownHookBehavior']">
-      <shutdown>
-         <xsl:attribute name="hookBehavior">
-            <xsl:value-of select="normalize-space(.)"/>
-         </xsl:attribute>
-      </shutdown>
-   </xsl:template>
-
-   <xsl:template match="//attribute[@name='ExposeManagementStatistics']">
-      <jmxStatistics>
-         <xsl:attribute name="enabled">
-            <xsl:value-of select="normalize-space(.)"/>
-         </xsl:attribute>
-      </jmxStatistics>
-   </xsl:template>
-
-   <xsl:template match="//attribute[@name='EvictionPolicyConfig']">
-      <eviction>
-         <xsl:if test="./config/attribute[@name='wakeUpIntervalSeconds']">
-            <xsl:attribute name="wakeUpInterval">
-               <xsl:value-of select="concat(normalize-space(./config/attribute[@name='wakeUpIntervalSeconds']), '000')"/>
-            </xsl:attribute>
-         </xsl:if>
-         <xsl:if test="./config/attribute[@name='policyClass'] | ./config/attribute[@name='policyClass']">
-            <defaults>
-               <xsl:if test="./config/attribute[@name='policyClass']">
-                  <xsl:attribute name="policyClass">
-                     <xsl:value-of select="normalize-space(./config/attribute[@name='policyClass'])"/>
-                  </xsl:attribute>
-               </xsl:if>
-               <xsl:if test="./config/attribute[@name='eventQueueSize']">
-                  <xsl:attribute name="eventQueueSize">
-                     <xsl:value-of select="normalize-space(./config/attribute[@name='eventQueueSize'])"/>
-                  </xsl:attribute>
-               </xsl:if>
-            </defaults>
-         </xsl:if>
-         <xsl:if test="./config/region[@name='/_default_']">
-            <root>
-               <xsl:copy-of select="./config/region[@name='/_default_']/*"/>
-            </root>
-         </xsl:if>
-         <xsl:for-each select="./config/region[@name!='/_default_']">
-            <region>
-               <xsl:if test="@name">
-                  <xsl:attribute name="name">
-                     <xsl:value-of select="@name"/>
-                  </xsl:attribute>
-               </xsl:if>
-               <xsl:copy-of select="./*"/>
-            </region>
-         </xsl:for-each>
-      </eviction>
-   </xsl:template>
-
-   <xsl:template match="//attribute[@name='CacheLoaderConfiguration']">
-      <loaders>
-         <xsl:if test="./config/passivation">
-            <xsl:attribute name="passivation">
-               <xsl:value-of select="./config/passivation"/>
-            </xsl:attribute>
-         </xsl:if>
-         <xsl:if test="./config/shared">
-            <xsl:attribute name="shared">
-               <xsl:value-of select="./config/shared"/>
-            </xsl:attribute>
-         </xsl:if>
-         <xsl:if test="./config/preload">
-            <preload>
-               <xsl:call-template name="preloadTokenizer">
-                  <xsl:with-param name="string" select="./config/preload"/>
-                  <xsl:with-param name="delimiter" select="','"/>
-               </xsl:call-template>
-            </preload>
-         </xsl:if>
-         <xsl:for-each select="./config/cacheloader">
-            <loader>
-               <xsl:if test="./class">
-                  <xsl:attribute name="class">
-                     <xsl:value-of select="./class"/>
-                  </xsl:attribute>
-               </xsl:if>
-               <xsl:if test="./async">
-                  <xsl:attribute name="async">
-                     <xsl:value-of select="./async"/>
-                  </xsl:attribute>
-               </xsl:if>
-               <xsl:if test="./fetchPersistentState">
-                  <xsl:attribute name="fetchPersistentState">
-                     <xsl:value-of select="./fetchPersistentState"/>
-                  </xsl:attribute>
-               </xsl:if>
-               <xsl:if test="./ignoreModifications">
-                  <xsl:attribute name="ignoreModifications">
-                     <xsl:value-of select="./ignoreModifications"/>
-                  </xsl:attribute>
-               </xsl:if>
-               <xsl:if test="./purgeOnStartup">
-                  <xsl:attribute name="purgeOnStartup">
-                     <xsl:value-of select="./purgeOnStartup"/>
-                  </xsl:attribute>
-               </xsl:if>
-               <xsl:if test="./properties">
-                  <xsl:copy-of select="./properties"/>
-               </xsl:if>
-               <xsl:if test="./singletonStore">
-                  <singletonStore>
-                     <xsl:if test="./singletonStore/enabled">
-                        <xsl:attribute name="enabled">
-                           <xsl:value-of select="./singletonStore/enabled"/>
-                        </xsl:attribute>
-                     </xsl:if>
-                     <xsl:if test="./singletonStore/enabled">
-                        <xsl:attribute name="enabled">
-                           <xsl:value-of select="./singletonStore/enabled"/>
-                        </xsl:attribute>
-                     </xsl:if>
-                     <xsl:if test="./singletonStore/class">
-                        <xsl:attribute name="class">
-                           <xsl:value-of select="./singletonStore/class"/>
-                        </xsl:attribute>
-                     </xsl:if>
-                     <xsl:copy-of select="./singletonStore/properties"/>
-                  </singletonStore>
-               </xsl:if>
-            </loader>
-         </xsl:for-each>
-      </loaders>
-   </xsl:template>
-
-   <xsl:template name="preloadTokenizer">
-      <xsl:param name="string"/>
-      <xsl:param name="delimiter" select="' '"/>
-      <xsl:choose>
-         <xsl:when test="$delimiter and contains($string, $delimiter)">
-            <node>
-               <xsl:attribute name="fqn">
-                  <xsl:value-of select="substring-before($string,$delimiter)"/>
-               </xsl:attribute>
-            </node>
-            <xsl:call-template name="preloadTokenizer">
-               <xsl:with-param name="string" select="substring-after($string,$delimiter)"/>
-               <xsl:with-param name="delimiter" select="$delimiter"/>
-            </xsl:call-template>
-         </xsl:when>
-         <xsl:otherwise>
-            <node>
-               <xsl:attribute name="fqn">
-                  <xsl:value-of select="$string"/>
-               </xsl:attribute>
-            </node>
-         </xsl:otherwise>
-      </xsl:choose>
-   </xsl:template>
-
-
-   <xsl:template name="transport">
-      <xsl:if
-            test="//attribute[@name='ClusterName'] | //attribute[@name='MultiplexerStack'] | //attribute[@name='ClusterConfig']">
-         <transport>
-            <xsl:if test="//attribute[@name='ClusterName']">
-               <xsl:attribute name="clusterName">
-                  <xsl:value-of select="normalize-space(//attribute[@name='ClusterName'])"/>
-               </xsl:attribute>
-            </xsl:if>
-            <xsl:if test="//attribute[@name='MultiplexerStack']">
-               <xsl:attribute name="multiplexerStack">
-                  <xsl:value-of select="normalize-space(//attribute[@name='MultiplexerStack'])"/>
-               </xsl:attribute>
-            </xsl:if>
-            <xsl:if test="//attribute[@name='ClusterConfig']">
-               <jgroupsConfig>
-                  <xsl:copy-of select="//attribute[@name='ClusterConfig']/config/*"/>
-               </jgroupsConfig>
-            </xsl:if>
-         </transport>
-      </xsl:if>
-   </xsl:template>
-
-</xsl:stylesheet>
\ No newline at end of file

Modified: core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTransformerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTransformerTest.java	2008-06-26 14:57:18 UTC (rev 6057)
+++ core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTransformerTest.java	2008-06-26 15:44:26 UTC (rev 6058)
@@ -1,14 +1,14 @@
 package org.jboss.cache.config;
 
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeMethod;
 import org.jboss.cache.config.parsing.ConfigFilesConvertor;
 import org.jboss.cache.config.parsing.XmlConfigurationParser;
 import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
 
+import java.io.File;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.File;
 
 /**
  * Test how xsl for migrating config files from 2.x to 3.x works.
@@ -18,27 +18,18 @@
  * <li> it parses the file with 2.x parser
  * <li> it parses the transform with a 3.x parser
  * <li> checks that the two resulting <tt>Configuration</tt> objects are equal.
- * </ol>
+ * </ol>              
  *
  * @author Mircea.Markus at jboss.com
  * @since 3.0
  */
- at Test(groups = "functional")
+ at Test(groups = "unit")
 public class ConfigurationTransformerTest
 {
-   //TODO - make this reference relative
-   public static final String XSLT_FILE = "C:\\projects\\cache\\branches\\za_trunk\\src\\main\\etc\\META-INF\\config2to3.xslt";
+   public static final String XSLT_FILE = "config2to3.xslt";
    private static final String BASE_DIR = "META-INF/config2.x";
-   File xsltFile;
    ConfigFilesConvertor convertor = new ConfigFilesConvertor();
 
-   @BeforeMethod
-   public void setUp()
-   {
-      xsltFile = new File(XSLT_FILE);
-      assert xsltFile.exists();
-   }
-
    /**
     * Useful when {@link testEqualityOnTransformedFiles} fails and you need to isolate a failure.
     */
@@ -54,16 +45,14 @@
       Configuration newConfig = newParser.parse(new ByteArrayInputStream(baos.toByteArray()));
       Configuration oldConfig = oldParser.parseFile(fileName);
 
-      assert oldConfig.getNodeLockingScheme().equals(newConfig.getNodeLockingScheme());
-      assert oldConfig.getNodeLockingScheme() == newConfig.getNodeLockingScheme();
       assert oldConfig.equals(newConfig);
    }
 
    public void testEqualityOnTransformedFiles() throws Exception
    {
       String[] fileNames = {"buddy-replication-cache-service.xml", "cacheloader-enabled-cache-service.xml",
-                            "eviction-enabled-cache-service.xml", "local-cache-service.xml", "multiplexer-enabled-cache-service.xml",
-                            "optimistically-locked-cache-service.xml", "total-replication-cache-service.xml"};
+            "eviction-enabled-cache-service.xml", "local-cache-service.xml", "multiplexer-enabled-cache-service.xml",
+            "optimistically-locked-cache-service.xml", "total-replication-cache-service.xml"};
       for (String file : fileNames)
       {
          System.out.println("Processing file = " + file);




More information about the jbosscache-commits mailing list