Beispiel #1
0
 @Test
 public void testCheckFalse() throws Exception {
   assertFalse(Shuntsu.check(P1, M9, P2));
   assertFalse(Shuntsu.check(P9, S2, S1));
   assertFalse(Shuntsu.check(S1, S2, S5));
   assertFalse(Shuntsu.check(HAK, HAT, CHN));
 }
Beispiel #2
0
  @Test
  public final void testDropFunction() throws Exception {
    assertFalse(catalog.containFunction("test3", CatalogUtil.newSimpleDataTypeArray(Type.INT4)));
    FunctionDesc meta =
        new FunctionDesc(
            "test3",
            TestFunc1.class,
            FunctionType.UDF,
            CatalogUtil.newSimpleDataType(Type.INT4),
            CatalogUtil.newSimpleDataTypeArray(Type.INT4));
    catalog.createFunction(meta);
    assertTrue(catalog.containFunction("test3", CatalogUtil.newSimpleDataTypeArray(Type.INT4)));
    catalog.dropFunction("test3");
    assertFalse(catalog.containFunction("test3", CatalogUtil.newSimpleDataTypeArray(Type.INT4)));

    assertFalse(
        catalog.containFunction("test3", CatalogUtil.newSimpleDataTypeArray(Type.INT4, Type.BLOB)));
    FunctionDesc overload =
        new FunctionDesc(
            "test3",
            TestFunc2.class,
            FunctionType.GENERAL,
            CatalogUtil.newSimpleDataType(Type.INT4),
            CatalogUtil.newSimpleDataTypeArray(Type.INT4, Type.BLOB));
    catalog.createFunction(overload);
    assertTrue(
        catalog.containFunction("test3", CatalogUtil.newSimpleDataTypeArray(Type.INT4, Type.BLOB)));
  }
  @Test
  public void testAddGetParameters() {
    SimpleParameterManager manager = new SimpleParameterManager();
    SimpleParameter<?> parameter1 = new SimpleParameter<>();
    SimpleParameter<?> parameter2 = new SimpleParameter<>();
    SimpleParameter<?> parameter3 = new SimpleParameter<>();

    manager.addParameter(parameter1);
    assertEquals(1, manager.getParameters().size());
    assertTrue(manager.getParameters().contains(parameter1));
    assertFalse(manager.getParameters().contains(parameter2));
    assertFalse(manager.getParameters().contains(parameter3));

    manager.addParameter(parameter2);
    assertEquals(2, manager.getParameters().size());
    assertTrue(manager.getParameters().contains(parameter1));
    assertTrue(manager.getParameters().contains(parameter2));
    assertFalse(manager.getParameters().contains(parameter3));

    manager.addParameter(parameter3);
    assertEquals(3, manager.getParameters().size());
    assertTrue(manager.getParameters().contains(parameter1));
    assertTrue(manager.getParameters().contains(parameter2));
    assertTrue(manager.getParameters().contains(parameter3));
  }
Beispiel #4
0
  @Test
  public void testCreateAndDropTable() throws Exception {
    catalog.createDatabase("tmpdb1", TajoConstants.DEFAULT_TABLESPACE_NAME);
    assertTrue(catalog.existDatabase("tmpdb1"));
    catalog.createDatabase("tmpdb2", TajoConstants.DEFAULT_TABLESPACE_NAME);
    assertTrue(catalog.existDatabase("tmpdb2"));

    TableDesc table1 = createMockupTable("tmpdb1", "table1");
    catalog.createTable(table1);

    TableDesc table2 = createMockupTable("tmpdb2", "table2");
    catalog.createTable(table2);

    Set<String> tmpdb1 = Sets.newHashSet(catalog.getAllTableNames("tmpdb1"));
    assertEquals(1, tmpdb1.size());
    assertTrue(tmpdb1.contains("table1"));

    Set<String> tmpdb2 = Sets.newHashSet(catalog.getAllTableNames("tmpdb2"));
    assertEquals(1, tmpdb2.size());
    assertTrue(tmpdb2.contains("table2"));

    catalog.dropDatabase("tmpdb1");
    assertFalse(catalog.existDatabase("tmpdb1"));

    tmpdb2 = Sets.newHashSet(catalog.getAllTableNames("tmpdb2"));
    assertEquals(1, tmpdb2.size());
    assertTrue(tmpdb2.contains("table2"));

    catalog.dropDatabase("tmpdb2");
    assertFalse(catalog.existDatabase("tmpdb2"));
  }
