[jboss-svn-commits] JBoss Common SVN: r4725 - in arquillian/trunk: impl-base/src/main/java/org/jboss/arquillian/impl/context and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Jul 13 18:15:35 EDT 2010


Author: aslak
Date: 2010-07-13 18:15:34 -0400 (Tue, 13 Jul 2010)
New Revision: 4725

Added:
   arquillian/trunk/impl-base/src/main/java/org/jboss/arquillian/impl/context/ServiceLoadableProfileBuilder.java
   arquillian/trunk/spi/src/main/java/org/jboss/arquillian/spi/ClassContextAppender.java
   arquillian/trunk/spi/src/main/java/org/jboss/arquillian/spi/SuiteContextAppender.java
   arquillian/trunk/spi/src/main/java/org/jboss/arquillian/spi/TestContextAppender.java
Modified:
   arquillian/trunk/impl-base/src/main/java/org/jboss/arquillian/impl/DeployableTestBuilder.java
Log:
ARQ-128 Added a SericeLoadableProfileBuilder wrapper around the Configured ProfileBuilder that can load the SuiteContextAppender, ClassContextAppender and TestContextAppender SPIs. Used by extension to register them selves for callbacks during the test execution lifecycles.


Modified: arquillian/trunk/impl-base/src/main/java/org/jboss/arquillian/impl/DeployableTestBuilder.java
===================================================================
--- arquillian/trunk/impl-base/src/main/java/org/jboss/arquillian/impl/DeployableTestBuilder.java	2010-07-12 23:55:00 UTC (rev 4724)
+++ arquillian/trunk/impl-base/src/main/java/org/jboss/arquillian/impl/DeployableTestBuilder.java	2010-07-13 22:15:34 UTC (rev 4725)
@@ -20,6 +20,7 @@
 import org.jboss.arquillian.impl.context.ContainerProfileBuilder;
 import org.jboss.arquillian.impl.context.ContextLifecycleManager;
 import org.jboss.arquillian.impl.context.ProfileBuilder;
+import org.jboss.arquillian.impl.context.ServiceLoadableProfileBuilder;
 import org.jboss.arquillian.impl.context.StandaloneProfileBuilder;
 import org.jboss.arquillian.spi.Configuration;
 import org.jboss.arquillian.spi.ContainerConfiguration;
@@ -111,10 +112,11 @@
 
       ContextLifecycleManager eventManager = new ContextLifecycleManager(
             configuration, 
-            profileBuilder,
+            new ServiceLoadableProfileBuilder(serviceLoader, profileBuilder),
             serviceLoader
       );
 
       return new EventTestRunnerAdaptor(eventManager);
    }
+   
 }

