Example #1
0
  @Test
  public void testConfigurationModel() throws Exception {
    // Test the default configuration
    final HawkServerConfiguration configuration1 = new HawkServerConfiguration.Builder().build();
    configuration1.toString();
    configuration1.hashCode();
    assertEquals(configuration1, configuration1);
    assertNotEquals(configuration1, null);
    assertNotEquals(null, configuration1);

    // Test a copied configuration
    final HawkServerConfiguration configuration2 =
        new HawkServerConfiguration.Builder(configuration1)
            .bewitAllowed(false)
            .nonceCacheSize(500L)
            .payloadValidation(PayloadValidation.MANDATORY)
            .timestampSkew(30L)
            .build();
    configuration2.toString();
    configuration2.hashCode();
    assertEquals(configuration2, configuration2);
    assertNotEquals(configuration2, null);
    assertNotEquals(null, configuration2);
    assertNotEquals(configuration2, configuration1);
  }
Example #2
0
  @Test
  public void testModel() throws Exception {
    // Test a default server
    final HawkServer server1 = new HawkServer.Builder().build();
    server1.toString();
    server1.hashCode();
    assertEquals(server1, server1);
    assertNotEquals(null, server1);
    assertNotEquals(server1, null);

    // Test a copied server
    HawkServer server2 =
        new HawkServer.Builder(server1)
            .configuration(
                new HawkServerConfiguration.Builder()
                    .payloadValidation(PayloadValidation.MANDATORY)
                    .build())
            .build();
    server2.toString();
    server2.hashCode();
    assertEquals(server2, server2);
    assertNotEquals(null, server2);
    assertNotEquals(server2, null);
    assertNotEquals(server1, server2);
  }
 public void test_equals_notEqual() {
   LocalDateDoubleTimeSeries series1 = LocalDateDoubleTimeSeries.of(DATE_2014_01_01, 1d);
   LocalDateDoubleTimeSeries series2 = LocalDateDoubleTimeSeries.of(DATE_2013_06_01, 1d);
   LocalDateDoubleTimeSeries series3 = LocalDateDoubleTimeSeries.of(DATE_2014_01_01, 3d);
   assertNotEquals(series1, series2);
   assertNotEquals(series1, series3);
 }
Example #4
0
  @Test
  public void testConfigurationModel() throws Exception {
    // Test default configuration
    final HawkClientConfiguration configuration1 = new HawkClientConfiguration();
    assertNotNull(configuration1);
    configuration1.toString();
    configuration1.hashCode();
    assertEquals(configuration1, configuration1);
    assertNotEquals(null, configuration1);
    assertNotEquals(configuration1, null);

    // Test non-default configuration
    final HawkClientConfiguration configuration2 =
        new HawkClientConfiguration.Builder(configuration1)
            .payloadValidation(PayloadValidation.MANDATORY)
            .pathPrefix("/test")
            .build();
    assertNotNull(configuration2);
    configuration2.toString();
    configuration2.hashCode();
    assertEquals(configuration2, configuration2);
    assertNotEquals(null, configuration2);
    assertNotEquals(configuration2, null);
    assertNotEquals(configuration2, configuration1);
  }
 @Test
 public void checkNotRegistered() throws MalformedObjectNameException {
   MBeanServer jolokiaServer = JolokiaMBeanServerUtil.getJolokiaMBeanServer();
   Assert.assertNotEquals(ManagementFactory.getPlatformMBeanServer(), jolokiaServer);
   for (MBeanServer server : MBeanServerFactory.findMBeanServer(null)) {
     Assert.assertNotEquals(server, jolokiaServer);
   }
 }
  @Test
  public void testPartitionKey() {
    long tableId0 = 1;
    long tableId1 = 2;

    String partitionName0 = "ds=2013-06-01";
    String partitionName1 = "foo=bar";

    dao.insertPartition(tableId0, partitionName0);
    dao.insertPartition(tableId1, partitionName1);

    PartitionKey testKey0 =
        new NativePartitionKey(partitionName0, "ds", ColumnType.STRING, "2013-06-01");
    PartitionKey testKey1 = new NativePartitionKey(partitionName1, "foo", ColumnType.STRING, "bar");

    long keyId0 =
        dao.insertPartitionKey(
            tableId0,
            partitionName0,
            testKey0.getName(),
            testKey0.getType().toString(),
            testKey0.getValue());

    long keyId1 =
        dao.insertPartitionKey(
            tableId0,
            partitionName0,
            testKey1.getName(),
            testKey1.getType().toString(),
            testKey1.getValue());
    assertNotEquals(keyId1, keyId0);

    long keyId2 =
        dao.insertPartitionKey(
            tableId1,
            partitionName1,
            testKey1.getName(),
            testKey1.getType().toString(),
            testKey1.getValue());
    assertNotEquals(keyId2, keyId0);

    Set<NativePartitionKey> filteredKeys =
        ImmutableSet.copyOf(
            Collections2.filter(
                dao.getPartitionKeys(tableId1),
                NativePartitionKey.partitionNamePredicate(partitionName1)));
    assertEquals(filteredKeys.size(), 1);

    Set<NativePartitionKey> retrievedKeys = dao.getPartitionKeys(tableId1);
    assertNotNull(retrievedKeys);
    assertEquals(retrievedKeys.size(), 1);
    assertEquals(Iterables.getOnlyElement(retrievedKeys), testKey1);
  }
Example #7
0
 @Test
 public void testConfiguration() throws Exception {
   // Test obtaining the configuration from a valid configuration source
   final HawkClientConfiguration configuration =
       new ConfigurationSource<HawkClientConfiguration>()
           .getConfiguration("clientconfig-test1.json", HawkClientConfiguration.class);
   assertNotNull(configuration);
   configuration.toString();
   configuration.hashCode();
   assertEquals(configuration, configuration);
   assertNotEquals(null, configuration);
   assertNotEquals(configuration, null);
 }
 @Test
 public void basics() {
   Injector injector = Guice.createInjector(new M(), new FinderModule());
   MyFinder a = injector.getInstance(MyFinder.class);
   MyFinder a1 = injector.getInstance(MyFinder.class);
   Assert.assertSame(a, a1);
   MyFinder b = Guice.createInjector(new M(), new FinderModule()).getInstance(MyFinder.class);
   Assert.assertNotEquals(a, b);
   Assert.assertNotEquals(a.hashCode(), b.hashCode());
   Assert.assertEquals(a, a);
   Assert.assertEquals(a.hashCode(), a.hashCode());
   Assert.assertTrue(a.toString().startsWith("DynamicFinder@"));
 }
Example #9
0
  @Test(groups = "unitTest")
  public void testCopyNullTargetWithFilledTarget() {
    // given
    final Anime target = new Anime();
    target.setEpisodes(4);
    target.setInfoLink("http://myanimelist.net/anime/10863");
    target.setLocation("/anime/series/steins_gate_special");
    target.setPicture("https://myanimelist.cdn-dena.com/images/anime/7/36531.jpg");
    target.setThumbnail("https://myanimelist.cdn-dena.com/images/anime/7/36531t.jpg");
    target.setTitle("Steins;Gate: Oukoubakko no Poriomania");
    target.setType(AnimeType.SPECIAL);

    final Anime anime = new Anime();
    anime.setEpisodes(37);
    anime.setInfoLink("http://myanimelist.net/anime/1535");
    anime.setLocation("/anime/series/death_note");
    anime.setPicture("https://myanimelist.cdn-dena.com/images/anime/9/9453.jpg");
    anime.setThumbnail("https://myanimelist.cdn-dena.com/images/anime/9/9453t.jpg");
    anime.setTitle("Death Note");
    anime.setType(AnimeType.TV);

    // when
    Anime.copyNullTarget(anime, target);

    // then
    assertNotEquals(target.getEpisodes(), anime.getEpisodes());
    assertNotEquals(target.getInfoLink(), anime.getInfoLink());
    assertNotEquals(target.getLocation(), anime.getLocation());
    assertNotEquals(target.getPicture(), anime.getPicture());
    assertNotEquals(target.getThumbnail(), anime.getThumbnail());
    assertNotEquals(target.getTitle(), anime.getTitle());
    assertNotEquals(target.getType(), anime.getType());
    assertNotEquals(target.getId(), anime.getId());
  }
  @Test
  public void testConfigureURI() throws Exception {
    final String TEST_URI = "hdfs://argggg:1111";
    LinkConfiguration linkConfiguration = new LinkConfiguration();
    Configuration conf = new Configuration();

    assertNotEquals(TEST_URI, conf.get("fs.default.name"));
    assertNotEquals(TEST_URI, conf.get("fs.defaultFS"));

    linkConfiguration.linkConfig.uri = TEST_URI;

    conf = HdfsUtils.configureURI(conf, linkConfiguration);
    assertEquals(TEST_URI, conf.get("fs.default.name"));
    assertEquals(TEST_URI, conf.get("fs.defaultFS"));
  }
  @Test
  public void testButtonLabel() {
    calendarAttributes.set(CalendarAttributes.buttonLabel, "label");

    assertTrue(
        Graphene.element(calendar.getPopupButton()).isVisible().apply(driver),
        "Button should be displayed.");
    assertEquals(calendar.getPopupButton().getText(), "label", "Label of the button.");
    assertNotEquals(
        calendar.getPopupButton().getTagName(), "img", "Image should not be displayed.");

    calendarAttributes.set(CalendarAttributes.buttonIcon, "star");
    assertNotEquals(
        calendar.getPopupButton().getTagName(), "img", "Image should not be displayed.");
  }
 @Test
 public void TestAppid() {
   final String reason =
       "You need a valid Azure Appid as the static final String AZURE_APPID in net.billylieurance.azuresearch.test.AzureAppid to run these tests.";
   Assert.assertNotNull(AzureAppid.AZURE_APPID, reason);
   Assert.assertNotEquals(AzureAppid.AZURE_APPID, "", reason);
 }
  @Test
  public void testGetManagementPlaneSyncStateInfersTimedOutNodeAsFailed() throws Exception {
    persister.delta(
        ManagementPlaneSyncRecordDeltaImpl.builder()
            .node(newManagerMemento(ownNodeId, ManagementNodeState.STANDBY, tickerCurrentMillis()))
            .node(newManagerMemento("node1", ManagementNodeState.MASTER, tickerCurrentMillis()))
            .setMaster("node1")
            .build());

    manager.start(HighAvailabilityMode.AUTO);

    ManagementPlaneSyncRecord state = manager.getManagementPlaneSyncState();
    assertEquals(state.getManagementNodes().get("node1").getStatus(), ManagementNodeState.MASTER);
    assertEquals(
        state.getManagementNodes().get(ownNodeId).getStatus(), ManagementNodeState.STANDBY);

    // Simulate passage of time; ticker used by this HA-manager so it will "correctly" publish
    // its own heartbeat with the new time; but node1's record is now out-of-date.
    tickerAdvance(Duration.seconds(31));

    ManagementPlaneSyncRecord state2 = manager.getManagementPlaneSyncState();
    assertEquals(state2.getManagementNodes().get("node1").getStatus(), ManagementNodeState.FAILED);
    assertNotEquals(
        state.getManagementNodes().get(ownNodeId).getStatus(), ManagementNodeState.FAILED);
  }
