Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9094789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:26:11+00:00 2026-06-16T23:26:11+00:00

I tried to use property file in my maven-java project for test automation. This

  • 0

I tried to use property file in my maven-java project for test automation.

This is the context.xml file

<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:util="http://www.springframework.org/schema/util"
   xmlns:context="http://www.springframework.org/schema/context"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/util
       http://www.springframework.org/schema/util/spring-util-2.0.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context.xsd
       http://www.springframework.org/schema/context ">

<util:properties id="properties" location="classpath:test-context.properties"/>

<context:property-placeholder properties-ref="properties" ignore-unresolvable="false"/>


<bean id="settings" class="util.TestSettings">
    <property name="properties" ref="properties"/>
</bean>

These are my java classes.

import java.util.Properties;

public class TestSettings {

private static Properties properties;

public static String getProperty(String key) {
    return properties.getProperty(key);
}

public void setProperties(Properties properties) {
    TestSettings.properties = properties;
}
}

@ContextConfiguration(locations = "classpath:test-context.xml")
public class P_1_LoginPage extends AbstractTestNGSpringContextTests {

private P_1_LoginPage p1LoginPage;
private WebDriver driver;

public P_1_LoginPage(WebDriver driver) {

    this.driver = driver;

    driver.get(TestSettings.getProperty("base.url"));

}

@BeforeClass(alwaysRun = true)
public void BeforeTest() throws MalformedURLException {

    DesiredCapabilities capability = DesiredCapabilities.firefox();
    driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
    p1LoginPage = new P_1_LoginPage(driver);

}

public void assertThere() {

   //assert here
}

update

here is my context.property file.

base.url=http://uname:pword@test.mysite.com.au/sdfdf
email.Queue.url=http://uname:pword@test.mysite.com.au/admin/admin/show_msgs

When I try to run test cases, it gives a null pointer exception here.

public static String getProperty(String key) {
    return properties.getProperty(key);
}

Can some one help me to figure out the issue here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T23:26:14+00:00Added an answer on June 16, 2026 at 11:26 pm

    Your code breaks few Spring guidelines, like for example static field used to access properties, or creating P_1_LoginPage with new operator outside container. But the main problem for NullPointer is, that Spring context is not yet initialized in @BeforeClass (method should be static also, otherwise it will cause exception). Replace @BeforeClass with @Before.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to use this snippet from the Soundcloud API: <script src=http://connect.soundcloud.com/sdk.js> <script> SC.initialize({
I need to use the values from the property file... I tried searching it..
I tried to use AsyncProcessor in test scenario, expecting only one message to run
I tried to use an image file in my HTML template. But when I
Hereabouts, we use a Sonatype Maven repository. This is jolly nice for our maven
I tried to use a cache configuration like this post from a website: <configSections>
I tried to use JPA in OSGi and faced with this exception: javax.persistence.PersistenceException: No
I had tried to use alert, prompt and result: If I open html file
I tried to use spring security in my project. But when I added spring-security-xxx.jar
I have a Java Spring project, configured with Maven. As the amount of unit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.