예제 #1
0
 @Test
 public void testCreateTag() throws FOMException, JSONException, FluidException, IOException {
   // Lets create a tag underneath the user's default root namespace
   Namespace testNamespace = new Namespace(this.fdb, "", this.fdb.getUsername());
   String newName = UUID.randomUUID().toString();
   Tag newTag = testNamespace.createTag(newName, "This is a test tag", true);
   // if we successfully created a tag there'll be an id
   assertEquals(true, newTag.getId().length() > 0);
   testNamespace.getItem(); // not really needed
   assertEquals(true, TestUtils.contains(testNamespace.getTagNames(), newName));
   newTag.delete();
   testNamespace.getItem();
   assertEquals(false, TestUtils.contains(testNamespace.getTagNames(), newName));
   // Lets make sure validation works correctly...
   newName = "this is wrong"; // e.g. space is an invalid character
   String msg = "";
   try {
     newTag = testNamespace.createTag(newName, "This is a test namespace", false);
   } catch (FOMException ex) {
     msg = ex.getMessage();
   }
   assertEquals("Invalid name (incorrect characters or too long)", msg);
   // the new name is too long
   newName =
       "foobarbazhamandeggscheeseandpicklespamspamspamspamfoobarbazhamandeggscheeseandpicklespamspamspamspamfoobarbazhamandeggscheeseandpicklespamspamspamspamfoobarbazhamandeggscheeseandpicklespamspamspamspamfoobarbazhamandeggscheeseandpicklespamspamspamspam";
   msg = "";
   try {
     newTag = testNamespace.createTag(newName, "This is a test namespace", false);
   } catch (FOMException ex) {
     msg = ex.getMessage();
   }
   assertEquals("Invalid name (incorrect characters or too long)", msg);
 }
예제 #2
0
  /**
   * Finds the menu that can be used by the owner to control the participant. Hovers over it. Finds
   * the mute link and mute it. Then checks in the second participant page whether it is muted
   */
  public void ownerMutesParticipantAndCheck() {
    System.err.println("Start ownerMutesParticipantAndCheck.");

    WebDriver owner = ConferenceFixture.getOwner();

    WebElement elem =
        owner.findElement(By.xpath("//div[@class='remotevideomenu']/i[@class='fa fa-angle-down']"));

    Actions action = new Actions(owner);
    action.moveToElement(elem);
    action.perform();

    TestUtils.waitForDisplayedElementByXPath(
        owner, "//ul[@class='popupmenu']/li/a[@class='mutelink']", 5);

    owner.findElement(By.xpath("//ul[@class='popupmenu']/li/a[@class='mutelink']")).click();

    // and now check whether second participant is muted
    TestUtils.waitForElementByXPath(
        ConferenceFixture.getSecondParticipant(),
        "//span[@class='audioMuted']/i[@class='icon-mic-disabled']",
        5);

    action.release();
  }
  @Test
  public void tc003_t1_t2_before_available_data() {
    long t1 = TestUtils.stringToDate(dateFormat, fileDate0 + " 00:00:00").getTime();
    long t2 = TestUtils.stringToDate(dateFormat, fileDate0 + " 00:59:59").getTime();

    LogFileReader fr = new LogFileReader(TestUtils.TESTFOLDERPATH, channelTestImpl);
    List<Record> records = fr.getValues(t1, t2);

    long expectedRecords = 0;
    System.out.print(Thread.currentThread().getStackTrace()[1].getMethodName());

    boolean result = true;
    int wrong = 0;
    int ok = 0;

    for (int i = 0; records.size() > i; i++) {
      if (records.get(i).getFlag().equals(Flag.NO_VALUE_RECEIVED_YET)) {
        ++ok;
      } else {
        ++wrong;
        result = false;
      }
    }
    System.out.print(" records = " + records.size() + " (" + expectedRecords + " expected); ");
    System.out.println("wrong = " + wrong + ", ok(with Flag 7) = " + ok);
    assertTrue(result);
  }
예제 #4
0
  /** 숫자형에 '0B' 또는 '0b'를 앞에 붙임으로써 이진법 표현이 가능 */
  @Test
  public void test() throws Exception {

    byte bit1 = 0B1;
    System.out.println(TestUtils.toBinaryString(bit1));
    // 00000001

    short bit16 = 0B0101101100001101;
    System.out.println(TestUtils.toBinaryString(bit16));
    // 0101101100001101

    int mask = 0b01010000101;
    System.out.println(TestUtils.toBinaryString(mask));
    // 00000000000000000000001010000101

    // _를 이용한 가독성 향상
    byte bit8 = 0B0101_1011;
    System.out.println(TestUtils.toBinaryString(bit8));
    // 01011011

    int binary = 0B0101_0000_1010_0010_1101_0000_1010_0010;
    System.out.println(TestUtils.toBinaryString(binary));
    // 01010000101000101101000010100010

    int binary100 = 0B0000_0000_0000_0000_0000_0000_0110_0100;
    int int100 = 100;
    if (binary100 == int100) {
      System.out.println("동일");
    }
  }
예제 #5
0
  public void testSMDPrimitivesNoResult() throws Exception {
    // request
    setRequestContent("smd-6.txt");
    this.request.addHeader("content-type", "application/json-rpc");

    JSONInterceptor interceptor = new JSONInterceptor();
    interceptor.setEnableSMD(true);
    SMDActionTest1 action = new SMDActionTest1();

    this.invocation.setAction(action);

    // can't be invoked
    interceptor.intercept(this.invocation);
    assertFalse(this.invocation.isInvoked());

    // asert values were passed properly
    assertEquals("string", action.getStringParam());
    assertEquals(1, action.getIntParam());
    assertEquals(true, action.isBooleanParam());
    assertEquals('c', action.getCharParam());
    assertEquals(2, action.getLongParam());
    assertEquals(new Float(3.3), action.getFloatParam());
    assertEquals(4.4, action.getDoubleParam());
    assertEquals(5, action.getShortParam());
    assertEquals(6, action.getByteParam());

    String json = response.getContentAsString();

    String normalizedActual = TestUtils.normalize(json, true);
    String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("smd-11.txt"));
    assertEquals(normalizedExpected, normalizedActual);

    assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
  }
  @Test
  public void testCheckLegalityAfterBrawlVictory() {
    World world = new WorldImpl(10, 10, null, null);
    world.addListener(new BrawlListener());
    WorldObject villagersOrganization = createVillagersOrganization(world);
    WorldObject performer =
        TestUtils.createSkilledWorldObject(
            2, Constants.GROUP, new IdList().add(villagersOrganization));
    MockMetaInformation.setMetaInformation(performer, Goals.BRAWL_GOAL);
    WorldObject actionTarget =
        TestUtils.createSkilledWorldObject(
            3, Constants.GROUP, new IdList().add(villagersOrganization));
    world.addWorldObject(performer);
    world.addWorldObject(actionTarget);
    world.addWorldObject(TestUtils.createIntelligentWorldObject(4, "observer"));

    villagersOrganization = createVillagersOrganization(world);

    BrawlPropertyUtils.startBrawl(performer, actionTarget, 20);
    actionTarget.setProperty(Constants.HIT_POINTS, 1);

    new OperationInfo(performer, actionTarget, Args.EMPTY, Actions.NON_LETHAL_MELEE_ATTACK_ACTION)
        .perform(world);

    assertEquals(1, performer.getProperty(Constants.GROUP).size());
    assertEquals(true, BrawlPropertyUtils.isBrawling(performer));
    assertEquals(true, BrawlPropertyUtils.isBrawling(actionTarget));

    BrawlPropertyUtils.completelyEndBrawling(performer);
    BrawlPropertyUtils.completelyEndBrawling(actionTarget);
    assertEquals(false, BrawlPropertyUtils.isBrawling(performer));
    assertEquals(false, BrawlPropertyUtils.isBrawling(actionTarget));
  }
