@Test
  public void testContinueOnSomeDbDirectoriesMissing() throws Exception {
    File targetDir1 = new File(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
    File targetDir2 = new File(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());

    try {
      assertTrue(targetDir1.mkdirs());
      assertTrue(targetDir2.mkdirs());

      if (!targetDir1.setWritable(false, false)) {
        System.err.println(
            "Cannot execute 'testContinueOnSomeDbDirectoriesMissing' because cannot mark directory non-writable");
        return;
      }

      RocksDBStateBackend rocksDbBackend = new RocksDBStateBackend(TEMP_URI);
      rocksDbBackend.setDbStoragePaths(targetDir1.getAbsolutePath(), targetDir2.getAbsolutePath());

      try {
        rocksDbBackend.initializeForJob(getMockEnvironment(), "foobar", IntSerializer.INSTANCE);
      } catch (Exception e) {
        e.printStackTrace();
        fail("Backend initialization failed even though some paths were available");
      }
    } finally {
      //noinspection ResultOfMethodCallIgnored
      targetDir1.setWritable(true, false);
      FileUtils.deleteDirectory(targetDir1);
      FileUtils.deleteDirectory(targetDir2);
    }
  }
  @BeforeClass
  public static void setUpBeforeClass() throws Exception {
    con.addCustomer(
        "Buddy", "Bear", "1520 Garnet Ave", "", "San Diego", "CA", "92109", "4766666656");
    con.addPublication("Runner Magazine", "Sports", 9.80, "Monthly", 5);

    ResultSet r = con.searchCustomer(0, "Buddy", "");
    try {
      while (r.next()) {
        testCustID = r.getInt("CustomerID");
      }
      r.close();

    } catch (Exception e) {
      e.printStackTrace();
    }

    ResultSet rs = con.searchPublication(0, "", "Runner Magazine");

    try {
      while (rs.next()) {
        testPubID = rs.getInt("PublicationID");
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    subscriptions newSub = new subscriptions(testCustID, testPubID);
  }
  @Test
  public void testCopyTo() {
    graph = createGraph();
    initExampleGraph(graph);
    GraphStorage gs = newRAMGraph();
    gs.setSegmentSize(8000);
    gs.create(10);
    try {
      graph.copyTo(gs);
      checkExampleGraph(gs);
    } catch (Exception ex) {
      ex.printStackTrace();
      assertTrue(ex.toString(), false);
    }

    try {
      Helper.close((Closeable) graph);
      graph = createGraph();
      gs.copyTo(graph);
      checkExampleGraph(graph);
    } catch (Exception ex) {
      ex.printStackTrace();
      assertTrue(ex.toString(), false);
    }
    Helper.close((Closeable) graph);
  }
Beispiel #4
0
  private Player getPlayer(Element el) {

    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
    Player p = new Player();

    try {

      String guid = el.getAttribute("id");
      String firstName = el.getAttribute("name_first");
      String lastName = el.getAttribute("name_last");
      String bdate = el.getAttribute("birthdate");
      String height = el.getAttribute("height");
      String weight = el.getAttribute("weight");
      String college = el.getAttribute("college");
      String position = el.getAttribute("position");
      String jersey = el.getAttribute("jersey_number");

      p.setId(guid);
      p.setFirstName(firstName);
      p.setLastName(lastName);
      p.setCollege(college);
      p.setPosition(position);
      p.setHeight(Integer.parseInt(height));
      p.setWeight(Integer.parseInt(weight));
      p.setBirthdate(formatter.parse(bdate));
      p.setJerseyNumber(Integer.parseInt(jersey));

    } catch (Exception e) {
      e.printStackTrace();
    }

    return p;
  }
Beispiel #5
0
  @Test
  public void testMain() {
    // Usage が標準出力に表示されること
    // main.main(null);

    String[] args = {
      "test/sim/simulator_raposda_2.xml",
      "test/sim/memoryModel.xml",
      "test/sim/dataDiskModel.xml",
      "test/sim/cacheDiskModel.xml",
      "test/sim/workload",
      "on",
      "on",
      "test/sim/out"
    };
    try {
      SimMain.main(args);
    } catch (Exception e) {
      e.printStackTrace();
      fail("Exceptionが発生しました.");
    }

    RAPoSDALayoutManager layoutManager = (RAPoSDALayoutManager) Environment.getLayoutManager();
    layoutManager.debugCreateManagedDevices();
    layoutManager.debugDeviceMapping();
  }
  @Test(timeout = 2000)
  public void testFirehoseFailsAsExpected() {
    AtomicInteger c = new AtomicInteger();
    TestSubscriber<Integer> ts = new TestSubscriber<>();

    firehose(c)
        .observeOn(Schedulers.computation())
        .map(
            v -> {
              try {
                Thread.sleep(10);
              } catch (Exception e) {
                e.printStackTrace();
              }
              return v;
            })
        .subscribe(ts);

    ts.awaitTerminalEvent();
    System.out.println(
        "testFirehoseFailsAsExpected => Received: " + ts.valueCount() + "  Emitted: " + c.get());

    // FIXME it is possible slow is not slow enough or the main gets delayed and thus more than one
    // source value is emitted.
    int vc = ts.valueCount();
    assertTrue("10 < " + vc, vc <= 10);

    ts.assertError(MissingBackpressureException.class);
  }
  @Test
  public void testClusterInitialization() {
    try {
      Cluster cluster = defaultFactory.getCluster("Cluster Un");
      assertNotNull("Test cluster should not be null", cluster);

      // now check that it has the data we expect from the database
      assertEquals("Wrong ID Found", 1000L, cluster.getId());
      assertEquals("Wrong name found", "Cluster Un", cluster.getName());

      // Now check for the master node
      Node master = cluster.getMaster();
      assertNotNull("Master node for cluster should not be null", master);
      assertEquals(
          "Unexpected name for master found", "Cluster 0 - Primary master", master.getName());
      assertEquals("Unexpected ID for master found", 1L, master.getId());
      assertTrue("Master should be available", master.isAvailable());

      // Now check for the slave nodes
      Set<Node> slaves = cluster.getSlaves();
      assertNotNull("Slave node set should not be null", slaves);
      assertEquals("Unexpected length for slave node set", 2, slaves.size());
    } catch (Exception e) {
      e.printStackTrace();
      fail("Exception caught: " + e.getLocalizedMessage());
    }
  }
  @Test
  public void testPersistence() {
    try {

      em.getTransaction().begin();

      Student u = new Student();
      u.setScore(12);
      u.setName("eskatos");

      em.persist(u);
      assertTrue(em.contains(u));

      em.remove(u);

      assertFalse(em.contains(u));

      em.getTransaction().commit();

    } catch (Exception ex) {
      em.getTransaction().rollback();
      ex.printStackTrace();
      fail("Exception during testPersistence");
    }
  }
  @Test
  public void testCloseNonEmptyQueue() {
    try {
      ClosableBlockingQueue<Integer> queue = new ClosableBlockingQueue<>(asList(1, 2, 3));
      assertTrue(queue.isOpen());

      assertFalse(queue.close());
      assertFalse(queue.close());

      queue.poll();

      assertFalse(queue.close());
      assertFalse(queue.close());

      queue.pollBatch();

      assertTrue(queue.close());
      assertFalse(queue.isOpen());

      assertFalse(queue.addIfOpen(42));
      assertTrue(queue.isEmpty());

      try {
        queue.add(99);
        fail("should cause an exception");
      } catch (IllegalStateException ignored) {
        // expected
      }
    } catch (Exception e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
  }
  public void testHomePageAndFeedLinks() {
    try {
      Crawler crawler = new LaRepubblicaCrawler();
      Set<String> set = new HashSet<String>();
      set.addAll(crawler.retrieveArticleUrlsFromFeed());
      set.addAll(crawler.retrieveArticleUrlsFromHomePage());

      Iterator<String> i = set.iterator();
      boolean result = true;
      while (i.hasNext()) {
        String s = i.next();
        try {
          if (crawler.getArticle(s) != null) {
            System.out.println("  OK  >> \t " + s);
            result &= true;
          }
        } catch (CrawlerCannotReadArticleException e) {
          System.err.println("ERROR >> \t " + s);
          result &= false;
          e.printStackTrace();
        }
      }
      assertEquals(true, result);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Beispiel #11
0
  @Test
  public void testOutputFormatVertex() {
    try {
      final TestingOutputFormat outputFormat = new TestingOutputFormat();
      final OutputFormatVertex of = new OutputFormatVertex("Name");
      new TaskConfig(of.getConfiguration())
          .setStubWrapper(new UserCodeObjectWrapper<OutputFormat<?>>(outputFormat));
      final ClassLoader cl = getClass().getClassLoader();

      try {
        of.initializeOnMaster(cl);
        fail("Did not throw expected exception.");
      } catch (TestException e) {
        // all good
      }

      OutputFormatVertex copy = SerializationUtils.clone(of);
      try {
        copy.initializeOnMaster(cl);
        fail("Did not throw expected exception.");
      } catch (TestException e) {
        // all good
      }
    } catch (Exception e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
  }
  @Before
  public void setUp() throws Exception {
    if (isNetwork) {
      if (url == null) {
        url = "jdbc:hsqldb:hsql://localhost/test";
      }

      server = new Server();

      server.putPropertiesFromString(serverProps);

      server.setDatabaseName(0, "test");
      server.setDatabasePath(0, "mem:test;sql.enforce_strict_size=true");
      server.setLogWriter(new PrintWriter(System.out));
      server.setErrWriter(new PrintWriter(System.err));
      server.start();
    } else {
      if (url == null) {
        url = "jdbc:hsqldb:file:test;sql.enforce_strict_size=true";
      }
    }

    try {
      Class.forName("org.hsqldb.jdbcDriver");
    } catch (Exception e) {
      e.printStackTrace();
      System.out.println(this + ".setUp() error: " + e.getMessage());
    }
  }
  @Test
  public void basicCRUD() {
    try {
      Actor actor = new Actor();
      actor.setFirstName("Arnold");
      actor.setLastName("Schwarzenegger");
      actor.setNickName("Arnie");
      Date date1 = new SimpleDateFormat("MM/dd/yy").parse("06/30/47");
      actor.setBirthDate(date1);

      getSession().save(actor);

      Query query = getSession().createQuery("from Actor where nickname=:nickname");
      query.setParameter("nickname", "Arnie");

      Actor arnie = (Actor) query.uniqueResult();
      assertEquals(2, arnie.getId());
      arnie.setNickName("Big Guy");
      getSession().save(arnie);

      query.setParameter("nickname", "Big Guy");
      Actor arnie2 = (Actor) query.uniqueResult();
      assertEquals("Version should match", 1, arnie2.getVersion());

      getSession().delete(actor);
      Actor arnie3 = (Actor) query.uniqueResult();
      assertEquals("Arnie should no longer exist!", null, arnie3);

    } catch (Exception ex) {
      logger.error("Excption thrown: ", ex.getMessage());
      assertTrue(ex.getMessage(), false);
      ex.printStackTrace();
    }
  }
  @Test
  public void onErrorFailureSafe() {
    try {
      new SafeSubscriber<String>(OBSERVER_ONERROR_FAIL())
          .onError(new SafeObserverTestException("error!"));
      fail("expects exception to be thrown");
    } catch (Exception e) {
      e.printStackTrace();
      assertTrue(e instanceof RuntimeException);
      assertEquals(
          "Error occurred when trying to propagate error to Observer.onError", e.getMessage());

      Throwable e2 = e.getCause();
      assertTrue(e2 instanceof CompositeException);
      assertEquals(
          "Chain of Causes for CompositeException In Order Received =>",
          e2.getCause().getMessage());

      Throwable e3 = e2.getCause();
      assertTrue(e3.getCause() instanceof SafeObserverTestException);
      assertEquals("error!", e3.getCause().getMessage());

      Throwable e4 = e3.getCause();
      assertTrue(e4.getCause() instanceof SafeObserverTestException);
      assertEquals("onErrorFail", e4.getCause().getMessage());
    }
  }
  @Test
  public void onErrorSuccessWithUnsubscribeFailure() {
    AtomicReference<Throwable> onError = new AtomicReference<Throwable>();
    Subscriber<String> o = OBSERVER_SUCCESS(onError);
    try {
      o.add(
          Subscriptions.create(
              new Action0() {

                @Override
                public void call() {
                  // break contract by throwing exception
                  throw new SafeObserverTestException("failure from unsubscribe");
                }
              }));
      new SafeSubscriber<String>(o).onError(new SafeObserverTestException("failed"));
      fail("we expect the unsubscribe failure to cause an exception to be thrown");
    } catch (Exception e) {
      e.printStackTrace();

      assertTrue(o.isUnsubscribed());

      // we still expect onError to have received something before unsubscribe blew up
      assertNotNull(onError.get());
      assertTrue(onError.get() instanceof SafeObserverTestException);
      assertEquals("failed", onError.get().getMessage());

      // now assert the exception that was thrown
      assertTrue(e instanceof SafeObserverTestException);
      assertEquals("failure from unsubscribe", e.getMessage());
    }
  }
  @Test
  public void onCompleteSuccessWithUnsubscribeFailure() {
    Subscriber<String> o = OBSERVER_SUCCESS();
    try {
      o.add(
          Subscriptions.create(
              new Action0() {

                @Override
                public void call() {
                  // break contract by throwing exception
                  throw new SafeObserverTestException("failure from unsubscribe");
                }
              }));
      new SafeSubscriber<String>(o).onCompleted();
      fail("expects exception to be thrown");
    } catch (Exception e) {
      e.printStackTrace();

      assertTrue(o.isUnsubscribed());

      assertTrue(e instanceof SafeObserverTestException);
      assertEquals("failure from unsubscribe", e.getMessage());
      // expected since onError fails so SafeObserver can't help
    }
  }
  @Test
  public void testNonEqualSplitsPerhost() {
    int numHosts = 3;
    int slotsPerHost = 2;
    int parallelism = 5;

    TestLocatableInputSplit[] splits =
        new TestLocatableInputSplit[] {
          new TestLocatableInputSplit(1, "host3"),
          new TestLocatableInputSplit(2, "host1"),
          new TestLocatableInputSplit(3, "host1"),
          new TestLocatableInputSplit(4, "host1"),
          new TestLocatableInputSplit(5, "host1"),
          new TestLocatableInputSplit(6, "host1"),
          new TestLocatableInputSplit(7, "host2"),
          new TestLocatableInputSplit(8, "host2")
        };

    try {
      String[] hostsForTasks = runTests(numHosts, slotsPerHost, parallelism, splits);

      assertEquals("host1", hostsForTasks[0]);
      assertEquals("host1", hostsForTasks[1]);
      assertEquals("host2", hostsForTasks[2]);
      assertEquals("host2", hostsForTasks[3]);
      assertEquals("host3", hostsForTasks[4]);
    } catch (Exception e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
  }
  @Test
  public void testTopologicalSort3() {
    //             --> op1 --
    //            /         \
    //  (source) -           +-> op2 -> op3
    //            \         /
    //             ---------

    try {
      AbstractJobVertex source = new AbstractJobVertex("source");
      AbstractJobVertex op1 = new AbstractJobVertex("op4");
      AbstractJobVertex op2 = new AbstractJobVertex("op2");
      AbstractJobVertex op3 = new AbstractJobVertex("op3");

      op1.connectNewDataSetAsInput(source, DistributionPattern.POINTWISE);
      op2.connectNewDataSetAsInput(op1, DistributionPattern.POINTWISE);
      op2.connectNewDataSetAsInput(source, DistributionPattern.POINTWISE);
      op3.connectNewDataSetAsInput(op2, DistributionPattern.POINTWISE);

      JobGraph graph = new JobGraph("TestGraph", source, op1, op2, op3);
      List<AbstractJobVertex> sorted = graph.getVerticesSortedTopologicallyFromSources();

      assertEquals(4, sorted.size());

      assertBefore(source, op1, sorted);
      assertBefore(source, op2, sorted);
      assertBefore(op1, op2, sorted);
      assertBefore(op2, op3, sorted);
    } catch (Exception e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
  }
  @Test
  public void testNotEnoughSubtasks() {
    int numHosts = 3;
    int slotsPerHost = 1;
    int parallelism = 2;

    TestLocatableInputSplit[] splits =
        new TestLocatableInputSplit[] {
          new TestLocatableInputSplit(1, "host1"),
          new TestLocatableInputSplit(2, "host2"),
          new TestLocatableInputSplit(3, "host3")
        };

    // This should fail with an exception, since the DOP of 2 does not
    // support strictly local assignment onto 3 hosts
    try {
      runTests(numHosts, slotsPerHost, parallelism, splits);
      fail("should throw an exception");
    } catch (JobException e) {
      // what a great day!
    } catch (Exception e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
  }
  @Test
  public void testTopoSortCyclicGraphIntermediateCycle() {
    try {
      AbstractJobVertex source = new AbstractJobVertex("source");
      AbstractJobVertex v1 = new AbstractJobVertex("1");
      AbstractJobVertex v2 = new AbstractJobVertex("2");
      AbstractJobVertex v3 = new AbstractJobVertex("3");
      AbstractJobVertex v4 = new AbstractJobVertex("4");
      AbstractJobVertex target = new AbstractJobVertex("target");

      v1.connectNewDataSetAsInput(source, DistributionPattern.POINTWISE);
      v1.connectNewDataSetAsInput(v4, DistributionPattern.POINTWISE);
      v2.connectNewDataSetAsInput(v1, DistributionPattern.POINTWISE);
      v3.connectNewDataSetAsInput(v2, DistributionPattern.POINTWISE);
      v4.connectNewDataSetAsInput(v3, DistributionPattern.POINTWISE);
      target.connectNewDataSetAsInput(v3, DistributionPattern.POINTWISE);

      JobGraph jg = new JobGraph("Cyclic Graph", v1, v2, v3, v4, source, target);
      try {
        jg.getVerticesSortedTopologicallyFromSources();
        fail("Failed to raise error on topologically sorting cyclic graph.");
      } catch (InvalidProgramException e) {
        // that what we wanted
      }
    } catch (Exception e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
  }
 protected boolean execute(int address, String expectedOutput) {
   boolean isSuccess = false;
   Cpu cpu = computer.getCpu();
   cpu.writeRegister(false, Cpu.PC, address);
   long startTime = System.currentTimeMillis();
   while ((System.currentTimeMillis() - startTime) < MAX_EXECUTION_TIME
       || terminal.getWrittenData().length() > Terminal.MAX_DATA_LENGTH) {
     try {
       cpu.executeNextOperation();
       if (cpu.isHaltMode()) {
         throw new IllegalStateException("HALT mode");
       }
     } catch (Exception e) {
       e.printStackTrace();
       fail(
           "can't execute operation, PC: 0"
               + Integer.toOctalString(cpu.readRegister(false, Cpu.PC)));
     }
     if (expectedOutput.equals(terminal.getWrittenData())) {
       isSuccess = true;
       break;
     }
   }
   return isSuccess;
 }
  @SuppressWarnings("serial")
  private String getTestProduct() {

    Map<String, Object> returnMap = new HashMap<String, Object>();

    SaveResult saveResult = null;

    try {
      saveResult =
          module
              .create(
                  ZObjectType.Product,
                  Collections.<Map<String, Object>>singletonList(
                      new HashMap<String, Object>() {
                        {
                          put("Name", "UnitTestProduct");
                          put("EffectiveStartDate", "2011-01-01T20:00:00");
                          put("EffectiveEndDate", "2013-01-01T20:00:00");
                        }
                      }))
              .get(0);
    } catch (Exception e) {
      e
          .printStackTrace(); // To change body of catch statement use File | Settings | File
                              // Templates.
    }

    return saveResult.getId();
  }
  @Test
  public void testPollBatch() {
    try {
      ClosableBlockingQueue<String> queue = new ClosableBlockingQueue<>();

      assertNull(queue.pollBatch());

      queue.add("a");
      queue.add("b");

      assertEquals(asList("a", "b"), queue.pollBatch());
      assertNull(queue.pollBatch());

      queue.add("c");

      assertEquals(singletonList("c"), queue.pollBatch());
      assertNull(queue.pollBatch());

      assertTrue(queue.close());

      try {
        queue.pollBatch();
        fail("should cause an exception");
      } catch (IllegalStateException ignored) {
        // expected
      }
    } catch (Exception e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
  }
Beispiel #24
0
 void report(Exception e) {
   System.out.println("Exception occurred:");
   System.out.println(e.toString());
   e.printStackTrace(System.err);
   report2(e);
   //        failed();
 }
  @Test
  public void testTopologicalSort1() {
    try {
      AbstractJobVertex source1 = new AbstractJobVertex("source1");
      AbstractJobVertex source2 = new AbstractJobVertex("source2");
      AbstractJobVertex target1 = new AbstractJobVertex("target1");
      AbstractJobVertex target2 = new AbstractJobVertex("target2");
      AbstractJobVertex intermediate1 = new AbstractJobVertex("intermediate1");
      AbstractJobVertex intermediate2 = new AbstractJobVertex("intermediate2");

      target1.connectNewDataSetAsInput(source1, DistributionPattern.POINTWISE);
      target2.connectNewDataSetAsInput(source1, DistributionPattern.POINTWISE);
      target2.connectNewDataSetAsInput(intermediate2, DistributionPattern.POINTWISE);
      intermediate2.connectNewDataSetAsInput(intermediate1, DistributionPattern.POINTWISE);
      intermediate1.connectNewDataSetAsInput(source2, DistributionPattern.POINTWISE);

      JobGraph graph =
          new JobGraph(
              "TestGraph", source1, source2, intermediate1, intermediate2, target1, target2);
      List<AbstractJobVertex> sorted = graph.getVerticesSortedTopologicallyFromSources();

      assertEquals(6, sorted.size());

      assertBefore(source1, target1, sorted);
      assertBefore(source1, target2, sorted);
      assertBefore(source2, target2, sorted);
      assertBefore(source2, intermediate1, sorted);
      assertBefore(source2, intermediate2, sorted);
      assertBefore(intermediate1, target2, sorted);
      assertBefore(intermediate2, target2, sorted);
    } catch (Exception e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
  }
  @Test
  public void test() {
    Cliente c1 = new Cliente();

    c1.setStatus(1);
    c1.setTipopessoa(2);
    c1.setSexo(1);
    c1.setDatanascimento(LocalDate.now());
    c1.setNomerazao("");
    c1.setCpfcnpj("");
    c1.setRgie("");
    c1.setEndereco("");
    c1.setNumero("54");
    c1.setComplemento("10");
    c1.setBairro("");
    c1.setEstado(3);
    c1.setCidade(3);
    c1.setCep("3678000");
    c1.setTel("");
    c1.setCel("");
    c1.setEmail("*****@*****.**");
    c1.setSite("teste");
    c1.setClientedesde(LocalDate.now());
    c1.setObs("teste");

    ClienteDao dao = new ClienteDao();
    Boolean b = true;
    try {
      assertEquals(b, dao.inserir(c1));
    } catch (Exception e) {
      // Todo Auto-generated catch block
      e.printStackTrace();
    }
  }
  @SuppressWarnings("serial")
  private String getTestProductRatePlan(final String productId) {
    SaveResult saveResult = null;

    try {
      saveResult =
          module
              .create(
                  ZObjectType.ProductRatePlan,
                  Collections.<Map<String, Object>>singletonList(
                      new HashMap<String, Object>() {
                        {
                          put("ProductId", productId);
                          put("Name", "TestProductRatePlan");
                          put("EffectiveStartDate", "2011-01-01T20:00:00");
                          put("EffectiveEndDate", "2013-01-01T20:00:00");
                          put("Description", "Test product used in unit test.");
                        }
                      }))
              .get(0);
    } catch (Exception e) {
      e
          .printStackTrace(); // To change body of catch statement use File | Settings | File
                              // Templates.
    }
    return saveResult.getId();
  }
  @Test
  public void testPostEmployee() {
    if (null == cookie) {
      fail("cannot login!!!");
    }
    Employee ep1 = generateEmployee();

    try {
      ResteasyClient client = new ResteasyClientBuilder().build();

      WebTarget target = client.target(baseUrl + "/rest/ag/employee");
      client.register(new CookieRequestFilter(cookie));

      Response response = target.request().post(Entity.entity(ep1, "application/json"));

      if (response.getStatus() != 200) {
        throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
      }

      Employee value = response.readEntity(Employee.class);
      System.out.println("Server response : \n");
      System.out.println(value.toString());

      assertEquals("same first name", "Special", value.getFirstName());

      client.close();

    } catch (Exception e) {

      e.printStackTrace();
    }
  }
  /**
   * checkEnvのテストケース 異常系:"ASAKUSA_HOME"の設定が不正のケース
   *
   * @throws Exception
   */
  @Test
  public void checkEnvTest04() throws Exception {
    ConfigurationLoader.init(properties_db, true, false);
    Map<String, String> m = new HashMap<String, String>();
    m.put(Constants.ASAKUSA_HOME, "J:\temp");
    m.put(
        Constants.THUNDER_GATE_HOME,
        ConfigurationLoader.getEnvProperty(Constants.THUNDER_GATE_HOME));
    ConfigurationLoader.setEnv(m);

    Properties p = System.getProperties();
    p.setProperty(Constants.ASAKUSA_HOME, "J:\temp");
    p.setProperty(Constants.THUNDER_GATE_HOME, "src/test");
    ConfigurationLoader.setSysProp(p);
    System.setProperties(p);

    try {
      ConfigurationLoader.checkEnv();
      fail();
    } catch (Exception e) {
      assertTrue(e instanceof Exception);
      System.out.println(e.getMessage());
      e.printStackTrace();
    }
  }
  @Test
  public void testDeleteDocument() {
    try {
      // create indexer
      CustomMemoryIndexer customMemoryIndexer = CustomMemoryIndexer.getIndex("TestIndex");

      assertNotNull(customMemoryIndexer);

      // create document
      Document document = customMemoryIndexer.createDocument("001", "Test Content");
      // index it
      customMemoryIndexer.indexDocument(document);
      // search it
      List<Document> hitDocs = customMemoryIndexer.search("Test");

      assertEquals(1, hitDocs.size());
      assertEquals("001", hitDocs.get(0).get("id"));

      document = customMemoryIndexer.createDocument("001", "Test Content");
      // clear index
      customMemoryIndexer.deleteDocument(document);
      // search again
      hitDocs = customMemoryIndexer.search("Test");
      // nothing found
      assertEquals(0, hitDocs.size());

    } catch (Exception e) {
      assertTrue(e.getMessage(), false);
      e.printStackTrace();
    }
  }