Beispiel #5
0
  @Test
  public void testCreateSameTables() throws IOException, TajoException {
    catalog.createDatabase("tmpdb3", TajoConstants.DEFAULT_TABLESPACE_NAME);
    assertTrue(catalog.existDatabase("tmpdb3"));
    catalog.createDatabase("tmpdb4", TajoConstants.DEFAULT_TABLESPACE_NAME);
    assertTrue(catalog.existDatabase("tmpdb4"));

    TableDesc table1 = createMockupTable("tmpdb3", "table1");
    catalog.createTable(table1);
    TableDesc table2 = createMockupTable("tmpdb3", "table2");
    catalog.createTable(table2);
    assertTrue(catalog.existsTable("tmpdb3", "table1"));
    assertTrue(catalog.existsTable("tmpdb3", "table2"));

    TableDesc table3 = createMockupTable("tmpdb4", "table1");
    catalog.createTable(table3);
    TableDesc table4 = createMockupTable("tmpdb4", "table2");
    catalog.createTable(table4);
    assertTrue(catalog.existsTable("tmpdb4", "table1"));
    assertTrue(catalog.existsTable("tmpdb4", "table2"));

    catalog.dropTable("tmpdb3.table1");
    catalog.dropTable("tmpdb3.table2");
    catalog.dropTable("tmpdb4.table1");
    catalog.dropTable("tmpdb4.table2");

    assertFalse(catalog.existsTable("tmpdb3.table1"));
    assertFalse(catalog.existsTable("tmpdb3.table2"));
    assertFalse(catalog.existsTable("tmpdb4.table1"));
    assertFalse(catalog.existsTable("tmpdb4.table2"));
  }
  /** Test of equals method, of class Vector. */
  @Test
  public void testEquals() {
    System.out.println("equal");
    // Arrange
    double[] original = {5.0, -2.9, 0.0, -50000, 9};
    double[] originalCopy = {5.0, -2.9, 0.0, -50000, 9};
    double[] mass1 = {0.0, 0.9, -6.4, 8, -0.4};
    double[] mass2 = {5.0, -2.9};
    double[] mass3 = {5.0, -2.9, 0.0, -50000, 9, 5.0, -2.9};

    VectorImpl instance = new VectorImpl(5);
    instance.setData(original);
    VectorImpl vector0 = new VectorImpl(5);
    vector0.setData(originalCopy);
    VectorImpl vector1 = new VectorImpl(5);
    vector1.setData(mass1);
    VectorImpl vector2 = new VectorImpl(2);
    vector2.setData(mass2);
    VectorImpl vector3 = new VectorImpl(7);
    vector3.setData(mass3);
    java.util.Vector vector4 = new java.util.Vector(5);
    // Act
    boolean result0 = instance.equals(vector0);
    boolean result1 = instance.equals(vector1);
    boolean result2 = instance.equals(vector2);
    boolean result3 = instance.equals(vector3);
    boolean result4 = instance.equals(vector4);
    // Assert
    assertTrue(result0);
    assertFalse(result1);
    assertFalse(result2);
    assertFalse(result3);
    assertFalse(result4);
  }
 @Test
 public void lahettiEiVoiSyodaOmaa() {
   // tapahtuu vain jos joku ylentää sotilaan lähetiksi (??)
   Lahetti testiLahetti = (Lahetti) lauta.asetaNappula(new Lahetti(true), 5, 2);
   assertFalse(ekaLahetti.mahdollisetSiirrot(lauta)[2][5]);
   assertFalse(testiLahetti.mahdollisetSiirrot(lauta)[3][4]);
 }
  @Test
  public void testTemplate9() {
    Template template1 = new Template("{anything}");
    assertEquals(0, template1.match("bla bla bla").getBoundaries()[0], 0.0);
    assertEquals(11, template1.match("bla bla bla").getBoundaries()[1], 0.0);
    Template template2 = new Template("this could be {anything}, right");
    assertEquals(
        4,
        template2.partialmatch("and this could be pretty much anything, right").getBoundaries()[0],
        0.0);
    assertEquals(
        "and this could be pretty much anything, right".length(),
        template2.partialmatch("and this could be pretty much anything, right").getBoundaries()[1],
        0.0);
    assertEquals(
        -1,
        template2.partialmatch("and this could be pretty much anything").getBoundaries()[1],
        0.0);

    Template template3 = new Template("{}");
    assertEquals(0, template3.getSlots().size());
    assertTrue(template3.match("{}").isMatching());
    // assertTrue(template3.partialmatch("{}").isMatching());
    assertFalse(template3.match("something").isMatching());
    assertFalse(template3.partialmatch("something").isMatching());
  }
 @Test
 public void testStar() {
   Template t1 = new Template("here is * test");
   assertTrue(t1.match("here is test").isMatching());
   assertTrue(t1.match("here is a test").isMatching());
   assertTrue(t1.match("here is a great test").isMatching());
   assertFalse(t1.match("here is a bad nest").isMatching());
   t1 = new Template("* test");
   assertTrue(t1.match("test").isMatching());
   assertTrue(t1.match("great test").isMatching());
   assertFalse(t1.match("here is a bad nest").isMatching());
   t1 = new Template("test *");
   assertTrue(t1.match("test").isMatching());
   assertTrue(t1.match("test that works").isMatching());
   assertFalse(t1.match("nest that is bad").isMatching());
   t1 = new Template("this is a * {test}");
   assertTrue(t1.match("this is a ball").isMatching());
   assertTrue(t1.match("this is a really great ball").isMatching());
   assertFalse(t1.match("this is huge").isMatching());
   assertEquals("ball", t1.match("this is a ball").getFilledSlots().getValue("test").toString());
   assertEquals(
       "ball", t1.match("this is a great blue ball").getFilledSlots().getValue("test").toString());
   t1 = new Template("* {test}");
   assertEquals(
       "ball", t1.match("this is a great ball").getFilledSlots().getValue("test").toString());
   assertEquals("ball", t1.match("ball").getFilledSlots().getValue("test").toString());
   t1 = new Template("{test} *");
   assertEquals("great ball", t1.match("great ball").getFilledSlots().getValue("test").toString());
   assertEquals("ball", t1.match("ball").getFilledSlots().getValue("test").toString());
 }
  @Test
  public void shouldUpdate() {
    // pre-conditions
    ConnectionFake connection = new ConnectionFake("fakeUser", null);
    connection.setRememberPassword(true);
    connection.setConnected(true);
    assertTrue(connection.isConnected());
    assertTrue(connection.isDefaultHost());

    String newUsername = "******";
    String newHost = "http://www.redhat.com";
    String newPassword = "******";
    Connection updatingConnection = new ConnectionFake(newUsername, newHost);
    updatingConnection.setPassword(newPassword);
    updatingConnection.setRememberPassword(false);

    // operations
    connection.update(updatingConnection);

    // verifications
    assertEquals(newUsername, connection.getUsername());
    assertEquals(newHost, connection.getHost());
    assertFalse(newUsername, connection.isDefaultHost());
    assertEquals(newPassword, connection.getPassword());
    assertFalse(connection.isRememberPassword());
    assertFalse(connection.isConnected());
  }
  @Test
  public void testRoomExists() throws Exception {

    // create room in shape of '+' with five total
    // rooms ; one in center and one at each extremity
    Room base = new Room("test");
    Room up = new Room("test1");
    Room down = new Room("test2");
    Room left = new Room("test3");
    Room right = new Room("test4");

    // set base
    base.setLocation(up, down, left, right);

    // set up
    up.setLocation(Direction.NORTH, null);
    up.setLocation(Direction.SOUTH, base);
    up.setLocation(Direction.EAST, null);
    up.setLocation(Direction.WEST, null);

    // are there rooms around base?
    assertTrue(base.roomExists(Direction.NORTH));
    assertTrue(base.roomExists(Direction.SOUTH));
    assertTrue(base.roomExists(Direction.EAST));
    assertTrue(base.roomExists(Direction.WEST));

    // are there rooms around up?
    assertFalse(up.roomExists(Direction.NORTH));
    assertTrue(up.roomExists(Direction.SOUTH));
    assertFalse(up.roomExists(Direction.EAST));
    assertFalse(up.roomExists(Direction.WEST));
  }
  @Test
  public void testClose() throws SQLException, InterruptedException {
    assertNotNull(dataSource.getConnection());

    // state before shutdown
    verify(mockPoolingDataSource, times(0)).close();
    assertFalse(dataSource.getDataSourceManager().isStopped());
    assertTrue(dataSource.getDataSourceManager().isAlive());

    dataSource.close();

    // state after shutdown
    verify(mockPoolingDataSource, times(1)).close();
    assertTrue(dataSource.getDataSourceManager().isStopped());

    // give the thread some time to process interrupt and die
    Thread.sleep(200);
    assertFalse(dataSource.getDataSourceManager().isAlive());

    try {
      dataSource.getConnection();
    } catch (SQLException e) {
      // expected , DataSource should not give out connections any longer
    }
  }
