[jboss-cvs] JBossAS SVN: r60128 - in projects/microcontainer/trunk/deployers: src/main/org/jboss/deployers/plugins and 10 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jan 30 23:13:48 EST 2007
Author: scott.stark at jboss.org
Date: 2007-01-30 23:13:48 -0500 (Tue, 30 Jan 2007)
New Revision: 60128
Added:
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/advice/
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/advice/TrackingAdvice.java
projects/microcontainer/trunk/deployers/src/resources/tests/org/
projects/microcontainer/trunk/deployers/src/resources/tests/org/jboss/
projects/microcontainer/trunk/deployers/src/resources/tests/org/jboss/test/
projects/microcontainer/trunk/deployers/src/resources/tests/org/jboss/test/deployers/
projects/microcontainer/trunk/deployers/src/resources/tests/org/jboss/test/deployers/attachments/
projects/microcontainer/trunk/deployers/src/resources/tests/org/jboss/test/deployers/attachments/test/
projects/microcontainer/trunk/deployers/src/resources/tests/org/jboss/test/deployers/attachments/test/AttachmentsTest-aop.xml
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/AttachmentsTestDelegate.java
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/DeploymentAttachmentsInterceptUnitTestCase.java
Modified:
projects/microcontainer/trunk/deployers/.classpath
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/AttachmentsTestSuite.java
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/AttachmentsTest.java
Log:
Add an advice for tracking attachment changes
Modified: projects/microcontainer/trunk/deployers/.classpath
===================================================================
--- projects/microcontainer/trunk/deployers/.classpath 2007-01-31 03:41:04 UTC (rev 60127)
+++ projects/microcontainer/trunk/deployers/.classpath 2007-01-31 04:13:48 UTC (rev 60128)
@@ -19,5 +19,7 @@
<classpathentry kind="lib" path="/thirdparty/sun-jaf/lib/activation.jar"/>
<classpathentry kind="lib" path="/thirdparty/sun-jaxb/lib/jaxb-api.jar"/>
<classpathentry kind="lib" path="/thirdparty/stax-api/lib/stax-api.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jboss/aop/lib/jboss-aop-jdk50.jar" sourcepath="/thirdparty/jboss/aop/lib/jboss-aop-src.zip"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/aop-mc-int"/>
<classpathentry kind="output" path="output/eclipse-classes"/>
</classpath>
Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/advice/TrackingAdvice.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/advice/TrackingAdvice.java (rev 0)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/advice/TrackingAdvice.java 2007-01-31 04:13:48 UTC (rev 60128)
@@ -0,0 +1,137 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.deployers.plugins.advice;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.aop.microcontainer.aspects.util.ProxyUtils;
+import org.jboss.deployers.spi.attachments.Attachments;
+import org.jboss.logging.Logger;
+
+/**
+ * An advice for capturing changes made to an Attachments.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class TrackingAdvice
+{
+ private static Logger log = Logger.getLogger(TrackingAdvice.class);
+ private static ConcurrentHashMap<Object, Map<String, Object>> attachmentsByTarget =
+ new ConcurrentHashMap<Object, Map<String, Object>>();
+
+ public static Attachments wrapAttachments(Attachments attachments)
+ {
+ return ProxyUtils.createProxy(attachments, Attachments.class);
+ }
+
+ public static Object invoke(Invocation inv)
+ throws Throwable
+ {
+ return inv.invokeNext();
+ }
+
+ public static Object addAttachment(MethodInvocation mi)
+ throws Throwable
+ {
+ Object target = mi.getTargetObject();
+ Object[] args = mi.getArguments();
+ Object value = mi.invokeNext();
+ String name;
+ Object attachment;
+ // addAttachment(Class<T> type, T attachment)
+ if( args[0] instanceof Class )
+ {
+ Class c = Class.class.cast(args[0]);
+ name = c.getName();
+ attachment = args[1];
+ }
+ // addAttachment(String name, T attachment, Class<T> expectedType)
+ // addAttachment(String name, T attachment)
+ else
+ {
+ name = String.class.cast(args[0]);
+ attachment = args[1];
+ }
+ addAttachment(target, name, attachment);
+ return value;
+ }
+
+ public static Object removeAttachment(MethodInvocation mi)
+ throws Throwable
+ {
+ Object target = mi.getTargetObject();
+ Object[] args = mi.getArguments();
+ Object value = mi.invokeNext();
+ String name;
+ // removeAttachment(Class<T> type)
+ if( args[0] instanceof Class )
+ {
+ Class c = Class.class.cast(args[0]);
+ name = c.getName();
+ }
+ // removeAttachment(String name, Class<T> expectedType)
+ // removeAttachment(String name)
+ else
+ {
+ name = String.class.cast(args[0]);
+ }
+ removeAttachment(target, name);
+ return value;
+ }
+
+ public static Map<String, Object> getAttachmentsForTarget(Object key)
+ {
+ Map<String, Object> attachments = attachmentsByTarget.get(key);
+ return attachments;
+ }
+ public static Map<String, Object> clearAttachmentsForTarget(Object key)
+ {
+ Map<String, Object> attachments = attachmentsByTarget.remove(key);
+ return attachments;
+ }
+
+ private static void addAttachment(Object target, String name, Object attachment)
+ {
+ Map<String, Object> attachments = attachmentsByTarget.get(target);
+ if( attachments == null )
+ {
+ attachments = new HashMap<String, Object>();
+ attachmentsByTarget.put(target, attachments);
+ }
+ attachments.put(name, attachment);
+ }
+ private static void removeAttachment(Object target, String name)
+ {
+ Map<String, Object> attachments = attachmentsByTarget.get(target);
+ if( attachments != null )
+ {
+ attachments.remove(name);
+ if( attachments.size() == 0 )
+ attachmentsByTarget.remove(target);
+ }
+ }
+}
Property changes on: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/advice/TrackingAdvice.java
___________________________________________________________________
Name: svn:keywords
+ Id,Revision
Name: svn:eol-style
+ native
Added: projects/microcontainer/trunk/deployers/src/resources/tests/org/jboss/test/deployers/attachments/test/AttachmentsTest-aop.xml
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/org/jboss/test/deployers/attachments/test/AttachmentsTest-aop.xml (rev 0)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/org/jboss/test/deployers/attachments/test/AttachmentsTest-aop.xml 2007-01-31 04:13:48 UTC (rev 60128)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE aop SYSTEM "jboss-aop_1_0.dtd">
+<aop>
+
+ <!-- This is the default AOP setup when the test doesn't having anything specific -->
+
+ <!-- ==== Advices ==== -->
+ <aspect name="track" class="org.jboss.deployers.plugins.advice.TrackingAdvice"/>
+
+ <!-- The attachments advice stack -->
+ <bind pointcut="execution(* $instanceof{org.jboss.deployers.spi.attachments.Attachments}->addAttachment(..))">
+ <advice name="addAttachment" aspect="track"/>
+ </bind>
+ <bind pointcut="execution(* $instanceof{org.jboss.deployers.spi.attachments.Attachments}->removeAttachment(..))">
+ <advice name="removeAttachment" aspect="track"/>
+ </bind>
+
+</aop>
Property changes on: projects/microcontainer/trunk/deployers/src/resources/tests/org/jboss/test/deployers/attachments/test/AttachmentsTest-aop.xml
___________________________________________________________________
Name: svn:keywords
+ Id,Revision
Name: svn:eol-style
+ native
Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/AttachmentsTestSuite.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/AttachmentsTestSuite.java 2007-01-31 03:41:04 UTC (rev 60127)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/AttachmentsTestSuite.java 2007-01-31 04:13:48 UTC (rev 60128)
@@ -26,6 +26,7 @@
import junit.textui.TestRunner;
import org.jboss.test.deployers.attachments.test.AttachmentsUnitTestCase;
+import org.jboss.test.deployers.attachments.test.DeploymentAttachmentsInterceptUnitTestCase;
import org.jboss.test.deployers.attachments.test.DeploymentUnitAttachmentHierarchyUnitTestCase;
import org.jboss.test.deployers.attachments.test.DeploymentUnitAttachmentsUnitTestCase;
import org.jboss.test.deployers.attachments.test.DeploymentUnitPredeterminedManagedObjectsUnitTestCase;
@@ -61,6 +62,7 @@
suite.addTest(DeploymentUnitTransientManagedObjectsUnitTestCase.suite());
suite.addTest(DeploymentUnitTransientAttachmentsUnitTestCase.suite());
suite.addTest(DeploymentUnitAttachmentHierarchyUnitTestCase.suite());
+ suite.addTest(DeploymentAttachmentsInterceptUnitTestCase.suite());
return suite;
}
Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/AttachmentsTest.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/AttachmentsTest.java 2007-01-31 03:41:04 UTC (rev 60127)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/AttachmentsTest.java 2007-01-31 04:13:48 UTC (rev 60128)
@@ -25,6 +25,8 @@
import junit.framework.TestSuite;
import org.jboss.deployers.spi.attachments.Attachments;
+import org.jboss.test.AbstractTestCaseWithSetup;
+import org.jboss.test.AbstractTestDelegate;
import org.jboss.test.BaseTestCase;
/**
@@ -33,13 +35,26 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public abstract class AttachmentsTest extends BaseTestCase
+public abstract class AttachmentsTest extends AbstractTestCaseWithSetup
{
public static Test suite()
{
return new TestSuite(AttachmentsTest.class);
}
-
+ /**
+ * A static getDelegate method that is called by the AbstractTestDelegate
+ * getDelegate logic to obtain the test specific delegate. This sets the
+ * default delegate for ManagedTests to ManagedTestDelegate.
+ *
+ * @param clazz the test class
+ * @return the delegate
+ * @throws Exception for any error
+ */
+ public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+ {
+ return new AttachmentsTestDelegate(clazz);
+ }
+
public AttachmentsTest(String name)
{
super(name);
@@ -48,7 +63,16 @@
protected abstract Attachments getAttachments();
protected abstract Attachments getMutable();
-
+
+ /**
+ * Adds a call to configureLogging after super.setUp.
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ configureLogging();
+ }
+
public void testAddAttachmentErrors() throws Exception
{
Attachments mutable = getMutable();
@@ -127,10 +151,10 @@
public void testAddAttachmentByName() throws Exception
{
ExpectedAttachments expected = new ExpectedAttachments();
- assertAddFreshAttachmentByName(expected, "name1", "attachment");
- assertAddFreshAttachmentByName(expected, "name2", "attachment");
+ assertAddFreshAttachmentByName(expected, "name1", "attachment1");
+ assertAddFreshAttachmentByName(expected, "name2", "attachment2");
- assertAddReplaceAttachmentByName(expected, "name1", "different", "attachment");
+ assertAddReplaceAttachmentByName(expected, "name1", "different1", "attachment1");
}
protected void assertAddFreshAttachmentByName(ExpectedAttachments expected, String name, Object attachment)
@@ -170,10 +194,10 @@
public void testAddAttachmentByNameAndType() throws Exception
{
ExpectedAttachments expected = new ExpectedAttachments();
- assertAddFreshAttachmentByNameAndType(expected, "name1", "attachment", String.class);
- assertAddFreshAttachmentByNameAndType(expected, "name2", "attachment", String.class);
+ assertAddFreshAttachmentByNameAndType(expected, "name1", "attachment1", String.class);
+ assertAddFreshAttachmentByNameAndType(expected, "name2", "attachment2", String.class);
- assertAddReplaceAttachmentByNameAndType(expected, "name1", "different", "attachment", String.class);
+ assertAddReplaceAttachmentByNameAndType(expected, "name1", "different1", "attachment1", String.class);
}
protected <T> void assertAddFreshAttachmentByNameAndType(ExpectedAttachments expected, String name, T attachment, Class<T> expectedType)
@@ -280,9 +304,9 @@
ExpectedAttachments expected = new ExpectedAttachments();
assertRemoveNotPresentAttachmentByName(expected, "name1");
- assertAddAttachmentByName(expected, "name1", "attachment");
- assertAddAttachmentByName(expected, "name2", "different");
- assertRemoveAttachmentByName(expected, "name1", "attachment");
+ assertAddAttachmentByName(expected, "name1", "attachment1");
+ assertAddAttachmentByName(expected, "name2", "different2");
+ assertRemoveAttachmentByName(expected, "name1", "attachment1");
}
protected void assertRemoveNotPresentAttachmentByName(ExpectedAttachments expected, String name)
@@ -324,9 +348,9 @@
ExpectedAttachments expected = new ExpectedAttachments();
assertRemoveNotPresentAttachmentByNameAndType(expected, "name1", String.class);
- assertAddAttachmentByNameAndType(expected, "name1", "attachment", String.class);
- assertAddAttachmentByNameAndType(expected, "name2", "different", String.class);
- assertRemoveAttachmentByNameAndType(expected, "name1", "attachment", String.class);
+ assertAddAttachmentByNameAndType(expected, "name1", "attachment1", String.class);
+ assertAddAttachmentByNameAndType(expected, "name2", "different2", String.class);
+ assertRemoveAttachmentByNameAndType(expected, "name1", "attachment1", String.class);
}
protected <T> void assertRemoveNotPresentAttachmentByNameAndType(ExpectedAttachments expected, String name, Class<T> expectedType)
Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/AttachmentsTestDelegate.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/AttachmentsTestDelegate.java (rev 0)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/AttachmentsTestDelegate.java 2007-01-31 04:13:48 UTC (rev 60128)
@@ -0,0 +1,132 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.deployers.attachments.test;
+
+import java.net.URL;
+
+import org.jboss.aop.AspectXmlLoader;
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ *
+ * AttachmentsTestDelegate overrides the AbstractTestDelegate to
+ * deploy/undeploy test specific aop descriptors in setUp/tearDown.
+ *
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.com
+ * @version $Revision:59255 $
+ */
+public class AttachmentsTestDelegate extends AbstractTestDelegate
+{
+ /** The AOP URL used */
+ private URL aopURL;
+
+ /**
+ * Create a new ManagedTestDelegate.
+ *
+ * @param clazz the class
+ * @throws Exception for any error
+ */
+ public AttachmentsTestDelegate(Class clazz) throws Exception
+ {
+ super(clazz);
+ }
+
+ /**
+ * Look for a test specific aop descriptor based on the ctor
+ * class first, and if none is found, the ManagedTest.class.
+ */
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ if (deployAOP(clazz) == false)
+ deployAOP(AttachmentsTest.class);
+ }
+
+ /**
+ * Undeployment any test specific aop descriptor deployed in setUp.
+ */
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ undeployAOP();
+ }
+
+ /**
+ * Look for a test specific resource name by appending "-aop.xml"
+ * to the referenceClass name as a resource. For example, a.b.SomeTest
+ * would produce a a/b/SomeTest-aop.xml resource that is queried
+ * for using clazz.getClassLoader().getResource("a/b/SomeTest-aop.xml");
+ *
+ * @param referenceClass - the class to use as the aop descriptor base name.
+ * @return true if the aop descriptor was found and deployed,
+ * false otherwise.
+ * @throws Exception on failure to deploy the aop descriptor.
+ */
+ protected boolean deployAOP(Class referenceClass) throws Exception
+ {
+ String testName = referenceClass.getName();
+ testName = testName.replace('.', '/') + "-aop.xml";
+ URL url = clazz.getClassLoader().getResource(testName);
+ if (url != null)
+ {
+ log.debug("Deploying " + url);
+ aopURL = url;
+ try
+ {
+ AspectXmlLoader.deployXML(aopURL);
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException("Error deploying: " + url, t);
+ }
+ return true;
+ }
+ else
+ {
+ log.debug("No test specific deployment " + testName);
+ return false;
+ }
+ }
+
+ /**
+ * Undeploy the aop descriptor deployed in deployAOP if
+ * one was found.
+ *
+ */
+ protected void undeployAOP()
+ {
+ if (aopURL == null)
+ return;
+ try
+ {
+ log.debug("Undeploying " + aopURL);
+ AspectXmlLoader.undeployXML(aopURL);
+ }
+ catch (Exception e)
+ {
+ log.warn("Ignored error undeploying " + aopURL, e);
+ }
+ }
+
+}
Property changes on: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/AttachmentsTestDelegate.java
___________________________________________________________________
Name: svn:keywords
+ Id,Revision
Name: svn:eol-style
+ native
Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/DeploymentAttachmentsInterceptUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/DeploymentAttachmentsInterceptUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/DeploymentAttachmentsInterceptUnitTestCase.java 2007-01-31 04:13:48 UTC (rev 60128)
@@ -0,0 +1,195 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.deployers.attachments.test;
+
+import java.util.Map;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.advice.TrackingAdvice;
+import org.jboss.deployers.plugins.deployer.AbstractDeploymentUnit;
+import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
+import org.jboss.deployers.spi.attachments.Attachments;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+
+/**
+ * Tests of intercepting the Attachments add/remove to collect change sets.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class DeploymentAttachmentsInterceptUnitTestCase
+ extends AttachmentsTest
+{
+ public static Test suite()
+ {
+ return new TestSuite(DeploymentUnitAttachmentsUnitTestCase.class);
+ }
+
+ private DeploymentUnit unit;
+
+ private Attachments mutable;
+
+ public DeploymentAttachmentsInterceptUnitTestCase(String name)
+ {
+ super(name);
+ AbstractDeploymentContext context = new AbstractDeploymentContext("attachments");
+ unit = new AbstractDeploymentUnit(context);
+ context.setDeploymentUnit(unit);
+ // Integrate with aop
+ mutable = TrackingAdvice.wrapAttachments(unit);
+ }
+
+ @Override
+ public void testAddAttachmentByName() throws Exception
+ {
+ super.testAddAttachmentByName();
+ // Validate that the attachments were captured
+ Map<String, Object> map = TrackingAdvice.getAttachmentsForTarget(mutable);
+ assertNotNull(map);
+ assertEquals("advice.map.size", 2, map.size());
+ Object name1 = map.get("name1");
+ assertEquals("name1.attachment", "different1", name1);
+ Object name2 = map.get("name2");
+ assertEquals("name2.attachment", "attachment2", name2);
+ map = TrackingAdvice.clearAttachmentsForTarget(mutable);
+ assertNotNull(map);
+ assertEquals("advice.map.size", 2, map.size());
+ map = TrackingAdvice.getAttachmentsForTarget(mutable);
+ assertNull(map);
+ }
+
+ @Override
+ public void testAddAttachmentByNameAndType() throws Exception
+ {
+ super.testAddAttachmentByNameAndType();
+ // Validate that the attachments were captured
+ Map<String, Object> map = TrackingAdvice.getAttachmentsForTarget(mutable);
+ assertNotNull(map);
+ assertEquals("advice.map.size", 2, map.size());
+ Object name1 = map.get("name1");
+ assertEquals("name1.attachment", "different1", name1);
+ Object name2 = map.get("name2");
+ assertEquals("name2.attachment", "attachment2", name2);
+ map = TrackingAdvice.clearAttachmentsForTarget(mutable);
+ assertNotNull(map);
+ assertEquals("advice.map.size", 2, map.size());
+ map = TrackingAdvice.getAttachmentsForTarget(mutable);
+ assertNull(map);
+ }
+
+ @Override
+ public void testAddAttachmentByType() throws Exception
+ {
+ super.testAddAttachmentByType();
+ // Validate that the attachments were captured
+ Map<String, Object> map = TrackingAdvice.getAttachmentsForTarget(mutable);
+ assertNotNull(map);
+ assertEquals("advice.map.size", 2, map.size());
+ Object name1 = map.get("java.lang.Integer");
+ assertEquals("name1.attachment", 1, name1);
+ Object name2 = map.get("java.lang.String");
+ assertEquals("name2.attachment", "different", name2);
+ map = TrackingAdvice.clearAttachmentsForTarget(mutable);
+ assertNotNull(map);
+ assertEquals("advice.map.size", 2, map.size());
+ map = TrackingAdvice.getAttachmentsForTarget(mutable);
+ assertNull(map);
+ }
+
+ @Override
+ public void testAddAttachmentErrors() throws Exception
+ {
+ super.testAddAttachmentErrors();
+ // Validate that no attachments were captured
+ Map<String, Object> map = TrackingAdvice.getAttachmentsForTarget(mutable);
+ assertNull(map);
+ }
+
+ @Override
+ public void testRemoveAttachmentByName() throws Exception
+ {
+ super.testRemoveAttachmentByName();
+ // Validate that the attachments were captured
+ Map<String, Object> map = TrackingAdvice.getAttachmentsForTarget(mutable);
+ assertNotNull(map);
+ assertEquals("advice.map.size", 1, map.size());
+ Object name1 = map.get("name1");
+ assertNull("name1.attachment", name1);
+ Object name2 = map.get("name2");
+ assertEquals("name2.attachment", "different2", name2);
+ map = TrackingAdvice.clearAttachmentsForTarget(mutable);
+ assertNotNull(map);
+ assertEquals("advice.map.size", 1, map.size());
+ map = TrackingAdvice.getAttachmentsForTarget(mutable);
+ assertNull(map);
+ }
+
+ @Override
+ public void testRemoveAttachmentByNameAndType() throws Exception
+ {
+ super.testRemoveAttachmentByNameAndType();
+ // Validate that the attachments were captured
+ Map<String, Object> map = TrackingAdvice.getAttachmentsForTarget(mutable);
+ assertNotNull(map);
+ assertEquals("advice.map.size", 1, map.size());
+ Object name1 = map.get("name1");
+ assertNull("name1.attachment", name1);
+ Object name2 = map.get("name2");
+ assertEquals("name2.attachment", "different2", name2);
+ map = TrackingAdvice.clearAttachmentsForTarget(mutable);
+ assertNotNull(map);
+ assertEquals("advice.map.size", 1, map.size());
+ map = TrackingAdvice.getAttachmentsForTarget(mutable);
+ assertNull(map);
+ }
+
+ @Override
+ public void testRemoveAttachmentByType() throws Exception
+ {
+ super.testRemoveAttachmentByType();
+ // Validate that the attachments were captured
+ Map<String, Object> map = TrackingAdvice.getAttachmentsForTarget(mutable);
+ assertEquals("advice.map.size", 1, map.size());
+ Object name1 = map.get("java.lang.Integer");
+ assertEquals("name1.attachment", 1, name1);
+ Object name2 = map.get("java.lang.String");
+ assertNull("name2.attachment", name2);
+ map = TrackingAdvice.clearAttachmentsForTarget(mutable);
+ assertNotNull(map);
+ assertEquals("advice.map.size", 1, map.size());
+ map = TrackingAdvice.getAttachmentsForTarget(mutable);
+ assertNull(map);
+ }
+
+ protected Attachments getAttachments()
+ {
+ return unit;
+ }
+
+ protected Attachments getMutable()
+ {
+ return mutable;
+ }
+
+}
Property changes on: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/DeploymentAttachmentsInterceptUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id,Revision
Name: svn:eol-style
+ native
More information about the jboss-cvs-commits
mailing list