示例#1
0
  @Ignore
  @Test
  public void whenReceiveNotCalledFromOwnerThenThrowException4() throws Exception {
    assumeTrue(Debug.isAssertionsEnabled());
    final Channel<String> ch = newChannel();

    Thread thread =
        new Thread(
            new Runnable() {
              @Override
              public void run() {
                try {
                  ch.receive();
                } catch (InterruptedException ex) {
                  throw new AssertionError(ex);
                } catch (SuspendExecution e) {
                  throw new AssertionError(e);
                }
              }
            });
    thread.start();

    Thread.sleep(100);
    ch.send("a message");

    boolean thrown = false;
    try {
      ch.receive();
    } catch (Throwable e) {
      thrown = true;
    }
    assertTrue(thrown);

    thread.join();
  }
示例#2
0
  @Ignore
  @Test
  public void crash() throws Exception {
    // Reproduces SIGBUS crash. Requires writing direct buffers
    // to a mapped file when there is not enough space left. To avoid having
    // to fill up a primary device use a small ramdisk, or loop device. E.g.
    //   $ dd if=/dev/zero of=file.img bs=1M count=100
    //   $ losetup /dev/loop0 file.img
    //   $ mkfs.ext4 /dev/loop0
    //   $ mkdir -p root
    //   $ mount -t ext4 /dev/loop0 root

    assumeTrue(Platform.isLinux());
    File f = new File("root/test.file");
    if (f.exists()) f.delete();

    FileIO fio = FileIO.open(f, EnumSet.of(OpenOption.CREATE, OpenOption.PREALLOCATE));
    final long len = f.getTotalSpace() * 5L;
    fio.setLength(len);
    fio.map();

    ByteBuffer bb = ByteBuffer.allocateDirect(4097);
    for (long pos = 0; pos < len - bb.remaining(); pos += 512) {
      fio.write(pos, bb);
      bb.flip();
    }

    fio.close();
  }
示例#3
0
  @Ignore
  @Test
  public void whenReceiveNotCalledFromOwnerThenThrowException3() throws Exception {
    assumeTrue(Debug.isAssertionsEnabled());
    final Channel<String> ch = newChannel();

    Fiber fib =
        new Fiber(
                "fiber",
                fjPool,
                new SuspendableRunnable() {
                  @Override
                  public void run() throws SuspendExecution, InterruptedException {
                    Fiber.sleep(100);

                    ch.send("a message");

                    boolean thrown = false;
                    try {
                      ch.receive();
                    } catch (Throwable e) {
                      thrown = true;
                    }
                    assertTrue(thrown);
                  }
                })
            .start();

    String m = ch.receive();

    assertThat(m, equalTo("a message"));

    fib.join();
  }
示例#4
0
  @Test
  public void preallocateTooLarge() throws Exception {
    assumeTrue(Platform.isLinux());
    FileIO fio =
        FileIO.open(file, EnumSet.of(OpenOption.CREATE, OpenOption.MAPPED, OpenOption.PREALLOCATE));

    FileStore fs = Files.getFileStore(file.toPath());
    assumeTrue("ext4".equals(fs.type()) && !fs.name().contains("docker"));

    long len = file.getTotalSpace() * 100L;
    // setLength traps the IOException and prevents resizing / remapping. Not remapping avoids
    // the SIGBUS issue.
    fio.setLength(len);
    assertEquals(0, fio.length());

    fio.close();
  }
 @Test
 public void testZlibDirectCompressDecompress() {
   int[] size = {1, 4, 16, 4 * 1024, 64 * 1024, 128 * 1024, 1024 * 1024};
   assumeTrue(NativeCodeLoader.isNativeCodeLoaded());
   try {
     for (int i = 0; i < size.length; i++) {
       compressDecompressLoop(size[i]);
     }
   } catch (IOException ex) {
     fail("testZlibDirectCompressDecompress ex !!!" + ex);
   }
 }
示例#6
0
 @Test
 public void testRemoteClient() throws Exception {
   assumeTrue(
       "Test requires a Spark installation in SPARK_HOME.", System.getenv("SPARK_HOME") != null);
   runTest(
       false,
       new TestFunction() {
         @Override
         public void call(LivyClient client) throws Exception {
           JobHandle<Long> handle = client.submit(new SparkJob());
           assertEquals(Long.valueOf(5L), handle.get(TIMEOUT, TimeUnit.SECONDS));
         }
       });
 }
  @Test
  public void testRemoteUrl() throws MalformedURLException {
    String base = System.getProperty("carrot2.xml.feed.url.base");
    assumeTrue("carrot2.xml.feed.url.base property undefined.", !Strings.isNullOrEmpty(base));

    IResource xml = new URLResourceWithParams(new URL(base + "&q=${query}&results=${results}"));
    final String query = "apple computer";

    processingAttributes.put(AttributeUtils.getKey(XmlDocumentSource.class, "xml"), xml);
    processingAttributes.put(AttributeNames.QUERY, query);
    processingAttributes.put(AttributeNames.RESULTS, 50);
    final int documentCount = runQuery();
    assertEquals(50, documentCount);
    assertEquals(query, resultAttributes.get(AttributeNames.QUERY));
  }
示例#8
0
  @Test
  public void preallocate() throws Exception {
    // Assuming a filesystem with delayed block allocation,
    // e.g. ext3 / ext4 on Linux.
    assumeTrue(Platform.isLinux() || Platform.isMac());

    long len = 100L * (1 << 20); // 100 MB
    FileIO fio = FileIO.open(file, EnumSet.of(OpenOption.CREATE, OpenOption.PREALLOCATE));
    long startFree = file.getFreeSpace();

    fio.setLength(len);
    long alloc = startFree - file.getFreeSpace();

    // Free space should be reduced. Pad expectation since external
    // events may interfere.
    assertTrue(alloc > (len >> 1));

    fio.close();
  }
示例#9
0
 @Theory
 public void canEntryは25歳以下の女性でない場合にfalseを返す(int age, Gender gender) throws Exception {
   assumeTrue(25 < age || gender != Gender.FEMALE);
   String msg = "When age=" + age + ", gender=" + gender;
   assertThat(msg, Member.canEntry(age, gender), is(false));
 }
示例#10
0
 @Theory
 public void canEntryは25歳以下の女性の場合にtrueを返す(int age, Gender gender) throws Exception {
   assumeTrue(age <= 25 && gender == Gender.FEMALE);
   String msg = "When age=" + age + ", gender=" + gender;
   assertThat(msg, Member.canEntry(age, gender), is(true));
 }
 @Before
 public void before() {
   assumeTrue(ZlibFactory.isNativeZlibLoaded(new Configuration()));
 }