Beispiel #13
0
  private void testRandomFilter() {
    findMenuItemByText("Random Filter...").click();
    DialogFixture dialog = WindowFinder.findDialog("filterDialog").using(robot);
    JButtonFixture nextRandomButton = findButtonByText(dialog, "Next Random Filter");
    JButtonFixture backButton = findButtonByText(dialog, "Back");
    JButtonFixture forwardButton = findButtonByText(dialog, "Forward");

    assertTrue(nextRandomButton.isEnabled());
    assertFalse(backButton.isEnabled());
    assertFalse(forwardButton.isEnabled());

    nextRandomButton.click();
    assertTrue(backButton.isEnabled());
    assertFalse(forwardButton.isEnabled());

    nextRandomButton.click();
    backButton.click();
    assertTrue(forwardButton.isEnabled());

    backButton.click();
    forwardButton.click();
    nextRandomButton.click();

    findButtonByText(dialog, "OK").click();
    keyboardUndoRedo();
    keyboardUndo();
  }
  @Test
  public void testEntryCriteriaAndExitCriteria() {
    // given

    // create sentry containing ifPart
    Sentry sentry = createElement(casePlanModel, "Sentry_1", Sentry.class);
    IfPart ifPart = createElement(sentry, "abc", IfPart.class);
    ConditionExpression conditionExpression =
        createElement(ifPart, "def", ConditionExpression.class);
    Body body = createElement(conditionExpression, null, Body.class);
    body.setTextContent("${test}");

    // set entry-/exitCriteria
    planItem.getEntryCriterias().add(sentry);
    planItem.getExitCriterias().add(sentry);

    // transform casePlanModel as parent
    CmmnActivity parent = new CasePlanModelHandler().handleElement(casePlanModel, context);
    context.setParent(parent);

    // transform Sentry
    CmmnSentryDeclaration sentryDeclaration = new SentryHandler().handleElement(sentry, context);

    // when
    CmmnActivity newActivity = handler.handleElement(planItem, context);

    // then
    assertFalse(newActivity.getExitCriteria().isEmpty());
    assertEquals(1, newActivity.getExitCriteria().size());
    assertEquals(sentryDeclaration, newActivity.getExitCriteria().get(0));

    assertFalse(newActivity.getEntryCriteria().isEmpty());
    assertEquals(1, newActivity.getEntryCriteria().size());
    assertEquals(sentryDeclaration, newActivity.getEntryCriteria().get(0));
  }
  @Test
  public void testDirectoryExists() {
    Repository repository = new VFSRepository(producer.getIoService());
    ((VFSRepository) repository).setDescriptor(descriptor);
    boolean rootFolderExists = repository.directoryExists("/test");
    assertFalse(rootFolderExists);

    Directory directoryId = repository.createDirectory("/test");
    assertNotNull(directoryId);
    assertEquals("test", directoryId.getName());
    assertEquals("/", directoryId.getLocation());
    assertNotNull(directoryId.getUniqueId());

    rootFolderExists = repository.directoryExists("/test");
    assertTrue(rootFolderExists);

    AssetBuilder builder = AssetBuilderFactory.getAssetBuilder(Asset.AssetType.Byte);
    builder.content("simple content".getBytes()).type("png").name("test").location("/test");

    String id = repository.createAsset(builder.getAsset());

    assertNotNull(id);

    boolean assetPathShouldNotExists = repository.directoryExists("/test/test.png");
    assertFalse(assetPathShouldNotExists);
  }
  /** Test that the equals() method distinguishes all fields. */
  @Test
  public void testEquals() {
    // default instances
    VectorDataItem v1 = new VectorDataItem(1.0, 2.0, 3.0, 4.0);
    VectorDataItem v2 = new VectorDataItem(1.0, 2.0, 3.0, 4.0);
    assertTrue(v1.equals(v2));
    assertTrue(v2.equals(v1));

    v1 = new VectorDataItem(1.1, 2.0, 3.0, 4.0);
    assertFalse(v1.equals(v2));
    v2 = new VectorDataItem(1.1, 2.0, 3.0, 4.0);
    assertTrue(v1.equals(v2));

    v1 = new VectorDataItem(1.1, 2.2, 3.0, 4.0);
    assertFalse(v1.equals(v2));
    v2 = new VectorDataItem(1.1, 2.2, 3.0, 4.0);
    assertTrue(v1.equals(v2));

    v1 = new VectorDataItem(1.1, 2.2, 3.3, 4.0);
    assertFalse(v1.equals(v2));
    v2 = new VectorDataItem(1.1, 2.2, 3.3, 4.0);
    assertTrue(v1.equals(v2));

    v1 = new VectorDataItem(1.1, 2.2, 3.3, 4.4);
    assertFalse(v1.equals(v2));
    v2 = new VectorDataItem(1.1, 2.2, 3.3, 4.4);
    assertTrue(v1.equals(v2));
  }