예제 #7
0
  public void testAddRecordsFromDifferentUsersToSameTime() throws ParseException {
    Team team = testBasicData.getTeamById(1);

    int userId1 = 10001;
    testBasicData.setUserId(userId1);
    Date recordDateTime = TestUtils.parseFullDate("20120516162000.000");
    TeamResult teamLevelPoint =
        TestUtils.createTeamLevelPoint(
            team, "КП1,КП2,КП3", DateFormat.parse("201205161400"), recordDateTime);
    scanPointRecords.put(teamLevelPoint);

    int userId2 = 10002;
    testBasicData.setUserId(userId2);
    teamLevelPoint =
        TestUtils.createTeamLevelPoint(
            team, "КП1,КП3,КП4,КП5", DateFormat.parse("201205161305"), recordDateTime);
    scanPointRecords.put(teamLevelPoint);

    assertEquals(1, scanPointRecords.getRecordDates().size());

    checkUserDate(userId1, "20120516162000.000");
    checkUserDate(userId2, "20120516162000.000");

    checkRecordForUser(userId1, recordDateTime, "201205161400", 3, !CHECK_SINGLE);
    checkRecordForUser(userId2, recordDateTime, "201205161305", 4, !CHECK_SINGLE);
  }
예제 #8
0
  public void testGetLastRecordSingle() throws ParseException {
    Team team = testBasicData.getTeamById(1);

    int userId1 = 10001;
    testBasicData.setUserId(userId1);
    Date recordDateTime1 = TestUtils.parseFullDate("20120516162030.500");
    TeamResult teamLevelPoint =
        TestUtils.createTeamLevelPoint(
            team, "КП1,КП2,КП3", DateFormat.parse("201205161400"), recordDateTime1);
    scanPointRecords.put(teamLevelPoint);

    int userId2 = 10002;
    testBasicData.setUserId(userId2);
    Date recordDateTime2 = TestUtils.parseFullDate("20120516162500.111");
    teamLevelPoint =
        TestUtils.createTeamLevelPoint(
            team, "КП1,КП3,КП4,КП5", DateFormat.parse("201205161305"), recordDateTime2);
    scanPointRecords.put(teamLevelPoint);

    ScanPointRecord teamRecord = scanPointRecords.getLastRecord();
    assertNotNull(teamRecord);
    assertEquals(1, teamRecord.size());

    List<TeamResult> teamLevelPoints = teamRecord.getTeamResults();
    assertNotNull(teamLevelPoints);
    assertEquals(1, teamLevelPoints.size());
    teamLevelPoint = teamLevelPoints.get(0);
    assertEquals(recordDateTime2, teamLevelPoint.getRecordDateTime());
    assertEquals(4, teamLevelPoint.getTakenCheckpoints().size());
    assertEquals(DateFormat.parse("201205161305"), teamLevelPoint.getCheckDateTime());
  }
  @Test
  public void testAlterRelationships() {
    World world = new WorldImpl(1, 1, null, null);
    WorldObject performer = TestUtils.createIntelligentWorldObject(1, Constants.GENDER, "male");
    WorldObject actionTarget =
        TestUtils.createIntelligentWorldObject(2, Constants.GROUP, new IdList());
    world.addWorldObject(performer);
    world.addWorldObject(actionTarget);
    WorldObject villagersOrganization = createVillagersOrganization(world);

    performer.setProperty(Constants.GROUP, new IdList().add(villagersOrganization));

    DefaultGoalObstructedHandler.alterRelationships(
        performer,
        actionTarget,
        actionTarget,
        null,
        Actions.MELEE_ATTACK_ACTION,
        world,
        -10,
        performer,
        actionTarget);

    assertEquals(-10, performer.getProperty(Constants.RELATIONSHIPS).getValue(actionTarget));
    assertEquals(-10, actionTarget.getProperty(Constants.RELATIONSHIPS).getValue(performer));
    assertEquals(true, actionTarget.getProperty(Constants.GROUP).getIds().isEmpty());
  }
예제 #10
0
  public void testAddLevelPointRecordTwice() throws ParseException {
    Team team = testBasicData.getTeamById(1);
    Date recordDateTime = TestUtils.parseFullDate("20120516162030.500");
    TeamResult teamLevelPoint =
        TestUtils.createTeamLevelPoint(
            team, "КП1,КП2,КП3", DateFormat.parse("201205161400"), recordDateTime);
    Integer userId = teamLevelPoint.getUserId();

    scanPointRecords.put(teamLevelPoint);
    assertEquals(1, scanPointRecords.getRecordDates().size());
    assertNotNull(scanPointRecords.getDateForUser(userId));
    assertEquals(recordDateTime, scanPointRecords.getDateForUser(userId));

    recordDateTime = TestUtils.parseFullDate("20120516162500.111");
    teamLevelPoint =
        TestUtils.createTeamLevelPoint(
            team, "КП1,КП3,КП4", DateFormat.parse("201205161305"), recordDateTime);
    scanPointRecords.put(teamLevelPoint);

    assertEquals(1, scanPointRecords.getRecordDates().size());
    assertNotNull(scanPointRecords.getDateForUser(userId));
    assertEquals(
        TestUtils.parseFullDate("20120516162500.111"), scanPointRecords.getDateForUser(userId));

    ScanPointRecord teamRecord = scanPointRecords.getByDate(recordDateTime);
    assertNotNull(teamRecord);
    assertEquals(1, teamRecord.size());

    teamLevelPoint = teamRecord.getByUserId(userId);
    assertNotNull(teamLevelPoint);
    assertEquals(3, teamLevelPoint.getTakenCheckpoints().size());
    assertTrue(teamLevelPoint.getTakenCheckpointNames().contains("КП4"));
    assertFalse(teamLevelPoint.getTakenCheckpointNames().contains("КП2"));
    assertEquals(DateFormat.parse("201205161305"), teamLevelPoint.getCheckDateTime());
  }
예제 #11
0
  public void testGetLastRecordMultiple() throws ParseException {
    Team team = testBasicData.getTeamById(1);

    int userId1 = 10001;
    testBasicData.setUserId(userId1);
    Date recordDateTime = TestUtils.parseFullDate("20120516162000.000");
    TeamResult teamLevelPoint =
        TestUtils.createTeamLevelPoint(
            team, "КП1,КП2,КП3", DateFormat.parse("201205161400"), recordDateTime);
    scanPointRecords.put(teamLevelPoint);

    int userId2 = 10002;
    testBasicData.setUserId(userId2);
    teamLevelPoint =
        TestUtils.createTeamLevelPoint(
            team, "КП1,КП3,КП4,КП5", DateFormat.parse("201205161305"), recordDateTime);
    scanPointRecords.put(teamLevelPoint);

    ScanPointRecord teamRecord = scanPointRecords.getLastRecord();
    assertNotNull(teamRecord);
    assertEquals(2, teamRecord.size());

    List<TeamResult> teamLevelPoints = teamRecord.getTeamResults();
    assertEquals(2, teamLevelPoints.size());
    teamLevelPoint = teamLevelPoints.get(0);
    checkRecord(teamLevelPoint, userId1, "201205161400", 3);
    teamLevelPoint = teamLevelPoints.get(1);
    checkRecord(teamLevelPoint, userId2, "201205161305", 4);
  }
예제 #12
0
  public void AddReview(String wineName, String wineryName, String newWineryName) {

    selenium.open("/");

    selenium.click("link=Reviews");
    selenium.waitForPageToLoad("30000");

    // add new review
    TestUtils.AddButton(selenium);

    TestUtils.TypeWineData(
        selenium,
        wineName,
        wineryName,
        newWineryName,
        "White",
        "2010",
        "12",
        "14",
        "750 ml",
        "12",
        "Glass",
        "aged in glass",
        "5000 l",
        "Closure1",
        "Cabernet",
        "100",
        "A very nice wine!",
        "Color",
        "Very nice color!");
    TestUtils.TypeReviewData(selenium, "3", "1", "2", "3", "This is the text of the review");

    TestUtils.SubmitButton(selenium);
  }
예제 #13
0
 @Test
 public void testCopyOptionsJson() {
   Random rand = new Random();
   boolean broadcast = rand.nextBoolean();
   boolean loopbackModeDisabled = rand.nextBoolean();
   int multicastTimeToLive = TestUtils.randomPositiveInt();
   String multicastNetworkInterface = TestUtils.randomAlphaString(100);
   boolean reuseAddress = rand.nextBoolean();
   boolean ipV6 = rand.nextBoolean();
   JsonObject json =
       new JsonObject()
           .putBoolean("broadcast", broadcast)
           .putBoolean("loopbackModeDisabled", loopbackModeDisabled)
           .putNumber("multicastTimeToLive", multicastTimeToLive)
           .putString("multicastNetworkInterface", multicastNetworkInterface)
           .putBoolean("reuseAddress", reuseAddress)
           .putBoolean("ipV6", ipV6);
   DatagramSocketOptions copy = new DatagramSocketOptions(json);
   assertEquals(broadcast, copy.isBroadcast());
   assertEquals(loopbackModeDisabled, copy.isLoopbackModeDisabled());
   assertEquals(multicastTimeToLive, copy.getMulticastTimeToLive());
   assertEquals(multicastNetworkInterface, copy.getMulticastNetworkInterface());
   assertEquals(reuseAddress, copy.isReuseAddress());
   assertEquals(ipV6, copy.isIpV6());
   testComplete();
 }
예제 #14
0
 @Test
 public void testCopyOptions() {
   DatagramSocketOptions options = new DatagramSocketOptions();
   Random rand = new Random();
   boolean broadcast = rand.nextBoolean();
   boolean loopbackModeDisabled = rand.nextBoolean();
   int multicastTimeToLive = TestUtils.randomPositiveInt();
   String multicastNetworkInterface = TestUtils.randomAlphaString(100);
   boolean reuseAddress = rand.nextBoolean();
   boolean ipV6 = rand.nextBoolean();
   options.setBroadcast(broadcast);
   options.setLoopbackModeDisabled(loopbackModeDisabled);
   options.setMulticastTimeToLive(multicastTimeToLive);
   options.setMulticastNetworkInterface(multicastNetworkInterface);
   options.setReuseAddress(reuseAddress);
   options.setIpV6(ipV6);
   DatagramSocketOptions copy = new DatagramSocketOptions(options);
   assertEquals(broadcast, copy.isBroadcast());
   assertEquals(loopbackModeDisabled, copy.isLoopbackModeDisabled());
   assertEquals(multicastTimeToLive, copy.getMulticastTimeToLive());
   assertEquals(multicastNetworkInterface, copy.getMulticastNetworkInterface());
   assertEquals(reuseAddress, copy.isReuseAddress());
   assertEquals(ipV6, copy.isIpV6());
   testComplete();
 }
예제 #15
0
  @Test
  public void dgetauthorizedSchoolDatas() {
    SchoolI sc = new SchoolE();

    sc.getAuthenticationToken().setUserName("user1");
    sc.setTimezone("2");
    sc.setSchoolName("SOUTHFIELD SENIOR HIGH SCHOOL");
    /*sc.setSubRegionalOffice("12");
    sc.setSchoolName("Binghamton High School");*/

    schoolService = TestUtils.getSchoolServiceContext();
    Result r = schoolService.getSchools(sc);
    requestId = new StringBuilder((String) r.getResult());

    LOG.trace("data Request--" + requestId);

    assertNotNull(requestId);

    LOG.trace("Checking testcase for status");
    statusService = TestUtils.getStatusServiceContext();
    boolean status = getStatus(requestId.toString(), sc);

    Result res = schoolService.getSchoolsDataForMDB(sc);
    ;
    List<SchoolI> schoolsData = (List<SchoolI>) res.getResult();

    /*List<SchoolDTO> schoolsData = schoolService.getSchoolsData(requestId, sc);

    LOG.trace("Size : " + schoolsData.size());
    assertTrue("Ivalid Data", schoolsData.size() >= 1);*/
  }
  @SmallTest
  @MediumTest
  @LargeTest
  public void testCacheRoundtrip() {
    ArrayList<String> permissions = Utility.arrayList("stream_publish", "go_outside_and_play");
    String token = "AnImaginaryTokenValue";
    Date later = TestUtils.nowPlusSeconds(60);
    Date earlier = TestUtils.nowPlusSeconds(-60);

    SharedPreferencesTokenCachingStrategy cache =
        new SharedPreferencesTokenCachingStrategy(getContext());
    cache.clear();

    Bundle bundle = new Bundle();
    TokenCachingStrategy.putToken(bundle, token);
    TokenCachingStrategy.putExpirationDate(bundle, later);
    TokenCachingStrategy.putSource(bundle, AccessTokenSource.FACEBOOK_APPLICATION_NATIVE);
    TokenCachingStrategy.putLastRefreshDate(bundle, earlier);
    TokenCachingStrategy.putPermissions(bundle, permissions);

    cache.save(bundle);
    bundle = cache.load();

    AccessToken accessToken = AccessToken.createFromCache(bundle);
    TestUtils.assertSamePermissions(permissions, accessToken);
    assertEquals(token, accessToken.getToken());
    assertEquals(AccessTokenSource.FACEBOOK_APPLICATION_NATIVE, accessToken.getSource());
    assertTrue(!accessToken.isInvalid());

    Bundle cachedBundle = accessToken.toCacheBundle();
    TestUtils.assertEqualContents(bundle, cachedBundle);
  }
  @Test
  public void testCalculateTargetNoDeception() {
    World world = new WorldImpl(10, 10, null, null);
    WorldObject performer = TestUtils.createIntelligentWorldObject(2, "performer");
    WorldObject target = TestUtils.createIntelligentWorldObject(3, "target");

    assertEquals(target, DefaultGoalObstructedHandler.calculateTarget(performer, target, world));
  }
예제 #18
0
  /**
   * Tests the performance of an event listener on the map for Update events of 2 MB strings. Expect
   * it to handle at least 50 2 MB updates per second.
   */
  @Test
  public void testSubscriptionMapEventListenerUpdatePerformance() {
    _testMap.clear();

    // Put values before testing as we want to ignore the insert events
    Function<Integer, Object> putFunction =
        a -> _testMap.put(TestUtils.getKey(_mapName, a), _twoMbTestString);

    IntStream.range(0, _noOfPuts)
        .forEach(
            i -> {
              putFunction.apply(i);
            });

    Jvm.pause(100);
    // Create subscriber and register
    TestChronicleMapEventListener mapEventListener =
        new TestChronicleMapEventListener(_mapName, _twoMbTestStringLength);

    Subscriber<MapEvent> mapEventSubscriber = e -> e.apply(mapEventListener);
    clientAssetTree.registerSubscriber(
        _mapName + "?bootstrap=false", MapEvent.class, mapEventSubscriber);

    KVSSubscription subscription =
        (KVSSubscription) serverAssetTree.getAsset(_mapName).subscription(false);

    waitFor(() -> subscription.entrySubscriberCount() == 1);
    Assert.assertEquals(1, subscription.entrySubscriberCount());

    // Perform test a number of times to allow the JVM to warm up, but verify runtime against
    // average
    TestUtils.runMultipleTimesAndVerifyAvgRuntime(
        i -> {
          if (i > 0) {
            waitFor(() -> mapEventListener.getNoOfUpdateEvents().get() >= _noOfPuts);

            // Test that the correct number of events were triggered on event listener
            Assert.assertEquals(_noOfPuts, mapEventListener.getNoOfUpdateEvents().get());
          }
          Assert.assertEquals(0, mapEventListener.getNoOfInsertEvents().get());
          Assert.assertEquals(0, mapEventListener.getNoOfRemoveEvents().get());

          mapEventListener.resetCounters();
        },
        () -> {
          IntStream.range(0, _noOfPuts)
              .forEach(
                  i -> {
                    putFunction.apply(i);
                  });
        },
        _noOfRunsToAverage,
        3 * _secondInNanos);
    clientAssetTree.unregisterSubscriber(_mapName, mapEventSubscriber);

    waitFor(() -> subscription.entrySubscriberCount() == 0);
    Assert.assertEquals(0, subscription.entrySubscriberCount());
  }
 public static void main(String[] args) {
   ListNode a = TestUtils.creatListNode(4);
   ListNode b = TestUtils.creatListNode(0);
   TestUtils.printListNode(a);
   TestUtils.printListNode(b);
   PlusLinkedListABTest test = new PlusLinkedListABTest();
   ListNode node = test.plusAB(a, b);
   TestUtils.printListNode(node);
 }
예제 #20
0
 @BeforeClass
 public static void init() throws FileNotFoundException {
   Set<Module> allModules = TestUtils.loadModulesFrom("/full-versions/yangs");
   assertNotNull(allModules);
   SchemaContext schemaContext = TestUtils.loadSchemaContext(allModules);
   ControllerContext controllerContext = ControllerContext.getInstance();
   controllerContext.setSchemas(schemaContext);
   restconfImpl.setControllerContext(controllerContext);
 }
  @Test
  public void testAreFightingInArenaNoFight() {
    WorldObject performer =
        TestUtils.createIntelligentWorldObject(1, Constants.ARENA_OPPONENT_ID, null);
    WorldObject actionTarget =
        TestUtils.createIntelligentWorldObject(2, Constants.ARENA_OPPONENT_ID, null);

    assertEquals(
        false, DefaultGoalObstructedHandler.areFightingInArena(performer, actionTarget, null));
  }
  @Test
  public void testPerformerCanAttackCriminals() {
    WorldObject performer =
        TestUtils.createIntelligentWorldObject(1, Constants.CAN_ATTACK_CRIMINALS, Boolean.TRUE);

    assertEquals(true, DefaultGoalObstructedHandler.performerCanAttackCriminals(performer));

    performer = TestUtils.createIntelligentWorldObject(1, Constants.FOOD, 500);
    assertEquals(false, DefaultGoalObstructedHandler.performerCanAttackCriminals(performer));
  }
  @Test
  public void scFloatAccumulator() throws Exception {
    ScriptEngine engine = TestUtils.getEngine();
    // String file = TestUtils.resourceToFile("/dream.txt");

    TestUtils.evalJSResource(engine, "/sparkcontexttests.js");
    Object ret = ((Invocable) engine).invokeFunction("scFloatAccumulator");

    assertEquals("failure - values are not equal", 11.0, ret);
  };
  @Test
  public void textFile() throws Exception {
    ScriptEngine engine = TestUtils.getEngine();
    // String file = TestUtils.resourceToFile("/dream.txt");

    TestUtils.evalJSResource(engine, "/sparkcontexttests.js");
    Object ret = ((Invocable) engine).invokeFunction("textFile");

    assertEquals("failure - values are not equal", "[\"Rating(0,260,9.0)\"]", ret);
  };
