Exemplo n.º 1
0
  @Test
  public void testDoCompare() {
    WNumberField trigger = new WNumberField();

    // ------------------------------
    // Setup EQUAL - with value
    Equal compare = new Equal(trigger, EQ_VALUE);

    trigger.setNumber(null);
    Assert.assertFalse("Equal Type - Compare for null value should be false", compare.execute());

    trigger.setNumber(LT_VALUE);
    Assert.assertFalse("Equal Type - Compare for less value should be false", compare.execute());

    trigger.setNumber(EQ_VALUE);
    Assert.assertTrue("Equal Type - Compare for equal value should be true", compare.execute());

    trigger.setNumber(GT_VALUE);
    Assert.assertFalse("Equal Type - Compare for greater value should be false", compare.execute());

    // ------------------------------
    // Setup EQUAL - with null value
    compare = new Equal(trigger, null);

    trigger.setNumber(null);
    Assert.assertTrue(
        "Equal Type With Null Value - Compare for null value should be true", compare.execute());

    trigger.setNumber(EQ_VALUE);
    Assert.assertFalse(
        "Equal Type With Null Value - Compare for value should be false", compare.execute());
  }
Exemplo n.º 2
0
  @Test
  public void testDeleteNonExistingFileInDir() throws IOException {
    String testFileInDir = "testDir/testDir/TestFile";
    Path testPath = qualifiedPath(testFileInDir, fc2);

    // TestCase1 : Test delete on file never existed
    // Ensure file does not exist
    Assert.assertFalse(exists(fc2, testPath));

    // Delete on non existing file should return false
    Assert.assertFalse(fc2.delete(testPath, false));

    // TestCase2 : Create , Delete , Delete file
    // Create a file on fc2's file system using fc1
    createFile(fc1, testPath);
    // Ensure file exist
    Assert.assertTrue(exists(fc2, testPath));

    // Delete test file, deleting existing file should return true
    Assert.assertTrue(fc2.delete(testPath, false));
    // Ensure file does not exist
    Assert.assertFalse(exists(fc2, testPath));
    // Delete on non existing file should return false
    Assert.assertFalse(fc2.delete(testPath, false));
  }
Exemplo n.º 3
0
  @Test
  public void testOrDecisions() {
    final WorkflowAction action1 = getAction(ACTIONCODES.ACTION1.name());
    final WorkflowAction action2 = getAction(ACTIONCODES.ACTION2.name());
    final WorkflowAction action3 = getAction(ACTIONCODES.ACTION3.name());
    final WorkflowAction action4 = getAction(ACTIONCODES.ACTION4.name());
    final WorkflowAction action5 = getAction(ACTIONCODES.ACTION5.name());
    final WorkflowAction action6 = getAction(ACTIONCODES.ACTION6.name());

    // complete action 1 with decision 2
    final WorkflowDecision decision2 = getDecision(DECISIONCODES.DECISION2.name(), action1);
    action1.setSelectedDecision(decision2);
    action1.decide();

    assertTrue("Action 1 should be completed", action1.isCompleted());
    assertTrue("Action 2 should be active", action2.isActive());
    assertFalse("Action 3 should be inactive", action3.isActive());
    assertTrue("Action 4 should be active", action4.isActive());
    assertFalse("Action 5 should be inactive", action5.isActive());
    assertFalse("Action 6 should be inactive", action6.isActive());

    // complete action 2 with decision 4
    final WorkflowDecision decision4 = getDecision(DECISIONCODES.DECISION4.name(), action2);
    action2.setSelectedDecision(decision4);
    action2.decide();

    assertTrue("Action 1 should be completed", action1.isCompleted());
    assertTrue("Action 2 should be completed", action2.isCompleted());
    assertFalse("Action 3 should be inactive", action3.isActive());
    assertTrue("Action 4 should be active", action4.isActive());
    assertTrue("Action 5 should be active", action5.isActive());
    assertFalse("Action 6 should be inactive", action6.isActive());
  }
  @Test
  public void getContacts()
      throws HubSpotConnectorException, HubSpotConnectorNoAccessTokenException,
          HubSpotConnectorAccessTokenExpiredException {

    createNewContact();

    ContactList cl = connector.getAllContacts(USER_ID, null, null);

    Assert.assertNotNull(cl);
    Assert.assertTrue(cl.getContacts().size() > 0);
    Assert.assertFalse(
        StringUtils.isEmpty(cl.getContacts().get(0).getContactProperties().getFirstname()));

    cl = connector.getRecentContacts(USER_ID, null, null, null);

    Assert.assertNotNull(cl);
    Assert.assertTrue(cl.getContacts().size() > 0);
    Assert.assertFalse(
        StringUtils.isEmpty(cl.getContacts().get(0).getContactProperties().getFirstname()));

    final String q = "mule";
    final ContactQuery cq = connector.getContactsByQuery(USER_ID, q, null);

    Assert.assertNotNull(cq);
    Assert.assertEquals(cq.getQuery(), q);
    Assert.assertTrue(cq.getContacts().size() >= 0);
    // Assert.assertFalse(StringUtils.isEmpty(cq.getContacts().get(0).getContactProperties().getFirstname()));
  }
