[jboss-cvs] JBossAS SVN: r81042 - 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 Nov 14 09:25:31 EST 2008
Author: emuckenhuber
Date: 2008-11-14 09:25:31 -0500 (Fri, 14 Nov 2008)
New Revision: 81042
Added:
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/resources/profileservice/persistence/jboss-service.xml
Modified:
trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/LocalDataSourcePersistenceFormatTestCase.java
Log:
[JBAS-3768] test for jboss-service.xml attachment marshalling
Added: trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/AbstractPersistenceFormatTest.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/AbstractPersistenceFormatTest.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/AbstractPersistenceFormatTest.java 2008-11-14 14:25:31 UTC (rev 81042)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.profileservice.persistenceformat.test;
+
+import java.io.File;
+
+import org.jboss.profileservice.spi.AttachmentsSerializer;
+import org.jboss.system.server.profileservice.repository.JAXBAttachmentSerializer;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class AbstractPersistenceFormatTest extends JBossTestCase
+{
+
+ public AbstractPersistenceFormatTest(String name)
+ {
+ super(name);
+ }
+
+ protected AttachmentsSerializer getAttachmentSerializer() throws Exception
+ {
+ File tempFile = File.createTempFile(getName(), null);
+ return createSerializer(tempFile);
+ }
+
+ /**
+ * Create the attachment serializer.
+ * Use a tempfile for storing the xml.
+ *
+ * @param tempFile the temp file
+ * @return a AttachmentSerializer.
+ * @throws Exception
+ */
+ protected AttachmentsSerializer createSerializer(File tempFile) throws Exception
+ {
+ JAXBAttachmentSerializer serializer = new JAXBAttachmentSerializer()
+ {
+ @Override
+ protected File getAttachmentPath(String baseName)
+ {
+ // Return the temp file
+ return getAttachmentsStoreDir();
+ }
+
+ };
+ serializer.setAttachmentsStoreDir(tempFile);
+
+ return serializer;
+ }
+
+}
+
Added: trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/JBossServicePersistenceFormatTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/JBossServicePersistenceFormatTestCase.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/JBossServicePersistenceFormatTestCase.java 2008-11-14 14:25:31 UTC (rev 81042)
@@ -0,0 +1,232 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.profileservice.persistenceformat.test;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.jboss.mx.loading.LoaderRepositoryFactory.LoaderRepositoryConfig;
+import org.jboss.profileservice.spi.AttachmentsSerializer;
+import org.jboss.system.metadata.ServiceConstructorMetaData;
+import org.jboss.system.metadata.ServiceDependencyMetaData;
+import org.jboss.system.metadata.ServiceDeployment;
+import org.jboss.system.metadata.ServiceDeploymentClassPath;
+import org.jboss.system.metadata.ServiceDeploymentParser;
+import org.jboss.system.metadata.ServiceMetaData;
+import org.jboss.system.metadata.ServiceMetaDataParser;
+import org.w3c.dom.Document;
+
+/**
+ * Testing the marshalling/unmarshalling with the JAXBAttachmentSerializer
+ * for ServiceDeployment (jboss-service.xml).
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class JBossServicePersistenceFormatTestCase extends AbstractPersistenceFormatTest
+{
+
+ public JBossServicePersistenceFormatTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testJbossService() throws Exception
+ {
+ // Parse
+ ServiceDeployment deployment = parseJbossServiceXml("profileservice/persistence/jboss-service.xml");
+ assertNotNull(deployment);
+ // Create serializer
+ AttachmentsSerializer serializer = getAttachmentSerializer();
+ // Save
+ serializer.saveAttachment("test", deployment);
+ // Restore
+ ServiceDeployment restored = serializer.loadAttachment("test", ServiceDeployment.class);
+ assertNotNull(restored);
+
+ // Assert services
+ assertServices(deployment.getServices(), restored.getServices());
+ // loader repository
+ assertLoaderRepository(deployment.getLoaderRepositoryConfig(), restored.getLoaderRepositoryConfig());
+ // classpath
+ assertClassPaths(deployment.getClassPaths(), restored.getClassPaths());
+ }
+
+ protected void assertServices(List<ServiceMetaData> original, List<ServiceMetaData> restored)
+ {
+ assertNotNull(original);
+ assertNotNull(restored);
+
+ assertEquals("same size", original.size(), restored.size());
+
+ Map<String, ServiceMetaData> restoredMap = new HashMap<String, ServiceMetaData>();
+ for(ServiceMetaData service : restored)
+ restoredMap.put(service.getObjectName().getCanonicalName(), service);
+
+ for(ServiceMetaData originalService : original)
+ {
+ ServiceMetaData restoredService = restoredMap.get(originalService.getObjectName().getCanonicalName());
+ assertNotNull(restoredService);
+ // assert service
+ assertServiceMetaData(originalService, restoredService);
+ }
+ }
+
+ protected void assertServiceMetaData(ServiceMetaData original, ServiceMetaData restored)
+ {
+ // Code
+ assertEquals(original.getCode(), restored.getCode());
+ // Interface
+ assertEquals(original.getInterfaceName(), restored.getInterfaceName());
+ // XMBeanCode
+ assertEquals(original.getXMBeanCode(), restored.getXMBeanCode());
+ // XMBeanDD
+ assertEquals(original.getXMBeanDD(), restored.getXMBeanDD());
+ // ClassLoaderName
+ assertEquals(original.getClassLoaderName(), restored.getClassLoaderName());
+ // Mode
+ assertEquals(original.getMode(), restored.getMode());
+ // XMBeanDescriptor
+ assertEquals(original.getXMBeanDescriptor(), restored.getXMBeanDescriptor());
+ // Constructor
+ assertServiceConstructor(original.getConstructor(), restored.getConstructor());
+
+ // TODO more checking
+
+ List<String> originalAliasases = original.getAliases();
+ List<String> restoredAliasases = restored.getAliases();
+
+ assertEquals(originalAliasases, restoredAliasases);
+
+ assertEquals(original.getAnnotations(), restored.getAnnotations());
+ if(original.getAnnotations() != null)
+ {
+ assertNotNull(restored.getAnnotations());
+ assertEquals(original.getAnnotations().size(), restored.getAnnotations().size());
+
+ }
+
+ assertEquals(original.getDependencies(), restored.getDependencies());
+ if(original.getDependencies() != null)
+ {
+ assertNotNull(restored.getDependencies());
+ assertEquals(original.getDependencies().size(), restored.getDependencies().size());
+ // TODO assertDependency
+ }
+ else
+ {
+ assertNull(restored.getDependencies());
+ }
+ }
+
+ protected void assertServiceConstructor(ServiceConstructorMetaData original, ServiceConstructorMetaData restored)
+ {
+ if(original == null)
+ {
+ assertNull(restored);
+ return;
+ }
+ else
+ {
+ assertNotNull(restored);
+ }
+
+ if(original.getParams() != null)
+ {
+ assertNotNull(restored.getParams());
+ assertEquals(original.getParams().length, restored.getParams().length);
+ }
+ }
+
+ protected void assertDependency(ServiceDependencyMetaData original, ServiceDependencyMetaData restored)
+ {
+ if(original == null)
+ {
+ assertNull(restored);
+ return;
+ }
+ else
+ {
+ assertNotNull(restored);
+ }
+
+ assertEquals(original.getIDependOn(), restored.getIDependOn());
+ }
+
+ protected void assertLoaderRepository(LoaderRepositoryConfig original, LoaderRepositoryConfig restored)
+ {
+ if(original == null)
+ {
+ assertNull(restored);
+ return;
+ }
+ else
+ {
+ assertNotNull(restored);
+ }
+
+ assertEquals(original.configParserClassName, restored.configParserClassName);
+ assertEquals(original.repositoryClassName, restored.repositoryClassName);
+ assertEquals(original.repositoryConfig, restored.repositoryConfig);
+ assertEquals(original.repositoryName, restored.repositoryName);
+ }
+
+ protected void assertClassPaths(List<ServiceDeploymentClassPath> original, List<ServiceDeploymentClassPath> restored)
+ {
+ if(original == null)
+ {
+ assertNull(restored);
+ return;
+ }
+ else
+ {
+ assertNotNull(restored);
+ }
+
+ assertEquals(original.size(), restored.size());
+ }
+
+
+ protected ServiceDeployment parseJbossServiceXml(String resource) throws Exception
+ {
+ File file = new File(Thread.currentThread().getContextClassLoader().getResource(resource).toURI());
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ Document document = factory.newDocumentBuilder().parse(file);
+
+ ServiceDeploymentParser parser = new ServiceDeploymentParser(document);
+
+ ServiceDeployment deployment = parser.parse();
+ assertNotNull(deployment);
+
+ ServiceMetaDataParser serviceParser = new ServiceMetaDataParser(deployment.getConfig());
+ List<ServiceMetaData> services = serviceParser.parse();
+ assertNotNull(services);
+
+ deployment.setServices(services);
+ return deployment;
+ }
+}
+
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 2008-11-14 14:24:22 UTC (rev 81041)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/LocalDataSourcePersistenceFormatTestCase.java 2008-11-14 14:25:31 UTC (rev 81042)
@@ -1,193 +1,161 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.profileservice.persistenceformat.test;
-
-import java.io.File;
-import java.net.URL;
-import java.util.List;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.transform.sax.SAXSource;
-
-import org.jboss.mx.loading.LoaderRepositoryFactory.LoaderRepositoryConfig;
-import org.jboss.profileservice.spi.AttachmentsSerializer;
-import org.jboss.resource.metadata.mcf.LocalDataSourceDeploymentMetaData;
-import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentGroup;
-import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
-import org.jboss.system.metadata.ServiceAttributeMetaData;
-import org.jboss.system.metadata.ServiceDependencyMetaData;
-import org.jboss.system.metadata.ServiceMetaData;
-import org.jboss.system.server.profileservice.repository.JAXBAttachmentSerializer;
-import org.jboss.test.JBossTestCase;
-import org.jboss.util.xml.JBossEntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.XMLReaderFactory;
-
-/**
- * Test marshalling/unmarshalling with the JAXBAttachmentSerializer.
- *
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class LocalDataSourcePersistenceFormatTestCase extends JBossTestCase
-{
- /** The attachment serializer. */
- private final AttachmentsSerializer serializer;
-
- public LocalDataSourcePersistenceFormatTestCase(String name) throws Exception
- {
- super(name);
-
- // Create the serializer
- File tempFile = File.createTempFile("DataSource", "test");
- this.serializer = createSerializer(tempFile);
- }
-
- public void testParsing() throws Exception
- {
- // Initial parsing of the dataSource deployment
- ManagedConnectionFactoryDeploymentGroup deployment = parseDataSource("profileservice/persistence/profileservice-test-ds.xml");
- assertNotNull(deployment);
-
- // Save attachment
- this.serializer.saveAttachment("test", deployment);
- // Restore attachment
- ManagedConnectionFactoryDeploymentGroup restored = this.serializer.loadAttachment("test", ManagedConnectionFactoryDeploymentGroup.class);
- assertNotNull(restored);
-
- List<ManagedConnectionFactoryDeploymentMetaData> deployments = restored.getDeployments();
- assertNotNull(deployments);
- assertEquals(deployments.size(), deployment.getDeployments().size());
-
- List<ServiceMetaData> services = restored.getServices();
- assertNotNull(services);
- assertEquals(services.size(), deployment.getServices().size());
-
- assertServiceMetaData(deployment.getServices().get(0), services.get(0));
-
- LoaderRepositoryConfig repository = restored.getLoaderRepositoryConfig();
- assertNotNull(repository);
- assertEquals(deployment.getLoaderRepositoryConfig().repositoryName, repository.repositoryName);
- assertEquals(deployment.getLoaderRepositoryConfig().configParserClassName, repository.configParserClassName);
- assertEquals(deployment.getLoaderRepositoryConfig().repositoryClassName, repository.repositoryClassName);
- }
-
- protected void assertServiceMetaData(ServiceMetaData original, ServiceMetaData restored)
- {
- assertNotNull(original);
- assertNotNull(restored);
-
- assertAttributes(original.getAttributes(), restored.getAttributes());
- assertDepends(original.getDependencies(), restored.getDependencies());
- }
-
- protected void assertAttributes(List<ServiceAttributeMetaData> original, List<ServiceAttributeMetaData> restored)
- {
- assertNotNull(original);
- assertNotNull(restored);
-
- assertEquals(original.size(), restored.size());
- // ...
- }
-
- protected void assertDepends(List<ServiceDependencyMetaData> original, List<ServiceDependencyMetaData> restored)
- {
- assertNotNull(original);
- assertNotNull(restored);
-
- assertEquals(original.size(), restored.size());
-
- ServiceDependencyMetaData dmo = original.get(0);
- ServiceDependencyMetaData dmr = restored.get(0);
-
- assertEquals(dmo.getIDependOn(), dmr.getIDependOn());
- }
-
- protected void assertLocalDataSource(ManagedConnectionFactoryDeploymentMetaData original, ManagedConnectionFactoryDeploymentMetaData restored)
- {
- assertNotNull(original);
- assertNotNull(restored);
-
- assertEquals(original.getJndiName(), restored.getJndiName());
- assertEquals(original.getLocalTransactions(), restored.getLocalTransactions());
-
- assertTrue(original instanceof LocalDataSourceDeploymentMetaData);
- assertTrue(restored instanceof LocalDataSourceDeploymentMetaData);
-
- LocalDataSourceDeploymentMetaData o = (LocalDataSourceDeploymentMetaData) original;
- LocalDataSourceDeploymentMetaData r = (LocalDataSourceDeploymentMetaData) restored;
-
- assertEquals(o.getDriverClass(), r.getDriverClass());
- assertEquals(o.getDriverClass(), r.getDriverClass());
- assertEquals(o.getConnectionUrl(), r.getConnectionUrl());
- assertEquals(o.getUserName(), r.getUserName());
- assertEquals(o.getPreparedStatementCacheSize(), r.getPreparedStatementCacheSize());
- assertEquals(o.getPassWord(), r.getPassWord());
- // ...
- }
-
- /**
- * Create the attachment serializer.
- * Use a tempfile for storing the xml.
- *
- * @param tempFile the temp file
- * @return a AttachmentSerializer.
- * @throws Exception
- */
- protected AttachmentsSerializer createSerializer(File tempFile) throws Exception
- {
- JAXBAttachmentSerializer serializer = new JAXBAttachmentSerializer()
- {
- @Override
- protected File getAttachmentPath(String baseName)
- {
- // Return the temp file
- return getAttachmentsStoreDir();
- }
-
- };
- serializer.setAttachmentsStoreDir(tempFile);
-
- return serializer;
- }
-
- protected ManagedConnectionFactoryDeploymentGroup parseDataSource(String resource) throws Exception
- {
- // Get resource
- URL url = Thread.currentThread().getContextClassLoader().getResource(resource);
- // The input source
- InputSource input = new InputSource(url.openStream());
- input.setSystemId(url.toURI().toString());
- XMLReader reader = XMLReaderFactory.createXMLReader();
- reader.setEntityResolver(new JBossEntityResolver());
- SAXSource source = new SAXSource(reader, input);
- // New JAXB context
- JAXBContext context = JAXBContext.newInstance(ManagedConnectionFactoryDeploymentGroup.class);
- Unmarshaller um = context.createUnmarshaller();
- // Unmarshal
- JAXBElement<ManagedConnectionFactoryDeploymentGroup> elem = um.unmarshal(source, ManagedConnectionFactoryDeploymentGroup.class);
- return elem.getValue();
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.profileservice.persistenceformat.test;
+
+import java.net.URL;
+import java.util.List;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.sax.SAXSource;
+
+import org.jboss.mx.loading.LoaderRepositoryFactory.LoaderRepositoryConfig;
+import org.jboss.profileservice.spi.AttachmentsSerializer;
+import org.jboss.resource.metadata.mcf.LocalDataSourceDeploymentMetaData;
+import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentGroup;
+import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
+import org.jboss.system.metadata.ServiceAttributeMetaData;
+import org.jboss.system.metadata.ServiceDependencyMetaData;
+import org.jboss.system.metadata.ServiceMetaData;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+/**
+ * Test marshalling/unmarshalling with the JAXBAttachmentSerializer.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class LocalDataSourcePersistenceFormatTestCase extends AbstractPersistenceFormatTest
+{
+
+ public LocalDataSourcePersistenceFormatTestCase(String name) throws Exception
+ {
+ super(name);
+ }
+
+ public void testParsing() throws Exception
+ {
+ // Initial parsing of the dataSource deployment
+ ManagedConnectionFactoryDeploymentGroup deployment = parseDataSource("profileservice/persistence/profileservice-test-ds.xml");
+ assertNotNull(deployment);
+ // create a attachment serializer
+ AttachmentsSerializer serializer = getAttachmentSerializer();
+
+ // Save attachment
+ serializer.saveAttachment("test", deployment);
+ // Restore attachment
+ ManagedConnectionFactoryDeploymentGroup restored = serializer.loadAttachment("test", ManagedConnectionFactoryDeploymentGroup.class);
+ assertNotNull(restored);
+
+ List<ManagedConnectionFactoryDeploymentMetaData> deployments = restored.getDeployments();
+ assertNotNull(deployments);
+ assertEquals(deployments.size(), deployment.getDeployments().size());
+
+ List<ServiceMetaData> services = restored.getServices();
+ assertNotNull(services);
+ assertEquals(services.size(), deployment.getServices().size());
+
+ assertServiceMetaData(deployment.getServices().get(0), services.get(0));
+
+ LoaderRepositoryConfig repository = restored.getLoaderRepositoryConfig();
+ assertNotNull(repository);
+ assertEquals(deployment.getLoaderRepositoryConfig().repositoryName, repository.repositoryName);
+ assertEquals(deployment.getLoaderRepositoryConfig().configParserClassName, repository.configParserClassName);
+ assertEquals(deployment.getLoaderRepositoryConfig().repositoryClassName, repository.repositoryClassName);
+ }
+
+ protected void assertServiceMetaData(ServiceMetaData original, ServiceMetaData restored)
+ {
+ assertNotNull(original);
+ assertNotNull(restored);
+
+ assertAttributes(original.getAttributes(), restored.getAttributes());
+ assertDepends(original.getDependencies(), restored.getDependencies());
+ }
+
+ protected void assertAttributes(List<ServiceAttributeMetaData> original, List<ServiceAttributeMetaData> restored)
+ {
+ assertNotNull(original);
+ assertNotNull(restored);
+
+ assertEquals(original.size(), restored.size());
+ // ...
+ }
+
+ protected void assertDepends(List<ServiceDependencyMetaData> original, List<ServiceDependencyMetaData> restored)
+ {
+ assertNotNull(original);
+ assertNotNull(restored);
+
+ assertEquals(original.size(), restored.size());
+
+ ServiceDependencyMetaData dmo = original.get(0);
+ ServiceDependencyMetaData dmr = restored.get(0);
+
+ assertEquals(dmo.getIDependOn(), dmr.getIDependOn());
+ }
+
+ protected void assertLocalDataSource(ManagedConnectionFactoryDeploymentMetaData original, ManagedConnectionFactoryDeploymentMetaData restored)
+ {
+ assertNotNull(original);
+ assertNotNull(restored);
+
+ assertEquals(original.getJndiName(), restored.getJndiName());
+ assertEquals(original.getLocalTransactions(), restored.getLocalTransactions());
+
+ assertTrue(original instanceof LocalDataSourceDeploymentMetaData);
+ assertTrue(restored instanceof LocalDataSourceDeploymentMetaData);
+
+ LocalDataSourceDeploymentMetaData o = (LocalDataSourceDeploymentMetaData) original;
+ LocalDataSourceDeploymentMetaData r = (LocalDataSourceDeploymentMetaData) restored;
+
+ assertEquals(o.getDriverClass(), r.getDriverClass());
+ assertEquals(o.getDriverClass(), r.getDriverClass());
+ assertEquals(o.getConnectionUrl(), r.getConnectionUrl());
+ assertEquals(o.getUserName(), r.getUserName());
+ assertEquals(o.getPreparedStatementCacheSize(), r.getPreparedStatementCacheSize());
+ assertEquals(o.getPassWord(), r.getPassWord());
+ // ...
+ }
+
+ protected ManagedConnectionFactoryDeploymentGroup parseDataSource(String resource) throws Exception
+ {
+ // Get resource
+ URL url = Thread.currentThread().getContextClassLoader().getResource(resource);
+ // The input source
+ InputSource input = new InputSource(url.openStream());
+ input.setSystemId(url.toURI().toString());
+ XMLReader reader = XMLReaderFactory.createXMLReader();
+ reader.setEntityResolver(new JBossEntityResolver());
+ SAXSource source = new SAXSource(reader, input);
+ // New JAXB context
+ JAXBContext context = JAXBContext.newInstance(ManagedConnectionFactoryDeploymentGroup.class);
+ Unmarshaller um = context.createUnmarshaller();
+ // Unmarshal
+ JAXBElement<ManagedConnectionFactoryDeploymentGroup> elem = um.unmarshal(source, ManagedConnectionFactoryDeploymentGroup.class);
+ return elem.getValue();
+ }
+}
Added: trunk/testsuite/src/resources/profileservice/persistence/jboss-service.xml
===================================================================
--- trunk/testsuite/src/resources/profileservice/persistence/jboss-service.xml (rev 0)
+++ trunk/testsuite/src/resources/profileservice/persistence/jboss-service.xml 2008-11-14 14:25:31 UTC (rev 81042)
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+
+ <loader-repository>
+ profile.service.test.ds:sar=profile.test.ds
+ <loader-repository-config>
+ java2ParentDelegation=true
+ </loader-repository-config>
+ </loader-repository>
+
+ <classpath codebase="${jboss.server.lib.url}" archives="*"/>
+ <classpath codebase="${jboss.shared.lib.url}" archives="*"/>
+
+ <mbean code="org.jboss.deployment.MainDeployer"
+ name="jboss.system:service=MainDeployer">
+ <!-- This is used to delegate the deployment handling -->
+ <attribute name="KernelMainDeployer"><inject bean="MainDeployer" /></attribute>
+ <!-- This is used to validate incomplete deployments -->
+ <attribute name="Controller"><inject bean="jboss.kernel:service=Kernel" property="controller"/></attribute>
+ </mbean>
+
+ <mbean code="org.jboss.system.pm.AttributePersistenceService"
+ name="jboss:service=AttributePersistenceService"
+ xmbean-dd="resource:xmdesc/AttributePersistenceService-xmbean.xml">
+ </mbean>
+
+ <!-- A Thread pool service -->
+ <mbean code="org.jboss.util.threadpool.BasicThreadPool"
+ name="jboss.system:service=ThreadPool">
+ <attribute name="Name">JBoss System Threads</attribute>
+ <attribute name="ThreadGroupName">System Threads</attribute>
+ <!-- How long a thread will live without any tasks in MS -->
+ <attribute name="KeepAliveTime">60000</attribute>
+ <!-- The max number of threads in the pool -->
+ <attribute name="MaximumPoolSize">10</attribute>
+ <!-- The max number of tasks before the queue is full -->
+ <attribute name="MaximumQueueSize">1000</attribute>
+ <attribute name="BlockingMode">run</attribute>
+ </mbean>
+
+ <mbean code="org.jboss.logging.Log4jService"
+ name="jboss.system:type=Log4jService,service=Logging"
+ xmbean-dd="resource:xmdesc/Log4jService-xmbean.xml">
+ <attribute name="ConfigurationURL">resource:jboss-log4j.xml</attribute>
+ <!-- Set the org.apache.log4j.helpers.LogLog.setQuiteMode. As of log4j1.2.8
+ this needs to be set to avoid a possible deadlock on exception at the
+ appender level. See bug#696819.
+ -->
+ <attribute name="Log4jQuietMode">true</attribute>
+ <!-- How frequently in seconds the ConfigurationURL is checked for changes -->
+ <attribute name="RefreshPeriod">60</attribute>
+ </mbean>
+
+ <mbean code="org.jboss.util.property.jmx.SystemPropertyClassValue"
+ name="jboss.rmi:type=RMIClassLoader">
+ <attribute name="Property">java.rmi.server.RMIClassLoaderSpi</attribute>
+ <attribute name="ClassName">org.jboss.system.JBossRMIClassLoader</attribute>
+ </mbean>
+
+ <mbean code="org.jboss.web.WebService"
+ name="jboss:service=WebService">
+ <!-- The Bind address and Port -->
+ <attribute name="BindAddress">${jboss.bind.address}</attribute>
+ <attribute name="Port">
+ <!-- Get the port to use from ServiceBindingManager. -->
+ <value-factory bean="ServiceBindingManager" method="getIntBinding" parameter="jboss:service=WebService"/>
+ </attribute>
+ <!-- The address to use for the host portion of the RMI codebase URL -->
+ <attribute name="Host">${java.rmi.server.hostname}</attribute>
+ <!-- Should non-EJB .class files be downloadable -->
+ <attribute name="DownloadServerClasses">true</attribute>
+ <attribute name="DownloadResources">false</attribute>
+
+ <!-- Use the default thread pool for dynamic class loading -->
+ <depends optional-attribute-name="ThreadPool"
+ proxy-type="attribute">jboss.system:service=ThreadPool</depends>
+ </mbean>
+
+ <mbean code="org.jnp.server.NamingBeanImpl"
+ name="jboss:service=NamingBeanImpl"
+ xmbean-dd="resource:xmdesc/NamingBean-xmbean.xml">
+ </mbean>
+
+ <mbean code="org.jboss.naming.NamingService"
+ name="jboss:service=Naming"
+ xmbean-dd="resource:xmdesc/NamingService-xmbean.xml">
+ <attribute name="CallByValue">false</attribute>
+ <attribute name="Port">
+ <value-factory bean="ServiceBindingManager" method="getIntBinding">
+ <parameter>jboss:service=Naming</parameter>
+ <parameter>Port</parameter>
+ </value-factory>
+ </attribute>
+
+ <attribute name="BindAddress">${jboss.bind.address}</attribute>
+ <!-- The port of the RMI naming service, 0 == anonymous -->
+ <attribute name="RmiPort">
+ <value-factory bean="ServiceBindingManager" method="getIntBinding">
+ <parameter>jboss:service=Naming</parameter>
+ <parameter>RmiPort</parameter>
+ </value-factory>
+ </attribute>
+ <!-- The RMI service bind address. Empty == all addresses
+ -->
+ <attribute name="RmiBindAddress">${jboss.bind.address}</attribute>
+ <!-- The thread pool service used to control the bootstrap lookups -->
+ <depends optional-attribute-name="LookupPool"
+ proxy-type="attribute">jboss.system:service=ThreadPool</depends>
+ <depends optional-attribute-name="Naming"
+ proxy-type="attribute">jboss:service=NamingBeanImpl</depends>
+ </mbean>
+
+ <mbean code="org.jboss.naming.JNDIView"
+ name="jboss:service=JNDIView"
+ xmbean-dd="resource:xmdesc/JNDIView-xmbean.xml">
+ <!-- The HANamingService service name -->
+ <attribute name="HANamingService">jboss:service=HAJNDI</attribute>
+ </mbean>
+
+ <mbean code="org.jboss.security.plugins.JaasSecurityManagerService"
+ name="jboss.security:service=JaasSecurityManager">
+ <attribute name="ServerMode">true</attribute>
+ <attribute name="SecurityManagerClassName">org.jboss.security.plugins.JaasSecurityManager</attribute>
+ <attribute name="DefaultUnauthenticatedPrincipal">anonymous</attribute>
+ <attribute name="DefaultCacheTimeout">1800</attribute>
+ <attribute name="DefaultCacheResolution">60</attribute>
+ <attribute name="DeepCopySubjectMode">false</attribute>
+ </mbean>
+
+ <mbean code="org.jboss.ejb.plugins.cmp.jdbc.metadata.MetaDataLibrary"
+ name="jboss.jdbc:service=metadata"/>
+
+ <mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+ <depends-list optional-attribute-name="Attribute">
+ <depends-list-element>
+ <mbean name="test:test=1" code="Nested"/>
+ </depends-list-element>
+ <depends-list-element>test:test=2</depends-list-element>
+ </depends-list>
+ </mbean>
+</server>
More information about the jboss-cvs-commits
mailing list