/javaee-impl/src/test/java/org/jboss/forge/spec/cdi/BeansPluginTest.java

https://github.com/mikebrock/core · Java · 78 lines · 44 code · 10 blank · 24 comment · 0 complexity · 71a74825f7f5defb035a67c8afdf375e MD5 · raw file

  1. package org.jboss.forge.spec.cdi;
  2. /*
  3. * JBoss, Home of Professional Open Source
  4. * Copyright 2010, Red Hat, Inc., and individual contributors
  5. * by the @authors tag. See the copyright.txt in the distribution for a
  6. * full listing of individual contributors.
  7. *
  8. * This is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU Lesser General Public License as
  10. * published by the Free Software Foundation; either version 2.1 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This software is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this software; if not, write to the Free
  20. * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  21. * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  22. */
  23. import junit.framework.Assert;
  24. import org.jboss.arquillian.junit.Arquillian;
  25. import org.jboss.forge.parser.java.JavaSource;
  26. import org.jboss.forge.project.Project;
  27. import org.jboss.forge.project.dependencies.DependencyBuilder;
  28. import org.jboss.forge.project.facets.DependencyFacet;
  29. import org.jboss.forge.project.facets.JavaSourceFacet;
  30. import org.jboss.forge.project.facets.ResourceFacet;
  31. import org.jboss.forge.resources.java.JavaResource;
  32. import org.jboss.forge.spec.javaee.CDIFacet;
  33. import org.jboss.forge.test.AbstractShellTest;
  34. import org.junit.Test;
  35. import org.junit.runner.RunWith;
  36. /**
  37. * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
  38. */
  39. @RunWith(Arquillian.class)
  40. public class BeansPluginTest extends AbstractShellTest
  41. {
  42. @Test
  43. public void testBeansSetup() throws Exception
  44. {
  45. Project project = initializeJavaProject();
  46. queueInputLines("y", "1", "6", "y");
  47. getShell().execute("beans setup");
  48. project.getFacet(CDIFacet.class).getConfig();
  49. Assert.assertTrue(project.getFacet(DependencyFacet.class).hasDependency(
  50. DependencyBuilder.create("org.jboss.spec:jboss-javaee-6.0")));
  51. Assert.assertTrue(project.getFacet(ResourceFacet.class).getResource("META-INF/beans.xml").exists());
  52. }
  53. @Test
  54. public void testNewBean() throws Exception
  55. {
  56. Project project = initializeJavaProject();
  57. queueInputLines("");
  58. getShell().execute("beans setup");
  59. getShell().execute("beans new-bean --type foo.beans.ExampleBean --scoped REQUEST");
  60. JavaSourceFacet java = project.getFacet(JavaSourceFacet.class);
  61. JavaResource resource = java.getJavaResource("foo.beans.ExampleBean");
  62. Assert.assertTrue(resource.exists());
  63. JavaSource<?> source = resource.getJavaSource();
  64. Assert.assertNotNull(source);
  65. Assert.assertEquals("foo.beans", source.getPackage());
  66. project.getFacet(CDIFacet.class).getConfig();
  67. }
  68. }