Exemplo n.º 5
0
  @Test
  public void testPointLineCreation() {
    List<Point> pts = createPoints();

    // construct MultiPoint
    MultiPoint mp = new MultiPoint(pts);
    assertEquals(pts.size(), mp.getNumParts());
    assertEquals(pts.size(), mp.getNumPoints());
    assertFalse(mp.is3D());

    // construct Line
    Line line = new Line(new ArrayList<Point>(pts));
    assertEquals(1, line.getNumParts());
    assertEquals(pts.size(), line.getNumPoints());
    assertFalse(line.is3D());

    Iterator<Point> it1 = line.iterator();
    Iterator<Point> it2 = mp.iterator();
    while (it1.hasNext() && it2.hasNext()) {
      assertEquals(it1.next(), it2.next());
    }
    assertFalse(it1.hasNext());
    assertFalse(it2.hasNext());

    List<Point> linePts = line.getPoints();
    List<Point> multiPts = mp.getPoints();
    assertEquals(linePts.size(), multiPts.size());
    for (int i = 0; i < linePts.size(); i++) {
      assertEquals(linePts.get(i), multiPts.get(i));
    }

    assertEquals(mp.getCenter(), line.getCenter());
  }
  @Test
  public void testProxyMethod() {
    Datastore ds = new RedisDatastore();
    ds.getMappingContext().addPersistentEntity(Person.class);
    Session conn = ds.connect();

    Person p = new Person();
    p.setName("Bob");
    Address a = new Address();
    a.setNumber("22");
    a.setPostCode("308420");
    p.setAddress(a);
    conn.persist(p);

    Person personProxy = (Person) conn.proxy(Person.class, p.getId());

    EntityProxy proxy = (EntityProxy) personProxy;

    assertFalse(proxy.isInitialized());
    assertEquals(p.getId(), personProxy.getId());

    assertFalse(proxy.isInitialized());

    assertEquals("Bob", personProxy.getName());

    assertTrue(proxy.isInitialized());
  }
Exemplo n.º 7
0
  @Test
  public void testIsServiceEnabled() {
    Service service = mock(Service.class);

    when(service.getPathName()).thenReturn("wms");
    defaults.setWMSCEnabled(true);
    assertTrue(mediator.isServiceEnabled(service));
    defaults.setWMSCEnabled(false);
    assertFalse(mediator.isServiceEnabled(service));

    when(service.getPathName()).thenReturn("tms");
    defaults.setTMSEnabled(true);
    assertTrue(mediator.isServiceEnabled(service));
    defaults.setTMSEnabled(false);
    assertFalse(mediator.isServiceEnabled(service));

    when(service.getPathName()).thenReturn("wmts");
    defaults.setWMTSEnabled(true);
    assertTrue(mediator.isServiceEnabled(service));
    defaults.setWMTSEnabled(false);
    assertFalse(mediator.isServiceEnabled(service));

    when(service.getPathName()).thenReturn("somethingElse");
    assertTrue(mediator.isServiceEnabled(service));
  }
  @Test
  public void testOrDecisions() {
    final WorkflowActionModel action1 = getAction(ACTIONCODES.ACTION1.name());
    final WorkflowActionModel action2 = getAction(ACTIONCODES.ACTION2.name());
    final WorkflowActionModel action3 = getAction(ACTIONCODES.ACTION3.name());
    final WorkflowActionModel action4 = getAction(ACTIONCODES.ACTION4.name());
    final WorkflowActionModel action5 = getAction(ACTIONCODES.ACTION5.name());
    final WorkflowActionModel action6 = getAction(ACTIONCODES.ACTION6.name());

    // complete action 1 with decision 2
    final WorkflowDecisionModel decision2 = getDecision(DECISIONCODES.DECISION2.name(), action1);
    workflowProcessingService.decideAction(action1, decision2);

    assertTrue("Action 1 should be completed", workflowActionService.isCompleted(action1));
    assertTrue("Action 2 should be active", workflowActionService.isActive(action2));
    assertFalse("Action 3 should be inactive", workflowActionService.isActive(action3));
    assertTrue("Action 4 should be active", workflowActionService.isActive(action4));
    assertFalse("Action 5 should be inactive", workflowActionService.isActive(action5));
    assertFalse("Action 6 should be inactive", workflowActionService.isActive(action6));

    // complete action 2 with decision 4
    final WorkflowDecisionModel decision4 = getDecision(DECISIONCODES.DECISION4.name(), action2);
    workflowProcessingService.decideAction(action2, decision4);

    assertTrue("Action 1 should be completed", workflowActionService.isCompleted(action1));
    assertTrue("Action 2 should be completed", workflowActionService.isCompleted(action2));
    assertFalse("Action 3 should be inactive", workflowActionService.isActive(action3));
    assertTrue("Action 4 should be active", workflowActionService.isActive(action4));
    assertTrue("Action 5 should be active", workflowActionService.isActive(action5));
    assertFalse("Action 6 should be inactive", workflowActionService.isActive(action6));
  }
