From 3ed37af473f735cbdea74902051d4ec195a3fea8 Mon Sep 17 00:00:00 2001 From: John Ament Date: Thu, 24 Mar 2011 23:45:53 -0400 Subject: [PATCH] SEAM-50 Fix tests for booking example on jboss as 6 remote. Changed profile names to be itest. --- booking/pom.xml | 4 +- .../booking/inventory/HotelSearchTest.java | 43 +++++++++++++------ 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/booking/pom.xml b/booking/pom.xml index 657144d..8c5a6e8 100644 --- a/booking/pom.xml +++ b/booking/pom.xml @@ -303,7 +303,7 @@ - jbossas-remote-6 + itest-jbossas-remote org.jboss.arquillian.container @@ -384,7 +384,6 @@ - diff --git a/booking/src/test/java/org/jboss/seam/examples/booking/inventory/HotelSearchTest.java b/booking/src/test/java/org/jboss/seam/examples/booking/inventory/HotelSearchTest.java index 9d2f98f..7722a45 100644 --- a/booking/src/test/java/org/jboss/seam/examples/booking/inventory/HotelSearchTest.java +++ b/booking/src/test/java/org/jboss/seam/examples/booking/inventory/HotelSearchTest.java @@ -16,6 +16,7 @@ */ package org.jboss.seam.examples.booking.inventory; +import java.util.HashMap; import java.util.List; import javax.enterprise.inject.Instance; @@ -33,6 +34,10 @@ import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.jboss.weld.Container; +import org.jboss.weld.context.bound.BoundConversationContext; +import org.jboss.weld.context.bound.BoundRequest; +import org.jboss.weld.context.bound.MutableBoundRequest; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -54,9 +59,9 @@ public static Archive createTestArchive() { .addPackage(HotelSearch.class.getPackage()) .addPackage(Hotel.class.getPackage()) .addClasses(NoOpLogger.class) - .addAsLibraries(MavenArtifactResolver.resolve("joda-time:joda-time:1.6"), - MavenArtifactResolver.resolve("org.jboss.seam.international:seam-international-api:3.0.0.Alpha1"), - MavenArtifactResolver.resolve("org.jboss.seam.international:seam-international:3.0.0.Alpha1")) + .addAsLibraries( + MavenArtifactResolver.resolve("org.jboss.seam.solder:seam-solder:3.0.0.CR4"), + MavenArtifactResolver.resolve("org.jboss.seam.international:seam-international:3.0.0.CR4")) .addAsWebInfResource("test-persistence.xml", "classes/META-INF/persistence.xml") .addAsWebInfResource(new StringAsset(""), "beans.xml"); return war; @@ -84,17 +89,29 @@ public void prepareSeedData() throws Exception { @Test public void testSearch() throws Exception { prepareSeedData(); + BoundConversationContext ctx = null; + BoundRequest storage = new MutableBoundRequest(new HashMap(), new HashMap()); + try { + ctx = Container.instance().deploymentManager().instance().select(BoundConversationContext.class).get(); + ctx.associate(storage); + ctx.activate(); + criteria.setQuery("atlanta"); + hotelSearch.find(); + List hotels = hotelsInstance.get(); + Assert.assertEquals(1, hotels.size()); + Assert.assertEquals(hotels.get(0).getName(), "Doubletree Atlanta-Buckhead"); - criteria.setQuery("atlanta"); - hotelSearch.find(); - List hotels = hotelsInstance.get(); - Assert.assertEquals(1, hotels.size()); - Assert.assertEquals(hotels.get(0).getName(), "Doubletree Atlanta-Buckhead"); - - criteria.setQuery("boston"); - hotelSearch.find(); - hotels = hotelsInstance.get(); - Assert.assertEquals(0, hotels.size()); + criteria.setQuery("boston"); + hotelSearch.find(); + hotels = hotelsInstance.get(); + Assert.assertEquals(0, hotels.size()); + } + finally { + if (ctx != null && ctx.isActive()) { + ctx.deactivate(); + ctx.dissociate(storage); + } + } } }