public void testContentDaoUpdateContent() throws Exception {
    User user = getUser(userDao, "testuser");
    CollectionItem root = (CollectionItem) contentDao.getRootItem(user);

    FileItem item = generateTestContent();

    ContentItem newItem = contentDao.createContent(root, item);
    Date newItemModifyDate = newItem.getModifiedDate();

    clearSession();

    FileItem queryItem = (FileItem) contentDao.findContentByUid(newItem.getUid());

    helper.verifyItem(newItem, queryItem);
    Assert.assertEquals(0, queryItem.getVersion().intValue());

    queryItem.setName("test2");
    queryItem.setDisplayName("this is a test item2");
    queryItem.removeAttribute("customattribute");
    queryItem.setContentLanguage("es");
    queryItem.setContent(helper.getBytes("testdata2.txt"));

    // Make sure modified date changes
    Thread.sleep(1000);
    queryItem = (FileItem) contentDao.updateContent(queryItem);

    clearSession();

    ContentItem queryItem2 = contentDao.findContentByUid(newItem.getUid());
    Assert.assertTrue(queryItem2.getVersion().intValue() > 0);
    helper.verifyItem(queryItem, queryItem2);

    Assert.assertTrue(newItemModifyDate.before(queryItem2.getModifiedDate()));
  }
Beispiel #2
0
  public void testBodyWithUTF8() throws Exception {

    String frame = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n\n" + Stomp.NULL;
    sendFrame(frame);

    frame = receiveFrame(100000);
    Assert.assertTrue(frame.startsWith("CONNECTED"));

    frame =
        "SUBSCRIBE\n"
            + "destination:"
            + getQueuePrefix()
            + getQueueName()
            + "\n"
            + "ack:auto\n\n"
            + Stomp.NULL;
    sendFrame(frame);

    String text = "A" + "\u00ea" + "\u00f1" + "\u00fc" + "C";
    System.out.println(text);
    sendMessage(text);

    frame = receiveFrame(10000);
    System.out.println(frame);
    Assert.assertTrue(frame.startsWith("MESSAGE"));
    Assert.assertTrue(frame.indexOf("destination:") > 0);
    Assert.assertTrue(frame.indexOf(text) > 0);

    frame = "DISCONNECT\n" + "\n\n" + Stomp.NULL;
    sendFrame(frame);
  }
Beispiel #3
0
  public void testRedeliveryWithClientAck() throws Exception {

    String frame = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n\n" + Stomp.NULL;
    sendFrame(frame);

    frame = receiveFrame(10000);
    Assert.assertTrue(frame.startsWith("CONNECTED"));

    frame =
        "SUBSCRIBE\n"
            + "destination:"
            + getQueuePrefix()
            + getQueueName()
            + "\n"
            + "ack:client\n\n"
            + Stomp.NULL;

    sendFrame(frame);

    sendMessage(getName());
    frame = receiveFrame(10000);
    Assert.assertTrue(frame.startsWith("MESSAGE"));

    frame = "DISCONNECT\n" + "\n\n" + Stomp.NULL;
    sendFrame(frame);

    // message should be received since message was not acknowledged
    MessageConsumer consumer = session.createConsumer(queue);
    Message message = consumer.receive(1000);
    Assert.assertNotNull(message);
    Assert.assertTrue(message.getJMSRedelivered());
  }
Beispiel #4
0
  public void testJMSXGroupIdCanBeSet() throws Exception {

    MessageConsumer consumer = session.createConsumer(queue);

    String frame = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n\n" + Stomp.NULL;
    sendFrame(frame);

    frame = receiveFrame(10000);
    Assert.assertTrue(frame.startsWith("CONNECTED"));

    frame =
        "SEND\n"
            + "destination:"
            + getQueuePrefix()
            + getQueueName()
            + "\n"
            + "JMSXGroupID: TEST\n\n"
            + "Hello World"
            + Stomp.NULL;

    sendFrame(frame);

    TextMessage message = (TextMessage) consumer.receive(1000);
    Assert.assertNotNull(message);
    Assert.assertEquals("Hello World", message.getText());
    // differ from StompConnect
    Assert.assertEquals("TEST", message.getStringProperty("JMSXGroupID"));
  }
