Examples of ProtocolServer


Examples of org.apache.james.protocols.api.ProtocolServer

   
    @Test
    public void testNoop() throws Exception {
        InetSocketAddress address = new InetSocketAddress("127.0.0.1", TestUtils.getFreePort());
       
        ProtocolServer server = null;
        try {
            String identifier = "id";
            TestPassCmdHandler factory = new TestPassCmdHandler();
           
            factory.add("valid", new MockMailbox(identifier));
            server = createServer(createProtocol(factory), address);
            server.bind();
           
            POP3Client client =  createClient();
            client.connect(address.getAddress().getHostAddress(), address.getPort());
           
            assertTrue(client.login("valid", "valid"));
            assertTrue(client.noop());
            assertTrue(client.logout());
          
        } finally {
            if (server != null) {
                server.unbind();
            }
        }
       
    }
View Full Code Here

Examples of org.apache.james.protocols.api.ProtocolServer

   
    @Test
    public void testRset() throws Exception {
        InetSocketAddress address = new InetSocketAddress("127.0.0.1", TestUtils.getFreePort());
       
        ProtocolServer server = null;
        try {
            String identifier = "id";
            TestPassCmdHandler factory = new TestPassCmdHandler();
           
            factory.add("valid", new MockMailbox(identifier, MESSAGE1));
            server = createServer(createProtocol(factory), address);
            server.bind();
           
            POP3Client client =  createClient();
            client.connect(address.getAddress().getHostAddress(), address.getPort());
           
            assertTrue(client.login("valid", "valid"));
            assertEquals(1, client.listMessages().length);
            assertTrue(client.deleteMessage(1));
            assertEquals(0, client.listMessages().length);
           
            // call RSET. After this the deleted mark should be removed again
            assertTrue(client.reset());
            assertEquals(1, client.listMessages().length);

            assertTrue(client.logout());
          
        } finally {
            if (server != null) {
                server.unbind();
            }
        }
       
    }
View Full Code Here

Examples of org.apache.james.protocols.api.ProtocolServer

   
    @Test
    public void testStat() throws Exception {
        InetSocketAddress address = new InetSocketAddress("127.0.0.1", TestUtils.getFreePort());
       
        ProtocolServer server = null;
        try {
            String identifier = "id";
            TestPassCmdHandler factory = new TestPassCmdHandler();
           
            factory.add("valid", new MockMailbox(identifier, MESSAGE1, MESSAGE2));
            server = createServer(createProtocol(factory), address);
            server.bind();
           
            POP3Client client =  createClient();
            client.connect(address.getAddress().getHostAddress(), address.getPort());
           
            assertTrue(client.login("valid", "valid"));
            POP3MessageInfo info = client.status();
            assertEquals((int)(MESSAGE1.meta.getSize() + MESSAGE2.meta.getSize()), info.size);
            assertEquals(2, info.number);
           
            assertTrue(client.logout());
          
        } finally {
            if (server != null) {
                server.unbind();
            }
        }
       
    }
View Full Code Here

Examples of org.apache.james.protocols.api.ProtocolServer

    }
    @Test
    public void testDifferentStates() throws Exception {
        InetSocketAddress address = new InetSocketAddress("127.0.0.1", TestUtils.getFreePort());
       
        ProtocolServer server = null;
        try {
            String identifier = "id";
            TestPassCmdHandler factory = new TestPassCmdHandler();
           
            factory.add("valid", new MockMailbox(identifier, MESSAGE1, MESSAGE2));
            server = createServer(createProtocol(factory), address);
            server.bind();
           
            POP3Client client =  createClient();
           
            client.connect(address.getAddress().getHostAddress(), address.getPort());
            assertNull(client.listMessages());
            assertNull(client.listUniqueIdentifiers());
            assertFalse(client.deleteMessage(1));
            assertNull(client.retrieveMessage(1));
            assertNull(client.retrieveMessageTop(1, 10));
            assertNull(client.status());
            assertFalse(client.reset());
            client.logout();
           
            client.connect(address.getAddress().getHostAddress(), address.getPort());

            assertTrue(client.login("valid", "valid"));
            assertNotNull(client.listMessages());
            assertNotNull(client.listUniqueIdentifiers());
            Reader reader = client.retrieveMessage(1);
            assertNotNull(reader);
            reader.close();
            assertNotNull(client.status());
            reader = client.retrieveMessageTop(1, 1);
            assertNotNull(reader);
            reader.close();
            assertTrue(client.deleteMessage(1));
            assertTrue(client.reset());

            assertTrue(client.logout());

        } finally {
            if (server != null) {
                server.unbind();
            }
        }
       
    }
View Full Code Here

Examples of org.apache.james.protocols.api.ProtocolServer

   
    @Test
    public void testAPop() throws Exception {
        InetSocketAddress address = new InetSocketAddress("127.0.0.1", TestUtils.getFreePort());
       
        ProtocolServer server = null;
        try {
            TestApopCmdHandler handler = new TestApopCmdHandler();
            server = createServer(createProtocol(handler), address);
            server.bind();
           
            POP3Client client =  createClient();
            client.connect(address.getAddress().getHostAddress(), address.getPort());
            String welcomeMessage = client.getReplyString();
           
            // check for valid syntax that include all info needed for APOP
            assertTrue(welcomeMessage.trim().matches("\\+OK \\<\\d+\\.\\d+@.+\\> .+"));
           
            int reply = client.sendCommand("APOP invalid invalid");
            assertEquals(POP3Reply.ERROR, reply);
           
            handler.add("valid", new MockMailbox("id"));
            reply = client.sendCommand("APOP valid valid");
            assertEquals(POP3Reply.OK, reply);
           
            assertTrue(client.logout());
          
        } finally {
            if (server != null) {
                server.unbind();
            }
        }
       
    }
