[jboss-svn-commits] JBoss Common SVN: r4270 - in arquillian/trunk/impl-base/src/test/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 Apr 20 11:06:00 EDT 2010
Author: aslak
Date: 2010-04-20 11:05:59 -0400 (Tue, 20 Apr 2010)
New Revision: 4270
Added:
arquillian/trunk/impl-base/src/test/java/org/jboss/arquillian/impl/context/
arquillian/trunk/impl-base/src/test/java/org/jboss/arquillian/impl/context/ContextLifecycleManagerTestCase.java
Removed:
arquillian/trunk/impl-base/src/test/java/org/jboss/arquillian/impl/event/ContextLifecycleManagerTestCase.java
Log:
ARQ-69 Moved TestCase to correct package
Copied: arquillian/trunk/impl-base/src/test/java/org/jboss/arquillian/impl/context/ContextLifecycleManagerTestCase.java (from rev 4269, arquillian/trunk/impl-base/src/test/java/org/jboss/arquillian/impl/event/ContextLifecycleManagerTestCase.java)
===================================================================
--- arquillian/trunk/impl-base/src/test/java/org/jboss/arquillian/impl/context/ContextLifecycleManagerTestCase.java (rev 0)
+++ arquillian/trunk/impl-base/src/test/java/org/jboss/arquillian/impl/context/ContextLifecycleManagerTestCase.java 2010-04-20 15:05:59 UTC (rev 4270)
@@ -0,0 +1,155 @@
+/*
+ * 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 junit.framework.Assert;
+
+import org.jboss.arquillian.impl.context.ClassContext;
+import org.jboss.arquillian.impl.context.ContextLifecycleManager;
+import org.jboss.arquillian.impl.context.ProfileBuilder;
+import org.jboss.arquillian.impl.context.SuiteContext;
+import org.jboss.arquillian.impl.context.TestContext;
+import org.jboss.arquillian.impl.event.EventHandler;
+import org.jboss.arquillian.impl.event.type.Before;
+import org.jboss.arquillian.impl.event.type.ClassEvent;
+import org.jboss.arquillian.impl.event.type.SuiteEvent;
+import org.jboss.arquillian.impl.event.type.TestEvent;
+import org.jboss.arquillian.spi.ServiceLoader;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+
+
+/**
+ * Test Case to verify context create/restore and event propagation model.
+ *
+ * @author <a href="mailto:aknutsen at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+ at RunWith(MockitoJUnitRunner.class)
+public class ContextLifecycleManagerTestCase
+{
+ @Mock
+ private ServiceLoader serviceLoader;
+
+ @Mock
+ private ProfileBuilder profileBuilder;
+
+ @Mock
+ private EventHandler<SuiteContext, SuiteEvent> suiteEventHandler;
+
+ @Mock
+ private EventHandler<ClassContext, ClassEvent> classEventHandler;
+
+ @Mock
+ private EventHandler<TestContext, TestEvent> testEventHandler;
+
+ @Test
+ public void shouldBeAbleToCreateRestoreSuiteContext() throws Exception
+ {
+ ContextLifecycleManager manager = new ContextLifecycleManager(profileBuilder, serviceLoader);
+
+ // Create a new
+ SuiteContext context = manager.createRestoreSuiteContext();
+
+ Assert.assertNotNull("Context should have been created", context);
+
+ // Restore
+ SuiteContext context2 = manager.createRestoreSuiteContext();
+
+ Assert.assertNotNull("Context should have been created", context2);
+ Assert.assertTrue("Restore of context should return same instance", context.equals(context2));
+
+ // Destroy and create a new
+ manager.destroySuiteContext();
+ context2 = manager.createRestoreSuiteContext();
+
+ Assert.assertNotNull("Context should have been created", context2);
+ Assert.assertFalse("Restore of context should return same instance", context.equals(context2));
+ }
+
+ @Test
+ public void shouldBeAbleToCreateRestoreClassContext() throws Exception
+ {
+ ContextLifecycleManager manager = new ContextLifecycleManager(profileBuilder, serviceLoader);
+
+ // Create a new
+ manager.createRestoreSuiteContext();
+
+ ClassContext context = manager.createRestoreClassContext(getClass());
+ Assert.assertNotNull("Context should have been created", context);
+
+ ClassContext context2 = manager.createRestoreClassContext(getClass());
+ Assert.assertNotNull("Context should have been created", context2);
+ Assert.assertTrue("Restore of context should return same instance", context.equals(context2));
+
+ manager.destroyClassContext(getClass());
+
+ context2 = manager.createRestoreClassContext(getClass());
+
+ Assert.assertNotNull("Context should have been created", context2);
+ Assert.assertFalse("Restore of context should return same instance", context.equals(context2));
+ }
+
+ @Test
+ public void shouldBeAbleToCreateRestoreTestContext() throws Exception
+ {
+ ContextLifecycleManager manager = new ContextLifecycleManager(profileBuilder, serviceLoader);
+
+ // Create a new
+ manager.createRestoreSuiteContext();
+ manager.createRestoreClassContext(getClass());
+
+ TestContext context = manager.createRestoreTestContext(this);
+ Assert.assertNotNull("Context should have been created", context);
+
+ TestContext context2 = manager.createRestoreTestContext(this);
+ Assert.assertNotNull("Context should have been created", context2);
+ Assert.assertTrue("Restore of context should return same instance", context.equals(context2));
+
+ manager.destroyTestContext(this);
+
+ context2 = manager.createRestoreTestContext(this);
+
+ Assert.assertNotNull("Context should have been created", context2);
+ Assert.assertFalse("Restore of context should return same instance", context.equals(context2));
+ }
+
+ @Test
+ public void shouldBeAbleToFireUpwards() throws Exception
+ {
+ Before event = new Before(getClass(), getClass().getMethod("shouldBeAbleToFireUpwards"));
+ ContextLifecycleManager manager = new ContextLifecycleManager(profileBuilder, serviceLoader);
+
+ SuiteContext suiteContext = manager.createRestoreSuiteContext();
+ suiteContext.register(Before.class, suiteEventHandler);
+
+ ClassContext classContext = manager.createRestoreClassContext(getClass());
+ classContext.register(Before.class, classEventHandler);
+
+ TestContext testContext = manager.createRestoreTestContext(this);
+ testContext.register(Before.class, testEventHandler);
+
+ testContext.fire(event);
+
+ Mockito.verify(suiteEventHandler, Mockito.times(1)).callback(suiteContext, event);
+ Mockito.verify(classEventHandler, Mockito.times(1)).callback(classContext, event);
+ Mockito.verify(testEventHandler, Mockito.times(1)).callback(testContext, event);
+ }
+}
Deleted: arquillian/trunk/impl-base/src/test/java/org/jboss/arquillian/impl/event/ContextLifecycleManagerTestCase.java
===================================================================
--- arquillian/trunk/impl-base/src/test/java/org/jboss/arquillian/impl/event/ContextLifecycleManagerTestCase.java 2010-04-20 15:02:38 UTC (rev 4269)
+++ arquillian/trunk/impl-base/src/test/java/org/jboss/arquillian/impl/event/ContextLifecycleManagerTestCase.java 2010-04-20 15:05:59 UTC (rev 4270)
@@ -1,154 +0,0 @@
-/*
- * 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.event;
-
-import junit.framework.Assert;
-
-import org.jboss.arquillian.impl.context.ClassContext;
-import org.jboss.arquillian.impl.context.ContextLifecycleManager;
-import org.jboss.arquillian.impl.context.ProfileBuilder;
-import org.jboss.arquillian.impl.context.SuiteContext;
-import org.jboss.arquillian.impl.context.TestContext;
-import org.jboss.arquillian.impl.event.type.Before;
-import org.jboss.arquillian.impl.event.type.ClassEvent;
-import org.jboss.arquillian.impl.event.type.SuiteEvent;
-import org.jboss.arquillian.impl.event.type.TestEvent;
-import org.jboss.arquillian.spi.ServiceLoader;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
-
-
-/**
- * Test Case to verify context create/restore and event propagation model.
- *
- * @author <a href="mailto:aknutsen at redhat.com">Aslak Knutsen</a>
- * @version $Revision: $
- */
- at RunWith(MockitoJUnitRunner.class)
-public class ContextLifecycleManagerTestCase
-{
- @Mock
- private ServiceLoader serviceLoader;
-
- @Mock
- private ProfileBuilder profileBuilder;
-
- @Mock
- private EventHandler<SuiteContext, SuiteEvent> suiteEventHandler;
-
- @Mock
- private EventHandler<ClassContext, ClassEvent> classEventHandler;
-
- @Mock
- private EventHandler<TestContext, TestEvent> testEventHandler;
-
- @Test
- public void shouldBeAbleToCreateRestoreSuiteContext() throws Exception
- {
- ContextLifecycleManager manager = new ContextLifecycleManager(profileBuilder, serviceLoader);
-
- // Create a new
- SuiteContext context = manager.createRestoreSuiteContext();
-
- Assert.assertNotNull("Context should have been created", context);
-
- // Restore
- SuiteContext context2 = manager.createRestoreSuiteContext();
-
- Assert.assertNotNull("Context should have been created", context2);
- Assert.assertTrue("Restore of context should return same instance", context.equals(context2));
-
- // Destroy and create a new
- manager.destroySuiteContext();
- context2 = manager.createRestoreSuiteContext();
-
- Assert.assertNotNull("Context should have been created", context2);
- Assert.assertFalse("Restore of context should return same instance", context.equals(context2));
- }
-
- @Test
- public void shouldBeAbleToCreateRestoreClassContext() throws Exception
- {
- ContextLifecycleManager manager = new ContextLifecycleManager(profileBuilder, serviceLoader);
-
- // Create a new
- manager.createRestoreSuiteContext();
-
- ClassContext context = manager.createRestoreClassContext(getClass());
- Assert.assertNotNull("Context should have been created", context);
-
- ClassContext context2 = manager.createRestoreClassContext(getClass());
- Assert.assertNotNull("Context should have been created", context2);
- Assert.assertTrue("Restore of context should return same instance", context.equals(context2));
-
- manager.destroyClassContext(getClass());
-
- context2 = manager.createRestoreClassContext(getClass());
-
- Assert.assertNotNull("Context should have been created", context2);
- Assert.assertFalse("Restore of context should return same instance", context.equals(context2));
- }
-
- @Test
- public void shouldBeAbleToCreateRestoreTestContext() throws Exception
- {
- ContextLifecycleManager manager = new ContextLifecycleManager(profileBuilder, serviceLoader);
-
- // Create a new
- manager.createRestoreSuiteContext();
- manager.createRestoreClassContext(getClass());
-
- TestContext context = manager.createRestoreTestContext(this);
- Assert.assertNotNull("Context should have been created", context);
-
- TestContext context2 = manager.createRestoreTestContext(this);
- Assert.assertNotNull("Context should have been created", context2);
- Assert.assertTrue("Restore of context should return same instance", context.equals(context2));
-
- manager.destroyTestContext(this);
-
- context2 = manager.createRestoreTestContext(this);
-
- Assert.assertNotNull("Context should have been created", context2);
- Assert.assertFalse("Restore of context should return same instance", context.equals(context2));
- }
-
- @Test
- public void shouldBeAbleToFireUpwards() throws Exception
- {
- Before event = new Before(getClass(), getClass().getMethod("shouldBeAbleToFireUpwards"));
- ContextLifecycleManager manager = new ContextLifecycleManager(profileBuilder, serviceLoader);
-
- SuiteContext suiteContext = manager.createRestoreSuiteContext();
- suiteContext.register(Before.class, suiteEventHandler);
-
- ClassContext classContext = manager.createRestoreClassContext(getClass());
- classContext.register(Before.class, classEventHandler);
-
- TestContext testContext = manager.createRestoreTestContext(this);
- testContext.register(Before.class, testEventHandler);
-
- testContext.fire(event);
-
- Mockito.verify(suiteEventHandler, Mockito.times(1)).callback(suiteContext, event);
- Mockito.verify(classEventHandler, Mockito.times(1)).callback(classContext, event);
- Mockito.verify(testEventHandler, Mockito.times(1)).callback(testContext, event);
- }
-}
More information about the jboss-svn-commits
mailing list