Created
October 17, 2010 22:34
-
-
Save aruld/631392 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SakilaSearchTest { | |
static Server server; | |
@BeforeClass | |
public static void setUp() { | |
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); | |
sf.setResourceClasses(SakilaResource.class); | |
sf.getInInterceptors().add(new LoggingInInterceptor()); | |
sf.getOutInterceptors().add(new LoggingOutInterceptor()); | |
sf.setResourceProvider(SakilaResource.class, new SingletonResourceProvider(new SakilaResource())); | |
sf.setAddress("http://localhost:9000"); | |
server = sf.create(); | |
} | |
@Test | |
public void searchActors() { | |
//http://localhost:9000/sakila/searchActors?_s=firstname==PENELOPE | |
WebClient wc = WebClient.create("http://localhost:9000/sakila/searchActors?_s=firstname%3D%3DPENELOPE"); | |
Collection<? extends Actor> actors = wc.getCollection(Actor.class); | |
assertEquals(4, actors.size()); | |
} | |
@Test | |
public void searchFilms() { | |
//http://localhost:9000/sakila/searchFilms?_s=rating==PG;rentalduration!=0;title==SANTA* | |
WebClient wc = WebClient.create("http://localhost:9000/sakila/searchFilms?_s=rating%3D%3DPG;rentalduration%21%3D0;title%3D%3DSANTA*"); | |
Collection<? extends Film> films = wc.getCollection(Film.class); | |
assertEquals(1, films.size()); | |
} | |
@Test | |
public void searchRentals() { | |
//http://localhost:9000/sakila/searchRentals?_s=rentaldate=lt=2005-05-27T00:00:00.000%2B00:00 | |
WebClient wc = WebClient.create("http://localhost:9000/sakila/searchRentals?_s=rentaldate%3Dlt%3D2005-05-27T00:00:00.000%2B00:00"); | |
Collection<? extends Rental> rentals = wc.getCollection(Rental.class); | |
assertEquals(278, rentals.size()); | |
} | |
@AfterClass | |
public static void tearDown() { | |
server.destroy(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment