Getting a NullPointerException Error when converting JUnit to TestNG

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting a NullPointerException Error when converting JUnit to TestNG

mane_uk
This post was updated on .
Hi all,

  I have been giving the task to convert around 20 of the projects of the company I work for from JUnit to TestNG. Below is only one of them. (I tried in other projects and the same happen!!)

  When I run the Maven Command line "mvn clean test -pl myfolder" before the conversion it builds without any failure. I do the conversion JUnit-TestNG using the Eclipse Helios IDE with the TestNG plugin, right clicking on the project and then choosing TestNG/Convert to TestNG.

  When I run the same Maven command line again, after the conversion, it pass some tests but fail a few as well with a NullPointerException Error. I have been looking into it for the last week and couldn't really find anything on the net. What can be the problem?

This is my POM.XML
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                     http://maven.apache.org/xsd/maven-4.0.0.xsd">
   
   <modelVersion>4.0.0</modelVersion>

   
   <parent>
       <groupId>com.risk</groupId>
       <artifactId>h-agg</artifactId>
       <version>1.0</version>
   </parent>

   
   <artifactId>pricreg</artifactId>
   <version>${version.qualifier}</version>

   <inceptionYear>2004</inceptionYear>

   <prerequisites>
       <maven>2.0</maven>
   </prerequisites>

   
   <name>pricreg</name>

   <build>
       <testResources>
           <testResource>
               <directory>${project.basedir}/src/test/resources</directory>
               <excludes>
                   <exclude>**/*</exclude>
               </excludes>
           </testResource>
       </testResources>
       <plugins>
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-jar-plugin</artifactId>
               <version>2.3.2</version>
               <configuration>
                   <skip>false</skip>
               </configuration>
               <executions>
                   <execution>
                       <goals>
                           <goal>test-jar</goal>
                       </goals>
                   </execution>
               </executions>
           </plugin>

           <plugin>
               <groupId>org.codehaus.mojo</groupId>
               <artifactId>script-maven-plugin</artifactId>
               <executions>
                   <execution>
                       <id>Publish-Scripts</id>
                       <phase>compile</phase>
                       <goals>
                           <goal>publish-nosuffix</goal>
                       </goals>
                       <configuration>
                           <debug>true</debug>
                           <sources>
                               <source>
                                   <scriptincludes>
                                       <scriptinclude>**/*.sh</scriptinclude>
                                       <scriptinclude>**/*.ksh</scriptinclude>
                                   </scriptincludes>
                                   <scriptexcludes>
                                       <scriptexclude>**/env.sh</scriptexclude>
                                   </scriptexcludes>
                               </source>
                           </sources>
                           <scriptSourceDirectory>${basedir}</scriptSourceDirectory>
                       </configuration>
                   </execution>
               </executions>
           </plugin>

           <plugin>
               <artifactId>maven-surefire-plugin</artifactId>
               <groupId>org.apache.maven.plugins</groupId>
               <version>${surefire.plugin.version}</version>
               <configuration>
                   <jvm>${jdk.home}\bin\java</jvm>
                   <forkMode>perTest</forkMode>
                   <printSummary>true</printSummary>
                   <argLine>-Xmx1024m -Xms512m</argLine>
                   <groups>functest</groups>
                   <additionalClasspathElements>
                       <classpathElement>${project.basedir}/src/test/resources</classpathElement>
                   </additionalClasspathElements>
                   <excludes>
                       <exclude>**/Test*.java</exclude>
                       <exclude>**/*Test.java</exclude>
                       <exclude>**/*TestCase.java</exclude>
                   </excludes>
                   <includes>
                       <include>**/RegMtmCompF.java</include>
                       <include>**/RegMtmMissingData.java</include>
                       <include>**/RegMtmCompI.java</include>
                       <include>**/AccMTMRegFXFW.java</include>
                       <include>**/AccMTMRegFXSP.java</include>
                       <include>**/AccMTMRegFXTU.java</include>
                       <include>**/AccMTMRegIRS_NC.java</include>
                       <include>**/AccMTMRegIRS_ND.java</include>
                       <include>**/AccMTMRegIRS_B_NC.java</include>
                       <include>**/AccMTMRegCS.java</include>
                       <include>**/AccMTMRegCS_MTM.java</include>
                       <include>**/AccMTMRegFLR.java</include>
                       <include>**/AccMTMRegCAP.java</include>
                       <include>**/AccMTMRegCAPD.java</include>
                       <include>**/AccMTMRegFLRD.java</include>
                   </includes>
               </configuration>
           </plugin>
       </plugins>
   </build>
   <profiles>
       <profile>
           <id>HUDSON_HAWK</id>
           <activation>
               <property>
                   <name>env.HUDSON_HOME</name>
               </property>
           </activation>
           <build>
               <plugins>
                   <plugin>
                       <artifactId>maven-surefire-plugin</artifactId>
                       <configuration>
                           <skipTests>false</skipTests>
                           <skip>false</skip>
                       </configuration>
                   </plugin>
                   <plugin>
                       <artifactId>maven-compiler-plugin</artifactId>
                       <configuration>
                           <skip>false</skip>
                       </configuration>
                   </plugin>
               </plugins>
           </build>
       </profile>
   </profiles>

   <dependencies>
       <dependency>
           <groupId>org.testng</groupId>
           <artifactId>testng</artifactId>
       </dependency>
        A FEW INTERNAL DEPENDENCIES HERE WHICH I DELETED TO NOT MAKE THIS POST TOO LONG.
   </dependencies>
</project>



And here is what the surefire report produce:

<?xml version="1.0" encoding="UTF-8" ?>
<testsuite failures="3" time="1.687" errors="0" skipped="0" tests="3"
name="com.risk.mtm.RegMtmMissingData">
 <properties>
   <property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/>
   <property name="sun.boot.library.path" value="C:\Program Files\Java\jdk1.6.0_29\jre\bin"/>
   <property name="java.vm.version" value="20.4-b02"/>
   <property name="java.vm.vendor" value="Sun Microsystems Inc."/>
   <property name="java.vendor.url" value="http://java.sun.com/"/>
   <property name="path.separator" value=";"/>
   <property name="java.vm.name" value="Java HotSpot(TM) Client VM"/>
   <property name="file.encoding.pkg" value="sun.io"/>
   <property name="user.country" value="GB"/>
   <property name="sun.java.launcher" value="SUN_STANDARD"/>
   <property name="sun.os.patch.level" value="Service Pack 3"/>
   <property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
   <property name="user.dir" value="C:\dev\h-agg"/>
   <property name="java.runtime.version" value="1.6.0_29-b11"/>
   <property name="java.awt.graphicsenv" value="sun.awt.Win32GraphicsEnvironment"/>
   <property name="java.endorsed.dirs" value="C:\Program Files\Java \jdk1.6.0_29\jre\lib\endorsed"/>
   <property name="os.arch" value="x86"/>
   <property name="java.io.tmpdir" value="C:\DOCUME~1\chiavem\LOCALS~1\Temp\"/>
   <property name="line.separator" value=""/>
   <property name="java.vm.specification.vendor" value="Sun Microsystems Inc."/>
   <property name="user.variant" value=""/>
   <property name="os.name" value="Windows XP"/>
   <property name="classworlds.conf" value="C:\maven\bin\m2.conf"/>
   <property name="sun.jnu.encoding" value="Cp1252"/>
   <property name="java.library.path" value="C:\Program Files\Java\jdk1.6.0_29\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\SYBASE12\OLEDB;C:\SYBASE12\ODBC;C:\SYBASE12\OCS-12_5\dll;C:\ProgramFiles\TIBCO\TIBRV\BIN;C:\Program Files\KVS\EVClient\;C:\Program Files\SlikSvn\bin\;C:\Program Files\TortoiseSVN\bin;%DERBY_HOME%\bin;%JAVA_HOME%\bin;C:\Program Files\Java\jdk1.6.0_29\bin;C:\maven\bin;."/
   <property name="java.specification.name" value="Java Platform API
