Example #1
0
  @Test
  public void meta() {
    try {
      Loggers.meta(null, null, null, null, null, 0);
      fail(
          "Expecting an IllegalArgumentException as the loggingFor Class<?> object must not be null.");
    } catch (NullPointerException npe) {
      // expected
    }
    // get meta without need for creation of an exception
    long now = System.currentTimeMillis();
    Meta meta =
        Loggers.meta(LoggersTest.class, null, null, null, Thread.currentThread().getName(), now);
    assertEquals(LoggersTest.class, meta.invokingClass());
    assertEquals(LoggersTest.class.getName(), meta.invokingClassName());
    assertEquals(now, meta.invokingEpochTime());
    assertEquals(Thread.currentThread().getName(), meta.invokingThreadName());
    assertNull(meta.invokingMethodName());
    assertNull(meta.invokingLineNumber());
    assertNull(meta.invokingFileName());
    // set need for file/method/line
    UncialConfig.get()
        .addAppender(
            new Appender() {
              @Override
              public String getName() {
                return null;
              }

              @Override
              public void handle(String logEvent) {}

              @Override
              public void close() {}

              @Override
              public void flush() {}
            },
            "%L"); // one is sufficient
    meta = Loggers.meta(LoggersTest.class, null, null, null, Thread.currentThread().getName(), now);
    assertEquals(LoggersTest.class, meta.invokingClass());
    assertEquals(LoggersTest.class.getName(), meta.invokingClassName());
    assertNotNull(meta.invokingClassName());
    assertEquals(now, meta.invokingEpochTime());
    assertEquals(Thread.currentThread().getName(), meta.invokingThreadName());
    assertEquals(
        "invoke0",
        meta.invokingMethodName()); // will be from NativeMethodAccessoImpl as uncial skips itself
    // including this test case
    assertEquals(-2, (int) meta.invokingLineNumber());
    assertEquals("NativeMethodAccessorImpl.java", meta.invokingFileName());
  }
Example #2
0
  @Override
  protected void before() throws Throwable {
    initialLevel = Loggers.getFactory().getLevel();

    // this shared instance breaks compatibility with parallel execution of tests
    LogInterceptors.set(new ListInterceptor());
    setLevel(LoggerLevel.TRACE);
  }
Example #3
0
 /** Fires a table network players updated event. */
 private void fireTableNetworkPlayersUpdated() {
   final TableNetworkEvent event = new TableNetworkEvent(this);
   for (final ITableNetworkListener listener : listeners_) {
     try {
       listener.tableNetworkPlayersUpdated(event);
     } catch (final RuntimeException e) {
       Loggers.getDefaultLogger()
           .log(
               Level.SEVERE,
               NonNlsMessages.TableNetwork_tableNetworkPlayersUpdated_unexpectedException,
               e);
     }
   }
 }
  @Override
  protected void init(final Object... initArgs) {
    this.requestedProfile = ((HumanId) initArgs[0]).getSelfAsValid();
    this.currUserAsVisitor = ((HumanId) initArgs[1]).getSelfAsValid();

    final HumansIdentity currUserAsVisitorHI =
        UserProperty.HUMANS_IDENTITY_CACHE.get((currUserAsVisitor.getHumanId()), "");
    final HumansIdentity requestedProfileHI =
        UserProperty.HUMANS_IDENTITY_CACHE.get((requestedProfile.getHumanId()), "");

    super.setWallProfileName(currUserAsVisitorHI.getHuman().getDisplayName());
    super.setWallProfilePhoto(
        UserProperty.formatProfilePhotoUrl(currUserAsVisitorHI.getHumansIdentityProfilePhoto()));
    super.setWallTitle(
        MessageFormat.format(
            RBGet.gui().getString(TALK_AT_DOWN_TOWN_ER_0_S),
            requestedProfileHI.getHuman().getDisplayName()));

    final int friendCount =
        ((List<HumansNetPeople>)
                $$getHumanUserFromRequest(request)
                    .cache(requestedProfile.getHumanId(), DownTownFlow.FRIENDS))
            .size();

    UCAddFriends:
    if (requestedProfile.equals(currUserAsVisitor)) { // Accessing own profile
      UCInviteFriendsIfNoFriends:
      {
        if (friendCount < 2) {

          $$displayNone(WallWidgetIds.wallWidget);

          String title = "Without followers your updates will be useless";

          // https://upload.wikimedia.org/wikipedia/commons/8/8d/Ambox_padlock_red.svg
          new Info(
              request,
              new InfoCriteria().setImage("/images/What_is_exciting_lately.png"),
              $$(WallWidgetIds.wallGame));

          new Info(
              request,
              new InfoCriteria().setImage("/images/What_is_exciting_lately_Talk.png"),
              $$(WallWidgetIds.wallGame));

          new Info(request, new InfoCriteria(), $$(WallWidgetIds.wallGame)) {
            /**
             * Use this only in conjunction with GENERIC constructor.
             *
             * @param infoCriteria
             */
            @Override
            protected void init(InfoCriteria infoCriteria) {
              UCSetFriendAddWidget:
              {
                String addFollowerTitle = "";

                if (friendCount == 0) {
                  addFollowerTitle = "Add 2 Follower emails To Start Posting!";
                } else if (friendCount == 1) {
                  addFollowerTitle = "Almost there! Add 1 More Follower To Posting!";
                }

                new AdaptableSignup(
                    request,
                    new AdaptableSignupCriteria()
                        .setHumanId(requestedProfile)
                        .setWidgetTitle(addFollowerTitle)
                        .setAdaptableSignupCallback(
                            new AdaptableSignupCallback() {
                              @Override
                              public String afterInvite(final HumanId invitee) {
                                return ai.ilikeplaces.logic.Listeners.widgets
                                        .UserProperty
                                        .HUMANS_IDENTITY_CACHE
                                        .get(invitee.getHumanId(), invitee.getHumanId())
                                        .getHuman()
                                        .getDisplayName()
                                    + " is now following you!";
                              }

                              @Override
                              public String jsToSend(HumanId invitee) {
                                return JSCodeToSend.refreshPageIn(5);
                              }
                            }),
                    $$(InfoIds.InfoAppend));
              }
            }
          };

        } else {

          String addFollowerTitle = "Add more followers!";

          new AdaptableSignup(
              request,
              new AdaptableSignupCriteria()
                  .setHumanId(requestedProfile)
                  .setWidgetTitle(addFollowerTitle)
                  .setAdaptableSignupCallback(
                      new AdaptableSignupCallback() {
                        @Override
                        public String afterInvite(final HumanId invitee) {
                          return ai.ilikeplaces.logic.Listeners.widgets
                                  .UserProperty
                                  .HUMANS_IDENTITY_CACHE
                                  .get(invitee.getHumanId(), invitee.getHumanId())
                                  .getHuman()
                                  .getDisplayName()
                              + " is now following you!";
                        }

                        @Override
                        public String jsToSend(HumanId invitee) {
                          return JSCodeToSend.refreshPageIn(5);
                        }
                      }),
              $$(WallWidgetIds.wallFollowers));
        }
      }
    }

    fetchToEmail();

    final Wall wall =
        DB.getHumanCrudWallLocal(true)
            .readWall(requestedProfile, new Obj<HumanId>(currUserAsVisitor), REFRESH_SPEC)
            .returnValueBadly();
    final List<Msg> wallEntries =
        DB.getHumanCrudWallLocal(true)
            .readWallLastEntries(
                requestedProfile, new Obj<HumanId>(currUserAsVisitor), 25, REFRESH_SPEC_EMPTY)
            .returnValueBadly();

    for (final Msg msg : wallEntries) {
      new UserProperty(request, $$(WallWidgetIds.wallContent), new HumanId(msg.getMsgMetadata())) {
        protected void init(final Object... initArgs) {
          $$(Controller.Page.user_property_content).setTextContent(msg.getMsgContent());
        }
      };
    }

    DB.getHumanCRUDHumansUnseenLocal(false)
        .removeEntry(currUserAsVisitor.getObjectAsValid(), wall.getWallId());

    $$displayWallAsMuted(
        $$(WallWidgetIds.wallMute), wall.getWallMutes().contains(currUserAsVisitor));

    UCFiltering:
    {
      final List<HumansNetPeople> beFriends =
          (List<HumansNetPeople>)
              $$getHumanUserFromRequest(request)
                  .cache(requestedProfile.getHumanId(), DownTownFlow.FRIENDS);

      @_see(
          seeClasses = {
            WallWidgetHumansWall.class,
            PrivateEventDelete.class,
            PrivateEventView.class,
            Tribe.class
          })
      final String peopleFetchToEmail1 =
          new People(
                  request,
                  new PeopleCriteria().setPeople((List<HumanIdFace>) (List<?>) beFriends),
                  $(Controller.Page.Skeleton_left_column))
              .fetchToEmail;

      Loggers.debug("PEOPLE FETCH TO EMAIL CONTENT:" + peopleFetchToEmail1);

      fetchToEmailSetLeftSidebar(peopleFetchToEmail1);
      fetchToEmailSetRightSidebar("&nbsp;");
    }
  }
Example #5
0
 private Class<?> getInvokingLogClass() {
   return Loggers.invokingLogClass();
 }
Example #6
0
 /**
  * Enable/disable debug logs. Info, warn and error logs are always enabled. By default debug logs
  * are enabled when LogTester is started.
  */
 public LogTester setLevel(LoggerLevel level) {
   Loggers.getFactory().setLevel(level);
   return this;
 }
Example #7
0
 LoggerLevel getLevel() {
   return Loggers.getFactory().getLevel();
 }