Added: arquillian/trunk/impl-base/src/main/java/org/jboss/arquillian/impl/context/ServiceLoadableProfileBuilder.java
===================================================================
--- arquillian/trunk/impl-base/src/main/java/org/jboss/arquillian/impl/context/ServiceLoadableProfileBuilder.java	                        (rev 0)
+++ arquillian/trunk/impl-base/src/main/java/org/jboss/arquillian/impl/context/ServiceLoadableProfileBuilder.java	2010-07-13 22:15:34 UTC (rev 4725)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.arquillian.impl.context;
+
+import java.util.Collection;
+
+import org.jboss.arquillian.impl.Validate;
+import org.jboss.arquillian.spi.ClassContextAppender;
+import org.jboss.arquillian.spi.ServiceLoader;
+import org.jboss.arquillian.spi.SuiteContextAppender;
+import org.jboss.arquillian.spi.TestContextAppender;
+
+/**
+ * A ProfileBuilder that combines the defined 'internal' Profile with the SPI loadable profiles.
+ *
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class ServiceLoadableProfileBuilder implements ProfileBuilder
+{
+   private ServiceLoader serviceLoader;
+   private ProfileBuilder containerProfileBuilder;
+   
+   public ServiceLoadableProfileBuilder(ServiceLoader serviceLoader, ProfileBuilder containerProfilebuilder)
+   {
+      Validate.notNull(serviceLoader, "ServiceLoader must be specified");
+      Validate.notNull(containerProfilebuilder, "ProfileBuilder must be specified");
+      
+      this.serviceLoader = serviceLoader;
+      this.containerProfileBuilder = containerProfilebuilder;
+   }
+   
+   /* (non-Javadoc)
+    * @see org.jboss.arquillian.impl.context.ProfileBuilder#buildSuiteContext(org.jboss.arquillian.impl.context.SuiteContext)
+    */
+   public void buildSuiteContext(SuiteContext context)
+   {
+      containerProfileBuilder.buildSuiteContext(context);
+      Collection<SuiteContextAppender> appenders = serviceLoader.all(SuiteContextAppender.class);
+      for(SuiteContextAppender appender : appenders)
+      {
+         appender.append(context);
+      }
+   }
+   
+   /* (non-Javadoc)
+    * @see org.jboss.arquillian.impl.context.ProfileBuilder#buildClassContext(org.jboss.arquillian.impl.context.ClassContext, java.lang.Class)
+    */
+   public void buildClassContext(ClassContext context, Class<?> testClass)
+   {
+      containerProfileBuilder.buildClassContext(context, testClass);
+      Collection<ClassContextAppender> appenders = serviceLoader.all(ClassContextAppender.class);
+      for(ClassContextAppender appender : appenders)
+      {
+         appender.append(context);
+      }
+   }
+   
+   /* (non-Javadoc)
+    * @see org.jboss.arquillian.impl.context.ProfileBuilder#buildTestContext(org.jboss.arquillian.impl.context.TestContext, java.lang.Object)
+    */
+   public void buildTestContext(TestContext context, Object testInstance)
+   {
+      containerProfileBuilder.buildTestContext(context, testInstance);
+      Collection<TestContextAppender> appenders = serviceLoader.all(TestContextAppender.class);
+      for(TestContextAppender appender : appenders)
+      {
+         appender.append(context);
+      }
+   }
+}

Added: arquillian/trunk/spi/src/main/java/org/jboss/arquillian/spi/ClassContextAppender.java
===================================================================
--- arquillian/trunk/spi/src/main/java/org/jboss/arquillian/spi/ClassContextAppender.java	                        (rev 0)
+++ arquillian/trunk/spi/src/main/java/org/jboss/arquillian/spi/ClassContextAppender.java	2010-07-13 22:15:34 UTC (rev 4725)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.arquillian.spi;
+
+import org.jboss.arquillian.spi.event.suite.EventHandler;
+
+/**
+ *  * SPI for adding {@link EventHandler}s to the Arquillian core ClassContext
+ *
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public interface ClassContextAppender
+{
+   /**
+    * @param context ClassContext
+    */
+   void append(Context context);
+}

Added: arquillian/trunk/spi/src/main/java/org/jboss/arquillian/spi/SuiteContextAppender.java
===================================================================
--- arquillian/trunk/spi/src/main/java/org/jboss/arquillian/spi/SuiteContextAppender.java	                        (rev 0)
+++ arquillian/trunk/spi/src/main/java/org/jboss/arquillian/spi/SuiteContextAppender.java	2010-07-13 22:15:34 UTC (rev 4725)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.arquillian.spi;
+
+import org.jboss.arquillian.spi.event.suite.EventHandler;
+
+/**
+ * SPI for adding {@link EventHandler}s to the Arquillian core SuiteContext
+ *
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public interface SuiteContextAppender
+{
+   /**
+    * @param context SuiteContext
+    */
+   void append(Context context);
+}

Added: arquillian/trunk/spi/src/main/java/org/jboss/arquillian/spi/TestContextAppender.java
===================================================================
--- arquillian/trunk/spi/src/main/java/org/jboss/arquillian/spi/TestContextAppender.java	                        (rev 0)
+++ arquillian/trunk/spi/src/main/java/org/jboss/arquillian/spi/TestContextAppender.java	2010-07-13 22:15:34 UTC (rev 4725)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.arquillian.spi;
+
+import org.jboss.arquillian.spi.event.suite.EventHandler;
+
+/**
+ * SPI for adding {@link EventHandler}s to the Arquillian core TestContext
+ *
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public interface TestContextAppender
+{
+   /**
+    * 
+    * @param context TestContext
+    */
+   void append(Context context);
+}



More information about the jboss-svn-commits mailing list