Specification"/>
   <property name="java.class.version" value="50.0"/>
   <property name="sun.management.compiler" value="HotSpot Client Compiler"/>
   <property name="os.version" value="5.1"/>
   <property name="user.home" value="\\eurfiler6home.fm.rbsgrp.net\chiavem\MyGEOSProfile\FDR"/>
   <property name="user.timezone" value="Europe/London"/>
   <property name="java.awt.printerjob" value="sun.awt.windows.WPrinterJob"/>
   <property name="file.encoding" value="Cp1252"/>
   <property name="java.specification.version" value="1.6"/>
   <property name="user.name" value="chiavem"/>
   <property name="java.class.path" value="C:\maven\boot\classworlds-1.1.jar"/>
   <property name="java.vm.specification.version" value="1.0"/>
   <property name="sun.arch.data.model" value="32"/>
   <property name="java.home" value="C:\Program Files\Java\jdk1.6.0_29\jre"/>
   <property name="sun.java.command" value="org.codehaus.classworlds.Launcher clean test -pl pricreg"/>
   <property name="java.specification.vendor" value="Sun Microsystems Inc."/>
   <property name="user.language" value="en"/>
   <property name="awt.toolkit" value="sun.awt.windows.WToolkit"/>
   <property name="java.vm.info" value="mixed mode"/>
   <property name="java.version" value="1.6.0_29"/>
   <property name="java.ext.dirs" value="C:\Program Files\Java\jdk1.6.0_29\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext"/>
   <property name="sun.boot.class.path" value="C:\Program Files\Java\jdk1.6.0_29\jre\lib\resources.jar;C:\Program Files\Java\jdk1.6.0_29\jre\lib\rt.jar;C:\Program Files\Java\jdk1.6.0_29\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.6.0_29\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.6.0_29\jre\lib\jce.jar;C:\Program Files\Java\jdk1.6.0_29\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.6.0_29\jre\lib\modules\jdk.boot.jar;C:\Program Files\Java\jdk1.6.0_29\jre\classes"/>
   <property name="java.vendor" value="Sun Microsystems Inc."/>
   <property name="maven.home" value="C:\maven"/>
   <property name="file.separator" value="\"/>
   <property name="java.vendor.url.bug" value="http://java.sun.com/cgi-bin/bugreport.cgi"/>
   <property name="sun.cpu.endian" value="little"/>
   <property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
   <property name="sun.desktop" value="windows"/>
   <property name="sun.cpu.isalist" value="pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86"/>
 </properties>
 <testcase time="0.031" classname="com.risk.mtm.RegMtmMissingData" name="testMissingAdjustments">
   <failure type="java.lang.NullPointerException">java.lang.NullPointerException
   at
com.risk.mtm.RegMtmMissingData.testMissingAdjustments(RegMtmMissingData.java:167)
</failure>
 </testcase>
 <testcase time="0" classname="com.risk.mtm.RegMtmMissingData" name="testMissingFixings">
   <failure type="java.lang.NullPointerException">java.lang.NullPointerException
   at
com.risk.mtm.RegMtmMissingData.testMissingFixings(RegMtmMissingData.java:108)
</failure>
 </testcase>
 <testcase time="0" classname="com.risk.mtm.RegMtmMissingData"
name="testMissingHolidayCalendars">
   <failure type="java.lang.NullPointerException">java.lang.NullPointerException
   at
com.risk.mtm.RegMtmMissingData.testMissingHolidayCalendars(RegMtmMissingData.java:51)
</failure>
 </testcase>
</testsuite>



Part of the Java code is:

@BeforeMethod
   public void setUp() {
       Workbook wb;
       try {
          wb =POIUtil.getWorkbookForFile(ResourceUtil.getInstance().getRegResourceFileForClass(getClass(),
"xls"));
           businessDate = new SimpleDateFormat("yyyyMMdd").parse("20110516");
           ConfigManagerStore providerStore = XLProviderStore.initialise(wb,this.getClass());

           market =providerStore.getMarketManager().getMarket(CreditKeyStore.marketKey(businessDate,
1, 1));
           holCalManager = providerStore.getHolidayCalendarManager();
       } catch (Exception e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
       }
   }

   @Test(groups={"functest"})
   public void testMissingHolidayCalendars() {
       holCalManager.startRecordingMissingData();



The lines 51, 108 and 167 are all the same holCalManager.startRecordingMissingData(); I noticed that most of the times the errors seem to appear when calling another class (some of them not part of the same module - i.e.: startRecordingMissindata can be a class from the module called myFolder2 which I have imported at the beginning of the project and added into the dependency on POM)

Ah, one last point is, which is more like a new question: in this particular module, if I delete the include/exclude instruction from my POM file it won't run the TestNG files!!!

Many thanks for all your help!!

Regards
Emanuel
Reply | Threaded
Open this post in threaded view
|

Re: [testng-dev] Getting a NullPointerError when converting JUnit to TestNG

Cédric Beust ♔-2
The NPE is in your code:

com.risk.mtm.RegMtmMissingData.testMissingAdjustments(RegMtmMissingData.java:167

so I'm not sure how we can help...

-- 
Cédric




On Thu, Feb 2, 2012 at 1:56 AM, mane_uk <[hidden email]> wrote:

Hi all,

 I have been giving the task to convert around 20 of the projects of the
company I work for from JUnit to TestNG.

 When I run the Maven Command line "mvn clean test -pl myfolder" before the
conversion it builds without any failure. I do the conversion JUnit-TestNG
using the Eclipse Helios IDE with the TestNG plugin, right clicking on the
project and then choosing TestNG/Convert to TestNG.

 When I run the same Maven command line again, after the conversion, it
pass some tests but fail a few as well with a NullPointerError. I have been
looking into it for the last week and couldn't really find anything on the
net. What
can be the problem?

This is my POM.XML
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                    http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <!-- Maven POM Version -->
  <modelVersion>4.0.0</modelVersion>

  <!-- PROJECT PARENT IDENTITY -->
  <parent>
      <groupId>com.risk</groupId>
      <artifactId>h-agg</artifactId>
      <version>1.0</version>
  </parent>

  <!-- PROJECT IDENTITY -->
  <artifactId>pricreg</artifactId>
  <version>${version.qualifier}</version>

  <inceptionYear>2004</inceptionYear>

  <prerequisites>
      <maven>2.0</maven>
  </prerequisites>

  <!-- PROJECT DESCRIPTION -->
  <name>pricreg</name>

  <build>
      <testResources>
          <testResource>
              <directory>${project.basedir}/src/test/resources</directory>
              <excludes>
                  <exclude>**/*</exclude>
              </excludes>
          </testResource>
      </testResources>
      <plugins>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-jar-plugin</artifactId>
              <version>2.3.2</version>
              <configuration>
                  <skip>false</skip>
              </configuration>
              <executions>
                  <execution>
                      <goals>
                          <goal>test-jar</goal>
                      </goals>
                  </execution>
              </executions>
          </plugin>

          <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>script-maven-plugin</artifactId>
              <executions>
                  <execution>
                      <id>Publish-Scripts</id>
                      <phase>compile</phase>
                      <goals>
                          <goal>publish-nosuffix</goal>
                      </goals>
                      <configuration>
                          <debug>true</debug>
                          <sources>
                              <source>
                                  <scriptincludes>

<scriptinclude>**/*.sh</scriptinclude>

<scriptinclude>**/*.ksh</scriptinclude>
                                  </scriptincludes>
                                  <scriptexcludes>

<scriptexclude>**/env.sh</scriptexclude>
                                  </scriptexcludes>
                              </source>
                          </sources>

<scriptSourceDirectory>${basedir}</scriptSourceDirectory>
                      </configuration>
                  </execution>
              </executions>
          </plugin>

          <plugin>
              <artifactId>maven-surefire-plugin</artifactId>
              <groupId>org.apache.maven.plugins</groupId>
              <version>${surefire.plugin.version}</version>
              <configuration>
                  <jvm>${jdk.home}\bin\java</jvm>
                  <forkMode>perTest</forkMode>
                  <printSummary>true</printSummary>
                  <argLine>-Xmx1024m -Xms512m</argLine>
                  <groups>functest</groups>
                  <additionalClasspathElements>

<classpathElement>${project.basedir}/src/test/resources</classpathElement>
                  </additionalClasspathElements>
                  <excludes>
                      <exclude>**/Test*.java</exclude>
                      <exclude>**/*Test.java</exclude>
                      <exclude>**/*TestCase.java</exclude>
                  </excludes>
                  <includes>
                      <include>**/RegMtmCompF.java</include>
                      <include>**/RegMtmMissingData.java</include>
                      <include>**/RegMtmCompI.java</include>
                      <include>**/AccMTMRegFXFW.java</include>
                      <include>**/AccMTMRegFXSP.java</include>
                      <include>**/AccMTMRegFXTU.java</include>
                      <include>**/AccMTMRegIRS_NC.java</include>
                      <include>**/AccMTMRegIRS_ND.java</include>
                      <include>**/AccMTMRegIRS_B_NC.java</include>
                      <include>**/AccMTMRegCS.java</include>
                      <include>**/AccMTMRegCS_MTM.java</include>
                      <include>**/AccMTMRegFLR.java</include>
                      <include>**/AccMTMRegCAP.java</include>
                      <include>**/AccMTMRegCAPD.java</include>
                      <include>**/AccMTMRegFLRD.java</include>
                  </includes>
              </configuration>
          </plugin>
      </plugins>
  </build>
  <profiles>
      <profile>
          <id>HUDSON_HAWK</id>
          <activation>
              <property>
                  <name>env.HUDSON_HOME</name>
              </property>
          </activation>
          <build>
              <plugins>
                  <plugin>
                      <artifactId>maven-surefire-plugin</artifactId>
                      <configuration>
                          <skipTests>false</skipTests>
                          <skip>false</skip>
                      </configuration>
                  </plugin>
                  <plugin>
                      <artifactId>maven-compiler-plugin</artifactId>
                      <configuration>
                          <skip>false</skip>
                      </configuration>
                  </plugin>
              </plugins>
          </build>
      </profile>
  </profiles>

  <dependencies>
      <dependency>
          <groupId>org.testng</groupId>
          <artifactId>testng</artifactId>
      </dependency>
       A FEW INTERNAL DEPENDENCIES HERE WHICH I DELETED TO NOT MAKE THIS
POST TOO LONG.
  </dependencies>
</project>


And here is what the surefire report produce:

<?xml version="1.0" encoding="UTF-8" ?>
<testsuite failures="3" time="1.687" errors="0" skipped="0" tests="3"
name="com.risk.mtm.RegMtmMissingData">
 <properties>
  <property name="java.runtime.name" value="Java(TM) SE Runtime
Environment"/>
  <property name="sun.boot.library.path" value="C:\Program
Files\Java\jdk1.6.0_29\jre\bin"/>
  <property name="java.vm.version" value="20.4-b02"/>
  <property name="java.vm.vendor" value="Sun Microsystems Inc."/>
  <property name="java.vendor.url" value="http://java.sun.com/"/>
  <property name="path.separator" value=";"/>
  <property name="java.vm.name" value="Java HotSpot(TM) Client VM"/>
  <property name="file.encoding.pkg" value="sun.io"/>
  <property name="user.country" value="GB"/>
  <property name="sun.java.launcher" value="SUN_STANDARD"/>
  <property name="sun.os.patch.level" value="Service Pack 3"/>
  <property name="java.vm.specification.name" value="Java Virtual Machine
Specification"/>
  <property name="user.dir" value="C:\dev\h-agg"/>
  <property name="java.runtime.version" value="1.6.0_29-b11"/>
  <property name="java.awt.graphicsenv"
value="sun.awt.Win32GraphicsEnvironment"/>
  <property name="java.endorsed.dirs" value="C:\Program Files\Java
\jdk1.6.0_29\jre\lib\endorsed"/>
  <property name="os.arch" value="x86"/>
  <property name="java.io.tmpdir"
value="C:\DOCUME~1\chiavem\LOCALS~1\Temp\"/>
  <property name="line.separator" value=""/>
  <property name="java.vm.specification.vendor" value="Sun Microsystems
Inc."/>
  <property name="user.variant" value=""/>
  <property name="os.name" value="Windows XP"/>
  <property name="classworlds.conf" value="C:\maven\bin\m2.conf"/>
  <property name="sun.jnu.encoding" value="Cp1252"/>
  <property name="java.library.path" value="C:\Program
Files\Java\jdk1.6.0_29\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\SYBASE12\OLEDB;C:\SYBASE12\ODBC;C:\SYBASE12\OCS-12_5\dll;C:\ProgramFiles\TIBCO\TIBRV\BIN;C:\Program
Files\KVS\EVClient\;C:\Program Files\SlikSvn\bin\;C:\Program
Files\TortoiseSVN\bin;%DERBY_HOME%\bin;%JAVA_HOME%\bin;C:\Program
Files\Java\jdk1.6.0_29\bin;C:\maven\bin;."/
  <property name="java.specification.name" value="Java Platform API
Specification"/>
  <property name="java.class.version" value="50.0"/>
  <property name="sun.management.compiler" value="HotSpot Client
Compiler"/>
  <property name="os.version" value="5.1"/>
  <property name="user.home"
value="\\eurfiler6home.fm.rbsgrp.net\chiavem\MyGEOSProfile\FDR"/>
  <property name="user.timezone" value="Europe/London"/>
  <property name="java.awt.printerjob"
value="sun.awt.windows.WPrinterJob"/>
  <property name="file.encoding" value="Cp1252"/>
  <property name="java.specification.version" value="1.6"/>
  <property name="user.name" value="chiavem"/>
  <property name="java.class.path"
value="C:\maven\boot\classworlds-1.1.jar"/>
  <property name="java.vm.specification.version" value="1.0"/>
  <property name="sun.arch.data.model" value="32"/>
  <property name="java.home" value="C:\Program
Files\Java\jdk1.6.0_29\jre"/>
  <property name="sun.java.command"
value="org.codehaus.classworlds.Launcher clean test -pl pricreg"/>
  <property name="java.specification.vendor" value="Sun Microsystems
Inc."/>
  <property name="user.language" value="en"/>
  <property name="awt.toolkit" value="sun.awt.windows.WToolkit"/>
  <property name="java.vm.info" value="mixed mode"/>
  <property name="java.version" value="1.6.0_29"/>
  <property name="java.ext.dirs" value="C:\Program
Files\Java\jdk1.6.0_29\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext"/>
  <property name="sun.boot.class.path" value="C:\Program
Files\Java\jdk1.6.0_29\jre\lib\resources.jar;C:\Program
Files\Java\jdk1.6.0_29\jre\lib\rt.jar;C:\Program
Files\Java\jdk1.6.0_29\jre\lib\sunrsasign.jar;C:\Program
Files\Java\jdk1.6.0_29\jre\lib\jsse.jar;C:\Program
Files\Java\jdk1.6.0_29\jre\lib\jce.jar;C:\Program
Files\Java\jdk1.6.0_29\jre\lib\charsets.jar;C:\Program
Files\Java\jdk1.6.0_29\jre\lib\modules\jdk.boot.jar;C:\Program
Files\Java\jdk1.6.0_29\jre\classes"/>
  <property name="java.vendor" value="Sun Microsystems Inc."/>
  <property name="maven.home" value="C:\maven"/>
  <property name="file.separator" value="\"/>
  <property name="java.vendor.url.bug"
value="http://java.sun.com/cgi-bin/bugreport.cgi"/>
  <property name="sun.cpu.endian" value="little"/>
  <property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
  <property name="sun.desktop" value="windows"/>
  <property name="sun.cpu.isalist" value="pentium_pro+mmx pentium_pro
pentium+mmx pentium i486 i386 i86"/>
 </properties>
 <testcase time="0.031" classname="com.risk.mtm.RegMtmMissingData"
name="testMissingAdjustments">
  <failure
type="java.lang.NullPointerException">java.lang.NullPointerException
  at
com.risk.mtm.RegMtmMissingData.testMissingAdjustments(RegMtmMissingData.java:167)
</failure>
 </testcase>
 <testcase time="0" classname="com.risk.mtm.RegMtmMissingData"
name="testMissingFixings">
  <failure
type="java.lang.NullPointerException">java.lang.NullPointerException
  at
com.risk.mtm.RegMtmMissingData.testMissingFixings(RegMtmMissingData.java:108)
</failure>
 </testcase>
 <testcase time="0" classname="com.risk.mtm.RegMtmMissingData"
name="testMissingHolidayCalendars">
  <failure
type="java.lang.NullPointerException">java.lang.NullPointerException
  at
com.risk.mtm.RegMtmMissingData.testMissingHolidayCalendars(RegMtmMissingData.java:51)
</failure>
 </testcase>
</testsuite>


Part of the Java code is:

@BeforeMethod
  public void setUp() {
      Workbook wb;
      try {
         wb
=POIUtil.getWorkbookForFile(ResourceUtil.getInstance().getRegResourceFileForClass(getClass(),
"xls"));
          businessDate = new
SimpleDateFormat("yyyyMMdd").parse("20110516");
          ConfigManagerStore providerStore =
XLProviderStore.initialise(wb,this.getClass());

          market
=providerStore.getMarketManager().getMarket(CreditKeyStore.marketKey(businessDate,
1, 1));
          holCalManager = providerStore.getHolidayCalendarManager();
      } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  }

  @Test(groups={"functest"})
  public void testMissingHolidayCalendars() {
      holCalManager.startRecordingMissingData();


The lines 51, 108 and 167 are all the same
holCalManager.startRecordingMissingData(); But I do believe the
problem is that wb workbook is coming back as null even though there is the
excel file in there to read!!!

Ah, one last point is, which is more like a new question: if I delete the
include/exclude instruction from my POM file it won't run the TestNG
files!!!

Many thanks for all your help!!

Regards
Emanuel
--
View this message in context: http://old.nabble.com/Getting-a-NullPointerError-when-converting-JUnit-to-TestNG-tp33249051p33249051.html
Sent from the testng-dev mailing list archive at Nabble.com.

--
You received this message because you are subscribed to the Google Groups "testng-dev" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-dev?hl=en.


--
You received this message because you are subscribed to the Google Groups "testng-dev" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-dev?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: [testng-dev] Getting a NullPointerError when converting JUnit to TestNG

mane_uk
Thanks Cedric for the reply.

I thought the problem could be related to the "convert to TestNG" automatic tool on the Eclipse IDE as this modules builds perfectly when running on JUnit before conversion.

I have noticed after converting some more modules of my project from JUnit to TestNG, that all of them returned at least 1 test of the code as NullPointerException error. 99% of it pointing to lines in the code which are doing assert.equals or compareTo or when calling different classes like in the example below.

Would you happen to have any idea on what I could try next? I have already deleted Maven and Java, uninstalled TestNG Eclipse plugin and back on... but every time the error persist.

Any help/ideas/suggestion are welcome!!

Cedric Beust wrote
The NPE is in your code:

com.risk.mtm.RegMtmMissingData.testMissingAdjustments(
RegMtmMissingData.java:167

so I'm not sure how we can help...

--
Cédric




On Thu, Feb 2, 2012 at 1:56 AM, mane_uk <mane_uk@hotmail.com> wrote:

>
> Hi all,
>
>  I have been giving the task to convert around 20 of the projects of the
> company I work for from JUnit to TestNG.
>
>  When I run the Maven Command line "mvn clean test -pl myfolder" before the
> conversion it builds without any failure. I do the conversion JUnit-TestNG
> using the Eclipse Helios IDE with the TestNG plugin, right clicking on the
> project and then choosing TestNG/Convert to TestNG.
>
>  When I run the same Maven command line again, after the conversion, it
> pass some tests but fail a few as well with a NullPointerError. I have been
> looking into it for the last week and couldn't really find anything on the
> net. What
> can be the problem?
>
> This is my POM.XML
> <project xmlns="http://maven.apache.org/POM/4.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
>                     http://maven.apache.org/xsd/maven-4.0.0.xsd">
>  
>   <modelVersion>4.0.0</modelVersion>
>
>  
>   <parent>
>       <groupId>com.risk</groupId>
>       <artifactId>h-agg</artifactId>
>       <version>1.0</version>
>   </parent>
>
>  
>   <artifactId>pricreg</artifactId>
>   <version>${version.qualifier}</version>
>
>   <inceptionYear>2004</inceptionYear>
>
>   <prerequisites>
>       <maven>2.0</maven>
>   </prerequisites>
>
>  
>   <name>pricreg</name>
>
>   <build>
>       <testResources>
>           <testResource>
>               <directory>${project.basedir}/src/test/resources</directory>
>               <excludes>
>                   <exclude>**/*</exclude>
>               </excludes>
>           </testResource>
>       </testResources>
>       <plugins>
>           <plugin>
>               <groupId>org.apache.maven.plugins</groupId>
>               <artifactId>maven-jar-plugin</artifactId>
>               <version>2.3.2</version>
>               <configuration>
>                   <skip>false</skip>
>               </configuration>
>               <executions>
>                   <execution>
>                       <goals>
>                           <goal>test-jar</goal>
>                       </goals>
>                   </execution>
>               </executions>
>           </plugin>
>
>           <plugin>
>               <groupId>org.codehaus.mojo</groupId>
>               <artifactId>script-maven-plugin</artifactId>
>               <executions>
>                   <execution>
>                       <id>Publish-Scripts</id>
>                       <phase>compile</phase>
>                       <goals>
>                           <goal>publish-nosuffix</goal>
>                       </goals>
>                       <configuration>
>                           <debug>true</debug>
>                           <sources>
>                               <source>
>                                   <scriptincludes>
>
> <scriptinclude>**/*.sh</scriptinclude>
>
> <scriptinclude>**/*.ksh</scriptinclude>
>                                   </scriptincludes>
>                                   <scriptexcludes>
>
> <scriptexclude>**/env.sh</scriptexclude>
>                                   </scriptexcludes>
>                               </source>
>                           </sources>
>
> <scriptSourceDirectory>${basedir}</scriptSourceDirectory>
>                       </configuration>
>                   </execution>
>               </executions>
>           </plugin>
>
>           <plugin>
>               <artifactId>maven-surefire-plugin</artifactId>
>               <groupId>org.apache.maven.plugins</groupId>
>               <version>${surefire.plugin.version}</version>
>               <configuration>
>                   <jvm>${jdk.home}\bin\java</jvm>
>                   <forkMode>perTest</forkMode>
>                   <printSummary>true</printSummary>
>                   <argLine>-Xmx1024m -Xms512m</argLine>
>                   <groups>functest</groups>
>                   <additionalClasspathElements>
>
> <classpathElement>${project.basedir}/src/test/resources</classpathElement>
>                   </additionalClasspathElements>
>                   <excludes>
>                       <exclude>**/Test*.java</exclude>
>                       <exclude>**/*Test.java</exclude>
>                       <exclude>**/*TestCase.java</exclude>
>                   </excludes>
>                   <includes>
>                       <include>**/RegMtmCompF.java</include>
>                       <include>**/RegMtmMissingData.java</include>
>                       <include>**/RegMtmCompI.java</include>
>                       <include>**/AccMTMRegFXFW.java</include>
>                       <include>**/AccMTMRegFXSP.java</include>
>                       <include>**/AccMTMRegFXTU.java</include>
>                       <include>**/AccMTMRegIRS_NC.java</include>
>                       <include>**/AccMTMRegIRS_ND.java</include>
>                       <include>**/AccMTMRegIRS_B_NC.java</include>
>                       <include>**/AccMTMRegCS.java</include>
>                       <include>**/AccMTMRegCS_MTM.java</include>
>                       <include>**/AccMTMRegFLR.java</include>
>                       <include>**/AccMTMRegCAP.java</include>
>                       <include>**/AccMTMRegCAPD.java</include>
>                       <include>**/AccMTMRegFLRD.java</include>
>                   </includes>
>               </configuration>
>           </plugin>
>       </plugins>
>   </build>
>   <profiles>
>       <profile>
>           <id>HUDSON_HAWK</id>
>           <activation>
>               <property>
>                   <name>env.HUDSON_HOME</name>
>               </property>
>           </activation>
>           <build>
>               <plugins>
>                   <plugin>
>                       <artifactId>maven-surefire-plugin</artifactId>
>                       <configuration>
>                           <skipTests>false</skipTests>
>                           <skip>false</skip>
>                       </configuration>
>                   </plugin>
>                   <plugin>
>                       <artifactId>maven-compiler-plugin</artifactId>
>                       <configuration>
>                           <skip>false</skip>
>                       </configuration>
>                   </plugin>
>               </plugins>
>           </build>
>       </profile>
>   </profiles>
>
>   <dependencies>
>       <dependency>
>           <groupId>org.testng</groupId>
>           <artifactId>testng</artifactId>
>       </dependency>
>        A FEW INTERNAL DEPENDENCIES HERE WHICH I DELETED TO NOT MAKE THIS
> POST TOO LONG.
>   </dependencies>
> </project>
>
>
> And here is what the surefire report produce:
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <testsuite failures="3" time="1.687" errors="0" skipped="0" tests="3"
> name="com.risk.mtm.RegMtmMissingData">
>  <properties>
>   <property name="java.runtime.name" value="Java(TM) SE Runtime
> Environment"/>
>   <property name="sun.boot.library.path" value="C:\Program
> Files\Java\jdk1.6.0_29\jre\bin"/>
>   <property name="java.vm.version" value="20.4-b02"/>
>   <property name="java.vm.vendor" value="Sun Microsystems Inc."/>
>   <property name="java.vendor.url" value="http://java.sun.com/"/>
>   <property name="path.separator" value=";"/>
>   <property name="java.vm.name" value="Java HotSpot(TM) Client VM"/>
>   <property name="file.encoding.pkg" value="sun.io"/>
>   <property name="user.country" value="GB"/>
>   <property name="sun.java.launcher" value="SUN_STANDARD"/>
>   <property name="sun.os.patch.level" value="Service Pack 3"/>
>   <property name="java.vm.specification.name" value="Java Virtual Machine
> Specification"/>
>   <property name="user.dir" value="C:\dev\h-agg"/>
>   <property name="java.runtime.version" value="1.6.0_29-b11"/>
>   <property name="java.awt.graphicsenv"
> value="sun.awt.Win32GraphicsEnvironment"/>
>   <property name="java.endorsed.dirs" value="C:\Program Files\Java
> \jdk1.6.0_29\jre\lib\endorsed"/>
>   <property name="os.arch" value="x86"/>
>   <property name="java.io.tmpdir"
> value="C:\DOCUME~1\chiavem\LOCALS~1\Temp\"/>
>   <property name="line.separator" value=""/>
>   <property name="java.vm.specification.vendor" value="Sun Microsystems
> Inc."/>
>   <property name="user.variant" value=""/>
>   <property name="os.name" value="Windows XP"/>
>   <property name="classworlds.conf" value="C:\maven\bin\m2.conf"/>
>   <property name="sun.jnu.encoding" value="Cp1252"/>
>   <property name="java.library.path" value="C:\Program
>
> Files\Java\jdk1.6.0_29\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\SYBASE12\OLEDB;C:\SYBASE12\ODBC;C:\SYBASE12\OCS-12_5\dll;C:\ProgramFiles\TIBCO\TIBRV\BIN;C:\Program
> Files\KVS\EVClient\;C:\Program Files\SlikSvn\bin\;C:\Program
> Files\TortoiseSVN\bin;%DERBY_HOME%\bin;%JAVA_HOME%\bin;C:\Program
> Files\Java\jdk1.6.0_29\bin;C:\maven\bin;."/
>   <property name="java.specification.name" value="Java Platform API
> Specification"/>
>   <property name="java.class.version" value="50.0"/>
>   <property name="sun.management.compiler" value="HotSpot Client
> Compiler"/>
>   <property name="os.version" value="5.1"/>
>   <property name="user.home"
> value="\\eurfiler6home.fm.rbsgrp.net\chiavem\MyGEOSProfile\FDR"/>
>   <property name="user.timezone" value="Europe/London"/>
>   <property name="java.awt.printerjob"
> value="sun.awt.windows.WPrinterJob"/>
>   <property name="file.encoding" value="Cp1252"/>
>   <property name="java.specification.version" value="1.6"/>
>   <property name="user.name" value="chiavem"/>
>   <property name="java.class.path"
> value="C:\maven\boot\classworlds-1.1.jar"/>
>   <property name="java.vm.specification.version" value="1.0"/>
>   <property name="sun.arch.data.model" value="32"/>
>   <property name="java.home" value="C:\Program
> Files\Java\jdk1.6.0_29\jre"/>
>   <property name="sun.java.command"
> value="org.codehaus.classworlds.Launcher clean test -pl pricreg"/>
>   <property name="java.specification.vendor" value="Sun Microsystems
> Inc."/>
>   <property name="user.language" value="en"/>
>   <property name="awt.toolkit" value="sun.awt.windows.WToolkit"/>
>   <property name="java.vm.info" value="mixed mode"/>
>   <property name="java.version" value="1.6.0_29"/>
>   <property name="java.ext.dirs" value="C:\Program
> Files\Java\jdk1.6.0_29\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext"/>
>   <property name="sun.boot.class.path" value="C:\Program
> Files\Java\jdk1.6.0_29\jre\lib\resources.jar;C:\Program
> Files\Java\jdk1.6.0_29\jre\lib\rt.jar;C:\Program
> Files\Java\jdk1.6.0_29\jre\lib\sunrsasign.jar;C:\Program
> Files\Java\jdk1.6.0_29\jre\lib\jsse.jar;C:\Program
> Files\Java\jdk1.6.0_29\jre\lib\jce.jar;C:\Program
> Files\Java\jdk1.6.0_29\jre\lib\charsets.jar;C:\Program
> Files\Java\jdk1.6.0_29\jre\lib\modules\jdk.boot.jar;C:\Program
> Files\Java\jdk1.6.0_29\jre\classes"/>
>   <property name="java.vendor" value="Sun Microsystems Inc."/>
>   <property name="maven.home" value="C:\maven"/>
>   <property name="file.separator" value="\"/>
>   <property name="java.vendor.url.bug"
> value="http://java.sun.com/cgi-bin/bugreport.cgi"/>
>   <property name="sun.cpu.endian" value="little"/>
>   <property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
>   <property name="sun.desktop" value="windows"/>
>   <property name="sun.cpu.isalist" value="pentium_pro+mmx pentium_pro
> pentium+mmx pentium i486 i386 i86"/>
>  </properties>
>  <testcase time="0.031" classname="com.risk.mtm.RegMtmMissingData"
> name="testMissingAdjustments">
>   <failure
> type="java.lang.NullPointerException">java.lang.NullPointerException
>   at
>
> com.risk.mtm.RegMtmMissingData.testMissingAdjustments(RegMtmMissingData.java:167)
> </failure>
>  </testcase>
>  <testcase time="0" classname="com.risk.mtm.RegMtmMissingData"
> name="testMissingFixings">
>   <failure
> type="java.lang.NullPointerException">java.lang.NullPointerException
>   at
>
> com.risk.mtm.RegMtmMissingData.testMissingFixings(RegMtmMissingData.java:108)
> </failure>
>  </testcase>
>  <testcase time="0" classname="com.risk.mtm.RegMtmMissingData"
> name="testMissingHolidayCalendars">
>   <failure
> type="java.lang.NullPointerException">java.lang.NullPointerException
>   at
>
> com.risk.mtm.RegMtmMissingData.testMissingHolidayCalendars(RegMtmMissingData.java:51)
> </failure>
>  </testcase>
> </testsuite>
>
>
> Part of the Java code is:
>
> @BeforeMethod
>   public void setUp() {
>       Workbook wb;
>       try {
>          wb
>
> =POIUtil.getWorkbookForFile(ResourceUtil.getInstance().getRegResourceFileForClass(getClass(),
> "xls"));
>           businessDate = new
> SimpleDateFormat("yyyyMMdd").parse("20110516");
>           ConfigManagerStore providerStore =
> XLProviderStore.initialise(wb,this.getClass());
>
>           market
>
> =providerStore.getMarketManager().getMarket(CreditKeyStore.marketKey(businessDate,
> 1, 1));
>           holCalManager = providerStore.getHolidayCalendarManager();
>       } catch (Exception e) {
>           // TODO Auto-generated catch block
>           e.printStackTrace();
>       }
>   }
>
>   @Test(groups={"functest"})
>   public void testMissingHolidayCalendars() {
>       holCalManager.startRecordingMissingData();
>
>
> The lines 51, 108 and 167 are all the same
> holCalManager.startRecordingMissingData(); But I do believe the
> problem is that wb workbook is coming back as null even though there is the
> excel file in there to read!!!
>
> Ah, one last point is, which is more like a new question: if I delete the
> include/exclude instruction from my POM file it won't run the TestNG
> files!!!
>
> Many thanks for all your help!!
>
> Regards
> Emanuel
> --
> View this message in context:
> http://old.nabble.com/Getting-a-NullPointerError-when-converting-JUnit-to-TestNG-tp33249051p33249051.html
> Sent from the testng-dev mailing list archive at Nabble.com.
>
> --
> You received this message because you are subscribed to the Google Groups
> "testng-dev" group.
> To post to this group, send email to testng-dev@googlegroups.com.
> To unsubscribe from this group, send email to
> testng-dev+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/testng-dev?hl=en.
>
>

--
You received this message because you are subscribed to the Google Groups "testng-dev" group.
To post to this group, send email to testng-dev@googlegroups.com.
To unsubscribe from this group, send email to testng-dev+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-dev?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: [testng-dev] Getting a NullPointerError when converting JUnit to TestNG

Cédric Beust ♔-2
Start with the NPE, these are trivial to debug. Why is this field null? Where does it get assigned? Does the code that assigns the value get run?

-- 
Cédric




On Thu, Feb 2, 2012 at 2:15 PM, mane_uk <[hidden email]> wrote:

Thanks Cedric for the reply.

I thought the problem could be related to the "convert to TestNG" automatic
tool on the Eclipse IDE as this modules builds perfectly when running on
JUnit before conversion.

I have noticed after converting some more modules of my project from JUnit
to TestNG, that all of them returned at least 1 test of the code as
NullPointerException error. 99% of it pointing to lines in the code which
are doing assert.equals or compareTo or when calling different classes like
in the example below.

Would you happen to have any idea on what I could try next? I have already
deleted Maven and Java, uninstalled TestNG Eclipse plugin and back on... but
every time the error persist.

Any help/ideas/suggestion are welcome!!


Cedric Beust wrote:
>
> The NPE is in your code:
>
> com.risk.mtm.RegMtmMissingData.testMissingAdjustments(
> RegMtmMissingData.java:167
>
> so I'm not sure how we can help...
>
> --
> Cédric
>
>
>
>
> On Thu, Feb 2, 2012 at 1:56 AM, mane_uk <[hidden email]> wrote:
>
>>
>> Hi all,
>>
>>  I have been giving the task to convert around 20 of the projects of the
>> company I work for from JUnit to TestNG.
>>
>>  When I run the Maven Command line "mvn clean test -pl myfolder" before
>> the
>> conversion it builds without any failure. I do the conversion
>> JUnit-TestNG
>> using the Eclipse Helios IDE with the TestNG plugin, right clicking on
>> the
>> project and then choosing TestNG/Convert to TestNG.
>>
>>  When I run the same Maven command line again, after the conversion, it
>> pass some tests but fail a few as well with a NullPointerError. I have
>> been
>> looking into it for the last week and couldn't really find anything on
>> the
>> net. What
>> can be the problem?
>>
>> This is my POM.XML
>> <project xmlns="http://maven.apache.org/POM/4.0.0"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
>>                     http://maven.apache.org/xsd/maven-4.0.0.xsd">
>>   <!-- Maven POM Version -->
>>   <modelVersion>4.0.0</modelVersion>
>>
>>   <!-- PROJECT PARENT IDENTITY -->
>>   <parent>
>>       <groupId>com.risk</groupId>
>>       <artifactId>h-agg</artifactId>
>>       <version>1.0</version>
>>   </parent>
>>
>>   <!-- PROJECT IDENTITY -->
>>   <artifactId>pricreg</artifactId>
>>   <version>${version.qualifier}</version>
>>
>>   <inceptionYear>2004</inceptionYear>
>>
>>   <prerequisites>
>>       <maven>2.0</maven>
>>   </prerequisites>
>>
>>   <!-- PROJECT DESCRIPTION -->
>>   <name>pricreg</name>
>>
>>   <build>
>>       <testResources>
>>           <testResource>
>>
>> <directory>${project.basedir}/src/test/resources</directory>
>>               <excludes>
>>                   <exclude>**/*</exclude>
>>               </excludes>
>>           </testResource>
>>       </testResources>
>>       <plugins>
>>           <plugin>
>>               <groupId>org.apache.maven.plugins</groupId>
>>               <artifactId>maven-jar-plugin</artifactId>
>>               <version>2.3.2</version>
>>               <configuration>
>>                   <skip>false</skip>
>>               </configuration>
>>               <executions>
>>                   <execution>
>>                       <goals>
>>                           <goal>test-jar</goal>
>>                       </goals>
>>                   </execution>
>>               </executions>
>>           </plugin>
>>
>>           <plugin>
>>               <groupId>org.codehaus.mojo</groupId>
>>               <artifactId>script-maven-plugin</artifactId>
>>               <executions>
>>                   <execution>
>>                       <id>Publish-Scripts</id>
>>                       <phase>compile</phase>
>>                       <goals>
>>                           <goal>publish-nosuffix</goal>
>>                       </goals>
>>                       <configuration>
>>                           <debug>true</debug>
>>                           <sources>
>>                               <source>
>>                                   <scriptincludes>
>>
>> <scriptinclude>**/*.sh</scriptinclude>
>>
>> <scriptinclude>**/*.ksh</scriptinclude>
>>                                   </scriptincludes>
>>                                   <scriptexcludes>
>>
>> <scriptexclude>**/env.sh</scriptexclude>
>>                                   </scriptexcludes>
>>                               </source>
>>                           </sources>
>>
>> <scriptSourceDirectory>${basedir}</scriptSourceDirectory>
>>                       </configuration>
>>                   </execution>
>>               </executions>
>>           </plugin>
>>
>>           <plugin>
>>               <artifactId>maven-surefire-plugin</artifactId>
>>               <groupId>org.apache.maven.plugins</groupId>
>>               <version>${surefire.plugin.version}</version>
>>               <configuration>
>>                   <jvm>${jdk.home}\bin\java</jvm>
>>                   <forkMode>perTest</forkMode>
>>                   <printSummary>true</printSummary>
>>                   <argLine>-Xmx1024m -Xms512m</argLine>
>>                   <groups>functest</groups>
>>                   <additionalClasspathElements>
>>
>> <classpathElement>${project.basedir}/src/test/resources</classpathElement>
>>                   </additionalClasspathElements>
>>                   <excludes>
>>                       <exclude>**/Test*.java</exclude>
>>                       <exclude>**/*Test.java</exclude>
>>                       <exclude>**/*TestCase.java</exclude>
>>                   </excludes>
>>                   <includes>
>>                       <include>**/RegMtmCompF.java</include>
>>                       <include>**/RegMtmMissingData.java</include>
>>                       <include>**/RegMtmCompI.java</include>
>>                       <include>**/AccMTMRegFXFW.java</include>
>>                       <include>**/AccMTMRegFXSP.java</include>
>>                       <include>**/AccMTMRegFXTU.java</include>
>>                       <include>**/AccMTMRegIRS_NC.java</include>
>>                       <include>**/AccMTMRegIRS_ND.java</include>
>>                       <include>**/AccMTMRegIRS_B_NC.java</include>
>>                       <include>**/AccMTMRegCS.java</include>
>>                       <include>**/AccMTMRegCS_MTM.java</include>
>>                       <include>**/AccMTMRegFLR.java</include>
>>                       <include>**/AccMTMRegCAP.java</include>
>>                       <include>**/AccMTMRegCAPD.java</include>
>>                       <include>**/AccMTMRegFLRD.java</include>
>>                   </includes>
>>               </configuration>
>>           </plugin>
>>       </plugins>
>>   </build>
>>   <profiles>
>>       <profile>
>>           <id>HUDSON_HAWK</id>
>>           <activation>
>>               <property>
>>                   <name>env.HUDSON_HOME</name>
>>               </property>
>>           </activation>
>>           <build>
>>               <plugins>
>>                   <plugin>
>>                       <artifactId>maven-surefire-plugin</artifactId>
>>                       <configuration>
>>                           <skipTests>false</skipTests>
>>                           <skip>false</skip>
>>                       </configuration>
>>                   </plugin>
>>                   <plugin>
>>                       <artifactId>maven-compiler-plugin</artifactId>
>>                       <configuration>
>>                           <skip>false</skip>
>>                       </configuration>
>>                   </plugin>
>>               </plugins>
>>           </build>
>>       </profile>
>>   </profiles>
>>
>>   <dependencies>
>>       <dependency>
>>           <groupId>org.testng</groupId>
>>           <artifactId>testng</artifactId>
>>       </dependency>
>>        A FEW INTERNAL DEPENDENCIES HERE WHICH I DELETED TO NOT MAKE THIS
>> POST TOO LONG.
>>   </dependencies>
>> </project>
>>
>>
>> And here is what the surefire report produce:
>>
>> <?xml version="1.0" encoding="UTF-8" ?>
>> <testsuite failures="3" time="1.687" errors="0" skipped="0" tests="3"
>> name="com.risk.mtm.RegMtmMissingData">
>>  <properties>
>>   <property name="java.runtime.name" value="Java(TM) SE Runtime
>> Environment"/>
>>   <property name="sun.boot.library.path" value="C:\Program
>> Files\Java\jdk1.6.0_29\jre\bin"/>
>>   <property name="java.vm.version" value="20.4-b02"/>
>>   <property name="java.vm.vendor" value="Sun Microsystems Inc."/>
>>   <property name="java.vendor.url" value="http://java.sun.com/"/>
>>   <property name="path.separator" value=";"/>
>>   <property name="java.vm.name" value="Java HotSpot(TM) Client VM"/>
>>   <property name="file.encoding.pkg" value="sun.io"/>
>>   <property name="user.country" value="GB"/>
>>   <property name="sun.java.launcher" value="SUN_STANDARD"/>
>>   <property name="sun.os.patch.level" value="Service Pack 3"/>
>>   <property name="java.vm.specification.name" value="Java Virtual Machine
>> Specification"/>
>>   <property name="user.dir" value="C:\dev\h-agg"/>
>>   <property name="java.runtime.version" value="1.6.0_29-b11"/>
>>   <property name="java.awt.graphicsenv"
>> value="sun.awt.Win32GraphicsEnvironment"/>
>>   <property name="java.endorsed.dirs" value="C:\Program Files\Java
>> \jdk1.6.0_29\jre\lib\endorsed"/>
>>   <property name="os.arch" value="x86"/>
>>   <property name="java.io.tmpdir"
>> value="C:\DOCUME~1\chiavem\LOCALS~1\Temp\"/>
>>   <property name="line.separator" value=""/>
>>   <property name="java.vm.specification.vendor" value="Sun Microsystems
>> Inc."/>
>>   <property name="user.variant" value=""/>
>>   <property name="os.name" value="Windows XP"/>
>>   <property name="classworlds.conf" value="C:\maven\bin\m2.conf"/>
>>   <property name="sun.jnu.encoding" value="Cp1252"/>
>>   <property name="java.library.path" value="C:\Program
>>
>> Files\Java\jdk1.6.0_29\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\SYBASE12\OLEDB;C:\SYBASE12\ODBC;C:\SYBASE12\OCS-12_5\dll;C:\ProgramFiles\TIBCO\TIBRV\BIN;C:\Program
>> Files\KVS\EVClient\;C:\Program Files\SlikSvn\bin\;C:\Program
>> Files\TortoiseSVN\bin;%DERBY_HOME%\bin;%JAVA_HOME%\bin;C:\Program
>> Files\Java\jdk1.6.0_29\bin;C:\maven\bin;."/
>>   <property name="java.specification.name" value="Java Platform API
>> Specification"/>
>>   <property name="java.class.version" value="50.0"/>
>>   <property name="sun.management.compiler" value="HotSpot Client
>> Compiler"/>
>>   <property name="os.version" value="5.1"/>
>>   <property name="user.home"
>> value="\\eurfiler6home.fm.rbsgrp.net\chiavem\MyGEOSProfile\FDR"/>
>>   <property name="user.timezone" value="Europe/London"/>
>>   <property name="java.awt.printerjob"
>> value="sun.awt.windows.WPrinterJob"/>
>>   <property name="file.encoding" value="Cp1252"/>
>>   <property name="java.specification.version" value="1.6"/>
>>   <property name="user.name" value="chiavem"/>
>>   <property name="java.class.path"
>> value="C:\maven\boot\classworlds-1.1.jar"/>
>>   <property name="java.vm.specification.version" value="1.0"/>
>>   <property name="sun.arch.data.model" value="32"/>
>>   <property name="java.home" value="C:\Program
>> Files\Java\jdk1.6.0_29\jre"/>
>>   <property name="sun.java.command"
>> value="org.codehaus.classworlds.Launcher clean test -pl pricreg"/>
>>   <property name="java.specification.vendor" value="Sun Microsystems
>> Inc."/>
>>   <property name="user.language" value="en"/>
>>   <property name="awt.toolkit" value="sun.awt.windows.WToolkit"/>
>>   <property name="java.vm.info" value="mixed mode"/>
>>   <property name="java.version" value="1.6.0_29"/>
>>   <property name="java.ext.dirs" value="C:\Program
>> Files\Java\jdk1.6.0_29\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext"/>
>>   <property name="sun.boot.class.path" value="C:\Program
>> Files\Java\jdk1.6.0_29\jre\lib\resources.jar;C:\Program
>> Files\Java\jdk1.6.0_29\jre\lib\rt.jar;C:\Program
>> Files\Java\jdk1.6.0_29\jre\lib\sunrsasign.jar;C:\Program
>> Files\Java\jdk1.6.0_29\jre\lib\jsse.jar;C:\Program
>> Files\Java\jdk1.6.0_29\jre\lib\jce.jar;C:\Program
>> Files\Java\jdk1.6.0_29\jre\lib\charsets.jar;C:\Program
>> Files\Java\jdk1.6.0_29\jre\lib\modules\jdk.boot.jar;C:\Program
>> Files\Java\jdk1.6.0_29\jre\classes"/>
>>   <property name="java.vendor" value="Sun Microsystems Inc."/>
>>   <property name="maven.home" value="C:\maven"/>
>>   <property name="file.separator" value="\"/>
>>   <property name="java.vendor.url.bug"
>> value="http://java.sun.com/cgi-bin/bugreport.cgi"/>
>>   <property name="sun.cpu.endian" value="little"/>
>>   <property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
>>   <property name="sun.desktop" value="windows"/>
>>   <property name="sun.cpu.isalist" value="pentium_pro+mmx pentium_pro
>> pentium+mmx pentium i486 i386 i86"/>
>>  </properties>
>>  <testcase time="0.031" classname="com.risk.mtm.RegMtmMissingData"
>> name="testMissingAdjustments">
>>   <failure
>> type="java.lang.NullPointerException">java.lang.NullPointerException
>>   at
>>
>> com.risk.mtm.RegMtmMissingData.testMissingAdjustments(RegMtmMissingData.java:167)
>> </failure>
>>  </testcase>
>>  <testcase time="0" classname="com.risk.mtm.RegMtmMissingData"
>> name="testMissingFixings">
>>   <failure
>> type="java.lang.NullPointerException">java.lang.NullPointerException
>>   at
>>
>> com.risk.mtm.RegMtmMissingData.testMissingFixings(RegMtmMissingData.java:108)
>> </failure>
>>  </testcase>
>>  <testcase time="0" classname="com.risk.mtm.RegMtmMissingData"
>> name="testMissingHolidayCalendars">
>>   <failure
>> type="java.lang.NullPointerException">java.lang.NullPointerException
>>   at
>>
>> com.risk.mtm.RegMtmMissingData.testMissingHolidayCalendars(RegMtmMissingData.java:51)
>> </failure>
>>  </testcase>
>> </testsuite>
>>
>>
>> Part of the Java code is:
>>
>> @BeforeMethod
>>   public void setUp() {
>>       Workbook wb;
>>       try {
>>          wb
>>
>> =POIUtil.getWorkbookForFile(ResourceUtil.getInstance().getRegResourceFileForClass(getClass(),
>> "xls"));
>>           businessDate = new
>> SimpleDateFormat("yyyyMMdd").parse("20110516");
>>           ConfigManagerStore providerStore =
>> XLProviderStore.initialise(wb,this.getClass());
>>
>>           market
>>
>> =providerStore.getMarketManager().getMarket(CreditKeyStore.marketKey(businessDate,
>> 1, 1));
>>           holCalManager = providerStore.getHolidayCalendarManager();
>>       } catch (Exception e) {
>>           // TODO Auto-generated catch block
>>           e.printStackTrace();
>>       }
>>   }
>>
>>   @Test(groups={"functest"})
>>   public void testMissingHolidayCalendars() {
>>       holCalManager.startRecordingMissingData();
>>
>>
>> The lines 51, 108 and 167 are all the same
>> holCalManager.startRecordingMissingData(); But I do believe the
>> problem is that wb workbook is coming back as null even though there is
>> the
>> excel file in there to read!!!
>>
>> Ah, one last point is, which is more like a new question: if I delete the
>> include/exclude instruction from my POM file it won't run the TestNG
>> files!!!
>>
>> Many thanks for all your help!!
>>
>> Regards
>> Emanuel
>> --
>> View this message in context:
>> http://old.nabble.com/Getting-a-NullPointerError-when-converting-JUnit-to-TestNG-tp33249051p33249051.html
>> Sent from the testng-dev mailing list archive at Nabble.com.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "testng-dev" group.
>> To post to this group, send email to [hidden email].
>> To unsubscribe from this group, send email to
>> [hidden email].
>> For more options, visit this group at
>> http://groups.google.com/group/testng-dev?hl=en.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "testng-dev" group.
> To post to this group, send email to [hidden email].
> To unsubscribe from this group, send email to
> [hidden email].
> For more options, visit this group at
> http://groups.google.com/group/testng-dev?hl=en.
>
>
>

--
View this message in context: http://old.nabble.com/Getting-a-NullPointerException-Error-when-converting-JUnit-to-TestNG-tp33249051p33253618.html
Sent from the testng-dev mailing list archive at Nabble.com.

--
You received this message because you are subscribed to the Google Groups "testng-dev" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-dev?hl=en.


--
You received this message because you are subscribed to the Google Groups "testng-dev" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-dev?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: [testng-dev] Getting a NullPointerError when converting JUnit to TestNG

Mark Derricutt
In reply to this post by Cédric Beust ♔-2
The @Test method has a group attached, but the @BeforeMethod doesn't - could it be the before method isn't running only the functest group ( can't recall immediate off hand if groupless @BeforeXXX methods run regardless or not ? )

Mark

--
"Great artists are extremely selfish and arrogant things" — Steven Wilson, Porcupine Tree


2012/2/3 Cédric Beust ♔ <[hidden email]>
The NPE is in your code:

com.risk.mtm.RegMtmMissingData.testMissingAdjustments(RegMtmMissingData.java:167

so I'm not sure how we can help...

-- 
Cédric




On Thu, Feb 2, 2012 at 1:56 AM, mane_uk <[hidden email]> wrote:

Hi all,

 I have been giving the task to convert around 20 of the projects of the
company I work for from JUnit to TestNG.

 When I run the Maven Command line "mvn clean test -pl myfolder" before the
conversion it builds without any failure. I do the conversion JUnit-TestNG
using the Eclipse Helios IDE with the TestNG plugin, right clicking on the
project and then choosing TestNG/Convert to TestNG.

 When I run the same Maven command line again, after the conversion, it
pass some tests but fail a few as well with a NullPointerError. I have been
looking into it for the last week and couldn't really find anything on the
net. What
can be the problem?

This is my POM.XML
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                    http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <!-- Maven POM Version -->
  <modelVersion>4.0.0</modelVersion>

  <!-- PROJECT PARENT IDENTITY -->
  <parent>
      <groupId>com.risk</groupId>
      <artifactId>h-agg</artifactId>
      <version>1.0</version>
  </parent>

  <!-- PROJECT IDENTITY -->
  <artifactId>pricreg</artifactId>
  <version>${version.qualifier}</version>

  <inceptionYear>2004</inceptionYear>

  <prerequisites>
      <maven>2.0</maven>
  </prerequisites>

  <!-- PROJECT DESCRIPTION -->
  <name>pricreg</name>

  <build>
      <testResources>
          <testResource>
              <directory>${project.basedir}/src/test/resources</directory>
              <excludes>
                  <exclude>**/*</exclude>
              </excludes>
          </testResource>
      </testResources>
      <plugins>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-jar-plugin</artifactId>
              <version>2.3.2</version>
              <configuration>
                  <skip>false</skip>
              </configuration>
              <executions>
                  <execution>
                      <goals>
                          <goal>test-jar</goal>
                      </goals>
                  </execution>
              </executions>
          </plugin>

          <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>script-maven-plugin</artifactId>
              <executions>
                  <execution>
                      <id>Publish-Scripts</id>
                      <phase>compile</phase>
                      <goals>
                          <goal>publish-nosuffix</goal>
                      </goals>
                      <configuration>
                          <debug>true</debug>
                          <sources>
                              <source>
                                  <scriptincludes>

<scriptinclude>**/*.sh</scriptinclude>

<scriptinclude>**/*.ksh</scriptinclude>
                                  </scriptincludes>
                                  <scriptexcludes>

<scriptexclude>**/env.sh</scriptexclude>
                                  </scriptexcludes>
                              </source>
                          </sources>

<scriptSourceDirectory>${basedir}</scriptSourceDirectory>
                      </configuration>
                  </execution>
              </executions>
          </plugin>

          <plugin>
              <artifactId>maven-surefire-plugin</artifactId>
              <groupId>org.apache.maven.plugins</groupId>
              <version>${surefire.plugin.version}</version>
              <configuration>
                  <jvm>${jdk.home}\bin\java</jvm>
                  <forkMode>perTest</forkMode>
                  <printSummary>true</printSummary>
                  <argLine>-Xmx1024m -Xms512m</argLine>
                  <groups>functest</groups>
                  <additionalClasspathElements>

<classpathElement>${project.basedir}/src/test/resources</classpathElement>
                  </additionalClasspathElements>
                  <excludes>
                      <exclude>**/Test*.java</exclude>
                      <exclude>**/*Test.java</exclude>
                      <exclude>**/*TestCase.java</exclude>
                  </excludes>
                  <includes>
                      <include>**/RegMtmCompF.java</include>
                      <include>**/RegMtmMissingData.java</include>
                      <include>**/RegMtmCompI.java</include>
                      <include>**/AccMTMRegFXFW.java</include>
                      <include>**/AccMTMRegFXSP.java</include>
                      <include>**/AccMTMRegFXTU.java</include>
                      <include>**/AccMTMRegIRS_NC.java</include>
                      <include>**/AccMTMRegIRS_ND.java</include>
                      <include>**/AccMTMRegIRS_B_NC.java</include>
                      <include>**/AccMTMRegCS.java</include>
                      <include>**/AccMTMRegCS_MTM.java</include>
                      <include>**/AccMTMRegFLR.java</include>
                      <include>**/AccMTMRegCAP.java</include>
                      <include>**/AccMTMRegCAPD.java</include>
                      <include>**/AccMTMRegFLRD.java</include>
                  </includes>
              </configuration>
          </plugin>
      </plugins>
  </build>
  <profiles>
      <profile>
          <id>HUDSON_HAWK</id>
          <activation>
              <property>
                  <name>env.HUDSON_HOME</name>
              </property>
          </activation>
          <build>
              <plugins>
                  <plugin>
                      <artifactId>maven-surefire-plugin</artifactId>
                      <configuration>
                          <skipTests>false</skipTests>
                          <skip>false</skip>
                      </configuration>
                  </plugin>
                  <plugin>
                      <artifactId>maven-compiler-plugin</artifactId>
                      <configuration>
                          <skip>false</skip>
                      </configuration>
                  </plugin>
              </plugins>
          </build>
      </profile>
  </profiles>

  <dependencies>
      <dependency>
          <groupId>org.testng</groupId>
          <artifactId>testng</artifactId>
      </dependency>
       A FEW INTERNAL DEPENDENCIES HERE WHICH I DELETED TO NOT MAKE THIS
POST TOO LONG.
  </dependencies>
</project>


And here is what the surefire report produce:

<?xml version="1.0" encoding="UTF-8" ?>
<testsuite failures="3" time="1.687" errors="0" skipped="0" tests="3"
name="com.risk.mtm.RegMtmMissingData">
 <properties>
  <property name="java.runtime.name" value="Java(TM) SE Runtime
Environment"/>
  <property name="sun.boot.library.path" value="C:\Program
Files\Java\jdk1.6.0_29\jre\bin"/>
  <property name="java.vm.version" value="20.4-b02"/>
  <property name="java.vm.vendor" value="Sun Microsystems Inc."/>
  <property name="java.vendor.url" value="http://java.sun.com/"/>
  <property name="path.separator" value=";"/>
  <property name="java.vm.name" value="Java HotSpot(TM) Client VM"/>
  <property name="file.encoding.pkg" value="sun.io"/>
  <property name="user.country" value="GB"/>
  <property name="sun.java.launcher" value="SUN_STANDARD"/>
  <property name="sun.os.patch.level" value="Service Pack 3"/>
  <property name="java.vm.specification.name" value="Java Virtual Machine
Specification"/>
  <property name="user.dir" value="C:\dev\h-agg"/>
  <property name="java.runtime.version" value="1.6.0_29-b11"/>
  <property name="java.awt.graphicsenv"
value="sun.awt.Win32GraphicsEnvironment"/>
  <property name="java.endorsed.dirs" value="C:\Program Files\Java
\jdk1.6.0_29\jre\lib\endorsed"/>
  <property name="os.arch" value="x86"/>
  <property name="java.io.tmpdir"
value="C:\DOCUME~1\chiavem\LOCALS~1\Temp\"/>
  <property name="line.separator" value=""/>
  <property name="java.vm.specification.vendor" value="Sun Microsystems
Inc."/>
  <property name="user.variant" value=""/>
  <property name="os.name" value="Windows XP"/>
  <property name="classworlds.conf" value="C:\maven\bin\m2.conf"/>
  <property name="sun.jnu.encoding" value="Cp1252"/>
  <property name="java.library.path" value="C:\Program
Files\Java\jdk1.6.0_29\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\SYBASE12\OLEDB;C:\SYBASE12\ODBC;C:\SYBASE12\OCS-12_5\dll;C:\ProgramFiles\TIBCO\TIBRV\BIN;C:\Program
Files\KVS\EVClient\;C:\Program Files\SlikSvn\bin\;C:\Program
Files\TortoiseSVN\bin;%DERBY_HOME%\bin;%JAVA_HOME%\bin;C:\Program
Files\Java\jdk1.6.0_29\bin;C:\maven\bin;."/
  <property name="java.specification.name" value="Java Platform API
Specification"/>
  <property name="java.class.version" value="50.0"/>
  <property name="sun.management.compiler" value="HotSpot Client
Compiler"/>
  <property name="os.version" value="5.1"/>
  <property name="user.home"
value="\\eurfiler6home.fm.rbsgrp.net\chiavem\MyGEOSProfile\FDR"/>
  <property name="user.timezone" value="Europe/London"/>
  <property name="java.awt.printerjob"
value="sun.awt.windows.WPrinterJob"/>
  <property name="file.encoding" value="Cp1252"/>
  <property name="java.specification.version" value="1.6"/>
  <property name="user.name" value="chiavem"/>
  <property name="java.class.path"
value="C:\maven\boot\classworlds-1.1.jar"/>
  <property name="java.vm.specification.version" value="1.0"/>
  <property name="sun.arch.data.model" value="32"/>
  <property name="java.home" value="C:\Program
Files\Java\jdk1.6.0_29\jre"/>
  <property name="sun.java.command"
value="org.codehaus.classworlds.Launcher clean test -pl pricreg"/>
  <property name="java.specification.vendor" value="Sun Microsystems
Inc."/>
  <property name="user.language" value="en"/>
  <property name="awt.toolkit" value="sun.awt.windows.WToolkit"/>
  <property name="java.vm.info" value="mixed mode"/>
  <property name="java.version" value="1.6.0_29"/>
  <property name="java.ext.dirs" value="C:\Program
Files\Java\jdk1.6.0_29\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext"/>
  <property name="sun.boot.class.path" value="C:\Program
Files\Java\jdk1.6.0_29\jre\lib\resources.jar;C:\Program
Files\Java\jdk1.6.0_29\jre\lib\rt.jar;C:\Program
Files\Java\jdk1.6.0_29\jre\lib\sunrsasign.jar;C:\Program
Files\Java\jdk1.6.0_29\jre\lib\jsse.jar;C:\Program
Files\Java\jdk1.6.0_29\jre\lib\jce.jar;C:\Program
Files\Java\jdk1.6.0_29\jre\lib\charsets.jar;C:\Program
Files\Java\jdk1.6.0_29\jre\lib\modules\jdk.boot.jar;C:\Program
Files\Java\jdk1.6.0_29\jre\classes"/>
  <property name="java.vendor" value="Sun Microsystems Inc."/>
  <property name="maven.home" value="C:\maven"/>
  <property name="file.separator" value="\"/>
  <property name="java.vendor.url.bug"
value="http://java.sun.com/cgi-bin/bugreport.cgi"/>
  <property name="sun.cpu.endian" value="little"/>
  <property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
  <property name="sun.desktop" value="windows"/>
  <property name="sun.cpu.isalist" value="pentium_pro+mmx pentium_pro
pentium+mmx pentium i486 i386 i86"/>
 </properties>
 <testcase time="0.031" classname="com.risk.mtm.RegMtmMissingData"
name="testMissingAdjustments">
  <failure
type="java.lang.NullPointerException">java.lang.NullPointerException
  at
com.risk.mtm.RegMtmMissingData.testMissingAdjustments(RegMtmMissingData.java:167)
</failure>
 </testcase>
 <testcase time="0" classname="com.risk.mtm.RegMtmMissingData"
name="testMissingFixings">
  <failure
type="java.lang.NullPointerException">java.lang.NullPointerException
  at
com.risk.mtm.RegMtmMissingData.testMissingFixings(RegMtmMissingData.java:108)
</failure>
 </testcase>
 <testcase time="0" classname="com.risk.mtm.RegMtmMissingData"
name="testMissingHolidayCalendars">
  <failure
type="java.lang.NullPointerException">java.lang.NullPointerException
  at
com.risk.mtm.RegMtmMissingData.testMissingHolidayCalendars(RegMtmMissingData.java:51)
</failure>
 </testcase>
</testsuite>


Part of the Java code is:

@BeforeMethod
  public void setUp() {
      Workbook wb;
      try {
         wb
=POIUtil.getWorkbookForFile(ResourceUtil.getInstance().getRegResourceFileForClass(getClass(),
"xls"));
          businessDate = new
SimpleDateFormat("yyyyMMdd").parse("20110516");
          ConfigManagerStore providerStore =
XLProviderStore.initialise(wb,this.getClass());

          market
=providerStore.getMarketManager().getMarket(CreditKeyStore.marketKey(businessDate,
1, 1));
          holCalManager = providerStore.getHolidayCalendarManager();
      } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  }

  @Test(groups={"functest"})
  public void testMissingHolidayCalendars() {
      holCalManager.startRecordingMissingData();


The lines 51, 108 and 167 are all the same
holCalManager.startRecordingMissingData(); But I do believe the
problem is that wb workbook is coming back as null even though there is the
excel file in there to read!!!

Ah, one last point is, which is more like a new question: if I delete the
include/exclude instruction from my POM file it won't run the TestNG
files!!!

Many thanks for all your help!!

Regards
Emanuel
--
View this message in context: http://old.nabble.com/Getting-a-NullPointerError-when-converting-JUnit-to-TestNG-tp33249051p33249051.html
Sent from the testng-dev mailing list archive at Nabble.com.

--
You received this message because you are subscribed to the Google Groups "testng-dev" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-dev?hl=en.


--
You received this message because you are subscribed to the Google Groups "testng-dev" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-dev?hl=en.

--
You received this message because you are subscribed to the Google Groups "testng-dev" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-dev?hl=en.