Example #14
0
  /**
   * The request context is destroyed at the end of the servlet request, after the service() method
   * and all doFilter() methods, and all requestDestroyed() notifications return.
   */
  @Test
  @SpecAssertions({
    @SpecAssertion(section = REQUEST_CONTEXT_EE, id = "ba"),
    @SpecAssertion(section = REQUEST_CONTEXT_EE, id = "bb"),
    @SpecAssertion(section = REQUEST_CONTEXT_EE, id = "bc")
  })
  public void testRequestScopeIsDestroyedAfterServletRequest() throws Exception {

    WebClient webClient = new WebClient();
    webClient.setThrowExceptionOnFailingStatusCode(true);

    // First request - response content contains SimpleRequestBean id
    TextPage firstRequestResult = webClient.getPage(contextPath + "introspect");
    assertNotNull(firstRequestResult.getContent());
    // Make a second request and make sure the same context is not there (compare SimpleRequestBean
    // ids)
    TextPage secondRequestResult = webClient.getPage(contextPath + "introspect");
    assertNotNull(secondRequestResult.getContent());
    assertNotEquals(
        secondRequestResult.getContent().trim(), firstRequestResult.getContent().trim());

    // Make sure request context is destroyed after service(), doFilter(), requestDestroyed()
    webClient.getPage(contextPath + "introspect?mode=collect");
    ActionSequence correctSequence =
        new ActionSequence()
            .add(IntrospectServlet.class.getName())
            .add(IntrospectFilter.class.getName())
            .add(TestServletRequestListener.class.getName())
            .add(ContextDestructionObserver.class.getName());
    TextPage destroyRequestResult = webClient.getPage(contextPath + "introspect?mode=verify");
    assertNotNull(destroyRequestResult.getContent());
    assertEquals(destroyRequestResult.getContent(), correctSequence.toString());
  }
 @Test
 public void seemsWorkHuh() {
   final byte[] expected = new byte[] {0x00, 0x09, 0x1A};
   final String encoded = new BigInteger(expected).toString(16);
   final byte[] actual = new BigInteger(encoded, 16).toByteArray();
   Assert.assertNotEquals(actual, expected);
 }
