reset password
Author Message
jonathankroening
Posts: 39
Posted 14:46 Jan 24, 2015 |

Hey all,

I've followed the directions up to the end of Testing (http://csns.calstatela.edu/wiki/content/cysun/course_materials/cs520/sham/testing).

But when I try and run the UserDaoTest class as TestNG Test, I get a TestNGException: cannot instantiate class springmvc.model.dao.UserDaoTest

I've made all the appropriate java files provided for us.  And I've double-checked through postgresql that the tables were created by the sql script under database cs520stuXX by owner cs520stuXX (and no, I didn't also run the drop script.)

Anyone have thoughts on why the UserDaoTest class won't instantiate?  I've tried everything I can think of.

cysun
Posts: 2935
Posted 15:15 Jan 24, 2015 |

Did you copy applicationContext.xml to src/test/resources?

krunalsolanki
Posts: 3
Posted 16:12 Jan 24, 2015 |

 I am attempting to test my UserDaoTests.java file with TestNG and receive a "FAILED CONFIGURATION: @BeforeClass 

 

error :

[TestNG] Running:
  C:\Users\kruna_000\AppData\Local\Temp\testng-eclipse-83868549\testng-customsuite.xml

FAILED CONFIGURATION: @BeforeClass springTestContextPrepareTestInstance
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
    at org.springframework.core.io.support.PathMatchingResourcePatternResolver.<clinit>(PathMatchingResourcePatternResolver.java:169)
    at org.springframework.context.support.AbstractApplicationContext.getResourcePatternResolver(AbstractApplicationContext.java:381)
    at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:220)
    at org.springframework.context.support.GenericApplicationContext.<init>(GenericApplicationContext.java:101)
    at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:108)
    at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60)
    at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:100)
    at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:248)
    at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContextInternal(CacheAwareContextLoaderDelegate.java:64)
    at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:91)
    at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:122)
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:307)
    at org.springframework.test.context.testng.AbstractTestNGSpringContextTests.springTestContextPrepareTestInstance(AbstractTestNGSpringContextTests.java:145)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
    at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
    at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:175)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:107)
    at org.testng.TestRunner.privateRun(TestRunner.java:767)
    at org.testng.TestRunner.run(TestRunner.java:617)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
    at org.testng.SuiteRunner.run(SuiteRunner.java:240)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
    at org.testng.TestNG.run(TestNG.java:1057)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

SKIPPED CONFIGURATION: @BeforeMethod springTestContextBeforeTestMethod
SKIPPED CONFIGURATION: @BeforeMethod springTestContextBeforeTestMethod
SKIPPED: getUser
SKIPPED: getUsers

===============================================
    Default test
    Tests run: 2, Failures: 0, Skips: 2
    Configuration Failures: 1, Skips: 2
===============================================


===============================================
Default suite
Total tests run: 2, Failures: 0, Skips: 2
Configuration Failures: 1, Skips: 2
===============================================

[TestNG] Time taken by org.testng.reporters.EmailableReporter2@2db0f6b2: 27 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@6d86b085: 89 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@3339ad8e: 12 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@43556938: 94 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@4c3e4790: 9 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 7 ms

Attachments:
jonathankroening
Posts: 39
Posted 16:29 Jan 24, 2015 |
cysun wrote:

Did you copy applicationContext.xml to src/test/resources?

yes, I did. 

plakhan
Posts: 37
Posted 17:32 Jan 24, 2015 |

I get the below error, when running the testng

 

org.testng.TestNGException: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 5; Content is not allowed in prolog.
    at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:341)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:88)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Caused by: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 5; Content is not allowed in prolog.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:441)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
    at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1436)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:999)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:649)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:333)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:195)
    at org.testng.xml.XMLParser.parse(XMLParser.java:39)
    at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:17)
    at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:10)
    at org.testng.xml.Parser.parse(Parser.java:168)
    at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:311)
    ... 3 more

 

fgomz
Posts: 6
Posted 18:41 Jan 24, 2015 |
jonathankroening wrote:

Hey all,

I've followed the directions up to the end of Testing (http://csns.calstatela.edu/wiki/content/cysun/course_materials/cs520/sham/testing).

But when I try and run the UserDaoTest class as TestNG Test, I get a TestNGException: cannot instantiate class springmvc.model.dao.UserDaoTest

Remember to use the same version of spring-test as spring-mvc, which is 3.2.8.RELEASE.

jonathankroening
Posts: 39
Posted 19:50 Jan 24, 2015 |
fgomz wrote:
jonathankroening wrote:

Hey all,

I've followed the directions up to the end of Testing (http://csns.calstatela.edu/wiki/content/cysun/course_materials/cs520/sham/testing).

But when I try and run the UserDaoTest class as TestNG Test, I get a TestNGException: cannot instantiate class springmvc.model.dao.UserDaoTest

Remember to use the same version of spring-test as spring-mvc, which is 3.2.8.RELEASE.

Thank you.  That was the trick.  I had it on the 4.1.4.RELEASE.

lishenyu
Posts: 103
Posted 18:58 Jan 25, 2015 |

when I was doing the testNG test , I have put all the java files and sql scripts in its folders , then I run the testNG  , it gave me an error of  "org.postgresql.util.PSQLException: FATAL: password authentication failed for user "cysun" ,

could you tell me how to create database with name/username/password with gefp/gefp/abcd ?  I am not clear with their relationships between them ,thanks !

lishenyu
Posts: 103
Posted 19:01 Jan 25, 2015 |

and do I need to make some change to springmvc-create.sql ?

cysun
Posts: 2935
Posted 08:20 Jan 26, 2015 |
lishenyu wrote:

when I was doing the testNG test , I have put all the java files and sql scripts in its folders , then I run the testNG  , it gave me an error of  "org.postgresql.util.PSQLException: FATAL: password authentication failed for user "cysun" ,

could you tell me how to create database with name/username/password with gefp/gefp/abcd ?  I am not clear with their relationships between them ,thanks !

Read PostgreSQL documentation on CREATE USER and CREATE DATABASE, or use the GUI client pgAdmin III.

sxiao11
Posts: 13
Posted 21:19 Jan 28, 2015 |

i had the same error "Cannot instantiate class gefp.model.dao.UserDaoTest" and it seem that i also used 4.1.4.RELEASE for spring-test dependency. However, when i tried to build the pom.xml file after i changed spring-test dependency to 3.2.8.RELEASE, it always show error on pom.xml file, Can you please help me with it? Thank you.

cysun
Posts: 2935
Posted 21:43 Jan 28, 2015 |
sxiao11 wrote:

i had the same error "Cannot instantiate class gefp.model.dao.UserDaoTest" and it seem that i also used 4.1.4.RELEASE for spring-test dependency. However, when i tried to build the pom.xml file after i changed spring-test dependency to 3.2.8.RELEASE, it always show error on pom.xml file, Can you please help me with it? Thank you.

Do a Maven -> Update Project ... If it doesn't fix the problem, try the fix for corrupted dependency.

sxiao11
Posts: 13
Posted 22:41 Jan 28, 2015 |
cysun wrote:
sxiao11 wrote:

i had the same error "Cannot instantiate class gefp.model.dao.UserDaoTest" and it seem that i also used 4.1.4.RELEASE for spring-test dependency. However, when i tried to build the pom.xml file after i changed spring-test dependency to 3.2.8.RELEASE, it always show error on pom.xml file, Can you please help me with it? Thank you.

Do a Maven -> Update Project ... If it doesn't fix the problem, try the fix for corrupted dependency.

After i updated the project, there was no more error in the pom.xml but show new errors in the UserDaoTest file as follows:

Can you please help me figure it out? thank you

cysun
Posts: 2935
Posted 08:32 Jan 29, 2015 |

The spring-test dependency probably was corrupted during download. Follow the instructions in the link in my previous post to re-download it.