Beispiel #5
0
  public void testSubscribeWithAutoAck() throws Exception {

    String frame = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n\n" + Stomp.NULL;
    sendFrame(frame);

    frame = receiveFrame(100000);
    Assert.assertTrue(frame.startsWith("CONNECTED"));

    frame =
        "SUBSCRIBE\n"
            + "destination:"
            + getQueuePrefix()
            + getQueueName()
            + "\n"
            + "ack:auto\n\nfff"
            + Stomp.NULL;
    sendFrame(frame);

    sendMessage(getName());

    frame = receiveFrame(10000);
    System.out.println("-------- frame received: " + frame);
    Assert.assertTrue(frame.startsWith("MESSAGE"));
    Assert.assertTrue(frame.indexOf("destination:") > 0);
    Assert.assertTrue(frame.indexOf(getName()) > 0);

    frame = "DISCONNECT\n" + "\n\n" + Stomp.NULL;
    sendFrame(frame);

    // message should not be received as it was auto-acked
    MessageConsumer consumer = session.createConsumer(queue);
    Message message = consumer.receive(1000);
    Assert.assertNull(message);
  }
Beispiel #6
0
  public void testDefaultSpeed1() {
    Assert.assertEquals(
        "default block speed", "Normal", InstanceManager.blockManagerInstance().getDefaultSpeed());

    // expect this to throw exception because no signal map loaded by default
    boolean threw = false;
    try {
      InstanceManager.blockManagerInstance().setDefaultSpeed("Faster");
    } catch (JmriException ex) {
      if (ex.getMessage().startsWith("Value of requested default block speed is not valid")) {
        threw = true;
      } else {
        Assert.fail("failed to set speed due to wrong reason: " + ex);
      }
    } finally {
      jmri.util.JUnitAppender.assertWarnMessage("attempting to set invalid speed: Faster");
    }
    // Assert.assertEquals("faster block speed", "Faster",
    // InstanceManager.blockManagerInstance().getDefaultSpeed());
    Assert.assertTrue("Expected exception", threw);

    try {
      InstanceManager.blockManagerInstance().setDefaultSpeed("Normal");
    } catch (JmriException ex) {
      Assert.fail("failed to reset speed due to: " + ex);
    }
    Assert.assertEquals(
        "block speed back to normal",
        "Normal",
        InstanceManager.blockManagerInstance().getDefaultSpeed());
  }
Beispiel #7
0
  @AfterTest
  public void end() throws InterruptedException {
    PollableChannel out =
        (PollableChannel) tm.getMessageChannel(new NamedChannelReference("output"));
    List<String> nonSingleton = new LinkedList<String>();
    String singleton = "";

    for (int i = 0; i < 50; ++i) {
      Message<?> msg = out.receive();
      Assert.assertNotNull(msg);

      String msgSingl = (String) msg.getHeader().get("SINGLETON");
      String msgNonSingl = (String) msg.getHeader().get("NONSINGLETON");
      System.out.println("msgSingl:" + msgSingl + " msgNonSingl:" + msgNonSingl);

      if (singleton.isEmpty()) {
        singleton = msgSingl;
      } else {
        Assert.assertTrue(singleton.equals(msgSingl));
      }

      if (!nonSingleton.contains(msgNonSingl)) {
        nonSingleton.add(msgNonSingl);
      }
    }

    for (String x : nonSingleton) {
      System.out.println(x);
    }

    Assert.assertTrue(nonSingleton.size() > 1);

    tm.shutdown();
  }