Beispiel #17
0
  @Test
  public void completeBuilder() throws Exception {
    CacheControl cacheControl =
        new CacheControl.Builder()
            .noCache()
            .noStore()
            .maxAge(1, TimeUnit.SECONDS)
            .maxStale(2, TimeUnit.SECONDS)
            .minFresh(3, TimeUnit.SECONDS)
            .onlyIfCached()
            .noTransform()
            .build();
    assertEquals(
        "no-cache, no-store, max-age=1, max-stale=2, min-fresh=3, only-if-cached, "
            + "no-transform",
        cacheControl.toString());
    assertTrue(cacheControl.noCache());
    assertTrue(cacheControl.noStore());
    assertEquals(1, cacheControl.maxAgeSeconds());
    assertEquals(2, cacheControl.maxStaleSeconds());
    assertEquals(3, cacheControl.minFreshSeconds());
    assertTrue(cacheControl.onlyIfCached());

    // These members are accessible to response headers only.
    assertEquals(-1, cacheControl.sMaxAgeSeconds());
    assertFalse(cacheControl.isPublic());
    assertFalse(cacheControl.mustRevalidate());
  }
  @Test
  public void supportsPosixlyCorrectBehavior() {
    OptionParser parser = new OptionParser("i:j::k");
    String[] arguments = {
      "-ibar", "-i", "junk", "xyz", "-jixnay", "foo", "-k", "blah", "--", "bah"
    };

    OptionSet options = parser.parse(arguments);

    assertTrue(options.has("i"));
    assertTrue(options.has("j"));
    assertTrue(options.has("k"));
    assertEquals(asList("bar", "junk"), options.valuesOf("i"));
    assertEquals(singletonList("ixnay"), options.valuesOf("j"));
    assertEquals(asList("xyz", "foo", "blah", "bah"), options.nonOptionArguments());

    parser.posixlyCorrect(true);
    options = parser.parse(arguments);

    assertTrue(options.has("i"));
    assertFalse(options.has("j"));
    assertFalse(options.has("k"));
    assertEquals(asList("bar", "junk"), options.valuesOf("i"));
    assertEquals(emptyList(), options.valuesOf("j"));
    assertEquals(
        asList("xyz", "-jixnay", "foo", "-k", "blah", "--", "bah"), options.nonOptionArguments());
  }
  /** @throws DSLException . */
  @Test
  public void testBasicExtendParsing() throws DSLException {

    final File testParsingBaseDslFile =
        new File(TEST_PARSING_RESOURCE_PATH + "test_parsing_base-service.groovy");
    final File testParsingBaseWorkDir = new File(TEST_PARSING_RESOURCE_PATH);
    final Service baseService =
        ServiceReader.getServiceFromFile(testParsingBaseDslFile, testParsingBaseWorkDir)
            .getService();
    Assert.assertFalse(baseService.getName().equals("test parsing extend"));
    final ServiceLifecycle baseLifecycle = baseService.getLifecycle();
    Assert.assertFalse(baseLifecycle.getInit().equals("test_parsing_extend_install.groovy"));
    Assert.assertNull(baseLifecycle.getStop());

    final File testParsingExtendDslFile =
        new File(TEST_PARSING_RESOURCE_PATH + "test_parsing_extend-service.groovy");
    final File testParsingExtendWorkDir = new File(TEST_PARSING_RESOURCE_PATH);
    final Service service =
        ServiceReader.getServiceFromFile(testParsingExtendDslFile, testParsingExtendWorkDir)
            .getService();
    Assert.assertEquals("test parsing extend", service.getName());
    final ServiceLifecycle lifecycle = service.getLifecycle();
    Assert.assertEquals(ExecutableDSLEntryType.STRING, lifecycle.getInit().getEntryType());
    Assert.assertEquals(
        "test_parsing_extend_install.groovy",
        ((StringExecutableEntry) lifecycle.getInit()).getCommand());
    Assert.assertNotNull(lifecycle.getStart());
    Assert.assertNotNull(lifecycle.getPostStart());
    Assert.assertNotNull(lifecycle.getPreStop());
    Assert.assertNotNull(lifecycle.getStop());
    Assert.assertEquals(1, service.getExtendedServicesPaths().size());
    Assert.assertEquals(
        new File(TEST_PARSING_RESOURCE_PATH, "test_parsing_base-service.groovy").getAbsolutePath(),
        service.getExtendedServicesPaths().getFirst());
  }
  @Test
  public void createEmpty() {
    mc = ImmutableMultiChState.fromChannelIds(cids);
    mc2 = ImmutableMultiChState.fromChannelIds(cids);

    // Make sure that the two instance pointers are identical, because of
    // internal caching.
    assertTrue(mc == mc2);
    assertTrue(mc.equals(mc2));
    assertTrue(mc.hashCode() == mc2.hashCode());

    // Now, attempt to create the same mc/mc2 instances, but by building
    // them from more explicit state instances.
    mc3 = ImmutableMultiChState.fromChannelStates(chStates);
    assertTrue(mc == mc3);
    assertTrue(mc.equals(mc3));

    cids = Util.newList(2);
    cid1 = new ChannelId(1, 2, 0);
    cid2 = new ChannelId(2, 2, 1);
    cids.add(cid1);
    cids.add(cid2);

    mc3 = ImmutableMultiChState.fromChannelIds(cids);
    assertFalse(mc == mc3);
    assertFalse(mc.equals(mc3));
  }