Exemplo n.º 9
0
 @Test
 public final void testApiKey() {
   final String key = mandrillApi.getKey();
   Assert.assertNotNull(key);
   Assert.assertFalse(key.isEmpty());
   Assert.assertFalse(key.equals("<put ur Mandrill API key here>"));
 }
Exemplo n.º 10
0
    @Test
    public void shouldReturnStringFieldObject() throws Exception {
      String xsd =
          "<root available-locales=\"en_US\" default-locale=\"en_US\"> "
              + "<dynamic-element "
              + "dataType=\"boolean\" "
              + "type=\"checkbox\" "
              + "name=\"A_Bool\" > "
              + "<meta-data locale=\"en_US\"> "
              + "<entry name=\"predefinedValue\"><![CDATA[false]]></entry> "
              + "</meta-data> "
              + "</dynamic-element>"
              + "</root>";

      List<Field> resultList = new XSDParser().parse(xsd, _usLocale);

      assertNotNull(resultList);
      assertEquals(1, resultList.size());

      Field resultField = resultList.get(0);
      assertTrue(resultField instanceof BooleanField);
      BooleanField booleanField = (BooleanField) resultField;

      assertEquals(Field.DataType.BOOLEAN.getValue(), booleanField.getDataType().getValue());
      assertEquals(Field.EditorType.CHECKBOX.getValue(), booleanField.getEditorType().getValue());
      assertEquals("A_Bool", booleanField.getName());
      assertFalse(booleanField.getCurrentValue());
      assertFalse(booleanField.getPredefinedValue());
    }
  @SuppressWarnings("unchecked")
  @Test
  public void testBuildEntityEdOrgRights() {

    Set<String> edOrgs = new HashSet<String>();
    edOrgs.add("edOrg1");
    edOrgs.add("edOrg2");
    edOrgs.add("edOrg3");
    edOrgs.add("edOrg4");

    Entity entity = Mockito.mock(Entity.class);
    Mockito.when(entity.getType()).thenReturn("student");

    Mockito.when(
            edOrgOwnershipArbiter.determineHierarchicalEdorgs(
                Matchers.anyList(), Matchers.anyString()))
        .thenReturn(edOrgs);

    Collection<GrantedAuthority> grantedAuthorities =
        entityEdOrgRightBuilder.buildEntityEdOrgRights(edOrgRights, entity, false);

    Assert.assertEquals(5, grantedAuthorities.size());
    Assert.assertTrue(grantedAuthorities.contains(READ_PUBLIC));
    Assert.assertTrue(grantedAuthorities.contains(READ_GENERAL));
    Assert.assertTrue(grantedAuthorities.contains(READ_RESTRICTED));
    Assert.assertTrue(grantedAuthorities.contains(WRITE_GENERAL));
    Assert.assertTrue(grantedAuthorities.contains(WRITE_RESTRICTED));
    Assert.assertFalse(grantedAuthorities.contains(AGGREGATE_READ));
    Assert.assertFalse(grantedAuthorities.contains(WRITE_PUBLIC));
    Assert.assertFalse(grantedAuthorities.contains(AGGREGATE_WRITE));
  }
  @Test
  public void testScenario02_ComparingNames() throws Exception {
    SpelExpressionParser parser = new SpelExpressionParser();
    StandardEvaluationContext ctx = new StandardEvaluationContext();

    ctx.addPropertyAccessor(new SecurityPrincipalAccessor());

    // Multiple options for supporting this expression: "p.name == principal.name"
    // (1) If the right person is the root context object then "name==principal.name" is good enough
    Expression expr = parser.parseRaw("name == principal.name");

    ctx.setRootObject(new Person("Andy"));
    Boolean value = expr.getValue(ctx, Boolean.class);
    Assert.assertTrue(value);

    ctx.setRootObject(new Person("Christian"));
    value = expr.getValue(ctx, Boolean.class);
    Assert.assertFalse(value);

    // (2) Or register an accessor that can understand 'p' and return the right person
    expr = parser.parseRaw("p.name == principal.name");

    PersonAccessor pAccessor = new PersonAccessor();
    ctx.addPropertyAccessor(pAccessor);
    ctx.setRootObject(null);

    pAccessor.setPerson(new Person("Andy"));
    value = expr.getValue(ctx, Boolean.class);
    Assert.assertTrue(value);

    pAccessor.setPerson(new Person("Christian"));
    value = expr.getValue(ctx, Boolean.class);
    Assert.assertFalse(value);
  }