View Full Code Here

Examples of org.apache.james.protocols.api.ProtocolServer

    @Override
    public void testMailWithoutBrackets() throws Exception {
        TestMessageHook hook = new TestMessageHook();
        InetSocketAddress address = new InetSocketAddress("127.0.0.1", TestUtils.getFreePort());
       
        ProtocolServer server = null;
        try {
            server = createServer(createProtocol(hook), address);
            server.bind();
           
            SMTPClient client = createClient();
            client.connect(address.getAddress().getHostAddress(), address.getPort());
            assertTrue(SMTPReply.isPositiveCompletion(client.getReplyCode()));
           
            client.helo("localhost");
            assertTrue(SMTPReply.isPositiveCompletion(client.getReplyCode()));

            client.mail(SENDER);
            assertTrue("Reply="+ client.getReplyString(), SMTPReply.isPositiveCompletion(client.getReplyCode()));
           
            client.quit();
            assertTrue("Reply="+ client.getReplyString(), SMTPReply.isPositiveCompletion(client.getReplyCode()));
            client.disconnect();

            Iterator<MailEnvelope> queued = hook.getQueued().iterator();
            assertFalse(queued.hasNext());

        } finally {
            if (server != null) {
                server.unbind();
            }
        }
       
    }
View Full Code Here

Examples of org.apache.james.protocols.api.ProtocolServer

    @Override
    public void testRcptWithoutBrackets() throws Exception {
        TestMessageHook hook = new TestMessageHook();
        InetSocketAddress address = new InetSocketAddress("127.0.0.1", TestUtils.getFreePort());
       
        ProtocolServer server = null;
        try {
            server = createServer(createProtocol(hook), address);
            server.bind();
           
            SMTPClient client = createClient();
            client.connect(address.getAddress().getHostAddress(), address.getPort());
            assertTrue(SMTPReply.isPositiveCompletion(client.getReplyCode()));
           
            client.helo("localhost");
            assertTrue(SMTPReply.isPositiveCompletion(client.getReplyCode()));

            client.setSender(SENDER);
            assertTrue("Reply="+ client.getReplyString(), SMTPReply.isPositiveCompletion(client.getReplyCode()));

            client.rcpt(RCPT1);
            assertTrue("Reply="+ client.getReplyString(), SMTPReply.isPositiveCompletion(client.getReplyCode()));
            client.quit();
            assertTrue("Reply="+ client.getReplyString(), SMTPReply.isPositiveCompletion(client.getReplyCode()));
            client.disconnect();

            Iterator<MailEnvelope> queued = hook.getQueued().iterator();
            assertFalse(queued.hasNext());

        } finally {
            if (server != null) {
                server.unbind();
            }
        }
    }
View Full Code Here

Examples of org.infinispan.server.core.ProtocolServer

      }
   }

   private void startProtocolServer(ProtocolServerConfiguration configuration) throws StartException {
      // Start the server and record it
      ProtocolServer server;
      try {
         server = serverClass.newInstance();
      } catch (Exception e) {
         throw ROOT_LOGGER.failedConnectorInstantiation(e, serverName);
      }
View Full Code Here

Examples of org.infinispan.server.core.ProtocolServer

      // Start HornetQ server
      HornetQBootstrapServer.main(new String[]{"hornetq-beans.xml"});
      // Start Infinispan remote data grid, listening on localhost:11222
      Main.main(new String[]{"-r", "hotrod"});

      ProtocolServer server = Main.getServer();
      EmbeddedCacheManager cm = Main.getCacheManager();
      Context ctx = new InitialContext();
      Connection con = null;
      try {
         con = ((ConnectionFactory) ctx.lookup("/ConnectionFactory"))
               .createConnection();
         con.start(); // Start delivery

         // Add a message producer to send invalidation messages to near cache clients
         Session s = con.createSession(false, Session.AUTO_ACKNOWLEDGE);

         // Set up the datagrid topic (TODO: Selective key/cache topics)
         Topic topic = (Topic) ctx.lookup("/topic/datagrid");

         // Add invalidation listener for default cache
         cm.getCache().addListener(new InvalidationProducer(s, topic));
      } finally {
         while (in.read() != -1) {}
         ctx.close();
         if (con != null) con.close();
         server.stop();
         cm.stop();
         System.exit(0);
      }
   }
View Full Code Here

Examples of org.jboss.as.process.protocol.ProtocolServer

        this.stdout = stdout;
        this.stderr = stderr;
        rng = new Random(new SecureRandom().nextLong());
        //noinspection ThisEscapedInObjectConstruction
        configuration.setConnectionHandler(new ProcessControllerServerHandler(this));
        final ProtocolServer server = new ProtocolServer(configuration);
        server.start();
        this.server = server;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.