Beispiel #21
0
  @Test
  public void testCreateAndDropManyDatabases() throws Exception {
    List<String> createdDatabases = new ArrayList<>();
    InfoSchemaMetadataDictionary dictionary = new InfoSchemaMetadataDictionary();
    String namePrefix = "database_";
    final int NUM = 10;
    for (int i = 0; i < NUM; i++) {
      String databaseName = namePrefix + i;
      assertFalse(catalog.existDatabase(databaseName));
      catalog.createDatabase(databaseName, TajoConstants.DEFAULT_TABLESPACE_NAME);
      assertTrue(catalog.existDatabase(databaseName));
      createdDatabases.add(databaseName);
    }

    Collection<String> allDatabaseNames = catalog.getAllDatabaseNames();
    for (String databaseName : allDatabaseNames) {
      assertTrue(
          databaseName.equals(DEFAULT_DATABASE_NAME)
              || createdDatabases.contains(databaseName)
              || dictionary.isSystemDatabase(databaseName));
    }
    // additional ones are 'default' and 'system' databases.
    assertEquals(NUM + 2, allDatabaseNames.size());

    Collections.shuffle(createdDatabases);
    for (String tobeDropped : createdDatabases) {
      assertTrue(catalog.existDatabase(tobeDropped));
      catalog.dropDatabase(tobeDropped);
      assertFalse(catalog.existDatabase(tobeDropped));
    }
  }
  @Ignore
  @Test
  public void testEdgeVersionMapper() throws Exception {
    Version version = getVersion("/version/edgepoc/TELLER,LCY_CASHIN_DENOM.version");
    MdfClass application = version.getForApplication();
    assertFalse(((EObject) application).eIsProxy());
    assertEquals("TELLER", application.getName());
    MdfProperty appProperty = application.getProperty("TRANSACTION_NUMBER");
    assertNotNull("application property for TRANSACTION_NUMBER is null", appProperty);
    assertFalse(
        "application property for TRANSACTION_NUMBER is a EMF proxy",
        ((EObject) appProperty).eIsProxy());

    // This doesn't work like this, because it doesn't handle multi value fields, which are only
    // inside the __ sub value classes in domain..
    //		EList<Field> fields = version.getFields();
    //		for (Field field : fields) {
    //		    if  ( ! "*".equals( field.getName() )) {
    //	            MdfProperty appProperty =
    // version.getForApplication().getProperty(field.getName());
    //		        assertNotNull( "Could not get application property for: " + field.getName(),
    // appProperty );
    //		    }
    //        }
  }
