Package org.jboss.jbossas.servermanager

Examples of org.jboss.jbossas.servermanager.Server


   }

   @Override
   public void stop() throws LifecycleException
   {
      Server server = serverManager.getServer(configuration.getProfileName());
      if (!server.isRunning())
      {
         throw new LifecycleException("Can not stop server. Server is not started");
      }

      try
      {
         serverManager.stopServer(server.getName());
      }
      catch (Exception e)
      {
         throw new LifecycleException("Could not stop server", e);
      }
View Full Code Here


      return manager;
   }

   private Server createAndConfigureServer(JBossASConfiguration configuration)
   {
      Server server = new Server();
      server.setName(configuration.getProfileName());
      server.setHttpPort(configuration.getHttpPort());
      server.setRmiPort(configuration.getRmiPort());
      server.setHost(configuration.getBindAddress());
      server.setHasWebServer(!configuration.isUseRmiPortForAliveCheck());

      server.setUsername(configuration.getUsername());
      server.setPassword(configuration.getPassword());
     
      if (configuration.getPartition() != null) {
          server.setPartition(configuration.getPartition());
      }
      else {
          server.setPartition(Long.toHexString(System.currentTimeMillis()));
      }

      // Set server's JVM arguments
      setServerVMArgs(server, configuration.getJavaVmArguments());

      // Set server's system properties
      Property prop = new Property();
      prop.setKey("jbosstest.udp.ip_ttl");
      prop.setValue("0");
      server.addSysProperty(prop);
      prop = new Property();
      prop.setKey("java.endorsed.dirs");
      prop.setValue(new File(configuration.getJbossHome(), "lib/endorsed").getAbsolutePath());
      server.addSysProperty(prop);

      return server;
   }
View Full Code Here

    */
   @Test
   public void testFailStart() throws Throwable
   {
      // Create test server
      Server server = new IgnoreStopServer();
      server.setName(SERVER_NAME);

      // Add the Server to the Manager
      TimeoutConfigurableMananager manager = (TimeoutConfigurableMananager) getServerManager();
      AsLifecycleDelegate.applyServerDefaults(server, manager);

      boolean timedOut = false;

      manager.setStartupTimeout(-1);

      // Start server
      try
      {
         ServerController.startServer(server, manager);
      }
      catch (IOException e)
      {
         if (e.toString().matches(".*start in time.*"))
         {
            timedOut = true;
         }
         else
         {
            throw e;
         }
      }

      // check server timed out and is destroyed
      TestCase.assertTrue("Server started successfully, but should not", timedOut);

      try
      {
         // exitValue() only returns if process has ended.
         server.getProcess().exitValue();
         // the process has ended, that's fine
      }
      catch (IllegalThreadStateException e)
      {
         TestCase.assertTrue("Server process was not terminated", false);
View Full Code Here

   @After
   public void after() throws Throwable
   {
      // Obtain the server
      TimeoutConfigurableMananager manager = (TimeoutConfigurableMananager) getServerManager();
      Server server = manager.getServer(SERVER_NAME);

      // If started/running
      if (ServerController.isServerStarted(server))
      {
         // Stop
View Full Code Here

   @Test
   public void testStart() throws Throwable
   {
      // Obtain the server
      ServerManager manager = getDelegate().getServerManager();
      Server server = manager.getServer(SERVER_NAME);

      // Ensure we read that it's up
      TestCase.assertTrue("The server has not been started.", ServerController.isServerStarted(server));
   }
View Full Code Here

   @Test
   public void testRestart() throws Throwable
   {
      // Obtain the server
      ServerManager manager = getDelegate().getServerManager();
      Server server = manager.getServer(SERVER_NAME);

      // Ensure we read that it's up
      TestCase.assertTrue("The server has not been started.", ServerController.isServerStarted(server));

      // Bring the server down
View Full Code Here

    */
   @Test
   public void testJmxInvocation() throws Exception
   {
      // Get the Server
      Server server = getDelegate().getServerManager().getServer(SERVER_NAME);

      /*
       * Deploy the test SAR into the Server
       */

      // Construct the deployable path name
      //TODO This whole section is Hacky as Maven doesn't let you define
      // an explicit name for your assembly, so we search for the right file by name
      String baseDirName = this.getBaseDirName();
      File buildDir = new File(baseDirName + "/target");
      assert (buildDir != null && buildDir.exists() && buildDir.isDirectory()) : baseDirName
            + " must be a valid directory";
      File[] files = buildDir.listFiles();
      File deployable = null;
      // For each file in the build directory
      for (File file : files)
      {
         // Look for the deployable one we want by name
         if (file.getName().contains(FILENAME_JMXINVOCATION_TEST))
         {
            deployable = file;
            break;
         }
      }
      assert deployable != null : "Deployable file could not be found";

      // Deploy
      server.deploy(deployable);

      /*
       * Invoke upon the Server
       */

      // Construct the ObjectName
      ObjectName name = new ObjectName(INVOCATION_OBJECT_NAME);

      // Invoke
      Object result = server.invoke(name, INVOCATION_METHOD_NAME, new Object[]
      {}, new String[]
      {});

      /*
       * Test the invocation result
View Full Code Here

   @AfterClass
   public static void afterClass() throws Throwable
   {
      // Obtain the server
      ServerManager manager = delegate.getServerManager();
      Server server = manager.getServer(SERVER_NAME);

      // If started/running
      if (ServerController.isServerStarted(server))
      {
         getDelegate().stopJbossAs(SERVER_NAME);
View Full Code Here

    *
    * @throws Throwable
    */
   public void startJbossAs(String serverName) throws Throwable
   {
      Server server = null;

      // Get ServerManager
      ServerManager manager = this.getServerManager();

      try
      {
         server = manager.getServer(serverName);
      }
      catch (IllegalArgumentException e)
      {
         // Create the Server
         server = new Server();
         server.setName(serverName);

         // Add a Server to the Manager with defaults
         applyServerDefaults(server, manager);
      }

View Full Code Here

    */
   public void stopJbossAs(String serverName) throws Throwable
   {
      // Obtain the server
      ServerManager manager = this.getServerManager();
      Server server = manager.getServer(serverName);

      // If started/running
      if (ServerController.isServerStarted(server))
      {
         // Stop
View Full Code Here

TOP

Related Classes of org.jboss.jbossas.servermanager.Server

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.