Angularjs

Run
How to run the sample
The source code for this sample can be found in the javaee7-samples GitHub repository. The first thing we need to do is to get the source by downloading the repository and then go into the samples folder:
git clone git://github.com/javaee-samples/javaee7-samples.git
cd javaee7-samples/jaxrs/angularjs/
Now we are ready to start testing. You can run all the tests in this sample by executing:
mvn test
Or you can run individual tests by executing one of the following:
mvn test -Dtest=NoteResourceImplTest

Angular JS consuming REST services

NoteResourceImplTest

Missing a description for the story. Add some javadoc to the TestClass. Show me how!
Missing a description for the deployment. Add some javadoc to the @Deployment method. Show me how!
@Deployment
public static Archive createDeployment()
{
    final GenericArchive webResources = ShrinkWrap.create(GenericArchive.class)
        .as(ExplodedImporter.class)
        .importDirectory("src/main/webapp")
        .as(GenericArchive.class);
    final File[] seleniumApi = Maven.resolver()
        .loadPomFromFile("pom.xml")
        .resolve("org.seleniumhq.selenium:selenium-api:2.35.0")
        .withTransitivity()
        .asFile();
    return ShrinkWrap.create(WebArchive.class, NoteResourceImplTest.class.getSimpleName() + ".war")
        .addClasses(Note.class, NoteApp.class, NoteResource.class, NoteResourceImpl.class)
        .addAsResource("META-INF/persistence.xml")
        .addAsWebInfResource("enforce-beans.xml", "jboss-all.xml")
        .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
        .addAsLibraries(seleniumApi)
        .merge(webResources);
}
@Test
@InSequence(1)
public void setupDB_ARQ1077_Workaround()
{
}
Missing a description for the test scenario. Add some javadoc to the @Test method. Show me how!
@Test
@InSequence(3)
public void setupDB_ARQ1077_Workaround_2()
{
}
Missing a description for the test scenario. Add some javadoc to the @Test method. Show me how!
@Test
@InSequence(5)
public void setupDB_ARQ1077_Workaround_3()
{
}
Missing a description for the test scenario. Add some javadoc to the @Test method. Show me how!
@InSequence(4)
@RunAsClient
@Test
public void addNewNote(@ArquillianResource URL deploymentURL, @Drone WebDriver driver) throws Exception
{
//        Given
    driver.navigate().to(deploymentURL);
    final TodoPage page = GrapheneRuntime.getInstance().goTo(TodoPage.class);
    assertEquals(3, page.getTodos().size());
//        When
    page.addNote();
    page.typeTitle("New title");
    page.typeSummary("New summary");
    page.save();
//        Then
    assertEquals(4, page.getTodos().size());
    assertEquals("New title", page.getTodos().get(3).getTitle());
    assertEquals("New summary", page.getTodos().get(3).getSummary());
}
Missing a description for the test scenario. Add some javadoc to the @Test method. Show me how!
@InSequence(2)
@RunAsClient
@Test
public void onenterContainsNotesFromDB(@ArquillianResource URL deploymentURL, @Drone WebDriver driver)
{
//        Given
//        When
    driver.navigate().to(deploymentURL);
    final TodoPage page = GrapheneRuntime.getInstance().goTo(TodoPage.class);
//        Then
    assertEquals(3, page.getTodos().size());
    assertEquals("Note A", page.getTodos().get(0).getTitle());
    assertEquals("Note B", page.getTodos().get(1).getTitle());
    assertEquals("Note C", page.getTodos().get(2).getTitle());
}
Missing a description for the test scenario. Add some javadoc to the @Test method. Show me how!
@InSequence(6)
@RunAsClient
@Test
public void removeNote(@ArquillianResource URL deploymentURL, @Drone WebDriver driver) throws Exception
{
//        Given
    driver.navigate().to(deploymentURL);
    final TodoPage page = GrapheneRuntime.getInstance().goTo(TodoPage.class);
    assertEquals(3, page.getTodos().size());
//        When
    page.getTodos().get(0).remove();
//        Then
    assertEquals("Note B", page.getTodos().get(0).getTitle());
    assertEquals("Note C", page.getTodos().get(1).getTitle());
}

Share the Knowledge

Find this sample useful? Share on

There's a lot more about JavaEE to cover. If you're ready to learn more, check out the other available samples.

Help Improve

Find a bug in the sample? Something missing? You can fix it by editing the source, making the correction and sending a pull request. Or report the problem to the issue tracker

Recent Changelog

  • Oct 05, 2014: #252 fixed arquillian configuration for the jobs by John D. Ament
  • Aug 12, 2014: Enforcing weld to scan only those archives which have beans.xml in it. otherwise any other 3rd party library which is using jsr-330 annotations will cause the deployment in cdi 1.1 environment (java ee 7) to fail. for example guava used in angularjs tests. related issue: #245 by Bartosz Majsak
  • Jul 15, 2014: Removed header license. the licensing is now referenced in the license file in the root of the project by Roberto Cortez
  • Dec 03, 2013: #10 angular js consuming rest services by bernard
How to help improve this sample
The source code for this sample can be found in the javaee7-samples GitHub repository. The first thing you need to do is to get the source by downloading the repository and then go into the samples folder:
git clone git://github.com/javaee-samples/javaee7-samples.git
cd javaee7-samples/jaxrs/angularjs/

Do the changes as you see fit and send a pull request!

Good Luck!