Beispiel #23
0
  /** It asserts the equality between an original table desc and a restored table desc. */
  private static void assertSchemaEquality(String tableName, Schema schema)
      throws IOException, TajoException {
    Path path = new Path(CommonTestingUtil.getTestDir(), tableName);
    TableDesc tableDesc =
        new TableDesc(
            IdentifierUtil.buildFQName(DEFAULT_DATABASE_NAME, tableName),
            schema,
            "TEXT",
            new KeyValueSet(),
            path.toUri());

    // schema creation
    assertFalse(catalog.existsTable(DEFAULT_DATABASE_NAME, tableName));
    catalog.createTable(tableDesc);
    assertTrue(catalog.existsTable(DEFAULT_DATABASE_NAME, tableName));

    // change it for the equals test.
    schema.setQualifier(IdentifierUtil.buildFQName(DEFAULT_DATABASE_NAME, tableName));
    TableDesc restored = catalog.getTableDesc(DEFAULT_DATABASE_NAME, tableName);
    assertEquals(schema, restored.getSchema());

    // drop test
    catalog.dropTable(IdentifierUtil.buildFQName(DEFAULT_DATABASE_NAME, tableName));
    assertFalse(catalog.existsTable(DEFAULT_DATABASE_NAME, tableName));
  }
Beispiel #24
0
  @Test
  public void testContainsOneNonTerminal() {
    Production production = new Production(new Symbol(), 2);

    assertFalse("null list", production.containsOneNonTerminal());

    production.setHandle(new SymbolList());
    assertFalse("empty list", production.containsOneNonTerminal());

    production.getHandle().clear();
    production.getHandle().add(new Symbol("Symbol1", SymbolType.NOISE, 1));
    assertFalse("one terminal symbol", production.containsOneNonTerminal());

    production.getHandle().clear();
    production.getHandle().add(new Symbol("Symbol1", SymbolType.NON_TERMINAL, 1));
    assertTrue("one non-terminal", production.containsOneNonTerminal());

    production.getHandle().add(new Symbol("Symbol2", SymbolType.NON_TERMINAL, 2));
    assertFalse("two non-terminals", production.containsOneNonTerminal());

    production.getHandle().clear();
    production.getHandle().add(new Symbol("Symbol1", SymbolType.NON_TERMINAL, 1));
    assertTrue("one non-terminal", production.containsOneNonTerminal());
    production.getHandle().add(new Symbol("Symbol2", SymbolType.NOISE, 2));
    assertFalse("one terminal/one non-terminal", production.containsOneNonTerminal());
  }