Example #16
0
 public void testAbstract() {
   final FunctionExclusionGroups groups =
       new AbstractFunctionExclusionGroups<String>() {
         @Override
         protected String getKey(final FunctionDefinition function) {
           if (function.getShortName().startsWith("A_")) {
             return "A";
           } else if (function.getShortName().startsWith("B_")) {
             return "B";
           } else {
             return null;
           }
         }
       };
   final FunctionDefinition a_foo = new Function("A_foo");
   final FunctionDefinition a_bar = new Function("A_bar");
   final FunctionDefinition b_foo = new Function("B_foo");
   final FunctionDefinition b_bar = new Function("B_bar");
   final FunctionDefinition foo = new Function("foo");
   final FunctionDefinition bar = new Function("bar");
   assertNull(groups.getExclusionGroup(foo));
   assertNull(groups.getExclusionGroup(bar));
   final FunctionExclusionGroup afoo1 = groups.getExclusionGroup(a_foo);
   final FunctionExclusionGroup afoo2 = groups.getExclusionGroup(a_foo);
   assertEquals(afoo1, afoo2);
   final FunctionExclusionGroup abar = groups.getExclusionGroup(a_bar);
   assertEquals(abar, afoo1);
   final FunctionExclusionGroup bfoo = groups.getExclusionGroup(b_foo);
   assertNotEquals(abar, bfoo);
   final FunctionExclusionGroup bbar = groups.getExclusionGroup(b_bar);
   assertEquals(bbar, bfoo);
 }
  @Test(
      groups = {"wso2.brs"},
      dependsOnMethods = {"uploadHealthCareService"})
  public void testHealthCareStub() throws Exception {

    requestSender.waitForProcessDeployment(
        getContext().getContextUrls().getServiceUrl() + "/HealthCareService");
    HealthCareServiceStub healthCareServiceStub =
        new HealthCareServiceStub(
            getContext().getContextUrls().getServiceUrl() + "/HealthCareService");

    PatientDetail patientDetail = new PatientDetail();
    Patient patient = new Patient();
    patient.setAge(43);
    patient.setCreatinineLevel(1.0);
    patient.setMedication("Levofloxacin");

    Patient[] patients = new Patient[1];
    patients[0] = patient;
    patientDetail.setPatientDetail(patients);

    Dose[] doses = healthCareServiceStub.recommendDose(patients);
    String result = doses[0].getMessage();
    assertNotNull(result, "Result cannot be null");
    assertNotEquals(result, "");
  }
  // Integration test because requires ssh'ing (and takes about 5 seconds)
  // See also SoftwareProcessEntityTest.testCustomInstallDirX for a lot more mocked variants
  @Test(groups = "Integration")
  public void testCanInstallMultipleVersionsOnSameMachine() throws Exception {
    managementContext
        .getBrooklynProperties()
        .put(BrooklynConfigKeys.ONBOX_BASE_DIR, tempDataDir.getAbsolutePath());

    MyService entity =
        app.createAndManageChild(
            EntitySpec.create(MyService.class)
                .configure(SoftwareProcess.SUGGESTED_VERSION, "0.1.0"));
    MyService entity2 =
        app.createAndManageChild(
            EntitySpec.create(MyService.class)
                .configure(SoftwareProcess.SUGGESTED_VERSION, "0.2.0"));
    app.start(ImmutableList.of(machine127));

    String installDir1 = entity.getAttribute(SoftwareProcess.INSTALL_DIR);
    String installDir2 = entity2.getAttribute(SoftwareProcess.INSTALL_DIR);

    assertNotEquals(installDir1, installDir2);
    assertTrue(installDir1.contains("0.1.0"), "installDir1=" + installDir1);
    assertTrue(installDir2.contains("0.2.0"), "installDir2=" + installDir2);
    assertTrue(new File(new File(installDir1), "myfile").isFile());
    assertTrue(new File(new File(installDir2), "myfile").isFile());
  }
  // TODO add test methods here.
  // The methods must be annotated with annotation @Test. For example:
  //
  @Test
  public void testImmutable() {
    // Object of class That Returns the array
    OtherEmployeeList Other_Emp_list_Obj = new OtherEmployeeList(other_employees);

    // Object To be added
    Other_Employees empObj =
        new Other_Employees(
            "900125", "Eesa", "Abrahams", convertDate("1990-01-10"), 900231, "Admin", "Secetary");

    // Size is zero
    Assert.assertEquals(other_employees.size(), 0, "Error List isnt empty");

    Other_Emp_list_Obj = Other_Emp_list_Obj.addToList(empObj);

    other_employees = Other_Emp_list_Obj.getList();
    Assert.assertNotEquals(
        Other_Emp_list_Obj.hashCode(),
        Other_Emp_list_Obj.addToList(empObj).hashCode(),
        "Error It is still the same object");

    // Test if an object got added
    Assert.assertEquals(other_employees.size(), 1, "Error Nothing was added");

    empObj = (Other_Employees) other_employees.get(0);

    Assert.assertEquals(empObj.getName(), "Eesa", "Error The value in the list is incorrect");
  }
