Laxmi Prasanna Bn

Greenhorn
+ Follow
since Feb 13, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Laxmi Prasanna Bn

Coul you please any one give me an brief explanatiaon about Connectionpool and how it follows the singlton designpattern.

Thanks for advance.
11 years ago
Finally got a solution,

By using
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
(
"classpath:applicationContext.xml"
}

and

<bean id="sessionBean" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces" value="com.td.term.session.sessionBean" />
<property name="target">
<bean class=" com.td.term.controllers.test.MockSessionImpl">
</bean>
</property>
</bean>


Here from MockSessionImpl class i'm added hardocded session.

and from applicationContext.xml by injecting the mock session , issues is fixed.
11 years ago
Thanks for your valuable replays..

I tried by using mockMVC,mockSession by using SPRING 3.2.1,but after code implementaion and started JUNIT RUN,
got the Jar version's mismatch on my project

SO Please provide one small sample example for Spring 3.0.5 MVC, JUNIT 4 Example for passing session from
TestController--->Controller---->Delegate.

In TestController mockSession is created.
I need to use this mock session in controller and Delegate.

Thanks..
11 years ago
Hi Friends,

I'm new to MVC Test

From below code i got the error while Autowiring the "WebApplicationContext" and other autowired fields,
how can we define those beans in äpplciationContext.xml" file ?

@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration

@ContextConfiguration
(
{
"classpath:applicationContext.xml"
}
)
public class ComplianceControllerTest {


@Autowired
WebApplicationContext wac; //Not able to create Object (Couldn't be autowired)
@Autowired
MockHttpSession session; //Not able to create Object (Couldn't be autowired)
@Autowired
MockHttpServletRequest request; //Not able to create Object (Couldn't be autowired)
@Autowired
MockHttpServletResponse response; //Not able to create Object (Couldn't be autowired)
@Autowired
ComplianceDelegate complianceDelegate;

private MockMvc mockMvc;

@Autowired
private TermSessionBean termSessionBean;

@Before
public void setup() {
log.info("webAppContext setup.");
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
}

@Test
public void testComplianceProcess() throws Exception {
System.out.println("Hello..");
log.info("Hello");
termSessionBean.setAccountTypeCd("05");
termSessionBean.getCustomerSessionBean().setCustomerTypeCd("P");
termSessionBean = buildSession();
this.mockMvc.perform(
get("/Compliance").session(
(MockHttpSession) termSessionBean).accept(
MediaType.TEXT_HTML)).andExpect(status().isOk())
.andExpect(view().name("test"));
}


One more question, from the above code i'm going to call Controller, here my question i "I'm define the TermSessionBean in this test class
, it will be avaliable in Controller and is this termssionbean also avaliable in Delegate class?"


Thanks for advance..
11 years ago
Thanks for your's valuable replay..

i'm going to be use MVC test, so here my concern is how it would be the "applciationContext.xml" file.

1) i have numbers of COntrollers and Delegates so , do i need to use this tag in XML file?

<context:component-scan base-package="com.td.term"></context:component-scan>
&&
interface and their impliment classes injection (IName -FullName)

(Correct me if any thing do we must should add some other code)
11 years ago
While doing spring MVC JUNITtest is there any way to pass httpMocksession
from controller to delegate, if possible please give me some sample example? (session is Autowired in Delegate class)
11 years ago
Iname (Interface)
-------
Interface IName{
String getName();
}


FullName
-------
Class FullName implements IName
{
getName(){
String name="hello";
}
}

