[jboss-cvs] JBossAS SVN: r84180 - in trunk/testsuite/src: resources/profileservice/persistence and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Feb 13 10:28:56 EST 2009


Author: emuckenhuber
Date: 2009-02-13 10:28:55 -0500 (Fri, 13 Feb 2009)
New Revision: 84180

Modified:
   trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/AbstractPersistenceFormatTest.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/JBossServicePersistenceFormatTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/LocalDataSourcePersistenceFormatTestCase.java
   trunk/testsuite/src/resources/profileservice/persistence/profileservice-test-ds.xml
Log:
update test cases

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/AbstractPersistenceFormatTest.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/AbstractPersistenceFormatTest.java	2009-02-13 15:27:39 UTC (rev 84179)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/AbstractPersistenceFormatTest.java	2009-02-13 15:28:55 UTC (rev 84180)
@@ -31,8 +31,6 @@
 import org.jboss.metatype.api.values.MetaValueFactory;
 import org.jboss.system.server.profileservice.persistence.ManagedObjectPeristenceHandler;
 import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
-import org.jboss.system.server.profileservice.repository.AbstractFileAttachmentsSerializer;
-import org.jboss.system.server.profileservice.repository.JAXBAttachmentSerializer;
 import org.jboss.test.JBossTestCase;
 import org.jboss.xb.binding.Unmarshaller;
 import org.jboss.xb.binding.UnmarshallerFactory;
@@ -79,70 +77,16 @@
       return getMOF().initManagedObject(o, null);
    }
    
-   protected AbstractFileAttachmentsSerializer getAttachmentSerializer() throws Exception
+   protected PersistedManagedObject createPersisted(ManagedObject mo)
    {
-      return getAttachmentSerializer(false);
+      ManagedObjectPeristenceHandler persistence = new ManagedObjectPeristenceHandler();
+      return persistence.createPersistenceMetaData(mo);      
    }
    
-   protected AbstractFileAttachmentsSerializer getAttachmentSerializer(boolean logToSystemOut) throws Exception
-   {
-      File tempFile = File.createTempFile(getName(), null);
-      return createSerializer(tempFile, logToSystemOut);
-   }
-
-   /**
-    * Create the attachment Serializer.
-    * Use a tempFile for storing the Xml.
-    * 
-    * @param tempFile the temp File
-    * @return a AttachmentSerializer.
-    * @throws Exception
-    */
-   protected AbstractFileAttachmentsSerializer createSerializer(File tempFile) throws Exception
-   {
-      return createSerializer(tempFile, false);
-   }
-   
-   protected AbstractFileAttachmentsSerializer createSerializer(final File tempFile, final boolean logToSystemOut) throws Exception
-   {
-      return new TempAttachmentSerializer(tempFile);
-   }
-   
-   private class TempAttachmentSerializer extends JAXBAttachmentSerializer
-   {
-      public TempAttachmentSerializer(File tempFile)
-      {
-         super(tempFile);
-      }
-      
-      @Override
-      protected void saveAttachment(File attachmentsStore, Object attachment) throws Exception
-      {
-         log.trace("saveAttachments, attachmentsStore="+attachmentsStore+ ", attachment="+attachment);
-         JAXBContext ctx = JAXBContext.newInstance(attachment.getClass());
-         Marshaller marshaller = ctx.createMarshaller();
-         marshaller.setProperty("jaxb.formatted.output", Boolean.TRUE);
-         marshaller.marshal(attachment, attachmentsStore);
-      }
-      
-      @Override
-      protected File getAttachmentPath(String baseName)
-      {
-         // Return the temp file
-         return getAttachmentsStoreDir();
-      }
-      
-   }
-   
    protected PersistedManagedObject restore(ManagedObject mo) throws Exception
    {
-      PersistedManagedObject moElement = new PersistedManagedObject();
-      
-      ManagedObjectPeristenceHandler persistence = new ManagedObjectPeristenceHandler();
-      persistence.processManagedObject(moElement, mo);
-      
       File file = File.createTempFile("test", null);
-      serialize(moElement, file);
+      serialize(createPersisted(mo), file);
       return deserialize(file);
    }
    

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/JBossServicePersistenceFormatTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/JBossServicePersistenceFormatTestCase.java	2009-02-13 15:27:39 UTC (rev 84179)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/JBossServicePersistenceFormatTestCase.java	2009-02-13 15:28:55 UTC (rev 84180)
@@ -26,6 +26,8 @@
 import java.util.List;
 import java.util.Map;
 
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
 import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.jboss.mx.loading.LoaderRepositoryFactory.LoaderRepositoryConfig;
@@ -37,6 +39,7 @@
 import org.jboss.system.metadata.ServiceMetaData;
 import org.jboss.system.metadata.ServiceMetaDataParser;
 import org.jboss.system.server.profileservice.repository.AbstractFileAttachmentsSerializer;