Exemplo n.º 13
0
  /*
   * INSERT INTO
   * FIELD_CONFIGURATION(FIELD_CONFIG_ID,FIELD_NAME,ENTITY_ID,MANDATORY_FLAG
   * ,HIDDEN_FLAG) VALUES(74,'AssignClients',1,0,0);
   */
  public void testStartFromStandardStore() throws Exception {
    int newId = 203;
    AddField upgrade =
        new AddField(
            DatabaseVersionPersistence.APPLICATION_VERSION + 1,
            newId,
            "AssignClients",
            EntityType.CLIENT,
            false,
            false);
    upgrade.upgrade(session.connection());
    FieldConfigurationEntity fetched =
        (FieldConfigurationEntity) session.get(FieldConfigurationEntity.class, newId);
    Assert.assertEquals(newId, (int) fetched.getFieldConfigId());
    Assert.assertFalse(fetched.isHidden());
    Assert.assertFalse(fetched.isMandatory());
    Assert.assertEquals(EntityType.CLIENT, fetched.getEntityType());
    Assert.assertEquals("AssignClients", fetched.getFieldName());

    /*
     * This upgrade doesn't yet have the ability to set the parent. Looks
     * like we'll probably need that some day (not for 106 upgrade).
     */
    Assert.assertEquals(null, fetched.getParentFieldConfig());
  }
Exemplo n.º 14
0
  public void testIdTagProviderGet() {
    DefaultIdTagManager m = getManager();
    IdTag t1 = m.newIdTag("ID0413276BC1", "Test Tag 1");
    IdTag t2 = m.newIdTag("ID0413275FCA", "Test Tag 2");

    Assert.assertFalse("Created IdTags are different", t1.equals(t2));

    Assert.assertTrue(
        "Matching IdTag returned via provideTag by system name",
        t1.equals(m.provideIdTag("ID0413276BC1")));
    Assert.assertTrue(
        "Matching IdTag returned via provideTag by user name",
        t1.equals(m.provideIdTag("Test Tag 1")));
    Assert.assertTrue(
        "Matching IdTag returned via provideTag by tag ID",
        t1.equals(m.provideIdTag("0413276BC1")));

    Assert.assertFalse(
        "Non-matching IdTag returned via provideTag by system name",
        t1.equals(m.provideIdTag("ID0413275FCA")));
    Assert.assertFalse(
        "Non-matching IdTag returned via provideTag by user name",
        t1.equals(m.provideIdTag("Test Tag 2")));
    Assert.assertFalse(
        "Non-matching IdTag returned via provideTag by tag ID",
        t1.equals(m.provideIdTag("0413275FCA")));
  }