class ADelegate
--------
Class ADelegate{

@Autowired
IName name;

public Request createRequest(){
FullName.getName(); /* Here how to create the object for FullName class
}

Class TestADelegate
-------------
@Autowired
ADelegate aDelegate;

public void testCreateRequest(){

aDelegate.createRequest();

}

From above code while i'm doing JUNIT test i couldn't able to create the Object for FullName class.
so how do we configure beans.xml file for creating the Object for FullName class (Using JUNIT Test)??

11 years ago
Hi
any one have idea about Spring MVC 3 JUNIT Testing,

I am doing the controller test, while loading the "applciation-context.xml" file getting some autowired exceptions.
as follows.

Throwable occurred: java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:308)
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:321)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:220)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:301)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:303)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ComplianceControllerTest': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.springframework.web.context.WebApplicationContext com.td.term.controllers.test.ComplianceControllerTest.wac; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [org.springframework.web.context.WebApplicationContext] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:84)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:280)
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:304)
... 24 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.springframework.web.context.WebApplicationContext com.td.term.controllers.test.ComplianceControllerTest.wac; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [org.springframework.web.context.WebApplicationContext] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:502)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:282)
... 38 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [org.springframework.web.context.WebApplicationContext] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:920)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:789)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:474)
... 40 more

My TestController
-------------------------------
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(locations = { "/applicationContext.xml" })
public class ComplianceControllerTest {

private static ca.tdbank.util.logging.Logger log = TDLog
.getLogger(ComplianceControllerTest.class);

@Autowired
WebApplicationContext wac;
@Autowired
MockHttpSession session;
@Autowired
MockHttpServletRequest request;

private MockMvc mockMvc;

@Autowired
private TermSessionBean termSessionBean;

@Before
public void setup() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
}

@Test
public void testComplianceProcess() throws Exception {

log.info("Hello");
termSessionBean.setAccountTypeCd("05");
termSessionBean.getCustomerSessionBean().setCustomerTypeCd("P");
// complianceController.complianceProcess(model, request);
this.mockMvc.perform(
get("/complianceController").session(
(MockHttpSession) termSessionBean).accept(
MediaType.TEXT_HTML)).andExpect(status().isOk())
.andExpect(view().name("test"));
System.out.println("Hello..");
}


My applciation-Context.xml
-------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

<bean id="ComplianceControllerTest" class="com.td.term.controllers.test.ComplianceControllerTest" />
<bean id="termSessionBean" class="com.td.term.session.TermSessionBeanImpl" />
</beans>


Note: Please let me if you need any information required about this code for resolving issue.
11 years ago
Thanks Jeanne Boyarsky,

Issue is fixed, Doyou have any idea about Spring MVC 3 JUNIT Testing,

[edited to remove question since asked in separate thread
11 years ago
Hi Friends,

I could not able to import those packages in my class please find teh atatched scrrens for those packahge names.
and also added one more screen for those jar's added on my application .

pleasae help me on this.
11 years ago
Thanks

I had two versions of JUNIT Jar's in my class. i removed and finally reolved.
11 years ago
Hi Friends,

While ruuning the JUNIT test case from RAD-7.5 i got the following error message on console.
here i understood that the problem is in JUNIT jar file, i'm adde the
"JUNIT4_4.3.1" file in my web project, but still getting the following problem please hellp me on this.

Thanks.
java.lang.NoClassDefFoundError: org.junit.runner.notification.RunListener
at java.lang.J9VMInternals.verifyImpl(Native Method)
at java.lang.J9VMInternals.verify(J9VMInternals.java:72)
at java.lang.J9VMInternals.verify(J9VMInternals.java:70)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:134)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:40)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:30)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.ClassNotFoundException: org.junit.runner.notification.RunListener
at java.net.URLClassLoader.findClass(URLClassLoader.java:434)
at java.lang.ClassLoader.loadClass(ClassLoader.java:660)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:358)
at java.lang.ClassLoader.loadClass(ClassLoader.java:626)
... 10 more
11 years ago
Hi Friends,

I am using RAD7 and WebSphere 7.0 combination, while i am started server I am getting this as shown below error message.

"Server WebSphere Application Server v7.0 at local-host was unable to start within 600 seconds. If the server requires more time, try increasing the timeout in the server editor."

Could you please any one let me the problem, why server showing this type of error message.

Thanks
-------
Laxmi
12 years ago
I am also getting the same problem like this

INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre1.5.0_06\bin;.;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.5.0_06/bin/client;C:/Program Files/Java/jre1.5.0_06/bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Toshiba\Bluetooth Toshiba Stack\sys\

But here problem is not in our application, i think problem in Tomcat path configuration.
12 years ago
Thanks for yours clue.
12 years ago