+import org.jboss.system.server.profileservice.repository.JAXBAttachmentSerializer;
 import org.w3c.dom.Document;
 
 /**
@@ -228,5 +231,59 @@
       deployment.setServices(services);
       return deployment;
    }
+   
+   protected AbstractFileAttachmentsSerializer getAttachmentSerializer() throws Exception
+   {
+      return getAttachmentSerializer(false);
+   }
+   
+   protected AbstractFileAttachmentsSerializer getAttachmentSerializer(boolean logToSystemOut) throws Exception
+   {
+      File tempFile = File.createTempFile(getName(), null);
+      return createSerializer(tempFile, logToSystemOut);
+   }
+
+   /**
+    * Create the attachment Serializer.
+    * Use a tempFile for storing the Xml.
+    * 
+    * @param tempFile the temp File
+    * @return a AttachmentSerializer.
+    * @throws Exception
+    */
+   protected AbstractFileAttachmentsSerializer createSerializer(File tempFile) throws Exception
+   {
+      return createSerializer(tempFile, false);
+   }
+   
+   protected AbstractFileAttachmentsSerializer createSerializer(final File tempFile, final boolean logToSystemOut) throws Exception
+   {
+      return new TempAttachmentSerializer(tempFile);
+   }
+   
+   private class TempAttachmentSerializer extends JAXBAttachmentSerializer
+   {
+      public TempAttachmentSerializer(File tempFile)
+      {
+         super(tempFile);
+      }
+      
+      @Override
+      protected void saveAttachment(File attachmentsStore, Object attachment) throws Exception
+      {
+         log.trace("saveAttachments, attachmentsStore="+attachmentsStore+ ", attachment="+attachment);
+         JAXBContext ctx = JAXBContext.newInstance(attachment.getClass());
+         Marshaller marshaller = ctx.createMarshaller();
+         marshaller.setProperty("jaxb.formatted.output", Boolean.TRUE);
+         marshaller.marshal(attachment, attachmentsStore);
+      }
+      
+      @Override
+      protected File getAttachmentPath(String baseName)
+      {
+         // Return the temp file
+         return getAttachmentsStoreDir();
+      }
+   }
 }
 

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/LocalDataSourcePersistenceFormatTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/LocalDataSourcePersistenceFormatTestCase.java	2009-02-13 15:27:39 UTC (rev 84179)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/LocalDataSourcePersistenceFormatTestCase.java	2009-02-13 15:28:55 UTC (rev 84180)
@@ -22,6 +22,7 @@
 package org.jboss.test.profileservice.persistenceformat.test;
 
 import java.net.URL;
+import java.util.List;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
@@ -29,8 +30,15 @@
 import javax.xml.transform.sax.SAXSource;
 
 import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.values.CollectionValue;
+import org.jboss.metatype.api.values.GenericValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
 import org.jboss.resource.deployers.management.LocalDSInstanceClassFactory;
 import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentGroup;
+import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
+import org.jboss.system.deployers.managed.ServiceMetaDataICF;
+import org.jboss.system.metadata.ServiceMetaData;
 import org.jboss.system.server.profileservice.persistence.ManagedObjectOverrideHandler;
 import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
 import org.jboss.util.xml.JBossEntityResolver;
