Package com.bj58.spat.gaea.client.utility

Examples of com.bj58.spat.gaea.client.utility.AutoResetEvent


*/
public class PathMatcherTest {

    @Test
    public void test() {
        PathMatcher pathMatcher = new AntPathMatcher();

        String pattern = "/{a}/{b}/{c}";

        String sample = "/aa/bb/cc";

        Assert.assertTrue(pathMatcher.match(pattern, sample));

    }
View Full Code Here


    }


    @Test
    public void testPathMatch(){
        PathMatcher pathMatcher = new AntPathMatcher();
        String registeredPath = "/me/hello/{name}";
        String url = "/me/hello/renjun";
        Assert.assertTrue(pathMatcher.match(registeredPath, url));

        Map<String, String> values = pathMatcher.extractUriTemplateVariables(registeredPath, url);
        Assert.assertEquals(1, values.size());
        Assert.assertEquals("renjun", values.get("name"));

        System.out.println("OK testpathMatch");
View Full Code Here

        InputStream in = new BufferedInputStream(request.getInputStream());
        String content_type = request.getContentType();

        File tempDir = new File(config.getLocation());

        MultiPartInputStreamParser mpis = new MultiPartInputStreamParser(in, content_type, config, tempDir);
        mpis.setDeleteOnExit(true);
        return mpis;
    }
View Full Code Here

        InputStream in = new BufferedInputStream(super.getInputStream());
        String content_type = super.getContentType();

        File tempDir = new File(config.getLocation());

        multiParser = new MultiPartInputStreamParser(in, content_type, config, tempDir);
        multiParser.setDeleteOnExit(true);

        Collection<Part> parts = multiParser.getParts();

        int keyCount = queryStrings.size();
View Full Code Here

*/
public class EnterpriseUserTest {

  @Test
  public void TestUser() throws Exception {
    SESUser user = new SESUser();
    user.setUserID(1L);
    user.setState(1);

    Serializer serializer = new Serializer();
    byte[] buffer = serializer.Serialize(user);
    assertNotNull(buffer);
    Object obj = serializer.Derialize(buffer, SimpleClass.class);
View Full Code Here

    public byte[] receive(int sessionId, int queueLen) throws IOException, TimeoutException, Exception {
        WindowData wd = WaitWindows.get(sessionId);
        if (wd == null) {
            throw new Exception("Need invoke 'registerRec' method before invoke 'receive' method!");
        }
        AutoResetEvent event = wd.getEvent();
        int timeout = getReadTimeout(socketConfig.getReceiveTimeout(), queueLen);
        if (!event.waitOne(timeout)) {
            throw new TimeoutException("Receive data timeout or error!timeout:" + timeout + "ms,queue length:" + queueLen);
        }
        byte[] data = wd.getData();
        int offset = SFPStruct.Version;
        int len = ByteConverter.bytesToIntLittleEndian(data, offset);
View Full Code Here

        }
        return data;
    }

    public void registerRec(int sessionId) {
        AutoResetEvent event = new AutoResetEvent();
        WindowData wd = new WindowData(event);
        WaitWindows.put(sessionId, wd);
    }
View Full Code Here

*/
public class AutoResetEventTest {

  @Test
  public void testSet() throws InterruptedException {
    final AutoResetEvent event = new AutoResetEvent();
    Thread th = new Thread(new Runnable() {
      @Override
      public void run() {
        try {
          Thread.sleep(1000);
        } catch (InterruptedException ex) {
          Logger.getLogger(AutoResetEventTest.class.getName()).log(Level.SEVERE, null, ex);
        }
        event.set();
        System.out.println("send set signal!");
      }
    });
    th.run();
    System.out.println("start wait!");
    event.waitOne(10000);
    System.out.println("end wait!");
  }
View Full Code Here

    System.out.println("end wait!");
  }

  @Test
  public void testWaitOne() throws Exception {
    final AutoResetEvent event = new AutoResetEvent();
    event.set();
    event.set();
    System.out.println("stime:" + System.currentTimeMillis());
    event.waitOne(10000);
    event.waitOne(10000);
    event.waitOne(10000);
    event.waitOne(10000);
    System.out.println("time:" + System.currentTimeMillis());
  }
View Full Code Here

*/
public class AutoResetEventTest {

  @Test
  public void testSet() throws InterruptedException {
    final AutoResetEvent event = new AutoResetEvent();
    Thread th = new Thread(new Runnable() {
      @Override
      public void run() {
        try {
          Thread.sleep(1000);
        } catch (InterruptedException ex) {
          Logger.getLogger(AutoResetEventTest.class.getName()).log(Level.SEVERE, null, ex);
        }
        event.set();
        System.out.println("send set signal!");
      }
    });
    th.run();
    System.out.println("start wait!");
    event.waitOne(10000);
    System.out.println("end wait!");
  }
View Full Code Here

TOP

Related Classes of com.bj58.spat.gaea.client.utility.AutoResetEvent

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.