[jboss-cvs] JBossAS SVN: r82805 - in trunk/testsuite/src/main/org/jboss/test/profileservice: persistenceformat/test and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jan 13 07:49:05 EST 2009
Author: emuckenhuber
Date: 2009-01-13 07:49:05 -0500 (Tue, 13 Jan 2009)
New Revision: 82805
Removed:
trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/support/Serializer.java
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/main/org/jboss/test/profileservice/persistenceformat/test/SimplePersistenceFormatUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/TestNestedPeristenceFormatUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/profileservice/test/AbstractProfileServiceTest.java
trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
Log:
update profileservice test cases
Deleted: trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/support/Serializer.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/support/Serializer.java 2009-01-13 12:33:49 UTC (rev 82804)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/support/Serializer.java 2009-01-13 12:49:05 UTC (rev 82805)
@@ -1,97 +0,0 @@
-/*
- * 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.support;
-
-import java.io.File;
-import java.io.Serializable;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
-
-import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedProperty;
-import org.jboss.system.server.profileservice.repository.AbstractFileAttachmentsSerializer;
-
-/**
- * A test attachment serializer
- *
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class Serializer extends AbstractFileAttachmentsSerializer implements Serializable
-{
- /** log */
- boolean logToSystemOut = false;
-
- public void setLogToSystemOut(boolean logToSystemOut)
- {
- this.logToSystemOut = logToSystemOut;
- }
-
- public void saveAttachment(File attachmentsStore, Object attachment) throws Exception
- {
- JAXBContext ctx = JAXBContext.newInstance(attachment.getClass());
- Marshaller marshaller = ctx.createMarshaller();
- marshaller.setProperty("jaxb.formatted.output", Boolean.TRUE);
- marshaller.marshal(attachment, attachmentsStore);
- if(logToSystemOut)
- marshaller.marshal(attachment, System.out);
- }
-
- protected <T> T loadAttachment(File attachmentsStore, Class<T> expected) throws Exception
- {
- JAXBContext ctx = JAXBContext.newInstance(expected);
- Unmarshaller unmarshaller = ctx.createUnmarshaller();
- // Hack JAXB
- if(PersistedManagedObject.class.getName().equals(expected.getName()))
- {
- hack(unmarshaller);
- }
- return (T) unmarshaller.unmarshal(attachmentsStore);
- }
-
- private void hack(Unmarshaller unmarshaller)
- {
- unmarshaller.setListener(new HackHandler());
- }
-
- /**
- * make JAXB do something useful at last.
- */
- private static class HackHandler extends Unmarshaller.Listener
- {
- @Override
- public void afterUnmarshal(Object target, Object parent)
- {
- if(parent instanceof PersistedManagedObject)
- {
- if(target instanceof PersistedProperty)
- {
- PersistedProperty p = (PersistedProperty) target;
- ((PersistedManagedObject) parent).put(p.getName(), p);
- }
- }
- }
- }
-}
-
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-01-13 12:33:49 UTC (rev 82804)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/AbstractPersistenceFormatTest.java 2009-01-13 12:49:05 UTC (rev 82805)
@@ -29,7 +29,7 @@
import org.jboss.managed.api.ManagedObject;
import org.jboss.managed.api.factory.ManagedObjectFactory;
import org.jboss.metatype.api.values.MetaValueFactory;
-import org.jboss.profileservice.spi.AttachmentsSerializer;
+import org.jboss.system.server.profileservice.repository.AbstractFileAttachmentsSerializer;
import org.jboss.system.server.profileservice.repository.JAXBAttachmentSerializer;
import org.jboss.test.JBossTestCase;
@@ -66,12 +66,12 @@
return getMOF().initManagedObject(o, null);
}
- protected AttachmentsSerializer getAttachmentSerializer() throws Exception
+ protected AbstractFileAttachmentsSerializer getAttachmentSerializer() throws Exception
{
return getAttachmentSerializer(false);
}
- protected AttachmentsSerializer getAttachmentSerializer(boolean logToSystemOut) throws Exception
+ protected AbstractFileAttachmentsSerializer getAttachmentSerializer(boolean logToSystemOut) throws Exception
{
File tempFile = File.createTempFile(getName(), null);
return createSerializer(tempFile, logToSystemOut);
@@ -85,49 +85,49 @@
* @return a AttachmentSerializer.
* @throws Exception
*/
- protected AttachmentsSerializer createSerializer(File tempFile) throws Exception
+ protected AbstractFileAttachmentsSerializer createSerializer(File tempFile) throws Exception
{
return createSerializer(tempFile, false);
}
- protected AttachmentsSerializer createSerializer(final File tempFile, final boolean logToSystemOut) throws Exception
+ protected AbstractFileAttachmentsSerializer createSerializer(final File tempFile, final boolean logToSystemOut) throws Exception
{
- JAXBAttachmentSerializer serializer = new JAXBAttachmentSerializer()
+ return new TempAttachmentSerializer(tempFile);
+ }
+
+ private class TempAttachmentSerializer extends JAXBAttachmentSerializer
+ {
+ public TempAttachmentSerializer(File tempFile)
{
-// @Override
-// protected <T> T loadAttachment(File attachmentsStore, Class<T> expected) throws Exception
-// {
-// Unmarshaller u = UnmarshallerFactory.newInstance().newUnmarshaller();
-// JBossXBBuilder builder = new JBossXBBuilder();
-// SchemaBinding binding = builder.build(expected);
-// return (T) u.unmarshal(attachmentsStore.getAbsolutePath(), binding);
-// }
-
- @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);
- // log to system out ?
- if(logToSystemOut)
- marshaller.marshal(attachment, System.out);
- }
-
- @Override
- protected File getAttachmentPath(String baseName)
- {
- // Return the temp file
- return getAttachmentsStoreDir();
- }
-
- };
- serializer.setAttachmentsStoreDir(tempFile);
+ super(tempFile.toURI());
+ }
- return serializer;
+// @Override
+// protected <T> T loadAttachment(File attachmentsStore, Class<T> expected) throws Exception
+// {
+// Unmarshaller u = UnmarshallerFactory.newInstance().newUnmarshaller();
+// JBossXBBuilder builder = new JBossXBBuilder();
+// SchemaBinding binding = builder.build(expected);
+// return (T) u.unmarshal(attachmentsStore.getAbsolutePath(), binding);
+// }
+
+ @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/JBossServicePersistenceFormatTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/JBossServicePersistenceFormatTestCase.java 2009-01-13 12:33:49 UTC (rev 82804)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/JBossServicePersistenceFormatTestCase.java 2009-01-13 12:49:05 UTC (rev 82805)
@@ -29,7 +29,6 @@
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;
@@ -37,6 +36,7 @@
import org.jboss.system.metadata.ServiceDeploymentParser;
import org.jboss.system.metadata.ServiceMetaData;
import org.jboss.system.metadata.ServiceMetaDataParser;
+import org.jboss.system.server.profileservice.repository.AbstractFileAttachmentsSerializer;
import org.w3c.dom.Document;
/**
@@ -60,7 +60,7 @@
ServiceDeployment deployment = parseJbossServiceXml("profileservice/persistence/jboss-service.xml");
assertNotNull(deployment);
// Create serializer
- AttachmentsSerializer serializer = getAttachmentSerializer();
+ AbstractFileAttachmentsSerializer serializer = getAttachmentSerializer();
// Save
serializer.saveAttachment("test", deployment);
// Restore
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-01-13 12:33:49 UTC (rev 82804)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/LocalDataSourcePersistenceFormatTestCase.java 2009-01-13 12:49:05 UTC (rev 82805)
@@ -30,13 +30,13 @@
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.AbstractFileAttachmentsSerializer;
import org.jboss.util.xml.JBossEntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
@@ -62,7 +62,7 @@
ManagedConnectionFactoryDeploymentGroup deployment = parseDataSource("profileservice/persistence/profileservice-test-ds.xml");
assertNotNull(deployment);
// create a attachment serializer
- AttachmentsSerializer serializer = getAttachmentSerializer();
+ AbstractFileAttachmentsSerializer serializer = getAttachmentSerializer();
// Save attachment
serializer.saveAttachment("test", deployment);
Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/SimplePersistenceFormatUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/SimplePersistenceFormatUnitTestCase.java 2009-01-13 12:33:49 UTC (rev 82804)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/SimplePersistenceFormatUnitTestCase.java 2009-01-13 12:49:05 UTC (rev 82805)
@@ -29,20 +29,18 @@
import org.jboss.managed.api.ManagedObject;
import org.jboss.managed.api.ManagedProperty;
import org.jboss.metatype.api.types.SimpleMetaType;
-import org.jboss.metatype.api.values.ArrayValue;
-import org.jboss.metatype.api.values.CollectionValue;
import org.jboss.metatype.api.values.CompositeValue;
import org.jboss.metatype.api.values.CompositeValueSupport;
import org.jboss.metatype.api.values.MapCompositeValueSupport;
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.SimpleValue;
import org.jboss.metatype.api.values.SimpleValueSupport;
-import org.jboss.profileservice.spi.AttachmentsSerializer;
import org.jboss.system.server.profileservice.persistence.ManagedObjectPeristenceHandler;
import org.jboss.system.server.profileservice.persistence.ManagedObjectUpdateHandler;
import org.jboss.system.server.profileservice.persistence.xml.PersistedCompositeValue;
import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
import org.jboss.system.server.profileservice.persistence.xml.PersistedProperty;
+import org.jboss.system.server.profileservice.repository.AbstractFileAttachmentsSerializer;
import org.jboss.test.profileservice.persistenceformat.support.PrimitiveMetaData;
import org.jboss.test.profileservice.persistenceformat.support.TestMetaData;
@@ -246,7 +244,7 @@
handler.processManagedObject(persisted, mo);
// Save
- AttachmentsSerializer serializer = getAttachmentSerializer(true);
+ AbstractFileAttachmentsSerializer serializer = getAttachmentSerializer(true);
serializer.saveAttachment("test", persisted);
// Restore
return serializer.loadAttachment("test", PersistedManagedObject.class);
Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/TestNestedPeristenceFormatUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/TestNestedPeristenceFormatUnitTestCase.java 2009-01-13 12:33:49 UTC (rev 82804)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/TestNestedPeristenceFormatUnitTestCase.java 2009-01-13 12:49:05 UTC (rev 82805)
@@ -36,12 +36,12 @@
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.SimpleValue;
import org.jboss.metatype.api.values.SimpleValueSupport;
-import org.jboss.profileservice.spi.AttachmentsSerializer;
import org.jboss.system.server.profileservice.persistence.ManagedObjectPeristenceHandler;
import org.jboss.system.server.profileservice.persistence.ManagedObjectUpdateHandler;
import org.jboss.system.server.profileservice.persistence.xml.PersistedCollectionValue;
import org.jboss.system.server.profileservice.persistence.xml.PersistedGenericValue;
import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
+import org.jboss.system.server.profileservice.repository.AbstractFileAttachmentsSerializer;
import org.jboss.test.profileservice.persistenceformat.support.NestedTestMetaData;
import org.jboss.test.profileservice.persistenceformat.support.PrimitiveMetaData;
import org.jboss.test.profileservice.persistenceformat.support.TestMetaData;
@@ -172,7 +172,7 @@
handler.processManagedObject(persisted, mo);
// Save
- AttachmentsSerializer serializer = getAttachmentSerializer(true);
+ AbstractFileAttachmentsSerializer serializer = getAttachmentSerializer(true);
serializer.saveAttachment("test", persisted);
// Restore
return serializer.loadAttachment("test", PersistedManagedObject.class);
Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/AbstractProfileServiceTest.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/AbstractProfileServiceTest.java 2009-01-13 12:33:49 UTC (rev 82804)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/AbstractProfileServiceTest.java 2009-01-13 12:49:05 UTC (rev 82805)
@@ -21,26 +21,25 @@
*/
package org.jboss.test.profileservice.test;
+import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
-import java.util.Map;
-import java.util.HashSet;
-import java.io.Serializable;
-import java.lang.reflect.Type;
+
import javax.naming.InitialContext;
-import org.jboss.test.JBossTestCase;
+
import org.jboss.deployers.spi.management.ManagementView;
import org.jboss.deployers.spi.management.deploy.DeploymentManager;
+import org.jboss.managed.api.ComponentType;
import org.jboss.managed.api.DeploymentTemplateInfo;
+import org.jboss.managed.api.ManagedComponent;
import org.jboss.managed.api.ManagedDeployment;
-import org.jboss.managed.api.ManagedComponent;
-import org.jboss.managed.api.ComponentType;
import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.profileservice.spi.ProfileKey;
import org.jboss.profileservice.spi.ProfileService;
-import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.test.JBossTestCase;
import org.jboss.virtual.VFS;
-import org.jboss.metatype.api.values.MetaValueFactory;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.SimpleValue;
/**
* @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
@@ -61,6 +60,11 @@
* @return the ProfileKey.name to use when loading the profile
*/
protected abstract String getProfileName();
+
+ protected ProfileKey getProfileKey()
+ {
+ return new ProfileKey(getProfileName());
+ }
protected void removeDeployment(String deployment)
throws Exception
@@ -128,15 +132,14 @@
{
if( activeView == null )
{
- String profileName = getProfileName();
InitialContext ctx = getInitialContext();
ProfileService ps = (ProfileService) ctx.lookup("ProfileService");
activeView = ps.getViewManager();
- ProfileKey defaultKey = new ProfileKey(profileName);
- activeView.loadProfile(defaultKey);
// Init the VFS to setup the vfs* protocol handlers
VFS.init();
}
+ // Reload
+ activeView.loadProfile(getProfileKey());
return activeView;
}
/**
@@ -149,12 +152,10 @@
{
if( deployMgr == null )
{
- String profileName = getProfileName();
InitialContext ctx = getInitialContext();
ProfileService ps = (ProfileService) ctx.lookup("ProfileService");
deployMgr = ps.getDeploymentManager();
- ProfileKey defaultKey = new ProfileKey(profileName);
- deployMgr.loadProfile(defaultKey, false);
+ deployMgr.loadProfile(getProfileKey(), false);
// Init the VFS to setup the vfs* protocol handlers
VFS.init();
}
Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java 2009-01-13 12:33:49 UTC (rev 82804)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java 2009-01-13 12:49:05 UTC (rev 82805)
@@ -21,9 +21,12 @@
*/
package org.jboss.test.profileservice.test;
+import java.util.HashMap;
import java.util.Map;
-import java.util.HashMap;
-import java.io.Serializable;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
import org.jboss.deployers.spi.management.KnownComponentTypes;
import org.jboss.deployers.spi.management.ManagementView;
import org.jboss.managed.api.ComponentType;
@@ -31,9 +34,6 @@
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.SimpleValueSupport;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
/**
* @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
* @version <tt>$Revision: $</tt>
@@ -114,6 +114,6 @@
@Override
protected String getProfileName()
{
- return "default";
+ return "profileservice";
}
}
Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java 2009-01-13 12:33:49 UTC (rev 82804)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java 2009-01-13 12:49:05 UTC (rev 82805)
@@ -120,6 +120,9 @@
/**
* Basic test of accessing the ProfileService and checking the
* available profile keys.
+ *
+ * As we are running the -c profileservice, the default key should be profileservice.
+ *
*/
public void testProfileKeys()
throws Exception
@@ -128,8 +131,8 @@
ProfileService ps = (ProfileService) ctx.lookup("ProfileService");
Collection<ProfileKey> keys = ps.getProfileKeys();
log.info("getProfileKeys: "+keys);
- ProfileKey defaultKey = new ProfileKey("default");
- assertTrue("keys contains default", keys.contains(defaultKey));
+ ProfileKey defaultKey = new ProfileKey("profileservice");
+ assertTrue("keys contains profileservice", keys.contains(defaultKey));
}
/**
More information about the jboss-cvs-commits
mailing list