7 Replies Latest reply on Oct 28, 2010 4:04 AM by hugirat

    why should i need to know the path to Glassfish in Remote Testing

    hugirat

      hello,

      why i need to know where is glassfish when i test with glassfish remote. isn't Arquillian.xml enogh to set the address to glassfish?

       

      best Regards

      Yahya

        • 1. Re: why should i need to know the path to Glassfish in Remote Testing
          aslak

          What needs to know where it is?

           

          The valid and only configuration options for GlassFish Remote 3 are:

          http://docs.jboss.org/arquillian/reference/latest/en-US/html_single/#container.glassfish-remote-3

          • 2. Re: why should i need to know the path to Glassfish in Remote Testing
            hugirat

            I'm starting to get the impression that I have misunderstood something

            so the situation is the following,

            I want to test webservices in Remote glassfish.

            so i have donn the following:

            @RunWith(Arquillian.class)
            @Run(RunModeType.AS_CLIENT) //RunModeType.IN_CONTAINER)

             

               /**
                * Deployment for the test
                * @return
                */

             

             

             

            public class EmployeeWSTest {

             

                @Deployment
               public static WebArchive getDeployment()
               {
                  return ShrinkWrap.create(WebArchive.class, "test.war").addClasses(EmployeeWS.class,employee.Employeebean.class,employee.Employee.class)
                  .addManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
               }
                @Inject  EmployeeWS webservice;
                public EmployeeWSTest() {
                }

             

                @BeforeClass
               public static void startContainer() throws Exception
               {
                  Runtime.getRuntime().exec(new String[] {
                        getAsadminCommand(),
                        "start-domain",
                        "tests"}).waitFor();
               }
                @AfterClass
                public static void stopContainer() throws Exception
               {
                  Runtime.getRuntime().exec(new String[] {
                        getAsadminCommand(),
                        "stop-domain",
                        "tests"}).waitFor();
               }

             

                @Before
                public void setUp() {
                }

             

                @After
                public void tearDown() {
                }

             

                /**
                 * Test of getEmployee method, of class NewWebService.
                 */
                @Test
                public void testGetEmployee() {
                    System.out.println("getEmployee");
                    webservice = new EmployeeWS();
                    String expResult = "yahya";
                    String result = webservice.getEmployee();
                    Assert.assertEquals(expResult, result);

             

                }
                 @Test
                 public void testSetEmployee(){
                    System.out.println("getEmployee");
                   webservice =new EmployeeWS();
                    boolean expected=true;
                    boolean result=webservice.setName("Test");
                    Assert.assertEquals(expected, result);
                 }

             

                public static String getAsadminCommand()
               {

             

                  File asadminFile = new File("/serv/glassfishv3/bin/./asadmin"); locally i have another path, this path for Hudson.
                  System.out.println(asadminFile.toString());
                  if (!asadminFile.exists() || !asadminFile.isFile())
                  {
                     Assert.fail("Path to asadmin command is invalid: " + asadminFile.getAbsolutePath());
                  }
                  return asadminFile.getAbsolutePath();
               }

             

            locally it had worked fine. but with hudson i get the following error:

             

            -do-test-run:
            [junit] Testsuite: employeews.EmployeeWSTest     [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0.075 sec     [junit]      [junit] Testcase: initializationError(employeews.EmployeeWSTest):     Caused an ERROR     [junit] org.jboss.arquillian.spi.LifecycleException: Could not connect to container     [junit] org.jboss.arquillian.impl.event.FiredEventException: org.jboss.arquillian.spi.LifecycleException: Could not connect to container     [junit]      at org.jboss.arquillian.impl.event.MapEventManager.fire(MapEventManager.java:68)     [junit]      at org.jboss.arquillian.impl.context.AbstractEventContext.fire(AbstractEventContext.java:115)     [junit]      at org.jboss.arquillian.impl.EventTestRunnerAdaptor.beforeSuite(EventTestRunnerAdaptor.java:68)     [junit]      at org.jboss.arquillian.junit.Arquillian.<init>(Arquillian.java:89)     [junit]      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)     [junit]      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)     [junit] Caused by: org.jboss.arquillian.spi.LifecycleException: Could not connect to container     [junit]      at org.jboss.arquillian.container.jsr88.remote_1_2.JSR88RemoteContainer.start(JSR88RemoteContainer.java:108)     [junit]      at org.jboss.arquillian.impl.handler.ContainerStarter.callback(ContainerStarter.java:52)     [junit]      at org.jboss.arquillian.impl.handler.ContainerStarter.callback(ContainerStarter.java:41)     [junit]      at org.jboss.arquillian.impl.event.MapEventManager.fire(MapEventManager.java:63)     [junit] Caused by: java.lang.ClassNotFoundException: org.glassfish.deployapi.SunDeploymentFactory     [junit]      at java.net.URLClassLoader$1.run(URLClassLoader.java:200)     [junit]      at java.security.AccessController.doPrivileged(Native Method)     [junit]      at java.net.URLClassLoader.findClass(URLClassLoader.java:188)     [junit]      at java.lang.ClassLoader.loadClass(ClassLoader.java:303)     [junit]      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)     [junit]      at java.lang.ClassLoader.loadClass(ClassLoader.java:248)     [junit]      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)     [junit]      at java.lang.Class.forName0(Native Method)     [junit]      at java.lang.Class.forName(Class.java:169)     [junit]      at org.jboss.arquillian.container.jsr88.remote_1_2.JSR88RemoteContainer.initDeploymentManager(JSR88RemoteContainer.java:240)     [junit]      at org.jboss.arquillian.container.jsr88.remote_1_2.JSR88RemoteContainer.start(JSR88RemoteContainer.java:101)     [junit]      [junit]      [junit] Test employeews.EmployeeWSTest FAILED
            I know that I have the path to the container wrong configured. then I though it would be better to use arquillian.xml to set the address to container but it didn't worked.
            cann you plz tell me what is the best way to test ws. ?
            • 3. Re: why should i need to know the path to Glassfish in Remote Testing
              aslak

              @BeforeClass/AfterClass will only work correctly in some embedded containers:  https://jira.jboss.org/browse/ARQ-56

               

              The GlassFish Remote Container will connect to a running instance, and it tries to do that long before BeforeClass is called. If you manually start the tests domain, point your Aarquillian configuration to the running instance and remove everything that has to do with starting the container.. it should work

              1 of 1 people found this helpful
              • 4. Re: why should i need to know the path to Glassfish in Remote Testing
                hugirat

                thank you for your reply,

                it still doesn't work, but now i have another error

                with this arquillian.xml:

                 

                <arquillian xmlns="http://jboss.com/arquillian"

                 

                        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                 

                        xmlns:jboss="urn:arq:org.jboss.arquillian.container.glassfish.remote_3">

                 


                    <glassfish-remote:container>
                      <glassfish-remote:deploymentUri>deployer:Sun:AppServer::sddev:4848</glassfish-remote:deploymentUri>
                      <glassfish-remote:remoteServerAddress>sddev</glassfish-remote:remoteServerAddress>
                      <glassfish-remote:remoteServerHttpPort>8585</glassfish-remote:remoteServerHttpPort>
                   </glassfish-remote:container>

                 

                </arquillian>

                 

                dan had posted it. I just changed the port and the address

                and i have emited the @BeforClass/AfterClass

                 

                this is the error what i get:

                do-test-run:
                    [junit] Testsuite: employeews.EmployeeWSTest
                    [junit] Oct 20, 2010 3:10:21 PM org.jboss.arquillian.impl.XmlConfigurationBuilder loadArquillianConfiguration
                    [junit] INFO: building configuration from XML file: arquillian.xml
                    [junit] [Fatal Error] :12:33: The prefix "glassfish-remote" for element "glassfish-remote:container" is not bound.
                    [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0.04 sec
                    [junit]
                    [junit] ------------- Standard Error -----------------
                    [junit] Oct 20, 2010 3:10:21 PM org.jboss.arquillian.impl.XmlConfigurationBuilder loadArquillianConfiguration
                    [junit] INFO: building configuration from XML file: arquillian.xml
                    [junit] [Fatal Error] :12:33: The prefix "glassfish-remote" for element "glassfish-remote:container" is not bound.
                    [junit] ------------- ---------------- ---------------
                    [junit] Testcase: initializationError(employeews.EmployeeWSTest):     Caused an ERROR
                    [junit] Could not create configuration
                    [junit] org.jboss.arquillian.spi.ConfigurationException: Could not create configuration
                    [junit]      at org.jboss.arquillian.impl.XmlConfigurationBuilder.build(XmlConfigurationBuilder.java:132)
                    [junit]      at org.jboss.arquillian.junit.Arquillian.<init>(Arquillian.java:84)
                    [junit]      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
                    [junit]      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
                    [junit] Caused by: org.xml.sax.SAXParseException: The prefix "glassfish-remote" for element "glassfish-remote:container" is not bound.
                    [junit]      at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:239)
                    [junit]      at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:283)
                    [junit]      at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:124)
                    [junit]      at org.jboss.arquillian.impl.XmlConfigurationBuilder.getDocument(XmlConfigurationBuilder.java:333)
                    [junit]      at org.jboss.arquillian.impl.XmlConfigurationBuilder.loadArquillianConfiguration(XmlConfigurationBuilder.java:149)
                    [junit]      at org.jboss.arquillian.impl.XmlConfigurationBuilder.build(XmlConfigurationBuilder.java:122)
                    [junit]
                    [junit]
                    [junit] Test employeews.EmployeeWSTest FAILED

                • 5. Re: why should i need to know the path to Glassfish in Remote Testing
                  aslak

                  your aliasing the glassfish namespace with jboss and refering to it in your contianer element as glassfish-remote..

                   

                  xmlns:jboss="urn:arq:org.jboss.arquillian.container.glassfish.remote_3"

                   

                  should be:

                  xmlns:glassfish-remote="urn:arq:org.jboss.arquillian.container.glassfish.remote_3"

                  1 of 1 people found this helpful
                  • 6. Re: why should i need to know the path to Glassfish in Remote Testing
                    hugirat

                    I have thought jboss i becouse of the company

                    it worked form the IDE manually started, with your help.

                    • 7. Re: why should i need to know the path to Glassfish in Remote Testing
                      hugirat
                      hello Aslak,
                      after i have added the demplyment-client i started to get this error:
                      -do-test-run:
                      [junit] Testsuite: employeews.EmployeeWSTest   
                      [junit] Oct 28, 2010 9:55:22 AM org.jboss.arquillian.impl.XmlConfigurationBuilder loadArquillianConfiguration   
                      [junit] INFO: building configuration from XML file: arquillian.xml   
                      [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0.248 sec   
                      [junit]    
                      [junit] ------------- Standard Error -----------------     [
                      junit] Oct 28, 2010 9:55:22 AM org.jboss.arquillian.impl.XmlConfigurationBuilder loadArquillianConfiguration   
                      [junit] INFO: building configuration from XML file: arquillian.xml   
                      [junit] ------------- ---------------- ---------------   
                      [junit] Testcase: initializationError(employeews.EmployeeWSTest):     Caused an ERROR   
                      [junit] com/sun/enterprise/util/LocalStringManagerImpl   
                      [junit] java.lang.NoClassDefFoundError: com/sun/enterprise/util/LocalStringManagerImpl   
                      [junit]      at org.glassfish.deployapi.SunDeploymentFactory.<clinit>(SunDeploymentFactory.java:57)   
                      [junit]      at java.lang.Class.forName0(Native Method)   
                      [junit]      at java.lang.Class.forName(Class.java:169)   
                      [junit]      at org.jboss.arquillian.container.jsr88.remote_1_2.JSR88RemoteContainer.initDeploymentManager(JSR88RemoteContainer.java:240)   
                      [junit]      at org.jboss.arquillian.container.jsr88.remote_1_2.JSR88RemoteContainer.start(JSR88RemoteContainer.java:101)   
                      [junit]      at org.jboss.arquillian.impl.handler.ContainerStarter.callback(ContainerStarter.java:52)   
                      [junit]      at org.jboss.arquillian.impl.handler.ContainerStarter.callback(ContainerStarter.java:41)   
                      [junit]      at org.jboss.arquillian.impl.event.MapEventManager.fire(MapEventManager.java:63)   
                      [junit]      at org.jboss.arquillian.impl.context.AbstractEventContext.fire(AbstractEventContext.java:115)   
                      [junit]      at org.jboss.arquillian.impl.EventTestRunnerAdaptor.beforeSuite(EventTestRunnerAdaptor.java:68)   
                      [junit]      at org.jboss.arquillian.junit.Arquillian.<init>(Arquillian.java:89)   
                      [junit]      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)   
                      [junit]      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)   
                      [junit] Caused by: java.lang.ClassNotFoundException: com.sun.enterprise.util.LocalStringManagerImpl   
                      [junit]      at java.net.URLClassLoader$1.run(URLClassLoader.java:200)   
                      [junit]      at java.security.AccessController.doPrivileged(Native Method)   
                      [junit]      at java.net.URLClassLoader.findClass(URLClassLoader.java:188)   
                      [junit]      at java.lang.ClassLoader.loadClass(ClassLoader.java:303)   
                      [junit]      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)   
                      [junit]      at java.lang.ClassLoader.loadClass(ClassLoader.java:248)   
                      [junit]      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)   
                      [junit]    
                      [junit]
                      [junit] Test employeews.EmployeeWSTest FAILED 
                      test-report: