Package org.apache.derby.drda

Examples of org.apache.derby.drda.NetworkServerControl


        }
  }

  private static void listProperties(String portString) throws Exception{
    int port = Integer.parseInt(portString);
    NetworkServerControl derbyServer = new NetworkServerControl( InetAddress.getByName("localhost"),
                          port);
    Properties p = derbyServer.getCurrentProperties();
    p.list(System.out);
  }
View Full Code Here


     * databases it has booted when started from the API.
     */
    public void testDatabasesShutDownWhenNSShutdown()
            throws Exception
    {
        server = new NetworkServerControl();
        // The server was started from the command line when the test was
        // started. Check that the database will be shut down when the server
        // is shut down.
        shutdownServerCheckDBShutDown(true);

View Full Code Here

                        portNumber = -1; // use the default
                    }
                    if( portNumber <= 0)
                        portNumber = NetworkServerControl.DEFAULT_PORTNUMBER;
                   
                    NetworkServerControl server = new NetworkServerControl(InetAddress.getByName(hostName),portNumber);
                    server.start(null);
          // Wait for server to come up
          for (int j = 0; j < 60; j++)
          {
            Thread.sleep(1000);
            if (isServerStarted(server))
View Full Code Here

    private static void stopServer( Process serverProcess)
    {
        try
        {
            NetworkServerControl server =
        new NetworkServerControl(InetAddress.getByName(hostName),
                   portNumber);
      server.shutdown();
            Thread.sleep(5000);
        }
        catch( Exception e)
        {
            System.out.println( "  Exception thrown while trying to shutdown the remote server.");
View Full Code Here

    public void doStart() throws Exception {
        InetAddress address = InetAddress.getByName(host);
     // set system property to enable Derby user authentication
        if ("false".equals(System.getProperty("derby.connection.requireAuthentication"))){
            network = new NetworkServerControl(address, port);
        } else {
            network = new NetworkServerControl(address, port, userName, userPassword);
        }       
        network.start(null); // todo work out how to add this to our log stream
        log.debug("Started on host " + host + ':' + port);
    }
View Full Code Here

    public void execute() throws BuildException {
        try {
            System.out.println("Stopping Derby");
            System.setProperty("derby.drda.portNumber", port);
            System.setProperty("derby.drda.host", "localhost");
            NetworkServerControl server = new NetworkServerControl();
            server.shutdown();
            try {Thread.sleep(2000);} catch (Exception ignored) {}

        } catch (Exception e) {
            throw new BuildException(e.getMessage());
        }
View Full Code Here

        try {
            System.out.println("Stopping Derby");
            System.setProperty("derby.system.home", database);
            System.setProperty("derby.drda.portNumber", port);
            System.setProperty("derby.drda.host", "localhost");
            NetworkServerControl server = new NetworkServerControl();
            server.start(new PrintWriter(System.out));
            try {Thread.sleep(2000);} catch (Exception ignored) {}
        } catch (Exception e) {
            throw new BuildException("Unable to load Derby driver");
        }
       
View Full Code Here

    throws Exception {
        try {
            // getting a networkservercontrol to shutdown the currently running
            // server, before setting the next security mechanism
            final TestConfiguration config = TestConfiguration.getCurrent();
            NetworkServerControl server = new NetworkServerControl(
                InetAddress.getByName(config.getHostName()),
                config.getPort(),
                config.getUserName(),
                config.getUserPassword());

            // shut down the server
            server.shutdown();
        } catch (Exception e) {
            if (!(e.getMessage().substring(0,17).equals("DRDA_InvalidValue")))
            {
                fail("unexpected error");
            }
        }

        setSystemProperty("derby.drda.securityMechanism",
                derby_drda_securityMechanism);
        try {
           
            // if the security mechanism isn't supported or invalid, getting a
            // networkservercontrol will fail.
            NetworkServerControl server2 = new NetworkServerControl(
                InetAddress.getByName(
                    TestConfiguration.getCurrent().getHostName()),
                    TestConfiguration.getCurrent().getPort());

            // For debugging, to make output come to console uncomment:
            //server2.start(new PrintWriter(System.out, true));
            // and comment out:
            server2.start(null);
            NetworkServerTestSetup.waitForServerStart(server2);
           
            if (derby_drda_securityMechanism.equals("") ||
                derby_drda_securityMechanism.equals("INVALID_VALUE"))
            {
View Full Code Here

     /**
     * @throws Exception
     */
    public void testTraceCommands() throws Exception
    {
        NetworkServerControl nsctrl = NetworkServerTestSetup.getNetworkServerControl();
        String derbySystemHome = getSystemProperty("derby.system.home");
        nsctrl.setTraceDirectory(derbySystemHome);
      
        nsctrl.trace(true);
        nsctrl.ping();
        assertTrue(fileExists(derbySystemHome+"/Server3.trace"));
        nsctrl.trace(false);
       
        // now try on a directory where we don't have permission
        // this won't actually cause a failure until we turn on tracing.
        // assume we don't have permission to write to root.
        nsctrl.setTraceDirectory("/");
       
        // attempt to turn on tracing to location where we don't have permisson
        try {
            nsctrl.trace(true);
            fail("Should have gotten an exception turning on tracing");
        } catch (Exception e) {
            // expected exception
        }
        // make sure we can still ping
        nsctrl.ping();
   
                       
    }
View Full Code Here

     */
    public void testPing() throws Exception
    {
        String currentHost = TestConfiguration.getCurrent().getHostName();
       
        NetworkServerControl nsctrl = NetworkServerTestSetup.getNetworkServerControl();
        nsctrl.ping();
       
        // Note:Cannot test ping with unknown host because it fails in
        // InetAddress.getByName()
       
        nsctrl = new NetworkServerControl(privInetAddressGetByName(currentHost), 9393);
        try {       
          nsctrl.ping();
          fail("Should not have been able to ping on port 9393");
        }catch (Exception e){
          // expected exception
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.derby.drda.NetworkServerControl

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.