Example usage for java.lang System getProperties

List of usage examples for java.lang System getProperties

Introduction

In this page you can find the example usage for java.lang System getProperties.

Prototype

public static Properties getProperties() 

Source Link

Document

Determines the current system properties.

Usage

From source file:org.jolokia.jvmagent.spring.SpringJolokiaServerTest.java

private void checkSystemPropertyMode(String mode, String propContext, String configContext,
        String expectContext) throws IOException, InterruptedException {
    if (propContext != null) {
        System.setProperty("jolokia.agentContext", propContext);
    }//from  w w w.j  ava  2s.c  o  m
    SpringJolokiaAgent server = new SpringJolokiaAgent();
    server.setConfig(getConfig(true, 100, "agentContext", configContext));
    server.setSystemPropertiesMode(mode);
    server.afterPropertiesSet();
    assertEquals(server.getServerConfig().getContextPath(), expectContext);
    System.getProperties().remove("jolokia.agentContext");
    server.stop();
    // Allow to shutdown server ...
    Thread.sleep(500);
}

From source file:ee.ignite.logtojira.AppenderServiceImpl.java

private String composeEnvironmentDescription() {

    StringBuilder result = new StringBuilder();

    for (Entry<String, String> e : System.getenv().entrySet()) {
        result.append(e.getKey());//from   w  w w .j av a2 s  . co m
        result.append("=");
        result.append(e.getValue());
        result.append("; ");
    }

    result.append("\n\n");

    for (Entry<Object, Object> e : System.getProperties().entrySet()) {
        result.append(e.getKey());
        result.append("=");
        result.append(e.getValue());
        result.append("; ");
    }

    return result.toString();
}

From source file:net.mindengine.galen.tests.runner.ReportingTest.java

@AfterMethod
public void removeAllSystemProperties() {
    System.getProperties().remove(GALEN_LOG_LEVEL);
}

From source file:org.agiso.tempel.Tempel.java

public Tempel() {
    // Odczytujemy waciwoci systemowe i zapamitujemy je w mapie systemProperties:
    Properties properties = System.getProperties();
    Map<String, Object> map = new HashMap<String, Object>(properties.size());
    for (String key : properties.stringPropertyNames()) {
        map.put(key.replace('.', '_'), properties.getProperty(key));
    }//  w  ww.  j a va 2  s  . c  o  m
    systemProperties = Collections.unmodifiableMap(map);
}

From source file:org.jasig.cas.CasEnvironmentContextListener.java

/**
 * Collect environment info with/*  w  w w .  jav a 2s  .  c  om*/
 * details on the java and os deployment
 * versions.
 *
 * @return environment info
 */
private String collectEnvironmentInfo() {
    final Properties properties = System.getProperties();
    final Formatter formatter = new Formatter();
    formatter.format("\n******************** Welcome to CAS ********************\n");
    formatter.format("CAS Version: %s\n", CasVersion.getVersion());
    formatter.format("Java Home: %s\n", properties.get("java.home"));
    formatter.format("Java Vendor: %s\n", properties.get("java.vendor"));
    formatter.format("Java Version: %s\n", properties.get("java.version"));
    formatter.format("OS Architecture: %s\n", properties.get("os.arch"));
    formatter.format("OS Name: %s\n", properties.get("os.name"));
    formatter.format("OS Version: %s\n", properties.get("os.version"));
    formatter.format("*******************************************************\n");
    return formatter.toString();
}

From source file:com.hiperium.bo.manager.mail.EmailMessageManager.java

/**
 * Sends an email with the new user password.
 * //  w ww . j  a  va2  s .c  o  m
 * @param user
 * @throws javax.mail.internet.AddressException
 * @throws javax.mail.MessagingException
 */