Example #20
0
  @Test(groups = "unitTest")
  public void testCopyNullTarget() {
    // given
    final Anime target = new Anime();

    final Anime anime = new Anime();
    anime.setEpisodes(37);
    anime.setInfoLink("http://myanimelist.net/anime/1535");
    anime.setLocation("/anime/series/death_note");
    anime.setPicture("https://myanimelist.cdn-dena.com/images/anime/9/9453.jpg");
    anime.setThumbnail("https://myanimelist.cdn-dena.com/images/anime/9/9453t.jpg");
    anime.setTitle("Death Note");
    anime.setType(AnimeType.TV);

    // when
    Anime.copyNullTarget(anime, target);

    // then
    assertEquals(target.getEpisodes(), anime.getEpisodes());
    assertEquals(target.getInfoLink(), anime.getInfoLink());
    assertEquals(target.getLocation(), anime.getLocation());
    assertEquals(target.getPicture(), anime.getPicture());
    assertEquals(target.getThumbnail(), anime.getThumbnail());
    assertEquals(target.getTitle(), anime.getTitle());
    assertEquals(target.getType(), anime.getType());
    assertNotEquals(target.getId(), anime.getId());
  }
  /** Test of isAdmin method, of class PersonFacadeImpl. */
  @Test
  public void testIsAdmin() {
    when(personDao.findById(person.getId())).thenReturn(person);

    Assert.assertEquals(personFacade.isAdmin(personDTO), person.isAdmin());
    Assert.assertNotEquals(personFacade.isAdmin(personDTO), person2.isAdmin());
  }
 @Test
 public void testEquals() {
   AbstractLocation l1 = new ConcreteLocation(MutableMap.of("id", "1", "name", "bob"));
   AbstractLocation l2 = new ConcreteLocation(MutableMap.of("id", "1", "name", "frank"));
   AbstractLocation l3 = new ConcreteLocation(MutableMap.of("id", "2", "name", "frank"));
   assertEquals(l1, l2);
   assertNotEquals(l2, l3);
 }
  @Test
  public void testRemoveSpecies() throws AWNoSuchEntityException {
    mSpeciesDao.updateIsDeleted(SPECIES_ONE_ID, true);
    Species species = mSpeciesDao.getSpecies(SPECIES_ONE_ID);

    Assert.assertNotEquals(species.isDeleted(), false);
    mSpeciesDao.updateIsDeleted(SPECIES_ONE_ID, false);
  }