Exemplo n.º 15
0
  public void testCarLengths() {
    CarLengths cl1 = CarLengths.instance();
    cl1.getNames(); // load predefined lengths

    Assert.assertTrue("Car Length Predefined 40", cl1.containsName("40"));
    Assert.assertTrue("Car Length Predefined 32", cl1.containsName("32"));
    Assert.assertTrue("Car Length Predefined 60", cl1.containsName("60"));

    cl1.addName("1");
    Assert.assertTrue("Car Length Add 1", cl1.containsName("1"));
    Assert.assertFalse("Car Length Never Added 13", cl1.containsName("13"));
    cl1.addName("2");
    Assert.assertTrue("Car Length Still Has 1", cl1.containsName("1"));
    Assert.assertTrue("Car Length Add s2", cl1.containsName("2"));
    String[] lengths = cl1.getNames();
    Assert.assertEquals("First length name", "2", lengths[0]);
    Assert.assertEquals("2nd length name", "1", lengths[1]);
    JComboBox<?> box = cl1.getComboBox();
    Assert.assertEquals("First comboBox length name", "2", box.getItemAt(0));
    Assert.assertEquals("2nd comboBox length name", "1", box.getItemAt(1));
    cl1.deleteName("2");
    Assert.assertFalse("Car Length Delete 2", cl1.containsName("2"));
    cl1.deleteName("1");
    Assert.assertFalse("Car Length Delete 1", cl1.containsName("1"));
  }
  @Test
  public void implicitGrantWithDeny() throws Exception {
    OAuthService service =
        new ServiceBuilder()
            .provider(OpenConextApi20Implicit.class)
            .apiKey(OAUTH_KEY.concat(UUID.randomUUID().toString()))
            .apiSecret(OAUTH_SECRET.concat("force_consent"))
            .callback(OAUTH_CALLBACK_URL)
            .scope(OAUTH_OPENCONEXT_API_READ_SCOPE)
            .build();
    String authUrl = service.getAuthorizationUrl(null);
    LOG.debug("Auth url: {}", authUrl);
    getWebDriver().get(authUrl);
    loginAtMujinaIfNeeded(USER_ID);

    // Deny on user consent page
    WebElement authorizeButton = getWebDriver().findElement(By.id("decline_terms_button"));
    authorizeButton.click();

    URI uri = URI.create(getWebDriver().getCurrentUrl());
    LOG.debug("URL is: " + uri.toString());
    LOG.debug("Response body is: " + getWebDriver().getPageSource());
    callbackRequestFragment = uri.getFragment();
    assertNotNull("redirect URL should contain fragment.", callbackRequestFragment);
    assertFalse(
        "redirect URL fragment should not contain access token",
        callbackRequestFragment.contains("access_token="));
    assertFalse(
        "redirect URL fragment should contain access token",
        callbackRequestFragment.contains("access_token="));
  }
  @Test
  public void testLazyLoadedOneToOne() {
    Datastore ds = new RedisDatastore();
    ds.getMappingContext().addPersistentEntity(Person.class);
    Session conn = ds.connect();

    Person p = new Person();
    p.setName("Bob");
    Address a = new Address();
    a.setNumber("22");
    a.setPostCode("308420");
    p.setAddress(a);
    conn.persist(p);

    p = (Person) conn.retrieve(Person.class, p.getId());

    Address proxy = p.getAddress();

    assertTrue(proxy instanceof javassist.util.proxy.ProxyObject);
    assertTrue(proxy instanceof EntityProxy);

    EntityProxy ep = (EntityProxy) proxy;
    assertFalse(ep.isInitialized());
    assertEquals(a.getId(), proxy.getId());

    assertFalse(ep.isInitialized());
    assertEquals("22", a.getNumber());
  }
Exemplo n.º 18
0
  @Test
  public void testDomainRespawn() throws Exception {
    // Make sure everything started
    List<RunningProcess> processes = waitForAllProcesses();
    readHostControllerServers();

    // Kill the master HC and make sure that it gets restarted
    RunningProcess originalHc = processUtil.getProcess(processes, HOST_CONTROLLER);
    Assert.assertNotNull(originalHc);
    processUtil.killProcess(originalHc);
    processes = waitForAllProcesses();
    RunningProcess respawnedHc = processUtil.getProcess(processes, HOST_CONTROLLER);
    Assert.assertNotNull(respawnedHc);
    Assert.assertFalse(originalHc.getProcessId().equals(respawnedHc.getProcessId()));

    readHostControllerServers();

    // Kill a server and make sure that it gets restarted
    RunningProcess originalServerOne = processUtil.getProcess(processes, SERVER_ONE);
    Assert.assertNotNull(originalServerOne);
    processUtil.killProcess(originalServerOne);
    processes = waitForAllProcesses();
    RunningProcess respawnedServerOne = processUtil.getProcess(processes, SERVER_ONE);
    Assert.assertNotNull(respawnedServerOne);
    Assert.assertFalse(originalServerOne.getProcessId().equals(respawnedServerOne.getProcessId()));
    readHostControllerServers();
  }