public void sendNewPassword(User user) {
    try {
        this.log.debug("sendNewPassword() - START");
        // Create the corresponding user locale.
        Locale locale = null;
        if (StringUtils.isBlank(user.getLanguageId())) {
            locale = Locale.getDefault();
        } else {
            locale = new Locale(user.getLanguageId());
        }
        ResourceBundle resource = ResourceBundle.getBundle(EnumI18N.COMMON.value(), locale);

        // Get system properties
        Properties properties = System.getProperties();
        // Setup mail server
        properties.setProperty("mail.smtp.host", CloudEmailUser.HOST);
        properties.setProperty("mail.user", CloudEmailUser.USERNAME);
        properties.setProperty("mail.password", CloudEmailUser.PASSWORD);
        // Get the default Session object.
        Session session = Session.getDefaultInstance(properties);
        // Create a default MimeMessage object.
        MimeMessage message = new MimeMessage(session);
        // Set From: header field of the header.
        message.setFrom(new InternetAddress(CloudEmailUser.ADDRESS));
        // Set To: header field of the header.
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(user.getEmail()));
        // Set Subject: header field
        message.setSubject(resource.getString(GENERATED_USER_PASSWD_SUBJECT));
        // Send the actual HTML message, as big as you like
        message.setContent(MessageFormat.format(resource.getString(GENERATED_USER_PASSWD_CONTENT),
                user.getFirstname(), user.getLastname(), user.getPassword()), "text/html");
        // Send message
        Transport.send(message);
        this.log.debug("sendNewPassword() - END");
    } catch (AddressException e) {
        this.log.error("AddressException to send email to " + user.getEmail(), e);
    } catch (MessagingException e) {
        this.log.error("MessagingException to send email to " + user.getEmail(), e);
    }
}

From source file:ch.cyberduck.core.sds.SDSDelegatingMoveFeatureTest.java

@Test
public void testMove() throws Exception {
    final Host host = new Host(new SDSProtocol(), "duck.ssp-europe.eu", new Credentials(
            System.getProperties().getProperty("sds.user"), System.getProperties().getProperty("sds.key")));
    final SDSSession session = new SDSSession(host, new DisabledX509TrustManager(),
            new DefaultX509KeyManager());
    session.enableMetrics();/*from  w  ww  .  j a va 2s  . c  o m*/
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path room = new SDSDirectoryFeature(session)
            .mkdir(new Path(new AlphanumericRandomStringService().random(),
                    EnumSet.of(Path.Type.directory, Path.Type.volume)), null, new TransferStatus());
    final Path test = new Path(room, new AlphanumericRandomStringService().random(),
            EnumSet.of(Path.Type.file));
    new SDSTouchFeature(session).touch(test, new TransferStatus());
    final Path target = new Path(room, new AlphanumericRandomStringService().random(),
            EnumSet.of(Path.Type.file));
    new SDSDelegatingMoveFeature(session, new SDSMoveFeature(session)).move(test, target, new TransferStatus(),
            new Delete.DisabledCallback(), new DisabledConnectionCallback());
    assertFalse(new SDSFindFeature(session).find(test));
    assertTrue(new SDSFindFeature(session).find(target));
    assertEquals(0, session.getMetrics().get(Copy.class));
    new SDSDeleteFeature(session).delete(Collections.singletonList(room), new DisabledLoginCallback(),
            new Delete.DisabledCallback());
    session.close();
}

From source file:ch.cyberduck.core.b2.B2ReadFeatureTest.java

@Test(expected = NotfoundException.class)
public void testReadNotFound() throws Exception {
    final B2Session session = new B2Session(new Host(new B2Protocol(), new B2Protocol().getDefaultHostname(),
            new Credentials(System.getProperties().getProperty("b2.user"),
                    System.getProperties().getProperty("b2.key"))));
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final TransferStatus status = new TransferStatus();
    new B2ReadFeature(session).read(
            new Path(new B2HomeFinderService(session).find(), "nosuchname", EnumSet.of(Path.Type.file)), status,
            new DisabledConnectionCallback());
}

From source file:com.silverpeas.mailinglist.service.job.TestYahooMailConnection.java