예제 #25
0
 @Test
 public void testPublishByteArray() {
   byte[] sent = TestUtils.randomByteArray(100);
   testPublish(
       sent,
       (bytes) -> {
         TestUtils.byteArraysEqual(sent, bytes);
         assertFalse(sent == bytes); // Make sure it's copied
       });
 }
 @Test
 public void simpleYangDataTest() {
   String jsonOutput;
   jsonOutput =
       TestUtils.convertCompositeNodeDataAndYangToJson(
           TestUtils.loadCompositeNode("/yang-to-json-conversion/simple-data-types/xml/data.xml"),
           "/yang-to-json-conversion/simple-data-types",
           "/yang-to-json-conversion/simple-data-types/xml");
   verifyJsonOutput(jsonOutput);
 }
예제 #27
0
 private static void loadData() throws IOException, URISyntaxException {
   InputStream xmlStream =
       RestconfImplTest.class.getResourceAsStream(
           "/parts/ietf-interfaces_interfaces_absolute_path.xml");
   xmlDataAbsolutePath =
       TestUtils.getDocumentInPrintableForm(TestUtils.loadDocumentFrom(xmlStream));
   xmlStream =
       RestconfImplTest.class.getResourceAsStream(
           "/parts/ietf-interfaces_interfaces_interface_absolute_path.xml");
   xmlDataInterfaceAbsolutePath =
       TestUtils.getDocumentInPrintableForm(TestUtils.loadDocumentFrom(xmlStream));
   String xmlPathRpcInput =
       RestconfImplTest.class
           .getResource("/full-versions/test-data2/data-rpc-input.xml")
           .getPath();
   xmlDataRpcInput = TestUtils.loadTextFile(xmlPathRpcInput);
   String xmlPathBlockData =
       RestconfImplTest.class.getResource("/test-config-data/xml/block-data.xml").getPath();
   xmlBlockData = TestUtils.loadTextFile(xmlPathBlockData);
   String xmlPathTestInterface =
       RestconfImplTest.class.getResource("/test-config-data/xml/test-interface.xml").getPath();
   xmlTestInterface = TestUtils.loadTextFile(xmlPathTestInterface);
   cnSnDataOutput = prepareCnSnRpcOutput();
   String data3Input =
       RestconfImplTest.class.getResource("/full-versions/test-data2/data3.xml").getPath();
   xmlData3 = TestUtils.loadTextFile(data3Input);
   String data4Input =
       RestconfImplTest.class.getResource("/full-versions/test-data2/data7.xml").getPath();
   xmlData4 = TestUtils.loadTextFile(data4Input);
 }
예제 #28
0
  /**
   * UnMutes once again the second participant and checks in the owner page does this change is
   * reflected.
   */
  public void participantUnMutesAfterOwnerMutedHimAndCheck() {
    MeetUIUtils.clickOnToolbarButton(ConferenceFixture.getSecondParticipant(), "mute");

    TestUtils.waitsForElementNotPresentByXPath(
        ConferenceFixture.getOwner(),
        "//span[@class='audioMuted']/i[@class='icon-mic-disabled']",
        5);

    // lets give time to the ui to reflect the change in the ui of the owner
    TestUtils.waits(1000);
  }
  @Test
  public void objectFile() throws Exception {
    ScriptEngine engine = TestUtils.getEngine();
    // String file = TestUtils.resourceToFile("/dream.txt");

    TestUtils.evalJSResource(engine, "/sparkcontexttests.js");
    Object ret = ((Invocable) engine).invokeFunction("objectFile");

    assertEquals(
        "failure - values are not equal", "[{\"user\":0,\"product\":260,\"rating\":9}]", ret);
  };
예제 #30
0
 @Test
 public void testDelete() throws FOMException, FluidException, JSONException, IOException {
   // Lets create a new namespace underneath the user's default root namespace
   Namespace testNamespace = new Namespace(this.fdb, "", this.fdb.getUsername());
   String newName = UUID.randomUUID().toString();
   Namespace newNamespace = testNamespace.createNamespace(newName, "This is a test namespace");
   assertEquals(true, TestUtils.contains(testNamespace.getNamespaceNames(), newName));
   newNamespace.delete();
   testNamespace.getItem();
   assertEquals(false, TestUtils.contains(testNamespace.getNamespaceNames(), newName));
 }