Beispiel #25
0
  @Test
  public final void testRegisterAndFindFunc() throws Exception {
    assertFalse(catalog.containFunction("test10", FunctionType.GENERAL));
    FunctionDesc meta =
        new FunctionDesc(
            "test10",
            TestFunc2.class,
            FunctionType.GENERAL,
            CatalogUtil.newSimpleDataType(Type.INT4),
            CatalogUtil.newSimpleDataTypeArray(Type.INT4, Type.BLOB));

    catalog.createFunction(meta);
    assertTrue(
        catalog.containFunction(
            "test10", CatalogUtil.newSimpleDataTypeArray(Type.INT4, Type.BLOB)));
    FunctionDesc retrived =
        catalog.getFunction("test10", CatalogUtil.newSimpleDataTypeArray(Type.INT4, Type.BLOB));

    assertEquals(retrived.getFunctionName(), "test10");
    assertEquals(retrived.getLegacyFuncClass(), TestFunc2.class);
    assertEquals(retrived.getFuncType(), FunctionType.GENERAL);

    assertFalse(
        catalog.containFunction(
            "test10", CatalogUtil.newSimpleDataTypeArray(Type.BLOB, Type.INT4)));
  }
Beispiel #26
0
  @Test
  public void testToAndFromString() {
    long longValue = 333333333;

    var2.setTo(longValue);
    String value = var2.toString();
    assertFalse(value.isEmpty());

    var2.fromString(Variant.type_integer, value);

    var2.fromString(Variant.type_real, "5.5");
    assertEquals(var2.getType(), Variant.type_real);

    value = var2.toString();
    assertEquals("5.5", value);

    value = var2.toString(true);
    assertEquals("(real) 5.5", value);

    String typeStr = Variant.typeToString(Variant.type_vec4d_vector);
    assertEquals("vec4d[]", typeStr);

    int type = Variant.typeFromString(typeStr);
    assertEquals(Variant.type_vec4d_vector, type);

    assertTrue(Variant.isConvertible(Variant.type_integer, Variant.type_real));
    assertFalse(Variant.isConvertible(Variant.type_integer, Variant.type_string));

    String base64Str = "trampampampampam";
    byte[] buf = Variant.base64Decode(base64Str);
    assertNotEquals(0, buf.length);

    assertEquals(base64Str, Variant.base64Encode(buf));
  }
  public void encryption(SimpleHDKeyChain unencChain) throws UnreadableWalletException {
    DeterministicKey key1 = unencChain.getKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
    SimpleHDKeyChain encChain = unencChain.toEncrypted("open secret");
    DeterministicKey encKey1 = encChain.findKeyFromPubKey(key1.getPubKey());
    checkEncryptedKeyChain(encChain, key1);

    // Round-trip to ensure de/serialization works and that we can store two chains and they both
    // deserialize.
    List<Protos.Key> serialized = encChain.toProtobuf();
    System.out.println(protoToString(serialized));
    encChain = SimpleHDKeyChain.fromProtobuf(serialized, encChain.getKeyCrypter());
    checkEncryptedKeyChain(encChain, unencChain.findKeyFromPubKey(key1.getPubKey()));

    DeterministicKey encKey2 = encChain.getKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
    // Decrypt and check the keys match.
    SimpleHDKeyChain decChain = encChain.toDecrypted("open secret");
    DeterministicKey decKey1 = decChain.findKeyFromPubHash(encKey1.getPubKeyHash());
    DeterministicKey decKey2 = decChain.findKeyFromPubHash(encKey2.getPubKeyHash());
    assertEquals(decKey1.getPubKeyPoint(), encKey1.getPubKeyPoint());
    assertEquals(decKey2.getPubKeyPoint(), encKey2.getPubKeyPoint());
    assertFalse(decKey1.isEncrypted());
    assertFalse(decKey2.isEncrypted());
    assertNotEquals(encKey1.getParent(), decKey1.getParent()); // parts of a different hierarchy
    // Check we can once again derive keys from the decrypted chain.
    decChain.getKey(KeyChain.KeyPurpose.RECEIVE_FUNDS).sign(Sha256Hash.ZERO_HASH);
    decChain.getKey(KeyChain.KeyPurpose.CHANGE).sign(Sha256Hash.ZERO_HASH);
  }
  @Test
  public void getAllCustomerCars() {
    assertFalse(customer1.getActive());
    assertFalse(customer2.getActive());
    assertFalse(customer3.getActive());

    manager.rentCarToCustomer(
        car2, customer1, Date.valueOf("2012-03-21"), Date.valueOf("2012-03-31"));
    manager.rentCarToCustomer(
        car3, customer1, Date.valueOf("2012-03-25"), Date.valueOf("2012-04-02"));
    manager.rentCarToCustomer(
        car1, customer2, Date.valueOf("2012-03-15"), Date.valueOf("2012-03-27"));

    List<Car> carsRetnedtoCustomer1 = Arrays.asList(car2, car3);
    List<Car> carsRetnedtoCustomer2 = Arrays.asList(car1);

    assertCarDeepEquals(carsRetnedtoCustomer1, manager.getAllCustomerCars(customer1));
    assertCarDeepEquals(carsRetnedtoCustomer2, manager.getAllCustomerCars(customer2));
    assertFalse(customer3.getActive());

    try {
      manager.getAllCustomerCars(null);
      fail();
    } catch (IllegalArgumentException e) {
    }

    try {
      manager.getAllCustomerCars(customerWithoutID);
      fail();
    } catch (IllegalArgumentException e) {
    }
  }
  /** Confirm that the equals method can distinguish all the required fields. */
  @Test
  public void testEquals() {
    QuarterDateFormat qf1 =
        new QuarterDateFormat(TimeZone.getTimeZone("GMT"), new String[] {"1", "2", "3", "4"});
    QuarterDateFormat qf2 =
        new QuarterDateFormat(TimeZone.getTimeZone("GMT"), new String[] {"1", "2", "3", "4"});
    assertEquals(qf1, qf2);
    assertEquals(qf2, qf1);

    qf1 = new QuarterDateFormat(TimeZone.getTimeZone("PST"), new String[] {"1", "2", "3", "4"});
    assertFalse(qf1.equals(qf2));
    qf2 = new QuarterDateFormat(TimeZone.getTimeZone("PST"), new String[] {"1", "2", "3", "4"});
    assertEquals(qf1, qf2);

    qf1 = new QuarterDateFormat(TimeZone.getTimeZone("PST"), new String[] {"A", "2", "3", "4"});
    assertFalse(qf1.equals(qf2));
    qf2 = new QuarterDateFormat(TimeZone.getTimeZone("PST"), new String[] {"A", "2", "3", "4"});
    assertEquals(qf1, qf2);

    qf1 =
        new QuarterDateFormat(TimeZone.getTimeZone("PST"), new String[] {"A", "2", "3", "4"}, true);
    assertFalse(qf1.equals(qf2));
    qf2 =
        new QuarterDateFormat(TimeZone.getTimeZone("PST"), new String[] {"A", "2", "3", "4"}, true);
    assertEquals(qf1, qf2);
  }
