Example usage for java.util.logging Logger fine

List of usage examples for java.util.logging Logger fine

Introduction

In this page you can find the example usage for java.util.logging Logger fine.

Prototype

public void fine(Supplier<String> msgSupplier) 

Source Link

Document

Log a FINE message, which is only to be constructed if the logging level is such that the message will actually be logged.

Usage

From source file:greensopinion.restexample.test.web.WebApplicationContainer.java

/**
 * start the webserver, guarantees that the webserver is started upon return.
 * @see #stop()//from   w ww . j  ava 2s.c o m
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public void start() {
    if (winstoneLauncher != null) {
        throw new IllegalStateException("already started");
    }
    port = findAvailablePort();

    Logger log = Logger.getLogger(WebApplicationContainer.class.getName());
    log.fine("Starting web container on " + getBaseUrl());

    Map args = new HashMap();
    try {
        args.put("ajp13Port", "-1");
        args.put("useJasper", "false");
        args.put("webroot", webRoot.getAbsolutePath());
        args.put("httpPort", String.valueOf(port));
        Launcher.initLogger(args);

        EmbeddedWebContextLoaderListener.setApplicationContext(applicationContext);

        // start winstone
        winstoneLauncher = new Launcher(args);

        // wait for Winstone to finish starting up
        // we do that by attempting to connect via socket
        final int maxRetries = 150;
        for (int x = 0; x < maxRetries; ++x) {
            if (testForSuccessfulStartup()) {
                break;
            }
            if (x == maxRetries - 1) {
                throw new IllegalStateException(String.format(
                        "Connection to localhost:%s failed.  Did the web container start up successfully?"));
            }
            // wait and then try again
            Thread.sleep(100L);
        }
        Logger.getLogger(WebApplicationContainer.class.getName())
                .info("Started web container at " + getBaseUrl());
    } catch (Exception e) {
        throw new IllegalStateException(e);
    }
}

From source file:mockit.integration.logging.LoggingIntegrationsTest.java

@Test
public void jdkLoggingShouldLogNothing() {
    Logger log1 = Logger.getAnonymousLogger();
    Logger log2 = Logger.getAnonymousLogger("bundle");
    Logger log3 = Logger.getLogger(LoggingIntegrationsTest.class.getName());
    Logger log4 = Logger.getLogger(LoggingIntegrationsTest.class.getName(), "bundle");

    assertFalse(log1.isLoggable(Level.ALL));
    log1.severe("testing that logger does nothing");
    log2.setLevel(Level.WARNING);
    log2.info("testing that logger does nothing");
    log3.warning("testing that logger does nothing");
    log4.fine("testing that logger does nothing");
    log4.finest("testing that logger does nothing");
}

From source file:com.ibm.ws.lars.rest.RepositoryRESTResourceLoggingTest.java

@Test
public void testGetFakeImConfig(@Mocked final Logger logger) {

    new Expectations() {
        {/*from   ww  w . ja v a  2  s  . c  om*/
            logger.isLoggable(Level.FINE);
            result = true;

            logger.fine("getFakeImConfig called");
        }
    };

    getRestResource().getFakeImConfig();
}

From source file:com.ibm.ws.lars.rest.RepositoryRESTResourceLoggingTest.java

@Test
public void testDeleteAttachment(@Mocked final Logger logger) throws InvalidIdException {

    new Expectations() {
        {//from  w ww  . j a  v  a 2 s  . c  om
            logger.isLoggable(Level.FINE);
            result = true;

            logger.fine("deleteAttachment called for assetId: " + NON_EXISTENT_ID + " and attachmentId: "
                    + NON_EXISTENT_ID);
        }
    };

    getRestResource().deleteAttachment(NON_EXISTENT_ID, NON_EXISTENT_ID);
}

From source file:com.ibm.ws.lars.rest.RepositoryRESTResourceLoggingTest.java

@Test
public void testGetAttachments(@Mocked final Logger logger, @Mocked final SecurityContext sc) throws Exception {

    new Expectations() {
        {/* w  w w .  j av  a 2  s .  c  o m*/
            logger.isLoggable(Level.FINE);
            result = true;
            logger.fine("getAttachments called for assetId: " + NON_EXISTENT_ID);
            sc.isUserInRole("Administrator");
            result = true;
        }
    };

    getRestResource().getAttachments(NON_EXISTENT_ID, dummyUriInfo, sc);
}

From source file:com.ibm.ws.lars.rest.RepositoryRESTResourceLoggingTest.java

@Test
public void testDeleteAssets(@Mocked final Logger logger)
        throws InvalidIdException, NonExistentArtefactException {

    new Expectations() {
        {// www  . j av  a2  s. c om
            logger.isLoggable(Level.FINE);
            result = true;

            logger.fine("deleteAsset called with id of " + NON_EXISTENT_ID);
        }
    };

    getRestResource().deleteAsset(NON_EXISTENT_ID);
}