@@ -46,34 +54,81 @@
  */
 public class LocalDataSourcePersistenceFormatTestCase extends AbstractPersistenceFormatTest
 {
-   
+
    public LocalDataSourcePersistenceFormatTestCase(String name) throws Exception
    {
-      super(name);      
+      super(name);
    }
    
-   public void testParsing() throws Exception
+   public void testProfileServiceTestDS() throws Exception
    {
       getMOF().addInstanceClassFactory(new LocalDSInstanceClassFactory());
-      
+      // FIXME
+//      getMOF().addInstanceClassFactory(new ServiceMetaDataICF());
+
       // Initial parsing of the dataSource deployment
       ManagedConnectionFactoryDeploymentGroup deployment = parseDataSource("profileservice/persistence/profileservice-test-ds.xml");
       assertNotNull(deployment);
 
       ManagedObject mo = getMOF().initManagedObject(deployment, null);
+
+      // Change values
+      getManagedProperty(mo, "min-pool-size").setValue(SimpleValueSupport.wrap(13));
+      getManagedProperty(mo, "max-pool-size").setValue(SimpleValueSupport.wrap(53));
       
       PersistedManagedObject moelement = restore(mo);
       assertNotNull(moelement);
 
       enableTrace("org.jboss.system");
-      
+
       ManagedObjectOverrideHandler override = new ManagedObjectOverrideHandler();
       ManagedObject restored = override.updateManagedObject(moelement, mo);
       assertNotNull(restored);
- 
+
+      ManagedConnectionFactoryDeploymentGroup mcfdg = (ManagedConnectionFactoryDeploymentGroup) restored.getAttachment();
+      assertNotNull(mcfdg);
+      // Assert services
+      assertServices(mcfdg.getServices()); 
+      // Assert deployments
+      assertDeployments(mcfdg.getDeployments());
+      // TODO Assert loader repository
+      assertNotNull(mcfdg.getLoaderRepositoryConfig());
    }
-    protected ManagedConnectionFactoryDeploymentGroup parseDataSource(String resource) throws Exception
+   
+   protected void assertDeployments(List<ManagedConnectionFactoryDeploymentMetaData> deployments)
    {
+      assertNotNull(deployments);
+      assertEquals(1, deployments.size());
+      
+      ManagedConnectionFactoryDeploymentMetaData deployment = deployments.get(0);
+      assertNotNull(deployment);
+      assertEquals(13, deployment.getMinSize());
+      assertEquals(53, deployment.getMaxSize());
+   }
+   
+   protected void assertServices(List<ServiceMetaData> services)
+   {
+      assertNotNull(services);
+      assertEquals(2, services.size());
+      
+      for(ServiceMetaData service : services)
+      {
+         assertNotNull(service.getCode());
+         assertNotNull(service.getAttributes());
+         assertFalse(service.getAttributes().isEmpty());
+      }
+   }
+   
+   protected ManagedProperty getManagedProperty(ManagedObject mo, String propertyName)
+   {
+      CollectionValue collection = (CollectionValue) mo.getProperty("deployments").getValue();
+      GenericValue generic = (GenericValue) collection.iterator().next();
+      ManagedObject deployment = (ManagedObject) generic.getValue();
+      return deployment.getProperty(propertyName);
+   }
+   
+   protected ManagedConnectionFactoryDeploymentGroup parseDataSource(String resource) throws Exception
+   {
       // Get resource
       URL url = Thread.currentThread().getContextClassLoader().getResource(resource);
       // The input source
@@ -86,7 +141,8 @@
       JAXBContext context = JAXBContext.newInstance(ManagedConnectionFactoryDeploymentGroup.class);
       Unmarshaller um = context.createUnmarshaller();
       // Unmarshal
-      JAXBElement<ManagedConnectionFactoryDeploymentGroup> elem = um.unmarshal(source, ManagedConnectionFactoryDeploymentGroup.class);
-      return  elem.getValue();      
+      JAXBElement<ManagedConnectionFactoryDeploymentGroup> elem = um.unmarshal(source,
+            ManagedConnectionFactoryDeploymentGroup.class);
+      return elem.getValue();
    }
 }

Modified: trunk/testsuite/src/resources/profileservice/persistence/profileservice-test-ds.xml
===================================================================
--- trunk/testsuite/src/resources/profileservice/persistence/profileservice-test-ds.xml	2009-02-13 15:27:39 UTC (rev 84179)
+++ trunk/testsuite/src/resources/profileservice/persistence/profileservice-test-ds.xml	2009-02-13 15:28:55 UTC (rev 84180)
@@ -12,12 +12,15 @@
       <idle-timeout-minutes>0</idle-timeout-minutes>
       <security-domain>HsqlDbRealm</security-domain>
       <prepared-statement-cache-size>32</prepared-statement-cache-size>
+      <track-statements/>
+      <security-domain>EncryptedHsqlDbRealm</security-domain>
+      <security-domain-and-application>HsqlDbRealm</security-domain-and-application>
       <metadata>
          <type-mapping>Hypersonic SQL</type-mapping>
       </metadata>
+      <depends>jboss:service=Hypersonic,database=profileserviceTestDB</depends>
    </local-tx-datasource>
 
-
    <mbean code="org.jboss.jdbc.HypersonicDatabase" 
      name="jboss:service=Hypersonic,database=profileserviceTestDB">
      <attribute name="Database">profileserviceTestDB</attribute>
@@ -25,6 +28,16 @@
      <depends>NoopDependency</depends>
    </mbean>
    
+   <mbean code="org.jboss.security.plugins.JaasSecurityDomain"
+      name="jboss.security:service=JaasSecurityDomain,domain=ServerMasterPassword">
+      <constructor>
+         <arg type="java.lang.String" value="ServerMasterPassword"/>
+      </constructor>
+      <attribute name="KeyStorePass">{CLASS}org.jboss.security.plugins.FilePassword:${jboss.server.home.dir}/conf/server.password</attribute>
+      <attribute name="Salt">abcdefgh</attribute>
+      <attribute name="IterationCount">13</attribute>
+   </mbean>
+   
    <loader-repository>
       profile.service.test.ds:sar=profile.test.ds
       <loader-repository-config>




More information about the jboss-cvs-commits mailing list