Beispiel #30
0
  private <T> void assertQueryable(
      QueryGranularity granularity,
      String dataSource,
      Interval interval,
      List<Pair<String, Interval>> expected) {
    Iterator<Pair<String, Interval>> expectedIter = expected.iterator();
    final List<Interval> intervals = Arrays.asList(interval);
    final SearchQuery query =
        Druids.newSearchQueryBuilder()
            .dataSource(dataSource)
            .intervals(intervals)
            .granularity(granularity)
            .limit(10000)
            .query("wow")
            .build();
    QueryRunner<Result<SearchResultValue>> runner =
        serverManager.getQueryRunnerForIntervals(query, intervals);
    final Sequence<Result<SearchResultValue>> seq = runner.run(query);
    Sequences.toList(seq, Lists.<Result<SearchResultValue>>newArrayList());
    Iterator<SegmentForTesting> adaptersIter = factory.getAdapters().iterator();

    while (expectedIter.hasNext() && adaptersIter.hasNext()) {
      Pair<String, Interval> expectedVals = expectedIter.next();
      SegmentForTesting value = adaptersIter.next();

      Assert.assertEquals(expectedVals.lhs, value.getVersion());
      Assert.assertEquals(expectedVals.rhs, value.getInterval());
    }

    Assert.assertFalse(expectedIter.hasNext());
    Assert.assertFalse(adaptersIter.hasNext());

    factory.clearAdapters();
  }