From source file:com.ibm.ws.lars.rest.RepositoryRESTResourceLoggingTest.java

@Test
public void testPostAssets(@Mocked final Logger logger, @Mocked SecurityContext context) {

    final String json = "{\"name\":\"myname\"}";

    new Expectations() {
        {/*www.j  av a2s .co  m*/
            logger.isLoggable(Level.FINE);
            result = true;

            logger.fine("postAssets called with json content:\n" + json);
        }
    };

    getRestResource().postAssets(json, context);
}

From source file:jp.ikedam.jenkins.plugins.ldap_sasl.SearchGroupResolver.java

/**
 * Resolves groups by querying the LDAP directory. 
 * /*from   w w  w  .j  a v a  2 s.c o m*/
 * Never return null in any case. Returns empty list instead.
 * 
 * @param ctx
 * @param dn
 * @param username
 * @return List of authorities (not null)
 * @see jp.ikedam.jenkins.plugins.ldap_sasl.GroupResolver#resolveGroup(javax.naming.ldap.LdapContext, java.lang.String, java.lang.String)
 */
@Override
public List<GrantedAuthority> resolveGroup(LdapContext ctx, String dn, String username) {
    List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();

    Logger logger = getLogger();

    if (dn == null) {
        logger.warning("Group cannot be resolved: DN of the user is not resolved!");
        return authorities;
    }

    try {
        SearchControls searchControls = new SearchControls();
        searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
        logger.fine(String.format("Searching groups base=%s, dn=%s", getSearchBase(), dn));
        NamingEnumeration<SearchResult> entries = ctx.search((getSearchBase() != null) ? getSearchBase() : "",
                getGroupSearchQuery(dn), searchControls);
        while (entries.hasMore()) {
            SearchResult entry = entries.next();
            String groupName = entry.getAttributes().get("cn").get().toString();
            if (getPrefix() != null) {
                groupName = getPrefix() + groupName;
            }
            authorities.add(new GrantedAuthorityImpl(groupName));
            logger.fine(String.format("group: %s", groupName));
        }
        entries.close();
    } catch (NamingException e) {
        logger.log(Level.WARNING, "Failed to search groups", e);
    }

    return authorities;
}

From source file:edu.uchicago.lowasser.flaginjection.Flags.java

public static Injector bootstrapFlagInjector(final String[] args, String mainClassName, List<String> packages,
        Module... baseModules) {/*  w  ww.j  av a  2 s  .c o m*/
    Logger logger = Logger.getLogger("org.learningu.scheduling.flags.Flags");
    AbstractModule linkingModule = new AbstractModule() {

        @Override
        protected void configure() {
        }

        @Provides
        @RuntimeArguments
        String[] commandLineArguments() {
            return args;
        }

        @Provides
        @Singleton
        Options options(Map<Flag, Type> flagsMap) {
            Options options = new Options();
            for (Flag flag : flagsMap.keySet()) {
                OptionBuilder.hasArgs();
                OptionBuilder.withLongOpt(flag.name());
                OptionBuilder.withDescription(flag.description());
                OptionBuilder.withArgName(flagsMap.get(flag).toString());
                options.addOption(OptionBuilder.create());
            }
            return options;
        }

        @Provides
        @Singleton
        CommandLine commandLine(Options options, @RuntimeArguments String[] args) {
            try {
                return new PosixParser().parse(options, args);
            } catch (ParseException e) {
                throw Throwables.propagate(e);
            }
        }
    };
    logger.fine("Built Options module");
    Injector baseInjector = Guice.createInjector(new FlagErrorModule(mainClassName),
            Modules.combine(Iterables.concat(Arrays.asList(baseModules), ImmutableList.of(linkingModule))));
    logger.fine("Bootstrapping flag injector with command line arguments");
    Injector createdInjector = baseInjector
            .createChildInjector(baseInjector.getInstance(FlagBootstrapModule.class));
    // Use reflection to instantiate the variables in FlagClass classes
    for (String packageName : packages) {
        Reflections reflections = new Reflections(packageName);
        Set<Class<? extends FlagsClass>> classes = reflections.getSubTypesOf(FlagsClass.class);
        for (Class<? extends FlagsClass> flagClass : classes) {
            createdInjector.getInstance(flagClass);
        }
    }
    return createdInjector;
}

From source file:com.ibm.ws.lars.rest.RepositoryRESTResourceLoggingTest.java

@Test
public void testGetAsset(@Mocked final Logger logger, @Mocked final SecurityContext sc)
        throws InvalidIdException, NonExistentArtefactException {

    new Expectations() {
        {// w  ww  .  j  a v  a  2  s.c  o  m
            logger.isLoggable(Level.FINE);
            result = true;
            logger.fine("getAsset called with id of 'ffffffffffffffffffffffff'");
            sc.isUserInRole("Administrator");
            result = true;
        }
    };

    getRestResource().getAsset(NON_EXISTENT_ID, dummyUriInfo, sc);
}