[jboss-cvs] JBossAS SVN: r110481 - in projects/kernel/trunk/jmx-mc-int/src/test/java/org/jboss/test/system/metadata/test: support and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jan 27 20:57:10 EST 2011
Author: alesj
Date: 2011-01-27 20:57:10 -0500 (Thu, 27 Jan 2011)
New Revision: 110481
Added:
projects/kernel/trunk/jmx-mc-int/src/test/java/org/jboss/test/system/metadata/test/JaxbMetaDataTestDelegate.java
projects/kernel/trunk/jmx-mc-int/src/test/java/org/jboss/test/system/metadata/test/support/
projects/kernel/trunk/jmx-mc-int/src/test/java/org/jboss/test/system/metadata/test/support/JaxbServiceDeployment.java
Log:
Add optional JAXB impl -- test purpose.
Copied: projects/kernel/trunk/jmx-mc-int/src/test/java/org/jboss/test/system/metadata/test/JaxbMetaDataTestDelegate.java (from rev 110102, projects/kernel/trunk/jmx-mc-int/src/test/java/org/jboss/test/system/metadata/test/MetaDataTestDelegate.java)
===================================================================
--- projects/kernel/trunk/jmx-mc-int/src/test/java/org/jboss/test/system/metadata/test/JaxbMetaDataTestDelegate.java (rev 0)
+++ projects/kernel/trunk/jmx-mc-int/src/test/java/org/jboss/test/system/metadata/test/JaxbMetaDataTestDelegate.java 2011-01-28 01:57:10 UTC (rev 110481)
@@ -0,0 +1,101 @@
+/*
+ * 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.system.metadata.test;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.sax.SAXSource;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.List;
+
+import org.jboss.system.metadata.ServiceMetaData;
+import org.jboss.test.AbstractTestDelegate;
+import org.jboss.test.system.metadata.test.support.JaxbServiceDeployment;
+import org.jboss.util.xml.JBossEntityResolver;
+
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+/**
+ * JAXB MetaDataTestDelegate.
+ *
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
+ */
+public class JaxbMetaDataTestDelegate extends AbstractTestDelegate
+{
+ /** The context */
+ private JAXBContext context;
+
+ public JaxbMetaDataTestDelegate(Class<?> clazz)
+ {
+ super(clazz);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ context = JAXBContext.newInstance(JaxbServiceDeployment.class);
+ }
+
+ /**
+ * Unmarshal an object
+ *
+ * @param url the url
+ * @return the list of services
+ * @throws Exception for any error
+ */
+ public List<ServiceMetaData> unmarshal(URL url) throws Exception
+ {
+ long start = System.currentTimeMillis();
+
+ try
+ {
+ InputStream is = url.openStream();
+ try
+ {
+ InputSource input = new InputSource(is);
+ input.setSystemId(url.toURI().toString());
+ XMLReader reader = XMLReaderFactory.createXMLReader();
+ reader.setEntityResolver(new JBossEntityResolver());
+ SAXSource source = new SAXSource(reader, input);
+ Unmarshaller um = context.createUnmarshaller();
+ JAXBElement<JaxbServiceDeployment> elem = um.unmarshal(source, JaxbServiceDeployment.class);
+ log.debug("Total parse for " + url + " took " + (System.currentTimeMillis() - start) + "ms");
+ return elem.getValue().getServices();
+ }
+ finally
+ {
+ if (is != null)
+ is.close();
+ }
+ }
+ catch (Exception e)
+ {
+ log.debug("Error during parsing: " + url + ": " + e);
+ throw e;
+ }
+ }
+}
Added: projects/kernel/trunk/jmx-mc-int/src/test/java/org/jboss/test/system/metadata/test/support/JaxbServiceDeployment.java
===================================================================
--- projects/kernel/trunk/jmx-mc-int/src/test/java/org/jboss/test/system/metadata/test/support/JaxbServiceDeployment.java (rev 0)
+++ projects/kernel/trunk/jmx-mc-int/src/test/java/org/jboss/test/system/metadata/test/support/JaxbServiceDeployment.java 2011-01-28 01:57:10 UTC (rev 110481)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.system.metadata.test.support;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.system.metadata.ServiceMetaData;
+import org.jboss.system.metadata.ServiceMetaDataAdapter;
+
+/**
+ * Mock service deployment.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+ at XmlAccessorType(XmlAccessType.NONE)
+ at XmlRootElement
+public class JaxbServiceDeployment implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ @XmlElement(name="mbean")
+ @XmlJavaTypeAdapter(ServiceMetaDataAdapter.class)
+ private List<ServiceMetaData> services = new ArrayList<ServiceMetaData>();
+
+ public List<ServiceMetaData> getServices()
+ {
+ return services;
+ }
+
+ public void setServices(List<ServiceMetaData> services)
+ {
+ this.services = services;
+ }
+}
More information about the jboss-cvs-commits
mailing list