Exemplo n.º 19
0
  @Test
  public void testRemoveAllLayerGridsetsDisablesLayer() throws Exception {

    when(tld.getConfiguration(same(tileLayer))).thenReturn(config);
    when(tld.getConfiguration(same(tileLayerGroup))).thenReturn(config);
    when(tld.modify(same(tileLayer))).thenReturn(config);
    when(tld.modify(same(tileLayerGroup))).thenReturn(config);
    when(tld.removeGridset(eq("EPSG:4326"))).thenReturn(config);
    when(tld.removeGridset(eq("EPSG:900913"))).thenReturn(config);

    // sanity check before modification
    assertTrue(tileLayer.getInfo().isEnabled());
    assertTrue(tileLayer.getInfo().isEnabled());

    mediator.removeGridSets(ImmutableSet.of("EPSG:900913", "EPSG:4326"));

    verify(config, times(1)).save(); // all other checks are in testRemoveGridsets
    verify(storageBroker, times(1)).deleteByGridSetId(eq(tileLayer.getName()), eq("EPSG:4326"));
    verify(storageBroker, times(1))
        .deleteByGridSetId(eq(tileLayerGroup.getName()), eq("EPSG:900913"));
    verify(storageBroker, times(1)).deleteByGridSetId(eq(tileLayer.getName()), eq("EPSG:4326"));
    verify(storageBroker, times(1))
        .deleteByGridSetId(eq(tileLayerGroup.getName()), eq("EPSG:900913"));

    assertTrue(tileLayer.getGridSubsets().isEmpty());
    assertTrue(tileLayerGroup.getGridSubsets().isEmpty());

    // layers ended up with no gridsubsets, shall have been disabled
    assertFalse(tileLayer.getInfo().isEnabled());
    assertFalse(tileLayerGroup.getInfo().isEnabled());
  }
  @Test
  public void testExecuteWithWPanel() {
    // Setup targets in a Panel
    WPanel panel = new WPanel();
    MyTarget target1 = new MyTarget();
    MyTarget target2 = new MyTarget();
    MyTarget target3 = new MyTarget();
    panel.add(target1);
    panel.add(target2);
    panel.add(target3);

    AbstractSetMandatory enable = new MyMandatory(panel, Boolean.TRUE);

    // Targets should be optional by default
    Assert.assertFalse("WPanel - Target1 should be optional", target1.isMandatory());
    Assert.assertFalse("WPanel - Target2 should be optional", target2.isMandatory());
    Assert.assertFalse("WPanel - Target3 should be optional", target3.isMandatory());

    enable.execute();

    // Targets should be mandatory
    Assert.assertTrue("WPanel - Target1 should be mandatory", target1.isMandatory());
    Assert.assertTrue("WPanel - Target2 should be mandatory", target2.isMandatory());
    Assert.assertTrue("WPanel - Target3 should be mandatory", target3.isMandatory());
  }
 public void testNonStopTimer() throws Exception {
   long startTime = System.nanoTime();
   int loopTmes = 4;
   long timeout = 500;
   for (int i = 0; i < loopTmes; i++) {
     System.out.println("executing loop count" + i);
     nonStopManager.begin(timeout);
     try {
       blockUntilAborted();
     } finally {
       Assert.assertTrue(abortableOperationManager.isAborted());
       Thread.currentThread().interrupt();
       nonStopManager.finish();
       // check that aborted status is cleared.
       Assert.assertFalse(abortableOperationManager.isAborted());
       // check that interrupted flag is cleared.
       Assert.assertFalse(Thread.interrupted());
     }
   }
   long timeTaken = System.nanoTime() - startTime;
   System.out.println("time taken to execute operations " + timeTaken);
   Assert.assertTrue(
       (timeTaken >= loopTmes * TimeUnit.MILLISECONDS.toNanos(timeout)
           && timeTaken
               < (loopTmes * TimeUnit.MILLISECONDS.toNanos(timeout)
                   + TimeUnit.SECONDS.toNanos(2))));
 }
Exemplo n.º 22
0
    @Test
    public void testRenderNameStyle() throws Exception {
        Select<?> s =
        create(new Settings().withRenderNameStyle(RenderNameStyle.AS_IS))
            .select(TBook_ID(), TBook_TITLE(), TAuthor_FIRST_NAME(), TAuthor_LAST_NAME())
            .from(TBook())
            .join(TAuthor()).on(TBook_AUTHOR_ID().equal(TAuthor_ID()))
            .orderBy(TBook_ID());

        Result<?> result = s.fetch();
        assertEquals(BOOK_IDS, result.getValues(TBook_ID()));
        assertEquals(BOOK_TITLES, result.getValues(TBook_TITLE()));
        assertEquals(BOOK_FIRST_NAMES, result.getValues(TAuthor_FIRST_NAME()));
        assertEquals(BOOK_LAST_NAMES, result.getValues(TAuthor_LAST_NAME()));

        // [#521] Ensure that no quote characters are rendered
        assertFalse(s.getSQL().contains("\""));
        assertFalse(s.getSQL().contains("["));
        assertFalse(s.getSQL().contains("]"));
        assertFalse(s.getSQL().contains("`"));

        assertTrue(s.getSQL().toUpperCase().contains("T_BOOK.ID"));
        assertTrue(s.getSQL().toUpperCase().contains("T_BOOK.TITLE"));
        assertTrue(s.getSQL().toUpperCase().contains("T_AUTHOR.FIRST_NAME"));
        assertTrue(s.getSQL().toUpperCase().contains("T_AUTHOR.LAST_NAME"));
    }