@Test
public void testOpenImapConnection() throws Exception {
    Store mailAccount = null;//w w w .  j av a  2s  . c o m
    Folder inbox = null;
    Session mailSession = Session.getInstance(System.getProperties());
    try {
        mailSession.setDebug(true);
        mailAccount = mailSession.getStore(props.getProperty("mail.server.protocol"));
        mailAccount.connect(props.getProperty("mail.server.host"),
                Integer.parseInt(props.getProperty("mail.server.port")), props.getProperty("mail.server.login"),
                props.getProperty("mail.server.password"));
        inbox = mailAccount.getFolder("INBOX");
        if (inbox == null) {
            throw new MessagingException("No POP3 INBOX");
        }
        // -- Open the folder for read write --
        inbox.open(Folder.READ_WRITE);

        // -- Get the message wrappers and process them --
        javax.mail.Message[] msgs = inbox.getMessages();
        FetchProfile profile = new FetchProfile();
        profile.add(FetchProfile.Item.FLAGS);
        inbox.fetch(msgs, profile);
        MailProcessor processor = new MailProcessor();
        MessageListener mailingList = mock(MessageListener.class);
        when(mailingList.checkSender(anyString())).thenReturn(Boolean.TRUE);
        when(mailingList.getComponentId()).thenReturn("mailingList38");
        MessageEvent event = new MessageEvent();
        for (javax.mail.Message message : msgs) {
            processor.prepareMessage((MimeMessage) message, mailingList, event);
        }
        assertThat(event.getMessages(), is(notNullValue()));
        assertThat(event.getMessages().size(), is(msgs.length));
        for (com.silverpeas.mailinglist.service.model.beans.Message message : event.getMessages()) {
            assertThat(message, is(notNullValue()));
            assertThat(message.getMessageId(), is(notNullValue()));
        }
    } finally {
        // -- Close down nicely --
        if (inbox != null) {
            inbox.close(false);
        }
        if (mailAccount != null) {
            mailAccount.close();
        }
    }
}

From source file:com.microsoft.alm.plugin.telemetry.TfsTelemetryHelper.java

private TfsTelemetryHelper() {
    final String skip = System.getProperties()
            .getProperty("com.microsoft.alm.plugin.telemetry.skipClientInitialization");
    if (StringUtils.isNotEmpty(skip) && StringUtils.equalsIgnoreCase(skip, "true")) {
        // this flag is here for testing purposes in which case we do not want to create a telemetry channel
        // or client.
        return;// www.  j a v  a2  s  .c om
    }

    // Initialize the internal logger
    final Map<String, String> loggerData = new HashMap<String, String>();
    loggerData.put("Level", InternalLogger.LoggingLevel.ERROR.toString()); //$NON-NLS-1$
    loggerData.put("UniquePrefix", UNIQUE_PREFIX); //$NON-NLS-1$
    loggerData.put("BaseFolder", BASE_FOLDER); //$NON-NLS-1$
    InternalLogger.INSTANCE.initialize(LoggerOutputType.FILE.toString(), loggerData);

    // Initialize the active TelemetryConfiguration
    ContextInitializer initializer = PluginServiceProvider.getInstance().getTelemetryContextInitializer();
    TelemetryConfiguration.getActive().getContextInitializers().add(initializer);

    // Create a channel to AppInsights
    final TelemetryChannel channel = TelemetryConfiguration.getActive().getChannel();
    if (channel != null) {
        channel.setDeveloperMode(TfsTelemetryInstrumentationInfo.getInstance().isDeveloperMode());
    } else {
        logger.error("Failed to load telemetry channel");
        return;
    }

    // Create the telemetry client and cache it for later use
    logger.debug("AppInsights telemetry initialized"); //$NON-NLS-1$
    logger.debug(MessageFormat.format("    Developer Mode: {0}", //$NON-NLS-1$
            TfsTelemetryInstrumentationInfo.getInstance().isDeveloperMode()));
    logger.debug(MessageFormat.format("    Production Environment: {0}", //$NON-NLS-1$
            !TfsTelemetryInstrumentationInfo.getInstance().isTestKey()));

    telemetryClient = new TelemetryClient();
    telemetryClient.getContext().getSession().setId(UUID.randomUUID().toString());
}