Example #24
0
  @Test
  public void testSize() throws Exception {
    int size = stack.size();

    stack.push("Agh?");
    assertNotEquals(size, stack.size());
    assertEquals(size + 1, stack.size());
  }
Example #25
0
 @Test
 public void seedLong() {
   for (int i = 0; i < 100; ++i) {
     final long seed1 = random.seed(i);
     final long seed2 = random.seed(i);
     Assert.assertNotEquals(seed1, seed2);
   }
 }
Example #26
0
  @Test
  public void testModel() throws Exception {
    final HawkClient testClient =
        new HawkClient.Builder().credentials(this.testcredentials1).build();
    testClient.toString();
    testClient.hashCode();
    assertEquals(testClient, testClient);
    assertNotEquals(testClient, null);
    assertNotEquals(null, testClient);

    final HawkClient testClient2 =
        new HawkClient.Builder(testClient).credentials(this.testcredentials2).build();
    testClient2.toString();
    testClient2.hashCode();
    assertEquals(testClient2, testClient2);
    assertNotEquals(testClient2, testClient);
  }
 @Test
 public void testUpdateSpecies() throws AWNoSuchEntityException, AWNonUniqueException {
   Species species = mSpeciesDao.getSpecies(SPECIES_ONE_ID);
   species.setName(SPECIES_ONE_NEW_NAME);
   species = mSpeciesDao.store(species);
   Assert.assertNotEquals(SPECIES_ONE_NAME, species.getName());
   species.setName(SPECIES_ONE_NAME);
   mSpeciesDao.store(species);
 }
 private void assertComponentInstancesNotEqual(String mode) throws Exception {
   WebClient webClient = new WebClient();
   webClient.setThrowExceptionOnFailingStatusCode(true);
   TextPage page = webClient.getPage(contextPath + "test?mode=" + mode);
   String[] ids = page.getContent().split(":");
   System.out.println(Arrays.toString(ids));
   assertEquals(ids.length, 2);
   assertNotEquals(ids[0], ids[1]);
 }
 @BeforeClass(groups = {"wso2.is"})
 public void init() throws Exception {
   ClientConnectionUtil.waitForPort(9763);
   logger.debug("Running Passive STS Tests...");
   passiveSTSServiceStub =
       new IdentityPassiveSTSServiceStub(UserAdminConstants.PASSIVE_STS_SERVICE_URL);
   assertNotEquals(
       passiveSTSServiceStub, null, "Error in instantiation passive sts service stub.");
 }
  @Test
  public void testStoreValidSpecies() throws AWNonUniqueException {
    Species species = new Species();
    species.setName(SPECIES_FOUR_NAME);
    species = mSpeciesDao.store(species);

    Assert.assertNotEquals(TestConstants.NON_PERSISTED_ID, species.getId());
    deleteSpecies(species);
  }