Beispiel #8
0
  /**
   * Will create a ServiceLocator after doing test-specific bindings from the TestModule
   *
   * @param name The name of the service locator to create. Should be unique per test, otherwise
   *     this method will fail.
   * @param parent The parent locator this one should have. May be null
   * @param modules The test modules, that will do test specific bindings. May be null
   * @return A service locator with all the test specific bindings bound
   */
  public static ServiceLocator create(
      String name, ServiceLocator parent, HK2TestModule... modules) {
    ServiceLocator retVal = factory.find(name);
    Assert.assertNull(
        "There is already a service locator of this name, change names to ensure a clean test: "
            + name,
        retVal);

    retVal = factory.create(name, parent);

    if (modules == null || modules.length <= 0) return retVal;

    DynamicConfigurationService dcs = retVal.getService(DynamicConfigurationService.class);
    Assert.assertNotNull("Their is no DynamicConfigurationService.  Epic fail", dcs);

    DynamicConfiguration dc = dcs.createDynamicConfiguration();
    Assert.assertNotNull("DynamicConfiguration creation failure", dc);

    for (HK2TestModule module : modules) {
      module.configure(dc);
    }

    dc.commit();

    return retVal;
  }
  @Test
  public void testTimeSeriesAPIEntity() {
    InternalLog internalLog = new InternalLog();
    Map<String, byte[]> map = new HashMap<String, byte[]>();
    TestTimeSeriesAPIEntity apiEntity = new TestTimeSeriesAPIEntity();
    EntityDefinition ed = null;
    try {
      ed = EntityDefinitionManager.getEntityByServiceName("TestTimeSeriesAPIEntity");
    } catch (InstantiationException e) {
      e.printStackTrace();
    } catch (IllegalAccessException e) {
      e.printStackTrace();
    }
    map.put("a", ByteUtil.intToBytes(12));
    map.put("c", ByteUtil.longToBytes(123432432l));
    map.put("cluster", new String("cluster4ut").getBytes());
    map.put("datacenter", new String("datacenter4ut").getBytes());

    internalLog.setQualifierValues(map);
    internalLog.setTimestamp(System.currentTimeMillis());

    try {
      TaggedLogAPIEntity entity = HBaseInternalLogHelper.buildEntity(internalLog, ed);
      Assert.assertTrue(entity instanceof TestTimeSeriesAPIEntity);
      TestTimeSeriesAPIEntity tsentity = (TestTimeSeriesAPIEntity) entity;
      Assert.assertEquals("cluster4ut", tsentity.getTags().get("cluster"));
      Assert.assertEquals("datacenter4ut", tsentity.getTags().get("datacenter"));
      Assert.assertEquals(12, tsentity.getField1());
      Assert.assertEquals(123432432l, tsentity.getField3());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
 @Test
 public void testClockwise() {
   Assert.assertEquals(WEST, MapTools.clockwise(SOUTH));
   Assert.assertEquals(SOUTH, MapTools.clockwise(EAST));
   Assert.assertEquals(NORTH, MapTools.clockwise(WEST));
   Assert.assertEquals(EAST, MapTools.clockwise(NORTH));
 }
  @Test
  public void changeProxyStatusTest() throws Exception {
    // change the name of the test repo
    RepositoryMessageUtil repoUtil =
        new RepositoryMessageUtil(
            this.getXMLXStream(), MediaType.APPLICATION_XML, getRepositoryTypeRegistry());

    RepositoryStatusResource repo = repoUtil.getStatus("release-proxy-repo-1");
    repo.setProxyMode(ProxyMode.BLOCKED_AUTO.name());
    repoUtil.updateStatus(repo);

    TaskScheduleUtil.waitForAllTasksToStop();

    SyndFeed systemFeed = FeedUtil.getFeed("systemChanges");
    this.validateLinksInFeeds(systemFeed);

    SyndFeed systemStatusFeed = FeedUtil.getFeed("systemRepositoryStatusChanges");
    this.validateLinksInFeeds(systemStatusFeed);

    Assert.assertTrue(
        findFeedEntry(
            systemFeed, "Repository proxy mode change", new String[] {"release-proxy-repo-1"}));

    Assert.assertTrue(
        findFeedEntry(
            systemStatusFeed,
            "Repository proxy mode change",
            new String[] {"release-proxy-repo-1"}));
  }
  @Test
  public void testCreateExportImportJobs() {
    // innerTestType("ZoneDeliveryMode");
    try {
      final ItemModel modelItem = modelService.create("ImpExImportCronJob");

      modelService.save(modelItem);
      // System.out.println(modelService.getSource(modelItem));
      Assert.assertEquals(
          ImpExManager.getInstance().createDefaultImpExImportCronJob().getComposedType(),
          ((Item) modelService.getSource(modelItem)).getComposedType());

    } finally {
      // nothing here
    }

    try {
      final ItemModel modelItem = modelService.create("ImpExExportCronJob");

      modelService.save(modelItem);
      // System.out.println(modelService.getSource(modelItem));
      Assert.assertEquals(
          ImpExManager.getInstance().createDefaultExportCronJob().getComposedType(),
          ((Item) modelService.getSource(modelItem)).getComposedType());

    } finally {
      // nothing here
    }
  }
  public void testContentDaoUpdateCollection() throws Exception {
    User user = getUser(userDao, "testuser2");
    CollectionItem root = (CollectionItem) contentDao.getRootItem(user);

    CollectionItem a = new HibCollectionItem();
    a.setName("a");
    a.setOwner(user);

    a = contentDao.createCollection(root, a);

    clearSession();

    Assert.assertTrue(getHibItem(a).getId() > -1);
    Assert.assertNotNull(a.getUid());

    CollectionItem queryItem = contentDao.findCollectionByUid(a.getUid());
    helper.verifyItem(a, queryItem);

    queryItem.setName("b");
    contentDao.updateCollection(queryItem);

    clearSession();

    queryItem = contentDao.findCollectionByUid(a.getUid());
    Assert.assertEquals("b", queryItem.getName());
  }
  public void testContentDaoDeleteContent() throws Exception {
    User user = getUser(userDao, "testuser");
    CollectionItem root = (CollectionItem) contentDao.getRootItem(user);

    ContentItem item = generateTestContent();

    ContentItem newItem = contentDao.createContent(root, item);

    clearSession();

    ContentItem queryItem = contentDao.findContentByUid(newItem.getUid());
    helper.verifyItem(newItem, queryItem);

    contentDao.removeContent(queryItem);

    clearSession();

    queryItem = contentDao.findContentByUid(queryItem.getUid());
    Assert.assertNull(queryItem);

    clearSession();

    root = (CollectionItem) contentDao.getRootItem(user);
    Assert.assertTrue(root.getChildren().size() == 0);
  }
Beispiel #15
0
  @SmallTest
  public void testPostIP() throws Throwable {
    Header[] x = {new BasicHeader("Host", "www.qiniu.com")};
    httpManager.postData(
        "http://183.136.139.12/",
        "hello".getBytes(),
        x,
        null,
        new CompletionHandler() {
          @Override
          public void complete(ResponseInfo rinfo, JSONObject response) {
            Log.d("qiniutest", rinfo.toString());
            info = rinfo;
            signal.countDown();
          }
        },
        null,
        false);

    try {
      signal.await(60, TimeUnit.SECONDS); // wait for callback
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    Assert.assertNotNull(info.reqId);
    Assert.assertEquals(200, info.statusCode);
  }
  @Test
  public void testCanParseBoxServerError()
      throws BoxRestException, IllegalStateException, IOException, BoxJSONException {
    BoxJSONParser jsonParser = new BoxJSONParser(new BoxResourceHub());
    EasyMock.reset(boxResponse, response, entity);
    inputStream =
        new ByteArrayInputStream(jsonParser.convertBoxObjectToJSONString(error).getBytes());
    EasyMock.expect(boxResponse.getHttpResponse()).andStubReturn(response);
    EasyMock.expect(response.getEntity()).andStubReturn(entity);
    EasyMock.expect(entity.getContent()).andStubReturn(inputStream);
    EasyMock.expect(entity.isStreaming()).andStubReturn(false);

    EasyMock.expect(boxResponse.getHttpResponse()).andStubReturn(response);
    EasyMock.expect(response.getStatusLine()).andStubReturn(statusLine);
    EasyMock.expect(statusLine.getStatusCode()).andStubReturn(statusCode);

    EasyMock.replay(boxResponse, response, entity, statusLine);
    ErrorResponseParser parser = new ErrorResponseParser(jsonParser);
    Object object = parser.parse(boxResponse);
    Assert.assertEquals(BoxServerError.class, object.getClass());

    Assert.assertEquals(
        jsonParser.convertBoxObjectToJSONString(error),
        jsonParser.convertBoxObjectToJSONString(object));
    EasyMock.verify(boxResponse, response, entity, statusLine);
  }
Beispiel #17
0
  @SmallTest
  public void testPost3() throws Throwable {
    runTestOnUiThread(
        new Runnable() { // THIS IS THE KEY TO SUCCESS
          public void run() {
            httpManager.postData(
                "http://httpbin.org/status/500",
                "hello".getBytes(),
                null,
                null,
                new CompletionHandler() {
                  @Override
                  public void complete(ResponseInfo rinfo, JSONObject response) {
                    Log.d("qiniutest", rinfo.toString());
                    info = rinfo;
                    signal.countDown();
                  }
                },
                null,
                false);
          }
        });

    try {
      signal.await(60, TimeUnit.SECONDS); // wait for callback
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    Assert.assertEquals(500, info.statusCode);
    Assert.assertNotNull(info.error);
  }
 public void testFindOne() {
   MockMusicService service = new MockMusicService();
   Song song = service.findOne("Dark Horse");
   Assert.assertEquals("Dark Horse", song.getSongTitle());
   Assert.assertEquals("Katy Perry", song.getArtistName());
   Assert.assertEquals("Single", song.getAlbumTitle());
 }
Beispiel #19
0
  public void testProvide1() {
    // original create with no systemname and a username
    Block b1 = InstanceManager.blockManagerInstance().createNewBlock("UserName5");
    Assert.assertEquals("system name", "IB:AUTO:0001", b1.getSystemName());
    Assert.assertEquals("user name", "UserName5", b1.getUserName());

    Block bprovide1 = InstanceManager.blockManagerInstance().provideBlock("UserName5");
    Assert.assertEquals(
        "provide system name by user name", "IB:AUTO:0001", bprovide1.getSystemName());
    Assert.assertEquals("provide user name by user name", "UserName5", bprovide1.getUserName());

    Block bprovide2 = InstanceManager.blockManagerInstance().provideBlock("IB:AUTO:0001");
    Assert.assertEquals(
        "provide system name by system name", "IB:AUTO:0001", bprovide2.getSystemName());
    Assert.assertEquals("provide user name by system name", "UserName5", bprovide2.getUserName());

    // auto create with prefixed systemname and no username
    Block bprovide3 = InstanceManager.blockManagerInstance().provideBlock("SystemName6");
    Assert.assertEquals(
        "provide system name by user name", "IBSYSTEMNAME6", bprovide3.getSystemName());
    Assert.assertEquals("provide user name by user name", null, bprovide3.getUserName());

    // auto create with accepted systemname and no username
    Block bprovide4 = InstanceManager.blockManagerInstance().provideBlock("IB:AUTO:0002");
    Assert.assertEquals(
        "provide system name by system name", "IB:AUTO:0002", bprovide4.getSystemName());
    Assert.assertEquals("provide user name by system name", null, bprovide4.getUserName());
  }
  @Test(timeout = 2000)
  public void testCleanupQueueClosesFilesystem()
      throws IOException, InterruptedException, NoSuchFieldException, IllegalAccessException {
    Configuration conf = new Configuration();
    File file = new File("afile.txt");
    file.createNewFile();
    Path path = new Path(file.getAbsoluteFile().toURI());

    FileSystem.get(conf);
    Assert.assertEquals(1, getFileSystemCacheSize());

    // With UGI, should close FileSystem
    CleanupQueue cleanupQueue = new CleanupQueue();
    PathDeletionContext context =
        new PathDeletionContext(path, conf, UserGroupInformation.getLoginUser(), null, null);
    cleanupQueue.addToQueue(context);

    while (getFileSystemCacheSize() > 0) {
      Thread.sleep(100);
    }

    file.createNewFile();
    FileSystem.get(conf);
    Assert.assertEquals(1, getFileSystemCacheSize());

    // Without UGI, should not close FileSystem
    context = new PathDeletionContext(path, conf);
    cleanupQueue.addToQueue(context);

    while (file.exists()) {
      Thread.sleep(100);
    }
    Assert.assertEquals(1, getFileSystemCacheSize());
  }
Beispiel #21
0
  /*
   * Some STOMP clients erroneously put a new line \n *after* the terminating NUL char at the end of the frame
   * This means next frame read might have a \n a the beginning.
   * This is contrary to STOMP spec but we deal with it so we can work nicely with crappy STOMP clients
   */
  public void testSendMessageWithLeadingNewLine() throws Exception {

    MessageConsumer consumer = session.createConsumer(queue);

    String frame = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n\n" + Stomp.NULL + "\n";
    sendFrame(frame);

    frame = receiveFrame(10000);
    Assert.assertTrue(frame.startsWith("CONNECTED"));

    frame =
        "SEND\n"
            + "destination:"
            + getQueuePrefix()
            + getQueueName()
            + "\n\n"
            + "Hello World"
            + Stomp.NULL
            + "\n";

    sendFrame(frame);

    TextMessage message = (TextMessage) consumer.receive(1000);
    Assert.assertNotNull(message);
    Assert.assertEquals("Hello World", message.getText());

    // Make sure that the timestamp is valid - should
    // be very close to the current time.
    long tnow = System.currentTimeMillis();
    long tmsg = message.getJMSTimestamp();
    Assert.assertTrue(Math.abs(tnow - tmsg) < 1000);
  }
Beispiel #22
0
  @Test
  public void testEnteringWithCounters() {
    addCard(Constants.Zone.BATTLEFIELD, playerA, "Plains", 5);
    addCard(Constants.Zone.GRAVEYARD, playerA, "Dearly Departed");
    addCard(Constants.Zone.BATTLEFIELD, playerA, "Thraben Doomsayer");

    activateAbility(
        2,
        Constants.PhaseStep.PRECOMBAT_MAIN,
        playerA,
        "{T}: Put a 1/1 white Human creature token onto the battlefield.");

    setStopAt(2, Constants.PhaseStep.BEGIN_COMBAT);
    execute();

    assertLife(playerA, 20);
    assertLife(playerB, 20);

    assertPermanentCount(playerA, "Human", 1);

    // check that the +1/+1 counter was added to the token
    Permanent humanToken = getPermanent("Human", playerA.getId());
    Assert.assertEquals(2, humanToken.getPower().getValue());
    Assert.assertEquals(2, humanToken.getToughness().getValue());
  }
Beispiel #23
0
  public void testSendMessageWithCustomHeadersAndSelector() throws Exception {

    MessageConsumer consumer = session.createConsumer(queue, "foo = 'abc'");

    String frame = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n\n" + Stomp.NULL;
    sendFrame(frame);

    frame = receiveFrame(10000);
    Assert.assertTrue(frame.startsWith("CONNECTED"));

    frame =
        "SEND\n"
            + "foo:abc\n"
            + "bar:123\n"
            + "destination:"
            + getQueuePrefix()
            + getQueueName()
            + "\n\n"
            + "Hello World"
            + Stomp.NULL;

    sendFrame(frame);

    TextMessage message = (TextMessage) consumer.receive(1000);
    Assert.assertNotNull(message);
    Assert.assertEquals("Hello World", message.getText());
    Assert.assertEquals("foo", "abc", message.getStringProperty("foo"));
    Assert.assertEquals("bar", "123", message.getStringProperty("bar"));
  }
  public void testCreateReadUpdateDelete() throws Exception {
    IdentificationCheckRepository repo = new IdentificationCheckRepositoryImpl(this.getContext());

    IdentificationCheck identificationCheck =
        new IdentificationCheck.Builder().response("approved").build();

    IdentificationCheck inserttedChassis = repo.save(identificationCheck);
    id = inserttedChassis.getId();
    Assert.assertNotNull(TAG + " CREATE", inserttedChassis);

    // READ ALL
    Set<IdentificationCheck> allIdentificationCheck = repo.findAll();
    Assert.assertTrue(TAG + " READ ALL", allIdentificationCheck.size() > 0);

    // READ ENTITY
    IdentificationCheck entity = repo.findById(id);
    Assert.assertNotNull(TAG + " READ ENTITY", entity);

    // UPDATE ENTITY
    IdentificationCheck updateEntity =
        new IdentificationCheck.Builder().copy(entity).response("disapproved").build();
    repo.update(updateEntity);
    IdentificationCheck newEntity = repo.findById(id);
    Assert.assertEquals(TAG + " UPDATE ENTITY", "disapproved", newEntity.getResponse());

    // DELETE ENTITY
    repo.delete(inserttedChassis);
    // repo.delete(updateEntity);
    IdentificationCheck deletedEntity = repo.findById(id);
    Assert.assertNull(TAG + " DELETE", deletedEntity);
  }
Beispiel #25
0
  public void testSubscribeWithID() throws Exception {

    String frame = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n\n" + Stomp.NULL;
    sendFrame(frame);

    frame = receiveFrame(100000);
    Assert.assertTrue(frame.startsWith("CONNECTED"));

    frame =
        "SUBSCRIBE\n"
            + "destination:"
            + getQueuePrefix()
            + getQueueName()
            + "\n"
            + "ack:auto\n"
            + "id: mysubid\n\n"
            + Stomp.NULL;
    sendFrame(frame);

    sendMessage(getName());

    frame = receiveFrame(10000);
    Assert.assertTrue(frame.startsWith("MESSAGE"));
    Assert.assertTrue(frame.indexOf("destination:") > 0);
    Assert.assertTrue(frame.indexOf("subscription:") > 0);
    Assert.assertTrue(frame.indexOf(getName()) > 0);

    frame = "DISCONNECT\n" + "\n\n" + Stomp.NULL;
    sendFrame(frame);
  }
  @Test
  public void testIsDefaultState() {
    WPanel root = new WPanel();
    WTextField component = new WTextField();
    WFieldErrorIndicator indicator = new WFieldErrorIndicator(component);

    root.add(indicator);
    root.add(component);

    root.setLocked(true);
    setActiveContext(createUIContext());
    Assert.assertTrue("Should be in default state by default", indicator.isDefaultState());

    List<Diagnostic> diags = new ArrayList<>();
    root.validate(diags);
    root.showErrorIndicators(diags);

    Assert.assertTrue("Should be in default if there are no errors", indicator.isDefaultState());

    // Add an error by making the field mandatory
    root.reset();
    component.setMandatory(true);
    root.validate(diags);
    root.showErrorIndicators(diags);

    Assert.assertFalse("Should not be in default if there are errors", indicator.isDefaultState());

    root.reset();
    Assert.assertTrue("Should be in default after reset", indicator.isDefaultState());
  }
Beispiel #27
0
  public void testSubscribeWithAutoAckAndSelector() throws Exception {

    String frame = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n\n" + Stomp.NULL;
    sendFrame(frame);

    frame = receiveFrame(100000);
    Assert.assertTrue(frame.startsWith("CONNECTED"));

    frame =
        "SUBSCRIBE\n"
            + "destination:"
            + getQueuePrefix()
            + getQueueName()
            + "\n"
            + "selector: foo = 'zzz'\n"
            + "ack:auto\n\n"
            + Stomp.NULL;
    sendFrame(frame);

    sendMessage("Ignored message", "foo", "1234");
    sendMessage("Real message", "foo", "zzz");

    frame = receiveFrame(10000);
    Assert.assertTrue(frame.startsWith("MESSAGE"));
    Assert.assertTrue(
        "Should have received the real message but got: " + frame,
        frame.indexOf("Real message") > 0);

    frame = "DISCONNECT\n" + "\n\n" + Stomp.NULL;
    sendFrame(frame);
  }
Beispiel #28
0
  @SmallTest
  public void testPostNoPort() throws Throwable {

    httpManager.postData(
        "http://up.qiniu.com:12345",
        "hello".getBytes(),
        null,
        null,
        new CompletionHandler() {
          @Override
          public void complete(ResponseInfo rinfo, JSONObject response) {
            Log.d("qiniutest", rinfo.toString());
            info = rinfo;
            signal.countDown();
          }
        },
        null,
        false);

    try {
      signal.await(60, TimeUnit.SECONDS); // wait for callback
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    Assert.assertNull(info.reqId);
    Assert.assertEquals(ResponseInfo.CannotConnectToHost, info.statusCode);
  }
Beispiel #29
0
  public void testDisconnectAndError() throws Exception {

    String connectFrame =
        "CONNECT\n"
            + "login: brianm\n"
            + "passcode: wombats\n"
            + "request-id: 1\n"
            + "\n"
            + Stomp.NULL;
    sendFrame(connectFrame);

    String f = receiveFrame(10000);
    Assert.assertTrue(f.startsWith("CONNECTED"));
    Assert.assertTrue(f.indexOf("response-id:1") >= 0);

    String disconnectFrame = "DISCONNECT\n\n" + Stomp.NULL;
    sendFrame(disconnectFrame);

    waitForFrameToTakeEffect();

    // sending a message will result in an error
    String frame =
        "SEND\n"
            + "destination:"
            + getQueuePrefix()
            + getQueueName()
            + "\n\n"
            + "Hello World"
            + Stomp.NULL;
    try {
      sendFrame(frame);
      Assert.fail("the socket must have been closed when the server handled the DISCONNECT");
    } catch (IOException e) {
    }
  }
  public void testContentDaoCreateAvailability() throws Exception {
    User user = getUser(userDao, "testuser");
    CollectionItem root = (CollectionItem) contentDao.getRootItem(user);

    AvailabilityItem newItem = new HibAvailabilityItem();
    newItem.setOwner(user);
    newItem.setName("test");
    newItem.setIcalUid("icaluid");

    CalendarBuilder cb = new CalendarBuilder();
    net.fortuna.ical4j.model.Calendar calendar =
        cb.build(helper.getInputStream("vavailability.ics"));

    newItem.setAvailabilityCalendar(calendar);

    newItem = (AvailabilityItem) contentDao.createContent(root, newItem);

    Assert.assertTrue(getHibItem(newItem).getId() > -1);
    Assert.assertTrue(newItem.getUid() != null);

    clearSession();

    ContentItem queryItem = contentDao.findContentByUid(newItem.getUid());

    helper.verifyItem(newItem, queryItem);
  }