Exemplo n.º 23
0
  @Test
  public void testLinerRing() {
    Point pt = getRandomPoint();
    Geodetic2DBounds bbox = new Geodetic2DBounds(pt.asGeodetic2DPoint());
    bbox.grow(500);
    // System.out.println(bbox);
    LinearRing ring1 = new LinearRing(bbox);

    // create second linear ring centered at north/east edge of the first
    // so it intersects
    bbox = new Geodetic2DBounds(pt.asGeodetic2DPoint());
    bbox.grow(50);
    System.out.println(bbox);
    LinearRing ring2 = new LinearRing(bbox);
    assertTrue(ring1.intersects(ring2));
    assertTrue(ring2.intersects(ring1));

    // create third linear ring at other side of the hemisphere so it cannot intersect
    bbox =
        new Geodetic2DBounds(
            new Geodetic2DPoint(
                new Longitude(-bbox.getEastLon().inRadians()),
                new Latitude(-bbox.getNorthLat().inRadians())));
    bbox.grow(10);
    // System.out.println(bbox);
    LinearRing ring3 = new LinearRing(bbox);
    assertFalse(ring1.intersects(ring3));
    assertFalse(ring1.contains(ring3));
  }
  /** @deprecated to suppress deprecation warnings */
  public void testCancellation() {
    TestProgressMonitor root = new TestProgressMonitor();
    root.beginTask("", 1000);

    SubProgressMonitor spm = new SubProgressMonitor(root, 1000);

    // Test that changes at the root propogate to the child
    root.setCanceled(true);
    Assert.assertTrue(spm.isCanceled());
    root.setCanceled(false);
    Assert.assertFalse(spm.isCanceled());

    // Test that changes to the child propogate to the root
    spm.setCanceled(true);
    Assert.assertTrue(root.isCanceled());
    spm.setCanceled(false);
    Assert.assertFalse(root.isCanceled());

    // Test a chain of depth 2
    spm.beginTask("", 1000);
    SubProgressMonitor spm2 = new SubProgressMonitor(spm, 1000);

    // Test that changes at the root propogate to the child
    root.setCanceled(true);
    Assert.assertTrue(spm2.isCanceled());
    root.setCanceled(false);
    Assert.assertFalse(spm2.isCanceled());

    // Test that changes to the child propogate to the root
    spm2.setCanceled(true);
    Assert.assertTrue(root.isCanceled());
    spm2.setCanceled(false);
    Assert.assertFalse(root.isCanceled());
  }
Exemplo n.º 25
0
  @Test
  public void testMkdirsFailsForSubdirectoryOfExistingFile() throws Exception {
    Path testDir = qualifiedPath("test/hadoop", fc2);
    Assert.assertFalse(exists(fc2, testDir));
    fc2.mkdir(testDir, FsPermission.getDefault(), true);
    Assert.assertTrue(exists(fc2, testDir));

    // Create file on fc1 using fc2 context
    createFile(fc1, qualifiedPath("test/hadoop/file", fc2));

    Path testSubDir = qualifiedPath("test/hadoop/file/subdir", fc2);
    try {
      fc1.mkdir(testSubDir, FsPermission.getDefault(), true);
      Assert.fail("Should throw IOException.");
    } catch (IOException e) {
      // expected
    }
    Assert.assertFalse(exists(fc1, testSubDir));

    Path testDeepSubDir = qualifiedPath("test/hadoop/file/deep/sub/dir", fc1);
    try {
      fc2.mkdir(testDeepSubDir, FsPermission.getDefault(), true);
      Assert.fail("Should throw IOException.");
    } catch (IOException e) {
      // expected
    }
    Assert.assertFalse(exists(fc1, testDeepSubDir));
  }
  @Test
  public void iterate_invalid_file() {
    XmlBinaryEvidenceStreamSource dataSource =
        new XmlBinaryEvidenceStreamSource(
            new File(
                XmlBinaryEvidenceStreamSourceTest.class
                    .getResource("/samples/empty.xml")
                    .getFile()));
    Iterator<BinaryInteractionEvidence> iterator = dataSource.getInteractionsIterator();
    Assert.assertFalse(iterator.hasNext());
    Assert.assertFalse(dataSource.validateSyntax());
    dataSource.close();

    dataSource = new XmlBinaryEvidenceStreamSource();
    Map<String, Object> options = new HashMap<String, Object>();
    options.put(
        MIFileDataSourceOptions.INPUT_OPTION_KEY,
        new File(
            XmlBinaryEvidenceStreamSourceTest.class.getResource("/samples/empty.xml").getFile()));
    dataSource.initialiseContext(options);
    iterator = dataSource.getInteractionsIterator();
    Assert.assertFalse(iterator.hasNext());
    Assert.assertFalse(dataSource.validateSyntax());
    dataSource.close();
  }
Exemplo n.º 27
0
  @Test
  public void testDeleteNonExistingDirectory() throws IOException {
    String testDirName = "testFile";
    Path testPath = qualifiedPath(testDirName, fc2);

    // TestCase1 : Test delete on directory never existed
    // Ensure directory does not exist
    Assert.assertFalse(exists(fc2, testPath));

    // Delete on non existing directory should return false
    Assert.assertFalse(fc2.delete(testPath, false));

    // TestCase2 : Create dir, Delete dir, Delete dir
    // Create a file on fc2's file system using fc1

    fc1.mkdir(testPath, FsPermission.getDefault(), true);
    // Ensure dir exist
    Assert.assertTrue(exists(fc2, testPath));

    // Delete test file, deleting existing file should return true
    Assert.assertTrue(fc2.delete(testPath, false));
    // Ensure file does not exist
    Assert.assertFalse(exists(fc2, testPath));
    // Delete on non existing file should return false
    Assert.assertFalse(fc2.delete(testPath, false));
  }
  @Test
  public void parse_valid_file() throws IOException {
    XmlBinaryEvidenceStreamSource dataSource =
        new XmlBinaryEvidenceStreamSource(
            new File(
                XmlBinaryEvidenceStreamSourceTest.class
                    .getResource("/samples/10049915.xml")
                    .getFile()));
    Iterator<BinaryInteractionEvidence> iterator = dataSource.getInteractionsIterator();
    Interaction i1 = iterator.next();
    Assert.assertNotNull(i1);
    Assert.assertFalse(iterator.hasNext());
    Assert.assertTrue(dataSource.validateSyntax());
    dataSource.close();

    dataSource = new XmlBinaryEvidenceStreamSource();
    Map<String, Object> options = new HashMap<String, Object>();
    options.put(
        MIFileDataSourceOptions.INPUT_OPTION_KEY,
        new File(
            XmlBinaryEvidenceStreamSourceTest.class
                .getResource("/samples/10049915.xml")
                .getFile()));
    dataSource.initialiseContext(options);
    iterator = dataSource.getInteractionsIterator();
    i1 = iterator.next();
    Assert.assertNotNull(i1);
    Assert.assertFalse(iterator.hasNext());
    Assert.assertTrue(dataSource.validateSyntax());
    dataSource.close();
  }
Exemplo n.º 29
0
  private void stackTestEmptyInternal(int capacity) {
    Oscilloscope x = new Oscilloscope(new Shell(), 0);
    IntegerFiFoCircularStack stack = x.new IntegerFiFoCircularStack(capacity);
    assertTrue(stack.isEmpty());

    stack.push(5);
    assertFalse(stack.isEmpty());

    stack.peek(0);
    assertFalse(stack.isEmpty());

    stack.pop(0);
    assertTrue(stack.isEmpty());

    for (int i = 0; i < capacity; i++) {
      stack.push(i);
    }

    assertTrue(stack.isFull());
    assertFalse(stack.isEmpty());

    for (int i = 0; i < capacity; i++) {
      assertFalse(stack.isEmpty());
      assertTrue(stack.pop(-1) != -1);
      assertFalse(stack.isFull());
    }

    assertTrue(stack.isEmpty());
  }
  @Test
  public void testIsAcceptedServiceInterface7() {
    final AutowiredRemoteServiceGroupConfig config;

    config = new AutowiredRemoteServiceGroupConfig();
    config.setBasePackages(Arrays.asList(new String[] {"de.itsvs.cwtrpc.controller.config."}));
    config.setIncludeFilters(
        Arrays.asList(
            new Pattern[] {
              PatternFactory.compile(
                  PatternType.REGEX, MatcherType.PACKAGE, "de\\..+\\.TestService[13]"),
              PatternFactory.compile(
                  PatternType.REGEX, MatcherType.PACKAGE, "de\\..+\\.TestService5")
            }));
    config.setExcludeFilters(
        Arrays.asList(
            new Pattern[] {
              PatternFactory.compile(
                  PatternType.REGEX, MatcherType.PACKAGE, "de\\..+\\.TestService1")
            }));

    Assert.assertFalse(config.isAcceptedServiceInterface(TestService1.class));
    Assert.assertFalse(config.isAcceptedServiceInterface(TestService2.class));
    Assert.assertTrue(config.isAcceptedServiceInterface(TestService3.class));
    Assert.assertTrue(config.isAcceptedServiceInterface(TestService5.class));
  }