tag:blogger.com,1999:blog-89036201236306254882024-03-22T00:32:28.654-07:00Automation HomeOne stop solution for all automation problems/issuesPraveen Kumarhttp://www.blogger.com/profile/14705482110609285232noreply@blogger.comBlogger163125tag:blogger.com,1999:blog-8903620123630625488.post-10080074139340522012022-07-02T05:21:00.002-07:002024-03-14T16:00:07.017-07:00Spring Part 09 - @Bean<h3 style="text-align: left;"> Spring - @Bean</h3><p class="MsoNormal" style="background-color: #2b2b2b; font-family: Calibri, sans-serif; margin: 0cm;"><span style="color: #cc7832; font-family: "Courier New"; font-size: 15pt;">package </span><span style="color: #a9b7c6; font-family: "Courier New"; font-size: 15pt;">com.ah.di</span><span style="color: #cc7832; font-family: "Courier New"; font-size: 15pt;">;<br /><br />import </span><span style="color: #a9b7c6; font-family: "Courier New"; font-size: 15pt;">org.springframework.context.annotation.</span><span style="color: #bbb529; font-family: "Courier New"; font-size: 15pt;">Bean</span><span style="color: #cc7832; font-family: "Courier New"; font-size: 15pt;">;<br />import </span><span style="color: #a9b7c6; font-family: "Courier New"; font-size: 15pt;">org.springframework.context.annotation.</span><span style="color: #bbb529; font-family: "Courier New"; font-size: 15pt;">ComponentScan</span><span style="color: #cc7832; font-family: "Courier New"; font-size: 15pt;">;<br />import </span><span style="color: #a9b7c6; font-family: "Courier New"; font-size: 15pt;">org.springframework.context.annotation.</span><span style="color: #bbb529; font-family: "Courier New"; font-size: 15pt;">Configuration</span><span style="color: #cc7832; font-family: "Courier New"; font-size: 15pt;">;<br /><br /></span><span style="color: #bbb529; font-family: "Courier New"; font-size: 15pt;">@Configuration<br />@ComponentScan<br /></span><span style="color: #cc7832; font-family: "Courier New"; font-size: 15pt;">public class </span><span style="color: #a9b7c6; font-family: "Courier New"; font-size: 15pt;">AppConf {<br /><br /> </span><span style="color: #bbb529; font-family: "Courier New"; font-size: 15pt;">@Bean</span><span style="color: #a9b7c6; font-family: "Courier New"; font-size: 15pt;">(</span><span style="color: #6a8759; font-family: "Courier New"; font-size: 15pt;">"car"</span><span style="color: #a9b7c6; font-family: "Courier New"; font-size: 15pt;">)<br /> </span><span style="color: #cc7832; font-family: "Courier New"; font-size: 15pt;">public </span><span style="color: #a9b7c6; font-family: "Courier New"; font-size: 15pt;">Car </span><span style="color: #ffc66d; font-family: "Courier New"; font-size: 15pt;">carBean</span><span style="color: #a9b7c6; font-family: "Courier New"; font-size: 15pt;">(){<br /> Car car = </span><span style="color: #cc7832; font-family: "Courier New"; font-size: 15pt;">new </span><span style="color: #a9b7c6; font-family: "Courier New"; font-size: 15pt;">Car()</span><span style="color: #cc7832; font-family: "Courier New"; font-size: 15pt;">;<br /> return </span><span style="color: #a9b7c6; font-family: "Courier New"; font-size: 15pt;">car</span><span style="color: #cc7832; font-family: "Courier New"; font-size: 15pt;">;<br /> </span><span style="color: #a9b7c6; font-family: "Courier New"; font-size: 15pt;">}<br />}</span></p><p><br /></p><pre style="background-color: #2b2b2b; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #cc7832; font-size: 15pt;">package </span><span style="color: #a9b7c6; font-size: 15pt;">com.ah.di</span><span style="color: #cc7832; font-size: 15pt;">;<br />
import </span><span style="color: #a9b7c6; font-size: 15pt;">org.springframework.beans.factory.annotation.</span><span style="color: #bbb529; font-size: 15pt;">Autowired</span><span style="color: #cc7832; font-size: 15pt;">;<br />
public class </span><span style="color: #a9b7c6; font-size: 15pt;">Car {<br />
</span><span style="color: #bbb529; font-size: 15pt;">@Autowired
</span><span style="color: #cc7832; font-size: 15pt;">private </span><span style="color: #a9b7c6; font-size: 15pt;">Engine </span><span style="color: #9876aa; font-size: 15pt;">engine</span><span style="color: #cc7832; font-size: 15pt;">;<br />
public void </span><span style="color: #ffc66d; font-size: 15pt;">displayCarInfo</span><span style="color: #a9b7c6; font-size: 15pt;">(){
System.</span><i><span style="color: #9876aa; font-size: 15pt;">out</span></i><span style="color: #a9b7c6; font-size: 15pt;">.println(</span><span style="color: #6a8759; font-size: 15pt;">"car class display method</span><span style="color: #cc7832; font-size: 15pt;">\n</span><span style="color: #6a8759; font-size: 15pt;">"</span><span style="color: #a9b7c6; font-size: 15pt;">)</span><span style="color: #cc7832; font-size: 15pt;">;<br />
if</span><span style="color: #a9b7c6; font-size: 15pt;">(</span><span style="color: #9876aa; font-size: 15pt;">engine</span><span style="color: #a9b7c6; font-size: 15pt;">==</span><span style="color: #cc7832; font-size: 15pt;">null</span><span style="color: #a9b7c6; font-size: 15pt;">){
System.</span><i><span style="color: #9876aa; font-size: 15pt;">out</span></i><span style="color: #a9b7c6; font-size: 15pt;">.println(</span><span style="color: #6a8759; font-size: 15pt;">"No engine object"</span><span style="color: #a9b7c6; font-size: 15pt;">)</span><span style="color: #cc7832; font-size: 15pt;">;
</span><span style="color: #a9b7c6; font-size: 15pt;">}</span><span style="color: #cc7832; font-size: 15pt;">else</span><span style="color: #a9b7c6; font-size: 15pt;">{
</span><span style="color: #9876aa; font-size: 15pt;">engine</span><span style="color: #a9b7c6; font-size: 15pt;">.testEngine()</span><span style="color: #cc7832; font-size: 15pt;">;
</span><span style="color: #a9b7c6; font-size: 15pt;">}
}<br />
}<o:p></o:p></span></pre><p><br /></p><pre style="background-color: #2b2b2b; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #cc7832; font-size: 15pt;">package </span><span style="color: #a9b7c6; font-size: 15pt;">com.ah.di</span><span style="color: #cc7832; font-size: 15pt;">;<br />
import </span><span style="color: #a9b7c6; font-size: 15pt;">org.springframework.stereotype.</span><span style="color: #bbb529; font-size: 15pt;">Component</span><span style="color: #cc7832; font-size: 15pt;">;<br />
</span><span style="color: #bbb529; font-size: 15pt;">@Component
</span><span style="color: #cc7832; font-size: 15pt;">public class </span><span style="color: #a9b7c6; font-size: 15pt;">Engine {<br />
</span><span style="color: #cc7832; font-size: 15pt;">public void </span><span style="color: #ffc66d; font-size: 15pt;">testEngine</span><span style="color: #a9b7c6; font-size: 15pt;">(){
System.</span><i><span style="color: #9876aa; font-size: 15pt;">out</span></i><span style="color: #a9b7c6; font-size: 15pt;">.println(</span><span style="color: #6a8759; font-size: 15pt;">"testEngine() method of </span></pre><pre style="background-color: #2b2b2b; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #6a8759; font-size: 15pt;">Engine class"</span><span style="color: #a9b7c6; font-size: 15pt;">)</span><span style="color: #cc7832; font-size: 15pt;">
</span><span style="color: #a9b7c6; font-size: 15pt;">}
}<o:p></o:p></span></pre><p><br /></p><pre style="background-color: #2b2b2b; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #cc7832; font-size: 15pt;">package </span><span style="color: #a9b7c6; font-size: 15pt;">com.ah.di</span><span style="color: #cc7832; font-size: 15pt;">;<br />
import </span><span style="color: #a9b7c6; font-size: 15pt;">org.springframework.context.ApplicationContext</span><span style="color: #cc7832; font-size: 15pt;">;
import </span><span style="color: #a9b7c6; font-size: 15pt;">org.springframework.context.annotation.AnnotationConfigApplicationContext</span><span style="color: #cc7832; font-size: 15pt;">;<br />
public class </span><span style="color: #a9b7c6; font-size: 15pt;">Test {<br />
</span><span style="color: #cc7832; font-size: 15pt;">public static void </span><span style="color: #ffc66d; font-size: 15pt;">main</span><span style="color: #a9b7c6; font-size: 15pt;">(String[] args) {
ApplicationContext context =
</span><span style="color: #cc7832; font-size: 15pt;">new </span><span style="color: #a9b7c6; font-size: 15pt;">AnnotationConfigApplicationContext</span></pre><pre style="background-color: #2b2b2b; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #a9b7c6; font-size: 15pt;">(AppConf.</span><span style="color: #cc7832; font-size: 15pt;">class</span><span style="color: #a9b7c6; font-size: 15pt;">)</span><span style="color: #cc7832; font-size: 15pt;">;<br />
var </span><span style="color: #a9b7c6; font-size: 15pt;">carObj = context.getBean(</span><span style="color: #6a8759; font-size: 15pt;">"car"</span><span style="color: #cc7832; font-size: 15pt;">,</span><span style="color: #a9b7c6; font-size: 15pt;">Car.</span><span style="color: #cc7832; font-size: 15pt;">class</span><span style="color: #a9b7c6; font-size: 15pt;">)</span><span style="color: #cc7832; font-size: 15pt;">;
</span><span style="color: #a9b7c6; font-size: 15pt;">carObj.displayCarInfo()</span><span style="color: #cc7832; font-size: 15pt;">;<br />
</span><span style="color: grey; font-size: 15pt;">//displyAppContextBeanInfo(context);
</span><span style="color: #a9b7c6; font-size: 15pt;">}<br />
</span><span style="color: #cc7832; font-size: 15pt;">public static void </span><span style="color: #ffc66d; font-size: 15pt;">displyAppContextBeanInfo</span><span style="color: #a9b7c6; font-size: 15pt;">(ApplicationContext context ){
</span><span style="color: #cc7832; font-size: 15pt;">for</span><span style="color: #a9b7c6; font-size: 15pt;">(String bean : </span></pre><pre style="background-color: #2b2b2b; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #a9b7c6; font-size: 15pt;">context.getBeanDefinitionNames()){
System.</span><i><span style="color: #9876aa; font-size: 15pt;">out</span></i><span style="color: #a9b7c6; font-size: 15pt;">.println(bean)</span><span style="color: #cc7832; font-size: 15pt;">;
</span><span style="color: #a9b7c6; font-size: 15pt;">}
}</span></pre><pre style="background-color: #2b2b2b; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #a9b7c6; font-size: 15pt;">
}<o:p></o:p></span></pre><p> Watch Demo</p><p></p><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/h8Y5tJpMSa0" width="320" youtube-src-id="h8Y5tJpMSa0"></iframe></div><br /><p></p>Praveen Kumarhttp://www.blogger.com/profile/14705482110609285232noreply@blogger.com0tag:blogger.com,1999:blog-8903620123630625488.post-19595671733982023882022-07-01T11:47:00.001-07:002022-07-01T11:59:44.545-07:00Spring Part 08 - @ComponentScan & @Configuration<h2 style="text-align: left;"> Spring - @ComponentScan & @Configuration</h2><p>In this Part of Spring Framework we will avoid using Spring configuration xml file, instead we will maintain configuration at java side by using the '@Configuration' annotation.</p><p class="MsoNormal" style="background-color: #2b2b2b; font-family: Calibri, sans-serif; margin: 0cm;"><span style="color: #cc7832; font-family: "Courier New"; font-size: 15pt;">package </span><span style="color: #a9b7c6; font-family: "Courier New"; font-size: 15pt;">com.ah.di.samp</span><span style="color: #cc7832; font-family: "Courier New"; font-size: 15pt;">;<br /><br />import </span><span style="color: #a9b7c6; font-family: "Courier New"; font-size: 15pt;">org.springframework.context.annotation.</span><span style="color: #bbb529; font-family: "Courier New"; font-size: 15pt;">ComponentScan</span><span style="color: #cc7832; font-family: "Courier New"; font-size: 15pt;">;<br />import </span><span style="color: #a9b7c6; font-family: "Courier New"; font-size: 15pt;">org.springframework.context.annotation.</span><span style="color: #bbb529; font-family: "Courier New"; font-size: 15pt;">Configuration</span><span style="color: #cc7832; font-family: "Courier New"; font-size: 15pt;">;<br /><br /></span><span style="color: #bbb529; font-family: "Courier New"; font-size: 15pt;">@Configuration<br />@ComponentScan</span><span style="color: #a9b7c6; font-family: "Courier New"; font-size: 15pt;">(basePackages = </span><span style="color: #6a8759; font-family: "Courier New"; font-size: 15pt;">"com.ah.di"</span><span style="color: #a9b7c6; font-family: "Courier New"; font-size: 15pt;">)<br /></span><span style="color: #cc7832; font-family: "Courier New"; font-size: 15pt;">public class </span><span style="color: #a9b7c6; font-family: "Courier New"; font-size: 15pt;">AppConf {<br />}<o:p></o:p></span></p><p><br /></p><pre style="background-color: #2b2b2b; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #cc7832; font-size: 15pt;">package </span><span style="color: #a9b7c6; font-size: 15pt;">com.ah.di</span><span style="color: #cc7832; font-size: 15pt;">;<br />
import </span><span style="color: #a9b7c6; font-size: 15pt;">org.springframework.stereotype.</span><span style="color: #bbb529; font-size: 15pt;">Component</span><span style="color: #cc7832; font-size: 15pt;">;<br />
</span><span style="color: #bbb529; font-size: 15pt;">@Component
</span><span style="color: #cc7832; font-size: 15pt;">public class </span><span style="color: #a9b7c6; font-size: 15pt;">Car {<br />
</span><span style="color: #cc7832; font-size: 15pt;">public void </span><span style="color: #ffc66d; font-size: 15pt;">displayCarInfo</span><span style="color: #a9b7c6; font-size: 15pt;">(){
System.</span><i><span style="color: #9876aa; font-size: 15pt;">out</span></i><span style="color: #a9b7c6; font-size: 15pt;">.println(</span><span style="color: #6a8759; font-size: 15pt;">"car class display method"</span><span style="color: #a9b7c6; font-size: 15pt;">)</span><span style="color: #cc7832; font-size: 15pt;">;
</span><span style="color: #a9b7c6; font-size: 15pt;">}
}</span></pre><p><br /></p><pre style="background-color: #2b2b2b; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #cc7832; font-size: 15pt;">package </span><span style="color: #a9b7c6; font-size: 15pt;">com.ah.di</span><span style="color: #cc7832; font-size: 15pt;">;<br />
import </span><span style="color: #a9b7c6; font-size: 15pt;">com.ah.di.samp.AppConf</span><span style="color: #cc7832; font-size: 15pt;">;
import </span><span style="color: #a9b7c6; font-size: 15pt;">org.springframework.context.ApplicationContext</span><span style="color: #cc7832; font-size: 15pt;">;
import </span><span style="color: #a9b7c6; font-size: 15pt;">org.springframework.context.annotation.</span></pre><pre style="background-color: #2b2b2b; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #a9b7c6; font-size: 15pt;">AnnotationConfigApplicationContext</span><span style="color: #cc7832; font-size: 15pt;">;<br />
public class </span><span style="color: #a9b7c6; font-size: 15pt;">Test {<br />
</span><span style="color: #cc7832; font-size: 15pt;">public static void </span><span style="color: #ffc66d; font-size: 15pt;">main</span><span style="color: #a9b7c6; font-size: 15pt;">(String[] args) {<br />
ApplicationContext context =<br />
</span><span style="color: #cc7832; font-size: 15pt;">new </span><span style="color: #a9b7c6; font-size: 15pt;">AnnotationConfigApplicationContext</span></pre><pre style="background-color: #2b2b2b; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #a9b7c6; font-size: 15pt;">(AppConf.</span><span style="color: #cc7832; font-size: 15pt;">class</span><span style="color: #a9b7c6; font-size: 15pt;">)</span><span style="color: #cc7832; font-size: 15pt;">;<br />
var </span><span style="color: #a9b7c6; font-size: 15pt;">carObj = context.getBean(</span><span style="color: #6a8759; font-size: 15pt;">"car"</span><span style="color: #cc7832; font-size: 15pt;">,</span><span style="color: #a9b7c6; font-size: 15pt;">Car.</span><span style="color: #cc7832; font-size: 15pt;">class</span><span style="color: #a9b7c6; font-size: 15pt;">)</span><span style="color: #cc7832; font-size: 15pt;">;
</span><span style="color: #a9b7c6; font-size: 15pt;">carObj.displayCarInfo()</span><span style="color: #cc7832; font-size: 15pt;">;<br />
</span><span style="color: grey; font-size: 15pt;">//displyAppContextBeanInfo(context);<br />
</span><span style="color: #a9b7c6; font-size: 15pt;">}
</span><span style="color: #cc7832; font-size: 15pt;">public static void </span><span style="color: #ffc66d; font-size: 15pt;">displyAppContextBeanInfo</span></pre><pre style="background-color: #2b2b2b; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #a9b7c6; font-size: 15pt;">(ApplicationContext context ){<br />
</span><span style="color: #cc7832; font-size: 15pt;">for</span><span style="color: #a9b7c6; font-size: 15pt;">(String bean : context.</span></pre><pre style="background-color: #2b2b2b; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #a9b7c6; font-size: 15pt;">getBeanDefinitionNames()){<br />
System.</span><i><span style="color: #9876aa; font-size: 15pt;">out</span></i><span style="color: #a9b7c6; font-size: 15pt;">.println(bean)</span><span style="color: #cc7832; font-size: 15pt;">;<br />
</span><span style="color: #a9b7c6; font-size: 15pt;">}
}
}<o:p></o:p></span></pre><p><br /></p><p> Watch Demo</p><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/gWRG2akSHZs" width="320" youtube-src-id="gWRG2akSHZs"></iframe></div><br /><p><br /></p>Praveen Kumarhttp://www.blogger.com/profile/14705482110609285232noreply@blogger.com0tag:blogger.com,1999:blog-8903620123630625488.post-71392477563197993422022-06-30T12:35:00.001-07:002022-06-30T13:20:14.514-07:00Spring Part 07 - @Component<h2 style="text-align: left;"> Spring - @Component</h2><div><span><div><b>Maven Dependency:</b></div><div><span face="Arial, Tahoma, Helvetica, FreeSans, sans-serif"><p style="caret-color: rgb(34, 34, 34); color: #222222; font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"><dependency></p><p style="caret-color: rgb(34, 34, 34); color: #222222; font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"> <groupId>org.springframework</groupId></p><p style="caret-color: rgb(34, 34, 34); color: #222222; font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"> <artifactId>spring-context</artifactId></p><p style="caret-color: rgb(34, 34, 34); color: #222222; font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"> <version>5.3.16</version></p><p style="caret-color: rgb(34, 34, 34); color: #222222; font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"></dependency></p><p style="caret-color: rgb(34, 34, 34); color: #222222; font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"><br /></p><div style="caret-color: rgb(34, 34, 34); color: #222222;"><h3 style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; margin: 0px; position: relative;"><span style="font-size: medium;">Sample Program for @Component <span style="background-color: white;">using</span> 'Spring Framework'</span> </h3></div><div style="caret-color: rgb(34, 34, 34); color: #222222;"><span style="caret-color: rgb(0, 0, 0); color: black;">beans_di.xml</span></div><div style="caret-color: rgb(34, 34, 34); color: #222222;"><span style="caret-color: rgb(0, 0, 0); color: black;"><p class="MsoNormal" style="background-color: #2b2b2b; font-family: Calibri, sans-serif; margin: 0cm;"><span style="color: #e8bf6a; font-family: "Courier New"; font-size: 15pt;"><?</span><span style="color: #bababa; font-family: "Courier New"; font-size: 15pt;">xml version</span><span style="color: #6a8759; font-family: "Courier New"; font-size: 15pt;">="1.0" </span><span style="color: #bababa; font-family: "Courier New"; font-size: 15pt;">encoding</span><span style="color: #6a8759; font-family: "Courier New"; font-size: 15pt;">="UTF-8"</span><span style="color: #e8bf6a; font-family: "Courier New"; font-size: 15pt;">?><br /><beans </span><span style="color: #bababa; font-family: "Courier New"; font-size: 15pt;">xmlns</span><span style="color: #6a8759; font-family: "Courier New"; font-size: 15pt;">="http://www.springframework.org/schema/beans"<br /> </span><span style="color: #bababa; font-family: "Courier New"; font-size: 15pt;">xmlns:</span><span style="color: #9876aa; font-family: "Courier New"; font-size: 15pt;">xsi</span><span style="color: #6a8759; font-family: "Courier New"; font-size: 15pt;">="http://www.w3.org/2001/XMLSchema-instance"<br /> </span><span style="color: #bababa; font-family: "Courier New"; font-size: 15pt;">xmlns:</span><span style="color: #9876aa; font-family: "Courier New"; font-size: 15pt;">context</span><span style="color: #6a8759; font-family: "Courier New"; font-size: 15pt;">="http://www.springframework.org/schema/context"<br /> </span><span style="color: #9876aa; font-family: "Courier New"; font-size: 15pt;">xsi</span><span style="color: #bababa; font-family: "Courier New"; font-size: 15pt;">:schemaLocation</span><span style="color: #6a8759; font-family: "Courier New"; font-size: 15pt;">="http://www.springframework.org/schema/beans<br /> https://www.springframework.org/schema/beans/spring-beans.xsd<br /> http://www.springframework.org/schema/context<br /> https://www.springframework.org/schema/context/spring-context.xsd"</span><span style="color: #e8bf6a; font-family: "Courier New"; font-size: 15pt;">><br /><br /><b><</b></span><b><span style="color: #9876aa; font-family: "Courier New"; font-size: 15pt;">context</span></b><b><span style="color: #e8bf6a; font-family: "Courier New"; font-size: 15pt;">:component-scan </span></b><b><span style="color: #bababa; font-family: "Courier New"; font-size: 15pt;">base-package</span></b><b><span style="color: #6a8759; font-family: "Courier New"; font-size: 15pt;">="com.ah.di"</span></b><b><span style="color: #e8bf6a; font-family: "Courier New"; font-size: 15pt;">/><br /></span></b><span style="color: #e8bf6a; font-family: "Courier New"; font-size: 15pt;"><br /></beans></span><span style="color: #a9b7c6; font-family: "Courier New"; font-size: 15pt;"><o:p></o:p></span></p></span></div><div style="caret-color: rgb(34, 34, 34); color: #222222;"><span style="caret-color: rgb(0, 0, 0); color: black;"><br /></span></div><div style="caret-color: rgb(34, 34, 34); color: #222222;"><span style="caret-color: rgb(0, 0, 0); color: black;"><br /></span></div><div style="caret-color: rgb(34, 34, 34); color: #222222;"><span style="caret-color: rgb(0, 0, 0); color: black;"><pre style="background-color: #2b2b2b; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #e8bf6a; font-size: 15pt;"><</span><span style="color: #9876aa; font-size: 15pt;">context</span><span style="color: #e8bf6a; font-size: 15pt;">:component-scan </span><span style="color: #bababa; font-size: 15pt;">base-package</span><span style="color: #6a8759; font-size: 15pt;">="com.ah.di"</span><span style="color: #e8bf6a; font-size: 15pt;">/><o:p></o:p></span></pre></span></div><div style="caret-color: rgb(34, 34, 34); color: #222222;"><span style="caret-color: rgb(0, 0, 0); color: black;"><br /></span></div><div style="caret-color: rgb(34, 34, 34); color: #222222;"><span style="caret-color: rgb(0, 0, 0); color: black;"><br /></span></div><div style="caret-color: rgb(34, 34, 34); color: #222222;"><span style="caret-color: rgb(0, 0, 0); color: black;"><pre style="background-color: #2b2b2b; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #cc7832; font-size: 15pt;">package </span><span style="color: #a9b7c6; font-size: 15pt;">com.ah.di</span><span style="color: #cc7832; font-size: 15pt;">;<br />
<br />
import </span><span style="color: #a9b7c6; font-size: 15pt;">org.springframework.context.ApplicationContext</span><span style="color: #cc7832; font-size: 15pt;">;<br />
import </span><span style="color: #a9b7c6; font-size: 15pt;">org.springframework.context.support.</span></pre><pre style="background-color: #2b2b2b; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #a9b7c6; font-size: 15pt;">ClassPathXmlApplicationContext</span><span style="color: #cc7832; font-size: 15pt;">;<br />
<br />
public class </span><span style="color: #a9b7c6; font-size: 15pt;">Test {<br />
</span><span style="color: #cc7832; font-size: 15pt;">public static void </span><span style="color: #ffc66d; font-size: 15pt;">main</span><span style="color: #a9b7c6; font-size: 15pt;">(String[] args) {<br />
ApplicationContext context =<br />
</span><span style="color: #cc7832; font-size: 15pt;">new </span><span style="color: #a9b7c6; font-size: 15pt;">ClassPathXmlApplicationContext(</span><span style="color: #6a8759; font-size: 15pt;">"beans_di.xml"</span><span style="color: #a9b7c6; font-size: 15pt;">)</span><span style="color: #cc7832; font-size: 15pt;">;<br />
</span><span style="color: grey; font-size: 15pt;">/*for(String bean : </span></pre><pre style="background-color: #2b2b2b; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: grey; font-size: 15pt;">context.getBeanDefinitionNames()){<br />
System.out.println(bean);<br />
}*/
</span><span style="color: #cc7832; font-size: 15pt;">var </span><span style="color: #a9b7c6; font-size: 15pt;">carObj = context.getBean(</span><span style="color: #6a8759; font-size: 15pt;">"car"</span><span style="color: #cc7832; font-size: 15pt;">,</span><span style="color: #a9b7c6; font-size: 15pt;">Car.</span><span style="color: #cc7832; font-size: 15pt;">class</span><span style="color: #a9b7c6; font-size: 15pt;">)</span><span style="color: #cc7832; font-size: 15pt;">;
</span><span style="color: #a9b7c6; font-size: 15pt;">carObj.displayCarInfo()</span><span style="color: #cc7832; font-size: 15pt;">;
</span><span style="color: #a9b7c6; font-size: 15pt;">}
}<o:p></o:p></span></pre></span></div><div style="caret-color: rgb(34, 34, 34); color: #222222;"><span style="caret-color: rgb(0, 0, 0); color: black;"><br /></span></div><div style="caret-color: rgb(34, 34, 34); color: #222222;"><span style="caret-color: rgb(0, 0, 0); color: black;"><pre style="background-color: #2b2b2b; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #cc7832; font-size: 15pt;">package </span><span style="color: #a9b7c6; font-size: 15pt;">com.ah.di</span><span style="color: #cc7832; font-size: 15pt;">;<br />
import </span><span style="color: #a9b7c6; font-size: 15pt;">org.springframework.stereotype.</span><span style="color: #bbb529; font-size: 15pt;">Component</span><span style="color: #cc7832; font-size: 15pt;">;<br />
</span><span style="color: #bbb529; font-size: 15pt;">@Component
</span><span style="color: #cc7832; font-size: 15pt;">public class </span><span style="color: #a9b7c6; font-size: 15pt;">Car {<br />
</span><span style="color: #cc7832; font-size: 15pt;">public void </span><span style="color: #ffc66d; font-size: 15pt;">displayCarInfo</span><span style="color: #a9b7c6; font-size: 15pt;">(){
System.</span><i><span style="color: #9876aa; font-size: 15pt;">out</span></i><span style="color: #a9b7c6; font-size: 15pt;">.println(</span><span style="color: #6a8759; font-size: 15pt;">"car class display method</span></pre><pre style="background-color: #2b2b2b; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #6a8759; font-size: 15pt;">"</span><span style="color: #a9b7c6; font-size: 15pt;">)</span><span style="color: #cc7832; font-size: 15pt;">;
</span><span style="color: #a9b7c6; font-size: 15pt;">}
}<o:p></o:p></span></pre></span></div><div style="caret-color: rgb(34, 34, 34); color: #222222;"><span style="caret-color: rgb(0, 0, 0); color: black;"><br /></span></div><div style="caret-color: rgb(34, 34, 34); color: #222222;"><span style="caret-color: rgb(0, 0, 0); color: black;"><pre style="background-color: #2b2b2b; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #cc7832; font-size: 15pt;">package </span><span style="color: #a9b7c6; font-size: 15pt;">com.ah.di</span><span style="color: #cc7832; font-size: 15pt;">;<br />
import </span><span style="color: #a9b7c6; font-size: 15pt;">org.springframework.stereotype.</span><span style="color: #bbb529; font-size: 15pt;">Component</span><span style="color: #cc7832; font-size: 15pt;">;<br />
</span><span style="color: #bbb529; font-size: 15pt;">@Component
</span><span style="color: #cc7832; font-size: 15pt;">public class </span><span style="color: #a9b7c6; font-size: 15pt;">Engine {<br />
</span><span style="color: #cc7832; font-size: 15pt;">public void </span><span style="color: #ffc66d; font-size: 15pt;">testEngine</span><span style="color: #a9b7c6; font-size: 15pt;">(){
System.</span><i><span style="color: #9876aa; font-size: 15pt;">out</span></i><span style="color: #a9b7c6; font-size: 15pt;">.println(</span><span style="color: #6a8759; font-size: 15pt;">"Engine is working"</span><span style="color: #a9b7c6; font-size: 15pt;">)</span><span style="color: #cc7832; font-size: 15pt;">;
</span><span style="color: #a9b7c6; font-size: 15pt;">}
}<o:p></o:p></span></pre></span></div><div style="caret-color: rgb(34, 34, 34); color: #222222;"><span style="caret-color: rgb(0, 0, 0); color: black;"><br /></span></div><div style="caret-color: rgb(34, 34, 34); color: #222222;"><br /></div><div> Watch Demo</div><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/QaTHXBvjymc" width="320" youtube-src-id="QaTHXBvjymc"></iframe></div><br /><div><br /></div></span></div></span></div>Praveen Kumarhttp://www.blogger.com/profile/14705482110609285232noreply@blogger.com0tag:blogger.com,1999:blog-8903620123630625488.post-62034090605372961582022-06-29T04:26:00.000-07:002022-06-29T04:26:04.573-07:00Spring Part 06 - @Qualifier<h4 style="text-align: left;"> Spring - Qualifier</h4><div><span><div><b>Maven Dependency:</b></div><div><span face="Arial, Tahoma, Helvetica, FreeSans, sans-serif"><p style="caret-color: rgb(34, 34, 34); color: #222222; font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"><dependency></p><p style="caret-color: rgb(34, 34, 34); color: #222222; font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"> <groupId>org.springframework</groupId></p><p style="caret-color: rgb(34, 34, 34); color: #222222; font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"> <artifactId>spring-context</artifactId></p><p style="caret-color: rgb(34, 34, 34); color: #222222; font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"> <version>5.3.16</version></p><p style="caret-color: rgb(34, 34, 34); color: #222222; font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"></dependency></p><div style="caret-color: rgb(34, 34, 34); color: #222222;"><br /></div><div style="caret-color: rgb(34, 34, 34); color: #222222;"><h3 style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; margin: 0px; position: relative;"><span style="font-size: medium;">Sample Program for @Qualifier <span style="background-color: white;">using</span> 'Spring Framework'</span> </h3></div><div style="caret-color: rgb(34, 34, 34); color: #222222;"><span style="caret-color: rgb(0, 0, 0); color: black;">beans_di.xml</span></div><div style="caret-color: rgb(34, 34, 34); color: #222222;"><p class="MsoNormal" style="background-color: #2b2b2b; caret-color: rgb(0, 0, 0); color: black; font-family: Calibri, sans-serif; margin: 0cm;"><span style="color: #e8bf6a; font-family: "Courier New"; font-size: 13.5pt;"><?</span><span style="color: #bababa; font-family: "Courier New"; font-size: 13.5pt;">xml version</span><span style="color: #6a8759; font-family: "Courier New"; font-size: 13.5pt;">="1.0" </span><span style="color: #bababa; font-family: "Courier New"; font-size: 13.5pt;">encoding</span><span style="color: #6a8759; font-family: "Courier New"; font-size: 13.5pt;">="UTF-8"</span><span style="color: #e8bf6a; font-family: "Courier New"; font-size: 13.5pt;">?><br /><beans </span><span style="color: #bababa; font-family: "Courier New"; font-size: 13.5pt;">xmlns</span><span style="color: #6a8759; font-family: "Courier New"; font-size: 13.5pt;">="http://www.springframework.org/schema/beans"<br /> </span><span style="color: #bababa; font-family: "Courier New"; font-size: 13.5pt;">xmlns:</span><span style="color: #9876aa; font-family: "Courier New"; font-size: 13.5pt;">xsi</span><span style="color: #6a8759; font-family: "Courier New"; font-size: 13.5pt;">="http://www.w3.org/2001/XMLSchema-instance"<br /> </span><span style="color: #bababa; font-family: "Courier New"; font-size: 13.5pt;">xmlns:</span><span style="color: #9876aa; font-family: "Courier New"; font-size: 13.5pt;">context</span><span style="color: #6a8759; font-family: "Courier New"; font-size: 13.5pt;">="http://www.springframework.org/schema/context"<br /> </span><span style="color: #9876aa; font-family: "Courier New"; font-size: 13.5pt;">xsi</span><span style="color: #bababa; font-family: "Courier New"; font-size: 13.5pt;">:schemaLocation</span><span style="color: #6a8759; font-family: "Courier New"; font-size: 13.5pt;">="http://www.springframework.org/schema/beans<br /> https://www.springframework.org/schema/beans/spring-beans.xsd<br /> http://www.springframework.org/schema/context<br /> https://www.springframework.org/schema/context/spring-context.xsd"</span><span style="color: #e8bf6a; font-family: "Courier New"; font-size: 13.5pt;">><br /><br /> <</span><span style="color: #9876aa; font-family: "Courier New"; font-size: 13.5pt;">context</span><span style="color: #e8bf6a; font-family: "Courier New"; font-size: 13.5pt;">:annotation-config/><br /><br /> <bean </span><span style="color: #bababa; font-family: "Courier New"; font-size: 13.5pt;">id</span><span style="color: #6a8759; font-family: "Courier New"; font-size: 13.5pt;">="engineModel1" </span><span style="color: #bababa; font-family: "Courier New"; font-size: 13.5pt;">class</span><span style="color: #6a8759; font-family: "Courier New"; font-size: 13.5pt;">="com.ah.di.Engine"</span><span style="color: #e8bf6a; font-family: "Courier New"; font-size: 13.5pt;">><br /> <property </span><span style="color: #bababa; font-family: "Courier New"; font-size: 13.5pt;">name</span><span style="color: #6a8759; font-family: "Courier New"; font-size: 13.5pt;">="engineModel" </span><span style="color: #bababa; font-family: "Courier New"; font-size: 13.5pt;">value</span><span style="color: #6a8759; font-family: "Courier New"; font-size: 13.5pt;">="Model-1"</span><span style="color: #e8bf6a; font-family: "Courier New"; font-size: 13.5pt;">/><br /> </bean><br /><br /> <bean </span><span style="color: #bababa; font-family: "Courier New"; font-size: 13.5pt;">id</span><span style="color: #6a8759; font-family: "Courier New"; font-size: 13.5pt;">="engineModel2" </span><span style="color: #bababa; font-family: "Courier New"; font-size: 13.5pt;">class</span><span style="color: #6a8759; font-family: "Courier New"; font-size: 13.5pt;">="com.ah.di.Engine"</span><span style="color: #e8bf6a; font-family: "Courier New"; font-size: 13.5pt;">><br /> <property </span><span style="color: #bababa; font-family: "Courier New"; font-size: 13.5pt;">name</span><span style="color: #6a8759; font-family: "Courier New"; font-size: 13.5pt;">="engineModel" </span><span style="color: #bababa; font-family: "Courier New"; font-size: 13.5pt;">value</span><span style="color: #6a8759; font-family: "Courier New"; font-size: 13.5pt;">="Model-2"</span><span style="color: #e8bf6a; font-family: "Courier New"; font-size: 13.5pt;">/><br /> </bean><br /><br /> <bean </span><span style="color: #bababa; font-family: "Courier New"; font-size: 13.5pt;">id</span><span style="color: #6a8759; font-family: "Courier New"; font-size: 13.5pt;">="car" </span><span style="color: #bababa; font-family: "Courier New"; font-size: 13.5pt;">class</span><span style="color: #6a8759; font-family: "Courier New"; font-size: 13.5pt;">="com.ah.di.Car" </span><span style="color: #e8bf6a; font-family: "Courier New"; font-size: 13.5pt;">/><br /><br /></beans></span><span style="color: #a9b7c6; font-family: "Courier New"; font-size: 13.5pt;"><o:p></o:p></span></p></div><div style="caret-color: rgb(34, 34, 34); color: #222222;"><span style="caret-color: rgb(0, 0, 0); color: black;"><br /></span></div><div style="caret-color: rgb(34, 34, 34); color: #222222;"><span style="caret-color: rgb(0, 0, 0); color: black;"><br /></span></div><div style="caret-color: rgb(34, 34, 34); color: #222222;"><pre style="background-color: #2b2b2b; caret-color: rgb(0, 0, 0); color: black; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #cc7832; font-size: 13.5pt;">package </span><span style="color: #a9b7c6; font-size: 13.5pt;">com.ah.di</span><span style="color: #cc7832; font-size: 13.5pt;">;<br />
import </span><span style="color: #a9b7c6; font-size: 13.5pt;">org.springframework.context.ApplicationContext</span><span style="color: #cc7832; font-size: 13.5pt;">;
import </span><span style="color: #a9b7c6; font-size: 13.5pt;">org.springframework.context.support.ClassPathXmlApplicationContext</span><span style="color: #cc7832; font-size: 13.5pt;">;<br />
public class </span><span style="color: #a9b7c6; font-size: 13.5pt;">Test {<br />
</span><span style="color: #cc7832; font-size: 13.5pt;">public static void </span><span style="color: #ffc66d; font-size: 13.5pt;">main</span><span style="color: #a9b7c6; font-size: 13.5pt;">(String[] args) {<br />
ApplicationContext context =<br />
</span><span style="color: #cc7832; font-size: 13.5pt;">new </span><span style="color: #a9b7c6; font-size: 13.5pt;">ClassPathXmlApplicationContext(</span><span style="color: #6a8759; font-size: 13.5pt;">"beans_di.xml"</span><span style="color: #a9b7c6; font-size: 13.5pt;">)</span><span style="color: #cc7832; font-size: 13.5pt;">;<br />
</span><span style="color: #a9b7c6; font-size: 13.5pt;">Car car = context.getBean(</span><span style="color: #6a8759; font-size: 13.5pt;">"car"</span><span style="color: #cc7832; font-size: 13.5pt;">,</span><span style="color: #a9b7c6; font-size: 13.5pt;">Car.</span><span style="color: #cc7832; font-size: 13.5pt;">class</span><span style="color: #a9b7c6; font-size: 13.5pt;">)</span><span style="color: #cc7832; font-size: 13.5pt;">;
</span><span style="color: #a9b7c6; font-size: 13.5pt;">car.checkCarEngine()</span><span style="color: #cc7832; font-size: 13.5pt;">;
</span><span style="color: #a9b7c6; font-size: 13.5pt;">}<br />
}<o:p></o:p></span></pre></div><div style="caret-color: rgb(34, 34, 34); color: #222222;"><span style="caret-color: rgb(0, 0, 0); color: black;"><br /></span></div><div style="caret-color: rgb(34, 34, 34); color: #222222;"><span style="caret-color: rgb(0, 0, 0); color: black;"><br /></span></div><div style="caret-color: rgb(34, 34, 34); color: #222222;"><pre style="background-color: #2b2b2b; caret-color: rgb(0, 0, 0); color: black; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #cc7832; font-size: 13.5pt;">package </span><span style="color: #a9b7c6; font-size: 13.5pt;">com.ah.di</span><span style="color: #cc7832; font-size: 13.5pt;">;<br />
import </span><span style="color: #a9b7c6; font-size: 13.5pt;">org.springframework.beans.factory.annotation.</span><span style="color: #bbb529; font-size: 13.5pt;">Autowired</span><span style="color: #cc7832; font-size: 13.5pt;">
import </span><span style="color: #a9b7c6; font-size: 13.5pt;">or.springframework.beans.factory.annotation.</span><span style="color: #bbb529; font-size: 13.5pt;">Qualifier</span><span style="color: #cc7832; font-size: 13.5pt;">;<br />
public class </span><span style="color: #a9b7c6; font-size: 13.5pt;">Car {<br />
</span><span style="color: #bbb529; font-size: 13.5pt;">@Autowired
@Qualifier</span><span style="color: #a9b7c6; font-size: 13.5pt;">(</span><span style="color: #6a8759; font-size: 13.5pt;">"engineModel2"</span><span style="color: #a9b7c6; font-size: 13.5pt;">)
</span><span style="color: #cc7832; font-size: 13.5pt;">private </span><span style="color: #a9b7c6; font-size: 13.5pt;">Engine </span><span style="color: #9876aa; font-size: 13.5pt;">engine</span><span style="color: #cc7832; font-size: 13.5pt;">;<br />
public void </span><span style="color: #ffc66d; font-size: 13.5pt;">checkCarEngine</span><span style="color: #a9b7c6; font-size: 13.5pt;">(){
</span><span style="color: #cc7832; font-size: 13.5pt;">if</span><span style="color: #a9b7c6; font-size: 13.5pt;">(</span><span style="color: #9876aa; font-size: 13.5pt;">engine</span><span style="color: #a9b7c6; font-size: 13.5pt;">!=</span><span style="color: #cc7832; font-size: 13.5pt;">null</span><span style="color: #a9b7c6; font-size: 13.5pt;">){
</span><span style="color: #9876aa; font-size: 13.5pt;">engine</span><span style="color: #a9b7c6; font-size: 13.5pt;">.testEngine()</span><span style="color: #cc7832; font-size: 13.5pt;">;
</span><span style="color: #a9b7c6; font-size: 13.5pt;">}</span><span style="color: #cc7832; font-size: 13.5pt;">else</span><span style="color: #a9b7c6; font-size: 13.5pt;">{
System.</span><i><span style="color: #9876aa; font-size: 13.5pt;">out</span></i><span style="color: #a9b7c6; font-size: 13.5pt;">.println(</span><span style="color: #6a8759; font-size: 13.5pt;">"Engine is dead"</span><span style="color: #a9b7c6; font-size: 13.5pt;">)</span><span style="color: #cc7832; font-size: 13.5pt;">;
</span><span style="color: #a9b7c6; font-size: 13.5pt;">}
}
}<o:p></o:p></span></pre></div><div style="caret-color: rgb(34, 34, 34); color: #222222;"><span style="caret-color: rgb(0, 0, 0); color: black;"><br /></span></div><div style="caret-color: rgb(34, 34, 34); color: #222222;"><pre style="background-color: #2b2b2b; caret-color: rgb(0, 0, 0); color: black; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #cc7832; font-size: 13.5pt;">package </span><span style="color: #a9b7c6; font-size: 13.5pt;">com.ah.di</span><span style="color: #cc7832; font-size: 13.5pt;">;<br />
public class </span><span style="color: #a9b7c6; font-size: 13.5pt;">Engine {
</span><span style="color: #cc7832; font-size: 13.5pt;">public void </span><span style="color: #ffc66d; font-size: 13.5pt;">testEngine</span><span style="color: #a9b7c6; font-size: 13.5pt;">(){
System.</span><i><span style="color: #9876aa; font-size: 13.5pt;">out</span></i><span style="color: #a9b7c6; font-size: 13.5pt;">.println(</span><span style="color: #6a8759; font-size: 13.5pt;">"engine is working" </span><span style="color: #a9b7c6; font-size: 13.5pt;">)</span><span style="color: #cc7832; font-size: 13.5pt;">;
</span><span style="color: #a9b7c6; font-size: 13.5pt;">}
}<o:p></o:p></span></pre></div><div style="caret-color: rgb(34, 34, 34); color: #222222;"><br /></div><div> Watch Demo</div><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="270" src="https://www.youtube.com/embed/bocFgTlZbBc" width="325" youtube-src-id="bocFgTlZbBc"></iframe></div><br /><div><br /></div><div><br /></div></span></div></span></div>Praveen Kumarhttp://www.blogger.com/profile/14705482110609285232noreply@blogger.com0tag:blogger.com,1999:blog-8903620123630625488.post-19293051036185610122022-06-28T03:58:00.003-07:002022-06-28T03:58:58.360-07:00Spring Part 05 - Autowiring<p>Spring - Autowiring</p><div><span><div><b>Maven Dependency:</b></div><div><span face="Arial, Tahoma, Helvetica, FreeSans, sans-serif" style="caret-color: rgb(34, 34, 34); color: #222222;"><p style="font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"><dependency></p><p style="font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"> <groupId>org.springframework</groupId></p><p style="font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"> <artifactId>spring-context</artifactId></p><p style="font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"> <version>5.3.16</version></p><p style="font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"></dependency></p><div><br /></div><div><h3 style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; margin: 0px; position: relative;"><span style="font-size: medium;">Sample Program for Autowiring <span style="background-color: white;">using</span> 'Spring Framework'</span> </h3></div><div><span style="caret-color: rgb(0, 0, 0); color: black;">beans_di.xml</span></div><div><p class="MsoNormal" style="background-color: #2b2b2b; caret-color: rgb(0, 0, 0); color: black; font-family: Calibri, sans-serif; margin: 0cm;"><span style="color: #e8bf6a; font-family: "JetBrains Mono"; font-size: 13.5pt;"><?</span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">xml version</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="1.0" </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">encoding</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="UTF-8"</span><span style="color: #e8bf6a; font-family: "JetBrains Mono"; font-size: 13.5pt;">?><br /><beans </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">xmlns</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="http://www.springframework.org/schema/beans"<br /> </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">xmlns:</span><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">xsi</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="http://www.w3.org/2001/XMLSchema-instance"<br /> </span><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">xsi</span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">:schemaLocation</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="http://www.springframework.org/schema/beans<br /> https://www.springframework.org/schema/beans/spring-beans.xsd"</span><span style="color: #e8bf6a; font-family: "JetBrains Mono"; font-size: 13.5pt;">><br /><br /> <bean </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">id</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="engineObj" </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">class</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="com.ah.di.Engine"</span><span style="color: #e8bf6a; font-family: "JetBrains Mono"; font-size: 13.5pt;">/><br /><br /> <bean </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">id</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="car" </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">class</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="com.ah.di.Car" </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">autowire</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="byType"</span><span style="color: #e8bf6a; font-family: "JetBrains Mono"; font-size: 13.5pt;">/><br /><br /></beans></span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;"><o:p></o:p></span></p></div><div><span style="caret-color: rgb(0, 0, 0); color: black;"><br /></span></div><div><pre style="background-color: #2b2b2b; caret-color: rgb(0, 0, 0); color: black; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">package </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">com.ah.di</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
import </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">org.springframework.context.ApplicationContext</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
import </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">org.springframework.context.support.ClassPathXmlApplicationContext</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
public class </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">Test {<br />
</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">public static void </span><span style="color: #ffc66d; font-family: "JetBrains Mono"; font-size: 13.5pt;">main</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">(String[] args) {<br />
ApplicationContext context =<br />
</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">new </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">ClassPathXmlApplicationContext(</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">"beans_di.xml"</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">)</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">Car car = context.getBean(</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">"car"</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">,</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">Car.</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">class</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">)</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">car.checkCarEngine()</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">}<br />
}</span></pre></div><div><span style="caret-color: rgb(0, 0, 0); color: black;"><br /></span></div><div><span style="caret-color: rgb(0, 0, 0); color: black;"><br /></span></div><div><pre style="background-color: #2b2b2b; caret-color: rgb(0, 0, 0); color: black; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">package </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">com.ah.di</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
public class </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">Car {<br />
</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">private </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">Engine </span><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">engine</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
public void </span><span style="color: #ffc66d; font-family: "JetBrains Mono"; font-size: 13.5pt;">setEngine</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">(Engine engine) {
</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">this</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">.</span><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">engine </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">= engine</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">}<br />
</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">public void </span><span style="color: #ffc66d; font-family: "JetBrains Mono"; font-size: 13.5pt;">checkCarEngine</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">(){<br />
</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">if</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">(</span><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">engine</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">!=</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">null</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">){
</span><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">engine</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">.testEngine()</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">}</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">else</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">{
System.</span><i><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">out</span></i><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">.println(</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">"Engine is dead"</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">)</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">}<br />
}<br />
}<o:p></o:p></span></pre></div><div><span style="caret-color: rgb(0, 0, 0); color: black;"><br /></span></div><div><pre style="background-color: #2b2b2b; caret-color: rgb(0, 0, 0); color: black; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">package </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">com.ah.di</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
public class </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">Engine {<br />
</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">public </span><span style="color: #ffc66d; font-family: "JetBrains Mono"; font-size: 13.5pt;">Engine</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">(){
System.</span><i><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">out</span></i><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">.println(</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">"Engine Constructor.."</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">)</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">}<br />
</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">public void </span><span style="color: #ffc66d; font-family: "JetBrains Mono"; font-size: 13.5pt;">testEngine</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">(){
System.</span><i><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">out</span></i><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">.println(</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">"engine is working" </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">)</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">}<br />
}<o:p></o:p></span></pre></div><div><span style="caret-color: rgb(0, 0, 0); color: black;"><br /></span></div><div><span style="caret-color: rgb(0, 0, 0); color: black;"><br /></span></div><div><span style="caret-color: rgb(0, 0, 0); color: black;"><br /></span></div><div><span style="caret-color: rgb(0, 0, 0); color: black;">beans_di.xml</span></div><div><p class="MsoNormal" style="background-color: #2b2b2b; caret-color: rgb(0, 0, 0); color: black; font-family: Calibri, sans-serif; margin: 0cm;"><span style="color: #e8bf6a; font-family: "JetBrains Mono"; font-size: 13.5pt;"><?</span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">xml version</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="1.0" </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">encoding</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="UTF-8"</span><span style="color: #e8bf6a; font-family: "JetBrains Mono"; font-size: 13.5pt;">?><br /><beans </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">xmlns</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="http://www.springframework.org/schema/beans"<br /> </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">xmlns:</span><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">xsi</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="http://www.w3.org/2001/XMLSchema-instance"<br /> </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">xmlns:</span><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">context</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="http://www.springframework.org/schema/context"<br /> </span><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">xsi</span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">:schemaLocation</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="http://www.springframework.org/schema/beans<br /> https://www.springframework.org/schema/beans/spring-beans.xsd<br /> http://www.springframework.org/schema/context<br /> https://www.springframework.org/schema/context/spring-context.xsd"</span><span style="color: #e8bf6a; font-family: "JetBrains Mono"; font-size: 13.5pt;">><br /><br /> <</span><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">context</span><span style="color: #e8bf6a; font-family: "JetBrains Mono"; font-size: 13.5pt;">:annotation-config/><br /><br /> <bean </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">id</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="engine" </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">class</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="com.ah.di.Engine"</span><span style="color: #e8bf6a; font-family: "JetBrains Mono"; font-size: 13.5pt;">><br /> <property </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">name</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="engineModel" </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">value</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="Model-1"</span><span style="color: #e8bf6a; font-family: "JetBrains Mono"; font-size: 13.5pt;">/><br /> </bean><br /><br /> <bean </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">id</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="carBattery" </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">class</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="com.ah.di.Battery"</span><span style="color: #e8bf6a; font-family: "JetBrains Mono"; font-size: 13.5pt;">/><br /><br /> <bean </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">id</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="car" </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">class</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="com.ah.di.Car" </span><span style="color: #e8bf6a; font-family: "JetBrains Mono"; font-size: 13.5pt;">/><br /><br /></beans></span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;"><o:p></o:p></span></p></div><div><br /></div><div><pre style="background-color: #2b2b2b; caret-color: rgb(0, 0, 0); color: black; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">package </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">com.ah.di</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
import </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">org.springframework.context.ApplicationContext</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;
import </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">org.springframework.context.support.ClassPathXmlApplicationContext</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
public class </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">Test {<br />
</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">public static void </span><span style="color: #ffc66d; font-family: "JetBrains Mono"; font-size: 13.5pt;">main</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">(String[] args) {
ApplicationContext context =
</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">new </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">ClassPathXmlApplicationContext(</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">"beans_di.xml"</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">)</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">Car car = context.getBean(</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">"car"</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">,</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">Car.</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">class</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">)</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">car.checkCarEngine()</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">}
}<o:p></o:p></span></pre></div><div><span style="caret-color: rgb(0, 0, 0); color: black;"><br /></span></div><div><span style="caret-color: rgb(0, 0, 0); color: black;"><br /></span></div><div><pre style="background-color: #2b2b2b; caret-color: rgb(0, 0, 0); color: black; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">package </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">com.ah.di</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
import </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">org.springframework.beans.factory.annotation.</span><span style="color: #bbb529; font-family: "JetBrains Mono"; font-size: 13.5pt;">Autowired</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
public class </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">Car {<br />
</span><span style="color: #bbb529; font-family: "JetBrains Mono"; font-size: 13.5pt;">@Autowired
</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">private </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">Engine </span><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">engine</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
</span><span style="color: #bbb529; font-family: "JetBrains Mono"; font-size: 13.5pt;">@Autowired
</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">private </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">Battery </span><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">battery</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
public void </span><span style="color: #ffc66d; font-family: "JetBrains Mono"; font-size: 13.5pt;">checkCarEngine</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">(){
</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">if</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">(</span><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">engine</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">!=</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">null</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">){
</span><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">engine</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">.testEngine()</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">}</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">else</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">{
System.</span><i><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">out</span></i><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">.println(</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">"Engine is dead"</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">)</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">}<br />
</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">if</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">(</span><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">battery</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">!=</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">null</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">){
</span><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">battery</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">.displayBatteryStatus()</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">}</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">else</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">{
System.</span><i><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">out</span></i><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">.println(</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">"Battery is dead"</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">)</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">}
}<br />
}<o:p></o:p></span></pre></div><div><span style="caret-color: rgb(0, 0, 0); color: black;"><br /></span></div><div><pre style="background-color: #2b2b2b; caret-color: rgb(0, 0, 0); color: black; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">package </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">com.ah.di</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
public class </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">Engine {<br />
</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">private </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">String </span><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">engineModel</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
public void </span><span style="color: #ffc66d; font-family: "JetBrains Mono"; font-size: 13.5pt;">setEngineModel</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">(String engineModel) {
</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">this</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">.</span><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">engineModel </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">= engineModel</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">}<br />
</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">public void </span><span style="color: #ffc66d; font-family: "JetBrains Mono"; font-size: 13.5pt;">testEngine</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">(){
System.</span><i><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">out</span></i><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">.println(</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">"engine is working" </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">)</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">System.</span><i><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">out</span></i><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">.println(</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">"engineModel :: "</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">+</span><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">engineModel </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">)</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">}<br />
}<o:p></o:p></span></pre></div><div><br /></div><div><br /></div><div> Watch Demo</div><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/g9Uo9XlqMYg" width="320" youtube-src-id="g9Uo9XlqMYg"></iframe></div><br /><div><br /></div></span></div></span></div>Praveen Kumarhttp://www.blogger.com/profile/14705482110609285232noreply@blogger.com0tag:blogger.com,1999:blog-8903620123630625488.post-38192778336278474322022-06-26T23:04:00.001-07:002022-06-26T23:04:29.856-07:00Spring Part 04 - Setter Injection (Class)<h3><span style="font-weight: normal;">Spring - Dependency Injection</span></h3><div><span>Dependency Injection using class</span></div><div><span><br /></span></div><div><span><h3><span face="-webkit-standard" style="font-size: medium;">Sample Program for Dependency Injection using 'Spring Framework'</span></h3><div><span face="-webkit-standard" style="font-size: medium;"><span style="font-size: medium;">beans_di.xml</span></span></div><div><p class="MsoNormal" style="background-color: #2b2b2b; font-family: Calibri, sans-serif; margin: 0cm;"><span style="color: #e8bf6a; font-family: "JetBrains Mono"; font-size: 13.5pt;"><?</span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">xml version</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="1.0" </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">encoding</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="UTF-8"</span><span style="color: #e8bf6a; font-family: "JetBrains Mono"; font-size: 13.5pt;">?><br /><beans </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">xmlns</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="http://www.springframework.org/schema/beans"<br /> </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">xmlns:</span><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">xsi</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="http://www.w3.org/2001/XMLSchema-instance"<br /> </span><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">xsi</span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">:schemaLocation</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="http://www.springframework.org/schema/beans<br /> https://www.springframework.org/schema/beans/spring-beans.xsd"</span><span style="color: #e8bf6a; font-family: "JetBrains Mono"; font-size: 13.5pt;">><br /><br /> <bean </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">id</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="car" </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">class</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="com.ah.di.Car"</span><span style="color: #e8bf6a; font-family: "JetBrains Mono"; font-size: 13.5pt;">><br /> <property </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">name</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="engine"</span><span style="color: #e8bf6a; font-family: "JetBrains Mono"; font-size: 13.5pt;">><br /> <bean </span><span style="color: #bababa; font-family: "JetBrains Mono"; font-size: 13.5pt;">class</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">="com.ah.di.Engine"</span><span style="color: #e8bf6a; font-family: "JetBrains Mono"; font-size: 13.5pt;">/><br /> </property><br /> </bean><br /><br /></beans></span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;"><o:p></o:p></span></p></div><div><span face="-webkit-standard" style="font-size: medium;"><span style="font-size: medium;"><br /></span></span></div><div><span face="-webkit-standard" style="font-size: medium;"><span style="font-size: medium;"><br /></span></span></div><div><span face="-webkit-standard" style="font-size: medium;"><pre style="background-color: #2b2b2b; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">package </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">com.ah.di</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
import </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">org.springframework.context.ApplicationContext</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
import </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">org.springframework.context.support.ClassPathXmlApplicationContext</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
public class </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">Test {<br />
</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">public static void </span><span style="color: #ffc66d; font-family: "JetBrains Mono"; font-size: 13.5pt;">main</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">(String[] args) {<br />
ApplicationContext context = </span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">new </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">ClassPathXmlApplicationContext(</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">"beans_di.xml"</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">)</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">Car car = context.getBean(</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">"car"</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">,</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">Car.</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">class</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">)</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">car.checkCarEngine()</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">}<br />
}<o:p></o:p></span></pre></span></div><div><span face="-webkit-standard" style="font-size: medium;"><span style="font-size: medium;"><br /></span></span></div><div><span face="-webkit-standard" style="font-size: medium;"><span style="font-size: medium;"><br /></span></span></div><div><span face="-webkit-standard" style="font-size: medium;"><pre style="background-color: #2b2b2b; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">package </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">com.ah.di</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
<br />
public class </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">Car {<br />
</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">private </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">Engine </span><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">engine</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
<br />
public void </span><span style="color: #ffc66d; font-family: "JetBrains Mono"; font-size: 13.5pt;">setEngine</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">(Engine engine) {<br />
</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">this</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">.</span><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">engine </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">= engine</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">}<br />
</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">public void </span><span style="color: #ffc66d; font-family: "JetBrains Mono"; font-size: 13.5pt;">checkCarEngine</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">(){<br />
</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">if</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">(</span><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">engine</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">!=</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">null</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">){<br />
</span><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">engine</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">.testEngine()</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">}</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">else</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">{<br />
System.</span><i><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">out</span></i><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">.println(</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">"Engine is dead"</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">)</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">}<br />
}<br />
}<o:p></o:p></span></pre></span></div><div><span face="-webkit-standard" style="font-size: medium;"><span style="font-size: medium;"><br /></span></span></div><div><span face="-webkit-standard" style="font-size: medium;"><pre style="background-color: #2b2b2b; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">package </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">com.ah.di</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
public class </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">Engine {<br />
</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">public void </span><span style="color: #ffc66d; font-family: "JetBrains Mono"; font-size: 13.5pt;">testEngine</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">(){<br />
System.</span><i><span style="color: #9876aa; font-family: "JetBrains Mono"; font-size: 13.5pt;">out</span></i><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">.println(</span><span style="color: #6a8759; font-family: "JetBrains Mono"; font-size: 13.5pt;">"engine is working" </span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">)</span><span style="color: #cc7832; font-family: "JetBrains Mono"; font-size: 13.5pt;">;<br />
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono"; font-size: 13.5pt;">}<br />
}<o:p></o:p></span></pre></span></div><div><br /></div><div><br /></div><div> Watch Demo</div><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/s0D6GgEdqJY" width="320" youtube-src-id="s0D6GgEdqJY"></iframe></div><br /><div><br /></div><div><br /></div><div><br /></div><div><br /></div></span></div>Praveen Kumarhttp://www.blogger.com/profile/14705482110609285232noreply@blogger.com0tag:blogger.com,1999:blog-8903620123630625488.post-73591037706184182572022-06-26T06:56:00.005-07:002022-06-26T07:46:59.971-07:00Spring Part 03 - Constructor Injection<p> Spring - Construction Injection</p><div><span style="font-weight: normal;"><div><b>Maven Dependency:</b></div><div><span face="Arial, Tahoma, Helvetica, FreeSans, sans-serif" style="caret-color: rgb(34, 34, 34); color: #222222;"><p style="font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"><dependency></p><p style="font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"> <groupId>org.springframework</groupId></p><p style="font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"> <artifactId>spring-context</artifactId></p><p style="font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"> <version>5.3.16</version></p><p style="font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"></dependency></p><div><br /></div><div><h3 style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; margin: 0px; position: relative;"><span style="font-size: medium;">Sample Program for Construction Injection <span style="background-color: white;">using</span> 'Spring Framework'</span> </h3></div><div><span style="caret-color: rgb(0, 0, 0); color: black;">beans_di.xml</span></div><div><pre style="background-color: #2b2b2b; caret-color: rgb(0, 0, 0); color: black; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #e8bf6a; font-family: "JetBrains Mono";"><?</span><span style="color: #bababa; font-family: "JetBrains Mono";">xml version</span><span style="color: #6a8759; font-family: "JetBrains Mono";">="1.0" </span><span style="color: #bababa; font-family: "JetBrains Mono";">encoding</span><span style="color: #6a8759; font-family: "JetBrains Mono";">="UTF-8"</span><span style="color: #e8bf6a; font-family: "JetBrains Mono";">?><br />
<beans </span><span style="color: #bababa; font-family: "JetBrains Mono";">xmlns</span><span style="color: #6a8759; font-family: "JetBrains Mono";">="http://www.springframework.org/schema/beans"<br />
</span><span style="color: #bababa; font-family: "JetBrains Mono";">xmlns:</span><span style="color: #9876aa; font-family: "JetBrains Mono";">xsi</span><span style="color: #6a8759; font-family: "JetBrains Mono";">="http://www.w3.org/2001/XMLSchema-instance"<br />
</span><span style="color: #9876aa; font-family: "JetBrains Mono";">xsi</span><span style="color: #bababa; font-family: "JetBrains Mono";">:schemaLocation</span><span style="color: #6a8759; font-family: "JetBrains Mono";">="http://www.springframework.org/schema/beans<br />
https://www.springframework.org/schema/beans/spring-beans.xsd"</span><span style="color: #e8bf6a; font-family: "JetBrains Mono";">><br /><br /></span></pre><pre style="background-color: #2b2b2b; caret-color: rgb(0, 0, 0); color: black; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #e8bf6a; font-family: "JetBrains Mono";">
<bean </span><span style="color: #bababa; font-family: "JetBrains Mono";">id</span><span style="color: #6a8759; font-family: "JetBrains Mono";">="commonEngine" </span><span style="color: #bababa; font-family: "JetBrains Mono";">class</span><span style="color: #6a8759; font-family: "JetBrains Mono";">="com.ah.di.Engine"</span><span style="color: #e8bf6a; font-family: "JetBrains Mono";">/><br /><br />
<bean </span><span style="color: #bababa; font-family: "JetBrains Mono";">id</span><span style="color: #6a8759; font-family: "JetBrains Mono";">="car1" </span><span style="color: #bababa; font-family: "JetBrains Mono";">class</span><span style="color: #6a8759; font-family: "JetBrains Mono";">="com.ah.di.Car"</span><span style="color: #e8bf6a; font-family: "JetBrains Mono";">><br />
<constructor-arg </span><span style="color: #bababa; font-family: "JetBrains Mono";">name</span><span style="color: #6a8759; font-family: "JetBrains Mono";">="engine" </span><span style="color: #bababa; font-family: "JetBrains Mono";">ref</span><span style="color: #6a8759; font-family: "JetBrains Mono";">="commonEngine"</span><span style="color: #e8bf6a; font-family: "JetBrains Mono";">/><br />
</bean><br /><br />
<bean </span><span style="color: #bababa; font-family: "JetBrains Mono";">id</span><span style="color: #6a8759; font-family: "JetBrains Mono";">="car2" </span><span style="color: #bababa; font-family: "JetBrains Mono";">class</span><span style="color: #6a8759; font-family: "JetBrains Mono";">="com.ah.di.Car"</span><span style="color: #e8bf6a; font-family: "JetBrains Mono";">><br />
<constructor-arg </span><span style="color: #bababa; font-family: "JetBrains Mono";">name</span><span style="color: #6a8759; font-family: "JetBrains Mono";">="engine" </span><span style="color: #bababa; font-family: "JetBrains Mono";">ref</span><span style="color: #6a8759; font-family: "JetBrains Mono";">="commonEngine"</span><span style="color: #e8bf6a; font-family: "JetBrains Mono";">/><br />
</bean><br />
</beans></span></pre></div><div><br /></div><div><br /></div><div><p class="MsoNormal" style="background-color: #2b2b2b; caret-color: rgb(0, 0, 0); color: black; font-family: "Times New Roman", serif; font-size: 10pt; margin: 0cm;"><span style="color: #cc7832; font-family: "JetBrains Mono";">package </span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">com.ah.di</span><span style="color: #cc7832; font-family: "JetBrains Mono";">;<br /><br />import </span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">org.springframework.context.ApplicationContext</span><span style="color: #cc7832; font-family: "JetBrains Mono";">;<br />import </span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">org.springframework.context.support.ClassPathXmlApplicationContext</span><span style="color: #cc7832; font-family: "JetBrains Mono";">;<br /><br />public class </span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">Test {<br /> </span><span style="color: #cc7832; font-family: "JetBrains Mono";">public static void </span><span style="color: #ffc66d; font-family: "JetBrains Mono";">main</span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">(String[] args) {<br /><br /> </span><span style="color: grey; font-family: "JetBrains Mono";">/* Engine engine = new Engine();<br /> Car car = new Car(engine);<br /> car.callEngine();*/<br /><br />/* Car car = new Car(new Engine());<br /> car.callEngine();*/<br /><br /> </span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">ApplicationContext context = </span><span style="color: #cc7832; font-family: "JetBrains Mono";">new </span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">ClassPathXmlApplicationContext(</span><span style="color: #6a8759; font-family: "JetBrains Mono";">"beans_di.xml"</span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">)</span><span style="color: #cc7832; font-family: "JetBrains Mono";">;<br /> </span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">Car carObj1 = context.getBean(</span><span style="color: #6a8759; font-family: "JetBrains Mono";">"car1"</span><span style="color: #cc7832; font-family: "JetBrains Mono";">,</span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">Car.</span><span style="color: #cc7832; font-family: "JetBrains Mono";">class</span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">)</span><span style="color: #cc7832; font-family: "JetBrains Mono";">;<br /> </span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">carObj1.callEngine()</span><span style="color: #cc7832; font-family: "JetBrains Mono";">;<br /><br /> </span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">Car carObj2 = context.getBean(</span><span style="color: #6a8759; font-family: "JetBrains Mono";">"car2"</span><span style="color: #cc7832; font-family: "JetBrains Mono";">,</span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">Car.</span><span style="color: #cc7832; font-family: "JetBrains Mono";">class</span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">)</span><span style="color: #cc7832; font-family: "JetBrains Mono";">;<br /> </span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">carObj2.callEngine()</span><span style="color: #cc7832; font-family: "JetBrains Mono";">;<br /> </span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">}<br />}</span></p></div><div><br /></div><div><pre style="background-color: #2b2b2b; caret-color: rgb(0, 0, 0); color: black; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #cc7832; font-family: "JetBrains Mono";">package </span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">com.ah.di</span><span style="color: #cc7832; font-family: "JetBrains Mono";">;<br />
public class </span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">Engine {<br />
</span><span style="color: #cc7832; font-family: "JetBrains Mono";">public </span><span style="color: #ffc66d; font-family: "JetBrains Mono";">Engine</span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">() {<br />
System.</span><i><span style="color: #9876aa; font-family: "JetBrains Mono";">out</span></i><span style="color: #a9b7c6; font-family: "JetBrains Mono";">.println(</span><span style="color: #6a8759; font-family: "JetBrains Mono";">"Engine constructor."</span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">)</span><span style="color: #cc7832; font-family: "JetBrains Mono";">;<br />
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">}<br />
</span><span style="color: #cc7832; font-family: "JetBrains Mono";">public void </span><span style="color: #ffc66d; font-family: "JetBrains Mono";">engineInfo</span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">(){<br />
System.</span><i><span style="color: #9876aa; font-family: "JetBrains Mono";">out</span></i><span style="color: #a9b7c6; font-family: "JetBrains Mono";">.println(</span><span style="color: #6a8759; font-family: "JetBrains Mono";">"engineInfo method of Engine class called."</span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">)</span><span style="color: #cc7832; font-family: "JetBrains Mono";">;<br />
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">}<br />
}<o:p></o:p></span></pre></div><div><br /></div><div><pre style="background-color: #2b2b2b; caret-color: rgb(0, 0, 0); color: black; font-family: "Courier New"; font-size: 10pt; margin: 0cm 0cm 0.0001pt;"><span style="color: #cc7832; font-family: "JetBrains Mono";">package </span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">com.ah.di</span><span style="color: #cc7832; font-family: "JetBrains Mono";">;<br />
public class </span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">Car {<br />
</span><span style="color: #cc7832; font-family: "JetBrains Mono";">private </span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">Engine </span><span style="color: #9876aa; font-family: "JetBrains Mono";">engine</span><span style="color: #cc7832; font-family: "JetBrains Mono";">;<br />
public </span><span style="color: #ffc66d; font-family: "JetBrains Mono";">Car</span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">(Engine engine) {<br />
</span><span style="color: #cc7832; font-family: "JetBrains Mono";">this</span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">.</span><span style="color: #9876aa; font-family: "JetBrains Mono";">engine </span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">= engine</span><span style="color: #cc7832; font-family: "JetBrains Mono";">;<br />
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">}<br />
</span><span style="color: #cc7832; font-family: "JetBrains Mono";">public void </span><span style="color: #ffc66d; font-family: "JetBrains Mono";">callEngine</span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">(){<br />
</span><span style="color: #cc7832; font-family: "JetBrains Mono";">if</span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">(</span><span style="color: #9876aa; font-family: "JetBrains Mono";">engine</span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">==</span><span style="color: #cc7832; font-family: "JetBrains Mono";">null</span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">){<br />
System.</span><i><span style="color: #9876aa; font-family: "JetBrains Mono";">out</span></i><span style="color: #a9b7c6; font-family: "JetBrains Mono";">.println(</span><span style="color: #6a8759; font-family: "JetBrains Mono";">"Engine is dead"</span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">)</span><span style="color: #cc7832; font-family: "JetBrains Mono";">;<br />
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">}</span><span style="color: #cc7832; font-family: "JetBrains Mono";">else</span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">{<br />
System.</span><i><span style="color: #9876aa; font-family: "JetBrains Mono";">out</span></i><span style="color: #a9b7c6; font-family: "JetBrains Mono";">.println(</span><span style="color: #6a8759; font-family: "JetBrains Mono";">"Engine is working"</span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">)</span><span style="color: #cc7832; font-family: "JetBrains Mono";">;<br />
</span><span style="color: #9876aa; font-family: "JetBrains Mono";">engine</span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">.engineInfo()</span><span style="color: #cc7832; font-family: "JetBrains Mono";">;<br />
</span><span style="color: #a9b7c6; font-family: "JetBrains Mono";">}<br />
}<br />
}<o:p></o:p></span></pre></div><div><br /></div><div><br /></div></span></div></span></div><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><div><span style="font-weight: normal;"><div><span face="Arial, Tahoma, Helvetica, FreeSans, sans-serif" style="caret-color: rgb(34, 34, 34); color: #222222;"><div style="text-align: justify;"><span style="caret-color: rgb(0, 0, 0); color: black; text-align: center;"> Watch Demo</span></div></span></div></span></div></blockquote><div><span style="font-weight: normal;"><span face="Arial, Tahoma, Helvetica, FreeSans, sans-serif" style="caret-color: rgb(34, 34, 34); color: #222222;"><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/Ms1XK7EALDs" width="320" youtube-src-id="Ms1XK7EALDs"></iframe></div><br /><div><br /></div><p></p></span></span></div>Praveen Kumarhttp://www.blogger.com/profile/14705482110609285232noreply@blogger.com0tag:blogger.com,1999:blog-8903620123630625488.post-55986073215687873362022-05-24T14:56:00.003-07:002022-06-26T07:46:41.886-07:00Spring Part 02 - Dependency Injection (Primitives & String)<h3><span style="font-weight: normal;">Spring - Dependency Injection</span></h3><div><span style="font-weight: normal;">Dependency Injection using primitives & String</span></div><h3><span face="-webkit-standard" style="font-size: medium;">Sample Program for Dependency Injection <span style="background-color: #fcff01;">without</span> using 'Spring Framework'</span></h3><div><pre style="background-color: #2b2b2b; color: #a9b7c6; font-family: "JetBrains Mono", monospace; font-size: 9.8pt;"><span style="color: #cc7832;">package </span>com.ah.di.setterdemo<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"><br /></span><span style="color: #cc7832;">public class </span>Test {<br /> <span style="color: #cc7832;">public static void </span><span style="color: #ffc66d;">main</span>(String[] args) {<br /> Car car = <span style="color: #cc7832;">new </span>Car()<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>car.setCarName(<span style="color: #6a8759;">"Ford"</span>)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>car.displayCarInfo()<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>}<br />}<br /></pre></div><div><br /></div><div><pre style="background-color: #2b2b2b; color: #a9b7c6; font-family: "JetBrains Mono", monospace; font-size: 9.8pt;"><span style="color: #cc7832;">package </span>com.ah.di.setterdemo<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"><br /></span><span style="color: #cc7832;">public class </span>Car {<br /><br /> <span style="color: #cc7832;">private </span>String <span style="color: #9876aa;">carName</span><span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> <br /></span><span style="color: #cc7832;"> public void </span><span style="color: #ffc66d;">setCarName</span>(String carName) {<br /> <span style="color: #cc7832;">this</span>.<span style="color: #9876aa;">carName </span>= carName<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>}<br /><br /> <span style="color: #cc7832;">public void </span><span style="color: #ffc66d;">displayCarInfo</span>(){<br /> System.<span style="color: #9876aa; font-style: italic;">out</span>.println(<span style="color: #6a8759;">"Displaying car information"</span>+<br /> <span style="color: #6a8759;">"</span><span style="color: #cc7832;">\n</span><span style="color: #6a8759;"> car name : "</span>+<span style="color: #9876aa;">carName</span>)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>}<br />}<br /></pre></div><div><br /></div><div><div><b>Maven Dependency:</b></div><div><span face="Arial, Tahoma, Helvetica, FreeSans, sans-serif" style="caret-color: rgb(34, 34, 34); color: #222222;"><p style="font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"><dependency></p><p style="font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"> <groupId>org.springframework</groupId></p><p style="font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"> <artifactId>spring-context</artifactId></p><p style="font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"> <version>5.3.16</version></p><p style="font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"></dependency></p><p></p></span><h3 style="caret-color: rgb(34, 34, 34); color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; margin: 0px; position: relative;"><span style="font-size: medium;">Sample Program for Dependency Injection <span style="background-color: #fcff01;">using</span> 'Spring Framework'</span> </h3></div></div><div><br /></div><div>beans_di_setter.xml</div><div><pre style="background-color: #2b2b2b; color: #a9b7c6; font-family: "JetBrains Mono", monospace; font-size: 9.8pt;"><span style="color: #e8bf6a;"><?</span><span style="color: #bababa;">xml version</span><span style="color: #6a8759;">="1.0" </span><span style="color: #bababa;">encoding</span><span style="color: #6a8759;">="UTF-8"</span><span style="color: #e8bf6a;">?><br /></span><span style="color: #e8bf6a;"><beans </span><span style="color: #bababa;">xmlns</span><span style="color: #6a8759;">="http://www.springframework.org/schema/beans"<br /></span><span style="color: #6a8759;"> </span><span style="color: #bababa;">xmlns:</span><span style="color: #9876aa;">xsi</span><span style="color: #6a8759;">="http://www.w3.org/2001/XMLSchema-instance"<br /></span><span style="color: #6a8759;"> </span><span style="color: #9876aa;">xsi</span><span style="color: #bababa;">:schemaLocation</span><span style="color: #6a8759;">="http://www.springframework.org/schema/beans<br /></span><span style="color: #6a8759;"> http://www.springframework.org/schema/beans/spring-beans.xsd"</span><span style="color: #e8bf6a;">><br /></span><span style="color: #e8bf6a;"> <bean </span><span style="color: #bababa;">id</span><span style="color: #6a8759;">="car" </span><span style="color: #bababa;">class</span><span style="color: #6a8759;">="com.ah.di.setterdemo.Car"</span><span style="color: #e8bf6a;">><br /></span><span style="color: #e8bf6a;"> <property </span><span style="color: #bababa;">name</span><span style="color: #6a8759;">="carName" </span><span style="color: #bababa;">value</span><span style="color: #6a8759;">="Ford"</span><span style="color: #e8bf6a;">/><br /></span><span style="color: #e8bf6a;"> <property </span><span style="color: #bababa;">name</span><span style="color: #6a8759;">="mileage" </span><span style="color: #bababa;">value</span><span style="color: #6a8759;">="28"</span><span style="color: #e8bf6a;">/><br /></span><span style="color: #e8bf6a;"> </bean><br /></span><span style="color: #e8bf6a;"></beans></span></pre></div><div><pre style="background-color: #2b2b2b; color: #a9b7c6; font-family: "JetBrains Mono", monospace; font-size: 9.8pt;"><span style="color: #cc7832;">package </span>com.ah.di.setterdemo<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"><br /></span><span style="color: #cc7832;">import </span>org.springframework.context.ApplicationContext<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;">import </span>org.springframework.context.support.ClassPathXmlApplicationContext<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"><br /></span><span style="color: #cc7832;">public class </span>Test {<br /> <span style="color: #cc7832;">public static void </span><span style="color: #ffc66d;">main</span>(String[] args) {<br /> ApplicationContext context = <span style="color: #cc7832;">new </span>ClassPathXmlApplicationContext(<span style="color: #6a8759;">"beans_di_setter.xml"</span>)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>Car carObj = context.getBean(<span style="color: #6a8759;">"car"</span><span style="color: #cc7832;">, </span>Car.<span style="color: #cc7832;">class</span>)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>carObj.displayCarInfo()<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>}<br />}<br /></pre></div><div style="text-align: center;"><pre style="background-color: #2b2b2b; color: #a9b7c6; font-family: "JetBrains Mono", monospace; font-size: 9.8pt; text-align: start;"><span style="color: #cc7832;">package </span>com.ah.di.setterdemo<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"><br /></span><span style="color: #cc7832;">public class </span>Car {<br /><br /> <span style="color: #cc7832;">private </span>String <span style="color: #9876aa;">carName</span><span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> private int </span><span style="color: #9876aa;">mileage</span><span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"><br /></span><span style="color: #cc7832;"> public void </span><span style="color: #ffc66d;">setMileage</span>(<span style="color: #cc7832;">int </span>mileage) {<br /> <span style="color: #cc7832;">this</span>.<span style="color: #9876aa;">mileage </span>= mileage<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>}<br /><br /> <span style="color: #cc7832;">public void </span><span style="color: #ffc66d;">setCarName</span>(String carName) {<br /> <span style="color: #cc7832;">this</span>.<span style="color: #9876aa;">carName </span>= carName<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>}<br /><br /> <span style="color: #cc7832;">public void </span><span style="color: #ffc66d;">displayCarInfo</span>(){<br /> System.<span style="color: #9876aa; font-style: italic;">out</span>.println(<span style="color: #6a8759;">"Displaying car information"</span>+<br /> <span style="color: #6a8759;">"</span><span style="color: #cc7832;">\n</span><span style="color: #6a8759;"> car name : "</span>+<span style="color: #9876aa;">carName</span>+<br /> <span style="color: #6a8759;">"</span><span style="color: #cc7832;">\n</span><span style="color: #6a8759;"> mileage : "</span>+<span style="color: #9876aa;">mileage</span>)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>}<br />}<br /></pre></div><div style="text-align: center;"><br /></div><div style="text-align: center;">Watch Demo</div><div style="text-align: center;"><iframe frameborder="0" height="270" src="https://youtube.com/embed/JhGssYFW_ao" width="480"></iframe></div>Praveen Kumarhttp://www.blogger.com/profile/14705482110609285232noreply@blogger.com0tag:blogger.com,1999:blog-8903620123630625488.post-64063001048299540272022-05-22T17:04:00.017-07:002022-06-26T07:46:13.492-07:00Spring Part 01 - IOC<h3 style="text-align: left;"><span style="font-weight: normal; text-align: left;">Spring - Inversion of Control </span></h3><h3 style="text-align: left;"><span face="-webkit-standard" style="font-size: medium;">Sample Program to create object and call method <span style="background-color: #fcff01;">without</span> using 'Spring Framework'</span></h3><pre style="background-color: #2b2b2b; color: #a9b7c6; font-family: "JetBrains Mono", monospace; font-size: 9.8pt;"><pre style="font-family: "JetBrains Mono", monospace; font-size: 9.8pt;"><span style="color: #cc7832;">package </span>com.ah.ioc<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"><br /></span><span style="color: #cc7832;">public class </span>Test {<br /> <span style="color: #cc7832;">public static void </span><span style="color: #ffc66d;">main</span>(String[] args) {<br /> SamsungMobile sm = <span style="color: #cc7832;">new </span>SamsungMobile()<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>sm.display()<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>}<br />}<br /></pre></pre><pre style="background-color: #2b2b2b; color: #a9b7c6; font-family: "JetBrains Mono", monospace; font-size: 9.8pt;"><span style="color: #cc7832;">package </span>com.ah.ioc<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"><br /></span><span style="color: #cc7832;">public class </span>SamsungMobile <span style="color: #cc7832;">implements </span>Mobile{<br /> <span style="color: #cc7832;">public </span><span style="color: #ffc66d;">SamsungMobile</span>(){<br /> System.<span style="color: #9876aa; font-style: italic;">out</span>.println(<span style="color: #6a8759;">"Constructor of SamsungMobile class"</span>)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>}<br /><br /> <span style="color: #cc7832;">public void </span><span style="color: #ffc66d;">display</span>(){<br /> System.<span style="color: #9876aa; font-style: italic;">out</span>.println(<span style="color: #6a8759;">"display() method in SamsungMobile class"</span>)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>}<br />}<br /></pre><h3><span style="font-size: medium;"><br /></span></h3><div><span style="font-size: medium;"><b>Maven Dependency:</b></span></div><div><span style="font-size: medium;"><p style="font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"><dependency></p><p style="font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"> <groupId>org.springframework</groupId></p><p style="font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"> <artifactId>spring-context</artifactId></p><p style="font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"> <version>5.3.16</version></p><p style="font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"></dependency></p><p style="font-family: "Helvetica Neue"; font-size: 9.75pt; margin: 0in;"><br /></p></span></div><h3><span style="font-size: medium;">Sample Program to create object and call method <span style="background-color: #fcff01;">using</span> 'Spring Framework'</span> </h3><pre style="background-color: #2b2b2b; color: #a9b7c6; font-family: "JetBrains Mono", monospace; font-size: 9.8pt;"><span style="color: #cc7832;">package </span>com.ah.ioc<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"><br /></span><span style="color: #cc7832;">import </span>org.springframework.context.ApplicationContext<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;">import </span>org.springframework.context.support.ClassPathXmlApplicationContext<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"><br /></span><span style="color: #cc7832;">public class </span>Test {<br /> <span style="color: #cc7832;">public static void </span><span style="color: #ffc66d;">main</span>(String[] args) {<br /> ApplicationContext context =<br /> <span style="color: #cc7832;">new </span>ClassPathXmlApplicationContext(<span style="color: #6a8759;">"beans_ioc.xml"</span>)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>SamsungMobile samsungMobile = context.getBean(<span style="color: #6a8759;">"sm"</span><span style="color: #cc7832;">, </span>SamsungMobile.<span style="color: #cc7832;">class</span>)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>samsungMobile.display()<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>}<br /></pre><p><span style="background-color: #2b2b2b; color: #a9b7c6; font-family: "JetBrains Mono", monospace; font-size: 9.8pt;">}</span> </p><pre style="background-color: #2b2b2b; color: #a9b7c6; font-family: "JetBrains Mono", monospace; font-size: 9.8pt;"><span style="color: #cc7832;">package </span>com.ah.ioc<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"><br /></span><span style="color: #cc7832;">public class </span>SamsungMobile <span style="color: #cc7832;">implements </span>Mobile{<br /> <span style="color: #cc7832;">public </span><span style="color: #ffc66d;">SamsungMobile</span>(){<br /> System.<span style="color: #9876aa; font-style: italic;">out</span>.println(<span style="color: #6a8759;">"Constructor of SamsungMobile class"</span>)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>}<br /><br /> <span style="color: #cc7832;">public void </span><span style="color: #ffc66d;">display</span>(){<br /> System.<span style="color: #9876aa; font-style: italic;">out</span>.println(<span style="color: #6a8759;">"display() method in SamsungMobile class"</span>)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>}<br />}</pre><div class="separator" style="clear: both; text-align: left;"><b>beans_ioc.xml</b></div><div class="separator" style="clear: both; text-align: center;"><pre style="background-color: #2b2b2b; color: #a9b7c6; font-family: "JetBrains Mono", monospace; font-size: 9.8pt; text-align: start;"><span style="color: #e8bf6a;"><?</span><span style="color: #bababa;">xml version</span><span style="color: #6a8759;">="1.0" </span><span style="color: #bababa;">encoding</span><span style="color: #6a8759;">="UTF-8"</span><span style="color: #e8bf6a;">?><br /></span><span style="color: #e8bf6a;"><beans </span><span style="color: #bababa;">xmlns</span><span style="color: #6a8759;">="http://www.springframework.org/schema/beans"<br /></span><span style="color: #6a8759;"> </span><span style="color: #bababa;">xmlns:</span><span style="color: #9876aa;">xsi</span><span style="color: #6a8759;">="http://www.w3.org/2001/XMLSchema-instance"<br /></span><span style="color: #6a8759;"> </span><span style="color: #9876aa;">xsi</span><span style="color: #bababa;">:schemaLocation</span><span style="color: #6a8759;">="http://www.springframework.org/schema/beans<br /></span><span style="color: #6a8759;"> http://www.springframework.org/schema/beans/spring-beans.xsd"</span><span style="color: #e8bf6a;">><br /></span><span style="color: #e8bf6a;"> <bean </span><span style="color: #bababa;">id</span><span style="color: #6a8759;">="sm" </span><span style="color: #bababa;">class</span><span style="color: #6a8759;">="com.ah.ioc.SamsungMobile"</span><span style="color: #e8bf6a;">/><br /></span><span style="color: #e8bf6a;"></beans></span></pre></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><h3 style="text-align: left;"><span style="font-size: medium;">Sample Program <span style="background-color: #fcff01;">using</span> interface 'Spring Framework'</span></h3><div><pre style="background-color: #2b2b2b; color: #a9b7c6; font-family: "JetBrains Mono", monospace; font-size: 9.8pt; text-align: start;"><span style="color: #cc7832;">package </span>com.ah.ioc<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"><br /></span><span style="color: #cc7832;">public interface </span>Mobile {<br /> <span style="color: #cc7832;">public void </span><span style="color: #ffc66d;">display</span>()<span style="color: #cc7832;">;<br /></span>}<br /></pre></div><div><pre style="background-color: #2b2b2b; color: #a9b7c6; font-family: "JetBrains Mono", monospace; font-size: 9.8pt; text-align: start;"><span style="color: #cc7832;">package </span>com.ah.ioc<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"><br /></span><span style="color: #cc7832;">public class </span>SamsungMobile <span style="color: #cc7832;">implements </span>Mobile{<br /> <span style="color: #cc7832;">public </span><span style="color: #ffc66d;">SamsungMobile</span>(){<br /> System.<span style="color: #9876aa; font-style: italic;">out</span>.println(<span style="color: #6a8759;">"Constructor of SamsungMobile class"</span>)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>}<br /><br /> <span style="color: #cc7832;">public void </span><span style="color: #ffc66d;">display</span>(){<br /> System.<span style="color: #9876aa; font-style: italic;">out</span>.println(<span style="color: #6a8759;">"display() method in SamsungMobile class"</span>)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>}<br />}</pre></div></div><div class="separator" style="clear: both; text-align: center;"><pre style="background-color: #2b2b2b; color: #a9b7c6; font-family: "JetBrains Mono", monospace; font-size: 9.8pt; text-align: start;"><span style="color: #cc7832;">package </span>com.ah.ioc<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"><br /></span><span style="color: #cc7832;">public class </span>NokiaMobile <span style="color: #cc7832;">implements </span>Mobile{<br /> <span style="color: #cc7832;">public </span><span style="color: #ffc66d;">NokiaMobile</span>(){<br /> System.<span style="color: #9876aa; font-style: italic;">out</span>.println(<span style="color: #6a8759;">"Constructor of NokiaMobile class"</span>)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>}<br /><br /> <span style="color: #cc7832;">public void </span><span style="color: #ffc66d;">display</span>(){<br /> System.<span style="color: #9876aa; font-style: italic;">out</span>.println(<span style="color: #6a8759;">"display() method in NokiaMobile class"</span>)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>}<br />}<br /></pre></div><div class="separator" style="clear: both; text-align: center;"><pre style="background-color: #2b2b2b; color: #a9b7c6; font-family: "JetBrains Mono", monospace; font-size: 9.8pt; text-align: start;"><span style="color: #cc7832;">package </span>com.ah.ioc<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"><br /></span><span style="color: #cc7832;">public class </span>ABCMobile <span style="color: #cc7832;">implements </span>Mobile{<br /> <span style="color: #cc7832;">public </span><span style="color: #ffc66d;">ABCMobile</span>(){<br /> System.<span style="color: #9876aa; font-style: italic;">out</span>.println(<span style="color: #6a8759;">"Constructor of ABCMobile class"</span>)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>}<br /><br /> <span style="color: #cc7832;">public void </span><span style="color: #ffc66d;">display</span>(){<br /> System.<span style="color: #9876aa; font-style: italic;">out</span>.println(<span style="color: #6a8759;">"display() method in ABCMobile class"</span>)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>}<br />}<br /></pre></div><div class="separator" style="clear: both; text-align: center;"><pre style="background-color: #2b2b2b; color: #a9b7c6; font-family: "JetBrains Mono", monospace; font-size: 9.8pt; text-align: start;"><span style="color: #cc7832;">package </span>com.ah.ioc<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"><br /></span><span style="color: #cc7832;">import </span>org.springframework.context.ApplicationContext<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;">import </span>org.springframework.context.support.ClassPathXmlApplicationContext<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"><br /></span><span style="color: #cc7832;">public class </span>Test {<br /> <span style="color: #cc7832;">public static void </span><span style="color: #ffc66d;">main</span>(String[] args) {<br /><br /> ApplicationContext context =<br /> <span style="color: #cc7832;">new </span>ClassPathXmlApplicationContext(<span style="color: #6a8759;">"beans_ioc.xml"</span>)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>Mobile mobile = context.getBean(<span style="color: #6a8759;">"mobile"</span><span style="color: #cc7832;">, </span>Mobile.<span style="color: #cc7832;">class</span>)<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>mobile.display()<span style="color: #cc7832;">;<br /></span><span style="color: #cc7832;"> </span>}<br />}<br /></pre></div><div class="separator" style="clear: both; text-align: left;"><b>beans_ioc.xml</b></div><div class="separator" style="clear: both; text-align: center;"><pre style="color: #a9b7c6; font-family: "JetBrains Mono", monospace; font-size: 9.8pt; text-align: start;"><span style="background-color: #2b2b2b; color: #e8bf6a;"><?</span><span style="background-color: #2b2b2b; color: #bababa;">xml version</span><span style="background-color: #2b2b2b; color: #6a8759;">="1.0" </span><span style="background-color: #2b2b2b; color: #bababa;">encoding</span><span style="background-color: #2b2b2b; color: #6a8759;">="UTF-8"</span><span style="background-color: #2b2b2b; color: #e8bf6a;">?><br /></span><span style="background-color: #2b2b2b; color: #e8bf6a;"><beans </span><span style="background-color: #2b2b2b; color: #bababa;">xmlns</span><span style="background-color: #2b2b2b; color: #6a8759;">="http://www.springframework.org/schema/beans"<br /></span><span style="background-color: #2b2b2b; color: #6a8759;"> </span><span style="background-color: #2b2b2b; color: #bababa;">xmlns:</span><span style="background-color: #2b2b2b; color: #9876aa;">xsi</span><span style="background-color: #2b2b2b; color: #6a8759;">="http://www.w3.org/2001/XMLSchema-instance"<br /></span><span style="background-color: #2b2b2b; color: #6a8759;"> </span><span style="background-color: #2b2b2b; color: #9876aa;">xsi</span><span style="background-color: #2b2b2b; color: #bababa;">:schemaLocation</span><span style="background-color: #2b2b2b; color: #6a8759;">="http://www.springframework.org/schema/beans<br /></span><span style="background-color: #2b2b2b; color: #6a8759;"> http://www.springframework.org/schema/beans/spring-beans.xsd"</span><span style="background-color: #2b2b2b; color: #e8bf6a;">><br /></span><span style="background-color: #2b2b2b; color: #e8bf6a;"> <bean </span><span style="background-color: #2b2b2b; color: #bababa;">id</span><span style="background-color: #2b2b2b; color: #6a8759;">="mobile" </span><span style="background-color: #2b2b2b; color: #bababa;">class</span><span style="color: #6a8759;"><span style="background-color: #2b2b2b;">="com.ah.ioc.</span><b style="background-color: #fcff01;">ABCMobile</b><span style="background-color: #2b2b2b;">"</span></span><span style="background-color: #2b2b2b; color: #e8bf6a;">/><br /></span><span style="background-color: #2b2b2b; color: #e8bf6a;"></beans></span></pre></div><div class="separator" style="clear: both; text-align: center;"><b><br /></b></div><div class="separator" style="clear: both; text-align: center;"><b>Watch Demo</b></div><div class="separator" style="clear: both; text-align: center;"><iframe frameborder="0" height="360" src="https://youtube.com/embed/bgiryZ5BMzo" width="480"></iframe></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><p><br /></p>Praveen Kumarhttp://www.blogger.com/profile/14705482110609285232noreply@blogger.com0tag:blogger.com,1999:blog-8903620123630625488.post-11304180955894087362022-05-22T16:14:00.021-07:002022-07-02T05:22:17.642-07:00Spring<h3 style="text-align: left;"><b>Spring:</b></h3><p>Part 1- IOC: <a href="https://automation-home.blogspot.com/2022/05/spring-ioc.html" target="_blank">https://automation-home.blogspot.com/2022/05/spring-ioc.html</a> </p><p>Part 2- Dependency Injection </p><p>(Setter Injection : primitives & String) :</p><p><a href="https://automation-home.blogspot.com/2022/05/spring-dependency-injection-primitives.html" target="_blank">https://automation-home.blogspot.com/2022/05/spring-dependency-injection-primitives.html</a><br /></p><p>Part 3- Constructor Injection </p><p><a href="https://automation-home.blogspot.com/2022/06/spring-constructor-injection.html" target="_blank">https://automation-home.blogspot.com/2022/06/spring-constructor-injection.html</a><br /></p><p>Part 4- Dependency Injection </p><p>(Setter Injection : class) :</p><p><a href="https://automation-home.blogspot.com/2022/06/spring-setter-injection-class.html" target="_blank">https://automation-home.blogspot.com/2022/06/spring-setter-injection-class.html</a><br /></p><p>Part 5- Autowiring</p><p><a href="https://automation-home.blogspot.com/2022/06/Spring-Autowiring.html" target="_blank">https://automation-home.blogspot.com/2022/06/Spring-Autowiring.html</a><br /></p><p>Part 6- @Qualifier</p><p><a href="https://automation-home.blogspot.com/2022/06/spring-part-06-qualifier.html">https://automation-home.blogspot.com/2022/06/spring-part-06-qualifier.html</a><br /></p><p>Part 7- @Component</p><p><a href="https://automation-home.blogspot.com/2022/06/spring-part-07-component.html" target="_blank">https://automation-home.blogspot.com/2022/06/spring-part-07-component.html</a><br /></p><p>Part 8- @ComponentScan & @Configuration <span style="font-family: "Helvetica Neue"; font-size: 13px;"> </span></p><p><a href="https://automation-home.blogspot.com/2022/07/spring-part-08-componentscan.html" target="_blank">https://automation-home.blogspot.com/2022/07/spring-part-08-componentscan.html</a></p><p>Part 9- @Bean</p><p><a href="https://automation-home.blogspot.com/2022/07/spring-part-09-bean.html" target="_blank">https://automation-home.blogspot.com/2022/07/spring-part-09-bean.html</a><br /></p><div style="text-align: left;"><span class="tm7"><u><b>Note:</b></u><i> </i></span>Will start with Spring core/basic annotations and move towards Spring Boot topic in upcoming demos<br />- Prerequisite: Basic knowledge on Java programming language<br />- Intended for Absolute begineers of Spring/Spring Boot Framework. </div><p class="Normal" style="border: none; font-family: "Basic Roman"; font-size: 10pt; margin: 1pt 0pt;"> </p>Praveen Kumarhttp://www.blogger.com/profile/14705482110609285232noreply@blogger.com0tag:blogger.com,1999:blog-8903620123630625488.post-46788836852426775582017-05-15T20:10:00.000-07:002017-05-15T20:33:47.658-07:00Java - Reading the text content from file with out loop through<div dir="ltr" style="text-align: left;" trbidi="on">
Reading the text content from file with out loop through.<br />
<br />
<u>Sample Program:</u><br />
import java.io.IOException;<br />
import java.nio.charset.Charset;<br />
import java.nio.file.Files;<br />
import java.nio.file.Paths;<br />
<br />
public class ReadFile {<br />
<span style="white-space: pre;"> </span>public static void main(String[] args) throws IOException {<br />
<span style="white-space: pre;"> </span>byte[] encoded = Files.readAllBytes(Paths.get("C:\\filename.txt"));<br />
<span style="white-space: pre;"> </span>String fileContent = new String(encoded, Charset.defaultCharset());<br />
<br />
<span style="white-space: pre;"> </span>System.out.println(fileContent);<br />
<span style="white-space: pre;"> </span>}<br />
}<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-isWZFWHhOEE/WRpscqje1cI/AAAAAAAAEQs/yeOfPEQi_VkjvMQRBTGdPEdnQX__dXBAQCLcB/s1600/1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="311" src="https://1.bp.blogspot.com/-isWZFWHhOEE/WRpscqje1cI/AAAAAAAAEQs/yeOfPEQi_VkjvMQRBTGdPEdnQX__dXBAQCLcB/s400/1.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<b style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15.4px;"><span style="color: #0b5394;"><br /></span></b></div>
<div class="separator" style="clear: both; text-align: left;">
<b style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15.4px;"><span style="color: #0b5394;">Reading the text content from File using 'while' loop.</span></b></div>
<div>
<div>
<u style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15.4px;"><br /></u></div>
<div>
<u style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15.4px;">Sample Program:</u></div>
<div>
import java.io.BufferedReader;</div>
<div>
import java.io.FileReader;</div>
<div>
<br /></div>
<div>
public class Read2File {</div>
<div>
<span style="white-space: pre;"> </span>public static void main(String[] args) {</div>
<div>
<span style="white-space: pre;"> </span>try {</div>
<div>
<span style="white-space: pre;"> </span>FileReader fileReader = new FileReader("C:\\filename.txt");</div>
<div>
<span style="white-space: pre;"> </span>BufferedReader bufferedReader = new BufferedReader(fileReader);</div>
<div>
<span style="white-space: pre;"> </span></div>
<div>
<span style="white-space: pre;"> </span>String fileLine = null;</div>
<div>
<span style="white-space: pre;"> </span>StringBuffer temp = new StringBuffer();</div>
<div>
<span style="white-space: pre;"> </span>while((fileLine = bufferedReader.readLine()) != null) {</div>
<div>
temp.append(fileLine+"\n");</div>
<div>
}</div>
<div>
<span style="white-space: pre;"> </span></div>
<div>
<span style="white-space: pre;"> </span>System.out.println(temp);</div>
<div>
<span style="white-space: pre;"> </span></div>
<div>
<span style="white-space: pre;"> </span>bufferedReader.close();<br />
fileReader.close();</div>
<div>
<span style="white-space: pre;"> </span>}catch (Exception e) {</div>
<div>
<span style="white-space: pre;"> </span>e.printStackTrace();</div>
<div>
<span style="white-space: pre;"> </span>} <span style="white-space: pre;"> </span><span style="white-space: pre;"> </span></div>
<div>
<span style="white-space: pre;"> </span>}</div>
<div>
}</div>
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-DwZZZFBEhJA/WRps64QAFgI/AAAAAAAAEQw/Vhp2JZMTIGEEOrMGQGBKDnjudUoWHmKdACLcB/s1600/2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="197" src="https://3.bp.blogspot.com/-DwZZZFBEhJA/WRps64QAFgI/AAAAAAAAEQw/Vhp2JZMTIGEEOrMGQGBKDnjudUoWHmKdACLcB/s400/2.PNG" width="400" /></a></div>
<div>
<br /></div>
</div>
Praveen Kumarhttp://www.blogger.com/profile/14705482110609285232noreply@blogger.com0tag:blogger.com,1999:blog-8903620123630625488.post-38746237140525185792017-05-01T02:23:00.000-07:002017-05-01T02:24:14.753-07:00Java - Reading the text content(xml/json) with out loop through 'InputStreamReader'<div dir="ltr" style="text-align: left;" trbidi="on">
Reading the text content(xml/json) with out loop through 'InputStreamReader'.<br />
<br />
<b><span style="color: #0b5394;">Prerequisite:</span></b><br />
Requires java 8 to execute below program<br />
<br />
<u>Sample Program:</u><br />
import java.io.BufferedReader;<br />
import java.io.InputStreamReader;<br />
import java.net.HttpURLConnection;<br />
import java.net.URL;<br />
import java.util.stream.Collectors;<br />
<br />
public class Test8WsGet {<br />
<br />
<span style="white-space: pre;"> </span>public static void main(String[] args) {<br />
<span style="white-space: pre;"> </span>try {<br />
<br />
<span style="white-space: pre;"> </span>URL url = new URL("<a href="http://thomas-bayer.com/sqlrest/CUSTOMER/2/" target="_blank">http://thomas-bayer.com/sqlrest/CUSTOMER/2/</a>");<br />
<span style="white-space: pre;"> </span>HttpURLConnection connection = (HttpURLConnection) url.openConnection();<br />
<span style="white-space: pre;"> </span>connection.setRequestMethod("GET");<br />
<span style="white-space: pre;"> </span>connection.setRequestProperty("Accept", "application/json");<br />
<br />
<span style="white-space: pre;"> </span>if (connection.getResponseCode() != 200) {<br />
<span style="white-space: pre;"> </span>throw new RuntimeException("Failed with HTTP error code : " + connection.getResponseCode());<br />
<span style="white-space: pre;"> </span>}<br />
<br />
<span style="white-space: pre;"> </span>String responseXml;<br />
<span style="white-space: pre;"> </span>System.out.println("Response xml from Server .... \n");<br />
<span style="white-space: pre;"> </span><br />
<span style="background-color: #eeeeee;"><span style="white-space: pre;"> </span>BufferedReader bufferReader = new BufferedReader(new InputStreamReader(connection.getInputStream()));</span><br />
<span style="background-color: #cccccc;"><span style="white-space: pre;"> </span>responseXml = bufferReader.lines().collect(Collectors.joining("\n"));</span><br />
<span style="white-space: pre;"> </span><br />
<span style="white-space: pre;"> </span>System.out.println(responseXml);<br />
<span style="white-space: pre;"> </span><br />
<span style="white-space: pre;"> </span>connection.disconnect();<br />
<span style="white-space: pre;"> </span>} catch (Exception e) {<br />
<span style="white-space: pre;"> </span>e.printStackTrace();<br />
<br />
<span style="white-space: pre;"> </span>}<br />
<span style="white-space: pre;"> </span>}<br />
}<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-N18ZCSMMIkg/WQb5sBek4yI/AAAAAAAAEQY/BeUoD6FkrD8oGI_spyKaEd38vjzMmgniACLcB/s1600/1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="207" src="https://4.bp.blogspot.com/-N18ZCSMMIkg/WQb5sBek4yI/AAAAAAAAEQY/BeUoD6FkrD8oGI_spyKaEd38vjzMmgniACLcB/s400/1.PNG" width="400" /></a></div>
<u>Troubleshooting :</u><br />
If you are executing above program using maven(i.e. pom.xml) then add below maven-compiler-plugin<br />
<i>Reference:</i> <a href="https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html" target="_blank">https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html</a><br />
<plugins><br />
<plugin><br />
<groupId>org.apache.maven.plugins</groupId><br />
<artifactId>maven-compiler-plugin</artifactId><br />
<version>3.6.1</version><br />
<configuration><br />
<source>1.8</source><br />
<target>1.8</target><br />
</configuration><br />
</plugin><br />
</plugins><br />
<br />
<span style="white-space: pre;"> </span><span style="white-space: pre;"> </span><br />
<b><span style="color: #0b5394;">Reading the text content(xml/json) from 'InputStreamReader' using 'while' loop.</span></b><br />
<u><br /></u>
<u>Sample Program:</u><br />
import java.io.BufferedReader;<br />
import java.io.InputStreamReader;<br />
import java.net.HttpURLConnection;<br />
import java.net.URL;<br />
<br />
public class TestWsGet {<br />
<br />
<span style="white-space: pre;"> </span>public static void main(String[] args) {<br />
<span style="white-space: pre;"> </span>try {<br />
<br />
<span style="white-space: pre;"> </span>URL url = new URL("<a href="http://thomas-bayer.com/sqlrest/CUSTOMER/2/" target="_blank">http://thomas-bayer.com/sqlrest/CUSTOMER/2/</a>");<br />
<span style="white-space: pre;"> </span>HttpURLConnection connection = (HttpURLConnection) url.openConnection();<br />
<span style="white-space: pre;"> </span>connection.setRequestMethod("GET");<br />
<span style="white-space: pre;"> </span>connection.setRequestProperty("Accept", "application/json");<br />
<br />
<span style="white-space: pre;"> </span>if (connection.getResponseCode() != 200) {<br />
<span style="white-space: pre;"> </span>throw new RuntimeException("Failed with HTTP error code : " + connection.getResponseCode());<br />
<span style="white-space: pre;"> </span>}<br />
<br />
<span style="white-space: pre;"> </span>String responseXml;<br />
<span style="white-space: pre;"> </span>System.out.println("Response xml from Server .... \n");<br />
<span style="white-space: pre;"> </span><br />
<span style="white-space: pre;"> </span><span style="background-color: #eeeeee;">BufferedReader br = new BufferedReader(new InputStreamReader((connection.getInputStream())));</span><br />
<span style="background-color: #cccccc;"><span style="white-space: pre;"> </span>while ((responseXml = br.readLine()) != null) {</span><br />
<span style="background-color: #cccccc;"><span style="white-space: pre;"> </span>System.out.println(responseXml);</span><br />
<span style="background-color: #cccccc;"><span style="white-space: pre;"> </span>}</span><br />
<span style="white-space: pre;"> </span><br />
<span style="white-space: pre;"> </span>connection.disconnect();<br />
<span style="white-space: pre;"> </span>} catch (Exception e) {<br />
<span style="white-space: pre;"> </span>e.printStackTrace();<br />
<span style="white-space: pre;"> </span>}<br />
<span style="white-space: pre;"> </span>}<br />
}<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-hLxHhtiEMRA/WQb53B6HfwI/AAAAAAAAEQc/d2SRz0NX_gsisQ8ArzwkZDwZHftp5hSXQCLcB/s1600/2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="195" src="https://4.bp.blogspot.com/-hLxHhtiEMRA/WQb53B6HfwI/AAAAAAAAEQc/d2SRz0NX_gsisQ8ArzwkZDwZHftp5hSXQCLcB/s400/2.PNG" width="400" /></a></div>
<br />
<span style="white-space: pre;"> </span></div>
Praveen Kumarhttp://www.blogger.com/profile/14705482110609285232noreply@blogger.com0tag:blogger.com,1999:blog-8903620123630625488.post-23405438571364659522017-01-07T12:39:00.001-08:002020-11-16T03:16:38.565-08:00VBScripts Fundamentals - Part1<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: center;">
<b> </b><br />
<span style="color: #0b5394;"><b>Using concatenate, "&_" and "vbcrlf" in VB Script</b></span><br />
<br />
<b>Watch Video</b></div>
<iframe allowfullscreen="" frameborder="0" height="360" mozallowfullscreen="" src="https://player.vimeo.com/video/198498867" webkitallowfullscreen="" width="640"></iframe>
<span style="color: #0b5394;"><b> </b></span><br />
<span style="color: #0b5394;"><b>Prerequisite:</b></span><br />
<a href="http://automation-home.blogspot.com/2017/01/vb-script-basic-example.html" target="_blank"><span style="color: #0b5394;">http://automation-home.blogspot.in/2017/01/vb-script-basic-example.html</span></a><br />
<span style="color: #0b5394;"><b> </b></span> <br />
<span style="color: #0b5394;"><b>Using concatenate, "&_" and "vbcrlf" in VB Script</b></span><br />
- Concatenate using plus sign(+) and ampersand (&).<br />
<br />
- String in multiple lines using "&_" and ''+_''.<br />
ex: Sql query as string<br />
<br />
- To print in different lines use "vbcrlf" (it is like '\n').<br />
ex: "Hello welcome" --> "Hello" &vbcrlf& "welcome"<br />
<i>References:</i> <a href="http://powerasp.net/content/new/vbscript-constants.asp" target="_blank">http://powerasp.net/content/new/vbscript-constants.asp </a><br />
<a href="http://www.asciitable.com/" target="_blank">http://www.asciitable.com/</a></div>
Praveen Kumarhttp://www.blogger.com/profile/14705482110609285232noreply@blogger.com0tag:blogger.com,1999:blog-8903620123630625488.post-83915562782730970932017-01-05T17:04:00.000-08:002017-01-05T17:04:33.180-08:00VB Script Basic Example<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: center;">
<b>Watch Video</b></div>
<iframe allowfullscreen="" frameborder="0" height="359" mozallowfullscreen="" src="https://player.vimeo.com/video/198279750" webkitallowfullscreen="" width="640"></iframe>
<br />
<br />
<span style="color: #0b5394;"><b>Writing the VB Script</b></span> in<br />
- Notepad<br />
- Notepad++<br />
<a href="https://notepad-plus-plus.org/download/v7.3.html" target="_blank">https://notepad-plus-plus.org/download/v7.3.html</a><br />
- VbsEdit<br />
<a href="http://www.vbsedit.com/" target="_blank">http://www.vbsedit.com/</a><br />
<br />
<span style="color: #0b5394;"><b>Saving the file</b></span><br />
Save the file as <<File Name>><b>.vbs</b><br />
<br />
<span style="color: #0b5394;"><b>Execution the VB Script.</b></span><br />
- Command Prompt<br />
- Editor<br />
- Double click on VB Script file </div>
Praveen Kumarhttp://www.blogger.com/profile/14705482110609285232noreply@blogger.com0tag:blogger.com,1999:blog-8903620123630625488.post-63582067121668831522016-12-31T09:21:00.001-08:002016-12-31T09:34:40.368-08:00C# Xamarin Studio - SpecFlow configuration, creating sample feature file, step defintion and execution. <div dir="ltr" style="text-align: left;" trbidi="on">
<span style="color: #0b5394;"><b>Prerequisite:</b></span><br />
Download and install latest version of Xamarin Studio from <a href="http://www.monodevelop.com/download/" target="_blank">http://www.monodevelop.com/download/</a><br />
<br />
<div style="text-align: center;">
Download SpecFlow addin for Xamarin Studio 6 from</div>
<div style="text-align: center;">
<a href="https://github.com/mikeyjones/SpecFlow" target="_blank">https://github.com/mikeyjones/SpecFlow</a><br />
<a href="https://github.com/mikeyjones/SpecFlow/releases/download/v1.9.2/TechTalk.SpecFlow.TechTalk.SpecFlow_1.9.1.0.mpack" target="_blank">https://github.com/mikeyjones/SpecFlow/releases/download/v1.9.2/TechTalk.SpecFlow.TechTalk.SpecFlow_1.9.1.0.mpack</a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-rRfffUCoJUo/WGfUAzqtpEI/AAAAAAAAENM/2pKD5W0LWvkuK7mgIF2LkvvO82Jh3wh6ACLcB/s1600/1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="65" src="https://4.bp.blogspot.com/-rRfffUCoJUo/WGfUAzqtpEI/AAAAAAAAENM/2pKD5W0LWvkuK7mgIF2LkvvO82Jh3wh6ACLcB/s400/1.PNG" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
Xamarin Studio addin for SpecFlow is downloaded.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-BAhzQ9iEAeg/WGfT8MVw_3I/AAAAAAAAENI/M_L0GSf2SToxoxjlV_xCjsUYaqIwyc2YgCLcB/s1600/2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="280" src="https://2.bp.blogspot.com/-BAhzQ9iEAeg/WGfT8MVw_3I/AAAAAAAAENI/M_L0GSf2SToxoxjlV_xCjsUYaqIwyc2YgCLcB/s400/2.PNG" width="400" /></a></div>
<br />
<div style="text-align: center;">
Open the Xamarin Studio and </div>
<div style="text-align: center;">
select 'Tools' -> 'Add-ins' </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-yB-x2VgJWKY/WGfUSLFSnII/AAAAAAAAENQ/6RKGfVh3D7oOVjZRd2MB-RI0uhV4FcDeACLcB/s1600/3.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="111" src="https://4.bp.blogspot.com/-yB-x2VgJWKY/WGfUSLFSnII/AAAAAAAAENQ/6RKGfVh3D7oOVjZRd2MB-RI0uhV4FcDeACLcB/s320/3.PNG" width="320" /></a></div>
<div style="text-align: center;">
<br />
Click 'Install from file' button.</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-KvX6pJne5mA/WGfUgqCJLsI/AAAAAAAAENU/DWBqpUQoqbM9mBwrvp8EVFFf5UX_Bqw9wCLcB/s1600/4.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="297" src="https://4.bp.blogspot.com/-KvX6pJne5mA/WGfUgqCJLsI/AAAAAAAAENU/DWBqpUQoqbM9mBwrvp8EVFFf5UX_Bqw9wCLcB/s400/4.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Open the location of file downloaded(i.e. specflow addin file '<i>TechTalk.SpecFlow.TechTalk.SpecFlow_1.9.1.0.mpack</i>')</div>
<div style="text-align: center;">
Click 'Open' button.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-dS0WBcV0DbA/WGfVbDsY5eI/AAAAAAAAENo/4JYo3TcysMggOv1-wJ_L3jb-T7Rqx-Q4gCLcB/s1600/5.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="317" src="https://2.bp.blogspot.com/-dS0WBcV0DbA/WGfVbDsY5eI/AAAAAAAAENo/4JYo3TcysMggOv1-wJ_L3jb-T7Rqx-Q4gCLcB/s400/5.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Click 'Install' button.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-cbquq8rBu54/WGfVlIZ-kXI/AAAAAAAAENs/Q8-IF-HugXIzsryfGe4Rg5KAFWzJqMfqwCLcB/s1600/6.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="296" src="https://1.bp.blogspot.com/-cbquq8rBu54/WGfVlIZ-kXI/AAAAAAAAENs/Q8-IF-HugXIzsryfGe4Rg5KAFWzJqMfqwCLcB/s400/6.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-bzs93aArMkA/WGfUzMBRrII/AAAAAAAAENc/TLK3oRI7OyICUik0YrKEtOPHr7W74z2VwCLcB/s1600/7.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="207" src="https://4.bp.blogspot.com/-bzs93aArMkA/WGfUzMBRrII/AAAAAAAAENc/TLK3oRI7OyICUik0YrKEtOPHr7W74z2VwCLcB/s400/7.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-fnofMYfmIS4/WGfU2HvuUPI/AAAAAAAAENg/06KdlCcEQpoZWGk_EPv4RH1F_neyNF9jQCLcB/s1600/8.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="202" src="https://4.bp.blogspot.com/-fnofMYfmIS4/WGfU2HvuUPI/AAAAAAAAENg/06KdlCcEQpoZWGk_EPv4RH1F_neyNF9jQCLcB/s400/8.PNG" width="400" /></a></div>
<br />
<div style="text-align: center;">
Open the Xamarin Studio, Create the new solution</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-kalSC3IJNBs/WGfVwpVLUhI/AAAAAAAAENw/zFKjZluc-V0U9VEq_ycZrCb0vfASQFQ0ACLcB/s1600/9.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://1.bp.blogspot.com/-kalSC3IJNBs/WGfVwpVLUhI/AAAAAAAAENw/zFKjZluc-V0U9VEq_ycZrCb0vfASQFQ0ACLcB/s400/9.PNG" width="316" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
New Project dialog is opened, <br />
select '<i>Other > Miscellaneous > General > SpecFlow NUnit Library Project</i>' to select SpecFlow template for project.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-RHLa3FmWWuY/WGfV39ZOT7I/AAAAAAAAEN0/fP2KyHyzSf8vbhEXNLgefJQ_cT9BOCSXgCLcB/s1600/10.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="292" src="https://4.bp.blogspot.com/-RHLa3FmWWuY/WGfV39ZOT7I/AAAAAAAAEN0/fP2KyHyzSf8vbhEXNLgefJQ_cT9BOCSXgCLcB/s400/10.PNG" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
Enter project name and click 'Create' button.<br />
ex- project name: FirstSpecFlowTest </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-leXhQGRCWZQ/WGfWEz8QvpI/AAAAAAAAEN4/T6-vJeEKuLkFDU-Yi8apfqqd7xL9ch-OwCLcB/s1600/11.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="292" src="https://3.bp.blogspot.com/-leXhQGRCWZQ/WGfWEz8QvpI/AAAAAAAAEN4/T6-vJeEKuLkFDU-Yi8apfqqd7xL9ch-OwCLcB/s400/11.PNG" width="400" /></a></div>
<div style="text-align: center;">
</div>
<div style="text-align: center;">
Feature file is created(i.e. default feature file is created)</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-Z1Tt5OnjMIA/WGfWM4cl0uI/AAAAAAAAEN8/J1P5XKy4CE0AM19Kr25pR2INwVxkIwO0QCLcB/s1600/12.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="201" src="https://1.bp.blogspot.com/-Z1Tt5OnjMIA/WGfWM4cl0uI/AAAAAAAAEN8/J1P5XKy4CE0AM19Kr25pR2INwVxkIwO0QCLcB/s400/12.PNG" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
Select '<i>View</i>' -> '<i>Design</i>' to view solution explorer.</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-if8KjjNucJQ/WGfWWGuytCI/AAAAAAAAEOE/VACm-EUzQDoeqlFfQq262vsa7Af_AzTsQCLcB/s1600/13.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://4.bp.blogspot.com/-if8KjjNucJQ/WGfWWGuytCI/AAAAAAAAEOE/VACm-EUzQDoeqlFfQq262vsa7Af_AzTsQCLcB/s400/13.PNG" width="340" /></a> </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-YAkCURqeKzY/WGfWm05baCI/AAAAAAAAEOI/cFV982ZWiI8TW-LfYLlQIrLjNHhT1opvQCLcB/s1600/14.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="180" src="https://1.bp.blogspot.com/-YAkCURqeKzY/WGfWm05baCI/AAAAAAAAEOI/cFV982ZWiI8TW-LfYLlQIrLjNHhT1opvQCLcB/s400/14.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Add package '<i>Xamarin.UITest</i>' from Nuget package to the project. </div>
Search for '<i>Xamarin.UITest</i>', select checkbox for 'Xamarin.UITest' and click 'Add Package'. <br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-AY0mGqPJBQo/WGfXDhLLhXI/AAAAAAAAEOM/DzSvZjYLZZUAFwvgBBFCq55ThJr7raKxQCLcB/s1600/15.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://2.bp.blogspot.com/-AY0mGqPJBQo/WGfXDhLLhXI/AAAAAAAAEOM/DzSvZjYLZZUAFwvgBBFCq55ThJr7raKxQCLcB/s400/15.PNG" width="363" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-SVM4Efo6SLg/WGfXJpgmnQI/AAAAAAAAEOQ/p2j0bK5Nh5gDU3GBNwoMQzRnQrkUFrbYgCLcB/s1600/16.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="266" src="https://1.bp.blogspot.com/-SVM4Efo6SLg/WGfXJpgmnQI/AAAAAAAAEOQ/p2j0bK5Nh5gDU3GBNwoMQzRnQrkUFrbYgCLcB/s400/16.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
'Xamarin.UITest' is installed and added to project package.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-6wfKgYaDjHQ/WGfXX6lfw_I/AAAAAAAAEOY/fSIUw9caUokAw0saLBGM8TPEWNezm2LmwCLcB/s1600/17.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://3.bp.blogspot.com/-6wfKgYaDjHQ/WGfXX6lfw_I/AAAAAAAAEOY/fSIUw9caUokAw0saLBGM8TPEWNezm2LmwCLcB/s400/17.PNG" width="247" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-06vHP3c9klw/WGfXcncJZQI/AAAAAAAAEOc/5C18oPrJwBIEiT5d93rCl-TI7CsH_RISQCLcB/s1600/18.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://3.bp.blogspot.com/-06vHP3c9klw/WGfXcncJZQI/AAAAAAAAEOc/5C18oPrJwBIEiT5d93rCl-TI7CsH_RISQCLcB/s400/18.PNG" width="250" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Select 'View' -> 'Test' to open 'Unit Test Window'</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-3iRf2TwKksY/WGfXk0ognSI/AAAAAAAAEOg/-y0UyHB282I9AtUFySk7O5ETBSmhgOxhQCLcB/s1600/19.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://4.bp.blogspot.com/-3iRf2TwKksY/WGfXk0ognSI/AAAAAAAAEOg/-y0UyHB282I9AtUFySk7O5ETBSmhgOxhQCLcB/s400/19.PNG" width="351" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
If 'Unit Test' pad is not opened, then select 'View' -> 'Pads' -> 'Unit Tests' to view 'Unit Test' pad.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-BbobEmnH4jA/WGfXsccx5FI/AAAAAAAAEOk/ApShNuc-luoROXxQI2LLrnJKVkjHhNfCACLcB/s1600/20.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="295" src="https://3.bp.blogspot.com/-BbobEmnH4jA/WGfXsccx5FI/AAAAAAAAEOk/ApShNuc-luoROXxQI2LLrnJKVkjHhNfCACLcB/s400/20.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Two files are present(i.e. created) </div>
<div style="text-align: center;">
<i>Test.feature</i> -> Feature file</div>
<div style="text-align: center;">
<i>TestSteps.cs</i> -> Step definitions file</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-fW5Uv4DIi8k/WGfY0e7bLFI/AAAAAAAAEOw/UIlDocMD46gmbZg9_Hdrbrnsb4AdFWBUgCLcB/s1600/22.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="165" src="https://1.bp.blogspot.com/-fW5Uv4DIi8k/WGfY0e7bLFI/AAAAAAAAEOw/UIlDocMD46gmbZg9_Hdrbrnsb4AdFWBUgCLcB/s400/22.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-kPRw-G_Hs-c/WGfY5jJBiCI/AAAAAAAAEO0/V24veRTlIBMsQG_JM9Kcz-eS6WfsUeEGgCLcB/s1600/22_1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="350" src="https://1.bp.blogspot.com/-kPRw-G_Hs-c/WGfY5jJBiCI/AAAAAAAAEO0/V24veRTlIBMsQG_JM9Kcz-eS6WfsUeEGgCLcB/s400/22_1.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Build Project</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-srBHPZbkxXs/WGfZKqCOOQI/AAAAAAAAEO4/LFx3ZpX7ai8NlRmDBRARDDhjoM1hnB-mQCLcB/s1600/23.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="301" src="https://2.bp.blogspot.com/-srBHPZbkxXs/WGfZKqCOOQI/AAAAAAAAEO4/LFx3ZpX7ai8NlRmDBRARDDhjoM1hnB-mQCLcB/s400/23.PNG" width="400" /></a> </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-TEYAw6YMebo/WGfZPc_iFaI/AAAAAAAAEO8/7fZyz-GrmEgquZ73ZAOJgUQb1cnloJ7bACLcB/s1600/24.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="155" src="https://1.bp.blogspot.com/-TEYAw6YMebo/WGfZPc_iFaI/AAAAAAAAEO8/7fZyz-GrmEgquZ73ZAOJgUQb1cnloJ7bACLcB/s400/24.PNG" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
Run Test in 'Unit Test'</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-YzFh8kL3DwY/WGfZbs8EBwI/AAAAAAAAEPA/-w0ITXXydVMkyl720csmisyogvkrB1bKACLcB/s1600/25.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="228" src="https://1.bp.blogspot.com/-YzFh8kL3DwY/WGfZbs8EBwI/AAAAAAAAEPA/-w0ITXXydVMkyl720csmisyogvkrB1bKACLcB/s400/25.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Test Result</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-qzMVV3F1jDk/WGfZjTipCRI/AAAAAAAAEPE/wCQq1F5E2IwecHowoMbGmcIfmLgnETCMACLcB/s1600/26.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="241" src="https://4.bp.blogspot.com/-qzMVV3F1jDk/WGfZjTipCRI/AAAAAAAAEPE/wCQq1F5E2IwecHowoMbGmcIfmLgnETCMACLcB/s400/26.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Add Console.Writeline(....) in step definition methods.</div>
<div style="text-align: center;">
<i><u>Note:</u></i> Console.Writeline(...) is added for only test demo purpose, in real time there will be some logic/implementation is added instead of Console.Writeline(...) in step definition methods.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-hMftZH2vhhU/WGfZ3IBK8pI/AAAAAAAAEPI/ahEsQzmcBrUbq-H2eIApBULZUzZStO9QgCLcB/s1600/27.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="176" src="https://1.bp.blogspot.com/-hMftZH2vhhU/WGfZ3IBK8pI/AAAAAAAAEPI/ahEsQzmcBrUbq-H2eIApBULZUzZStO9QgCLcB/s400/27.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Build the project and run the test again </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-0EVMPWqelb0/WGfaErYKIyI/AAAAAAAAEPM/DPhLFAaZYLAF_SYN_WNLrN32Yx16sDwpACLcB/s1600/28.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="206" src="https://4.bp.blogspot.com/-0EVMPWqelb0/WGfaErYKIyI/AAAAAAAAEPM/DPhLFAaZYLAF_SYN_WNLrN32Yx16sDwpACLcB/s400/28.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Open the '<i>Application Output</i>', by selecting 'View' -> 'Pads' -> 'Application Output'</div>
View the output of Console.Writeline(....) in 'Application Output' <br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-0FZxY63CCiA/WGfabo8I6lI/AAAAAAAAEPQ/NuqvK7pkEE4dYA56bKsb8Fk5uPIxwpLVACLcB/s1600/29.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="298" src="https://4.bp.blogspot.com/-0FZxY63CCiA/WGfabo8I6lI/AAAAAAAAEPQ/NuqvK7pkEE4dYA56bKsb8Fk5uPIxwpLVACLcB/s400/29.PNG" width="400" /></a> </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-xbDTILIjHo4/WGfagv-9BHI/AAAAAAAAEPU/Md1spAn6lW8HmySaXqaFSuzaJ3nzz_YQgCLcB/s1600/30.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="186" src="https://3.bp.blogspot.com/-xbDTILIjHo4/WGfagv-9BHI/AAAAAAAAEPU/Md1spAn6lW8HmySaXqaFSuzaJ3nzz_YQgCLcB/s400/30.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<i>References: </i> </div>
<div class="separator" style="clear: both; text-align: left;">
<a href="http://arteksoftware.com/bdd-tests-with-xamarin-uitest-and-specflow/" rel="" target="_blank">http://arteksoftware.com/bdd-tests-with-xamarin-uitest-and-specflow/</a></div>
</div>
Praveen Kumarhttp://www.blogger.com/profile/14705482110609285232noreply@blogger.com0tag:blogger.com,1999:blog-8903620123630625488.post-6927382621087184942016-12-31T01:33:00.001-08:002020-11-16T03:17:18.132-08:00C# Visual Studio - SpecFlow Step Definition file<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="color: #0b5394;"><b><span data-dobid="hdw">Prerequisite:</span></b></span><br />
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">Feature file is already created.<br />Creating the feature file: <a href="https://automation-home.blogspot.com/2016/12/c-visual-studio-specflow-feature-file.html" target="_blank">https://automation-home.blogspot.com/2016/12/c-visual-studio-specflow-feature-file.html</a></span></span></span><br />
<br />
<div style="text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">Create the class for step defintions</span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-lNEXcJqK1n4/WGdrNrDq_BI/AAAAAAAAEKk/l9tRDJkGoEg3F9Le699TMTVNqFwswDRQQCLcB/s1600/1.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="https://3.bp.blogspot.com/-lNEXcJqK1n4/WGdrNrDq_BI/AAAAAAAAEKk/l9tRDJkGoEg3F9Le699TMTVNqFwswDRQQCLcB/s400/1.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Enter the class name and click 'Add' button.</div>
<div style="text-align: center;">
ex: SampleFirstFeatureSteps.cs </div>
As a best practice, follow file name ends with 'Steps' <<FileName>>Steps.cs <br />
<div style="text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"></span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-seS6sso-gzA/WGdrpq3QB5I/AAAAAAAAEKo/YugVS6bIccUPoBEEXgB_M62TjEOMXr37ACLcB/s1600/2.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="245" src="https://4.bp.blogspot.com/-seS6sso-gzA/WGdrpq3QB5I/AAAAAAAAEKo/YugVS6bIccUPoBEEXgB_M62TjEOMXr37ACLcB/s400/2.PNG" width="400" /></a></div>
<b><span data-dobid="hdw"> </span></b><br />
<div style="text-align: center;">
</div>
<div style="text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">Class file for step definitions is created. </span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-GuLx6tr6QOA/WGdr0L81-BI/AAAAAAAAEKs/nDreCeZgSaE-5_j8ZEQPbbgObqHmSyMAQCLcB/s1600/3.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="218" src="https://4.bp.blogspot.com/-GuLx6tr6QOA/WGdr0L81-BI/AAAAAAAAEKs/nDreCeZgSaE-5_j8ZEQPbbgObqHmSyMAQCLcB/s400/3.PNG" width="400" /></a></div>
<div style="text-align: center;">
<span style="color: #0b5394;"><b><span data-dobid="hdw"><br /></span></b></span></div>
<div style="text-align: center;">
<span style="color: #0b5394;"><span data-dobid="hdw"><span style="color: black;">Mouse right click on step in feature file and select the 'Generate Step Definitions'.</span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/--7Krc4_hKZk/WGdsDTLYwyI/AAAAAAAAEK0/wVAGydyzDjIMbBfBgETxOr98Ch-O1z4XACLcB/s1600/4.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://1.bp.blogspot.com/--7Krc4_hKZk/WGdsDTLYwyI/AAAAAAAAEK0/wVAGydyzDjIMbBfBgETxOr98Ch-O1z4XACLcB/s400/4.PNG" width="353" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<span style="color: #0b5394;"><span data-dobid="hdw"><span style="color: black;">Click 'Preview' button.</span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-BFGfKZkPFoM/WGdsMUddTwI/AAAAAAAAEK4/Fo3wfRUAVj0ugJ-6ksT57dX28Qgbsos_wCLcB/s1600/4_1.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="336" src="https://2.bp.blogspot.com/-BFGfKZkPFoM/WGdsMUddTwI/AAAAAAAAEK4/Fo3wfRUAVj0ugJ-6ksT57dX28Qgbsos_wCLcB/s400/4_1.PNG" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<span style="color: #0b5394;"><span data-dobid="hdw"><span style="color: black;">Step definition skeleton preview is displayed, close the preview.</span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-AIl2ZoGFUyk/WGdsTgXskoI/AAAAAAAAELA/p5ZmWABHrCEUzhUrPe4B5mqUHl_V5at3gCLcB/s1600/4_2.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="385" src="https://1.bp.blogspot.com/-AIl2ZoGFUyk/WGdsTgXskoI/AAAAAAAAELA/p5ZmWABHrCEUzhUrPe4B5mqUHl_V5at3gCLcB/s400/4_2.PNG" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<span style="color: #0b5394;"><span data-dobid="hdw"><span style="color: black;">Copy the methods(i.e. step definitions methods)</span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-y26c1Cg2hxA/WGdsZ-h4MUI/AAAAAAAAELI/tP7kv5WOlYct-qAERU-roj5CmdpvTQSPwCLcB/s1600/4_3.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="https://2.bp.blogspot.com/-y26c1Cg2hxA/WGdsZ-h4MUI/AAAAAAAAELI/tP7kv5WOlYct-qAERU-roj5CmdpvTQSPwCLcB/s400/4_3.PNG" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<span style="color: #0b5394;"><span data-dobid="hdw"><span style="color: black;">Open the step definitions class file(i.e. 'SampleFirstFeatureSteps.cs'),<br /> paste the methods(i.e. step definitions) in class </span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-agUa-nQds-s/WGdslWAN4GI/AAAAAAAAELM/3ew-3kJw2DYK_GWpv6vigMrHFSnVN7SjACLcB/s1600/5.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://1.bp.blogspot.com/-agUa-nQds-s/WGdslWAN4GI/AAAAAAAAELM/3ew-3kJw2DYK_GWpv6vigMrHFSnVN7SjACLcB/s400/5.PNG" width="303" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<span style="color: #0b5394;"><span data-dobid="hdw"><span style="color: black;">Since references are missing, shows compilation error for the methods.</span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-30bofojBZoE/WGds4m1TZuI/AAAAAAAAELU/IQRs5kUqBRMHkKXUHCJJofZtP8wSDMlBgCLcB/s1600/5_1.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="312" src="https://3.bp.blogspot.com/-30bofojBZoE/WGds4m1TZuI/AAAAAAAAELU/IQRs5kUqBRMHkKXUHCJJofZtP8wSDMlBgCLcB/s400/5_1.PNG" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<span style="color: #0b5394;"><span data-dobid="hdw"><span style="color: black;">Add the missing references by clicking (Ctrl+.) </span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-PBVjTvrPKJ0/WGdtIeyP42I/AAAAAAAAELc/Vgw4mp0I8JkQeEhduf-mrrctFlUXCUemgCLcB/s1600/5_2.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="160" src="https://4.bp.blogspot.com/-PBVjTvrPKJ0/WGdtIeyP42I/AAAAAAAAELc/Vgw4mp0I8JkQeEhduf-mrrctFlUXCUemgCLcB/s400/5_2.PNG" width="400" /></a></div>
<div style="text-align: center;">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-6n0TBX-KKTw/WGdtZCvW4ZI/AAAAAAAAELk/D7HLZs9hLLAWz20NN315k3UXylhkn38NACLcB/s1600/5_3.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://2.bp.blogspot.com/-6n0TBX-KKTw/WGdtZCvW4ZI/AAAAAAAAELk/D7HLZs9hLLAWz20NN315k3UXylhkn38NACLcB/s400/5_3.PNG" width="396" /></a></div>
<span style="color: #0b5394;"><span data-dobid="hdw"><span style="color: black;"></span></span></span>
<div class="separator" style="clear: both; text-align: center;">
<span style="color: #0b5394;"><span data-dobid="hdw"><span style="color: black;"><a href="https://3.bp.blogspot.com/-omIUhYDxiWg/WGdtf-MMfpI/AAAAAAAAELo/itU9SxZ9ZE8pM78Nby4GF4WsrU_eGJJYwCLcB/s1600/5_4.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://3.bp.blogspot.com/-omIUhYDxiWg/WGdtf-MMfpI/AAAAAAAAELo/itU9SxZ9ZE8pM78Nby4GF4WsrU_eGJJYwCLcB/s400/5_4.PNG" width="352" /></a></span></span></span></div>
<span style="color: #0b5394;"><b><span data-dobid="hdw"><br /></span></b></span>
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">Open the feature file, right click on the step and select 'Go To Definition'.</span></span></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-v2mX0-5pM0w/WGdttUXFhMI/AAAAAAAAELw/BbehDu4m760Adw8BauO4JzquggiWnr2NACLcB/s1600/6.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="275" src="https://1.bp.blogspot.com/-v2mX0-5pM0w/WGdttUXFhMI/AAAAAAAAELw/BbehDu4m760Adw8BauO4JzquggiWnr2NACLcB/s400/6.PNG" width="400" /></a></div>
<br />
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">Click 'No' button to close.</span></span></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-PaQNhLJGGT0/WGdt22LdTFI/AAAAAAAAEL4/3M1i0VVHevQCcFowSeiUgGMLxTgAvI0eACLcB/s1600/6_1.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="351" src="https://3.bp.blogspot.com/-PaQNhLJGGT0/WGdt22LdTFI/AAAAAAAAEL4/3M1i0VVHevQCcFowSeiUgGMLxTgAvI0eACLcB/s400/6_1.PNG" width="400" /></a></div>
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"> There is no binding between Feature file and Step Definitions.</span></span></span></span></span></span><br />
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">Since there is no binding<span style="color: #0b5394;"> <span style="color: black;">above dialog window is displayed.</span></span></span></span></span></span></span></span><br />
<br />
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;">Add the attribute [Binding] for class in Step Definition file.</span></span></span></span></span></span></span></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-atNOVWD5dng/WGduv0MdvmI/AAAAAAAAEME/x__RRrJotPMcxMA3fZhWjcrW6Nitoe9tgCLcB/s1600/7.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="173" src="https://2.bp.blogspot.com/-atNOVWD5dng/WGduv0MdvmI/AAAAAAAAEME/x__RRrJotPMcxMA3fZhWjcrW6Nitoe9tgCLcB/s400/7.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="color: #0b5394;"><span data-dobid="hdw"><span style="color: #0b5394;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><a href="https://4.bp.blogspot.com/-DwBQLopE0_E/WGdu4MbGqTI/AAAAAAAAEMI/I2HJdF-2R2onhN8XmL52byH8IRi8Bnp9ACLcB/s1600/7_1.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="251" src="https://4.bp.blogspot.com/-DwBQLopE0_E/WGdu4MbGqTI/AAAAAAAAEMI/I2HJdF-2R2onhN8XmL52byH8IRi8Bnp9ACLcB/s400/7_1.PNG" width="400" /></a></span></span></span></span></span></span></div>
<br />
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;">Remove Unncessary Usings.</span></span></span></span></span></span></span></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-7VlH0wbtdds/WGdvFHMNbnI/AAAAAAAAEMQ/ihp2vAdWfv0grPMno9L_8_c_wUz6nL2ZACLcB/s1600/8.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="120" src="https://1.bp.blogspot.com/-7VlH0wbtdds/WGdvFHMNbnI/AAAAAAAAEMQ/ihp2vAdWfv0grPMno9L_8_c_wUz6nL2ZACLcB/s400/8.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-Ui01RJjv1CU/WGdvP3T-wFI/AAAAAAAAEMU/ruNU02JpmQgqGoebJSyUtFzGFEu9QDRMwCLcB/s1600/8_1.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="193" src="https://3.bp.blogspot.com/-Ui01RJjv1CU/WGdvP3T-wFI/AAAAAAAAEMU/ruNU02JpmQgqGoebJSyUtFzGFEu9QDRMwCLcB/s400/8_1.PNG" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
Observe the colour for steps in feature file, before and after adding <b>[Binding]</b> attribute for Step Definition class.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-vP8tJoJPAXE/WGdvdHGCp8I/AAAAAAAAEMc/nNfo6sf4V-Uxcufi-FHEq0ZCA2d7WsxZACLcB/s1600/8_2.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://1.bp.blogspot.com/-vP8tJoJPAXE/WGdvdHGCp8I/AAAAAAAAEMc/nNfo6sf4V-Uxcufi-FHEq0ZCA2d7WsxZACLcB/s400/8_2.png" width="363" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
Open the Feature file, mouse over on the step right click and select 'Go To Definition'.</div>
This time when 'Go To Definition' is selected, Steps defintion file is opened(i.e Binding of feature file and step defintion file is successfull).<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-N3AsRAhe_5c/WGdv0Zx9QmI/AAAAAAAAEMk/0ama_pMfrqgW6Qx5mPZ56QJLyACksXoFACLcB/s1600/8_3.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="198" src="https://2.bp.blogspot.com/-N3AsRAhe_5c/WGdv0Zx9QmI/AAAAAAAAEMk/0ama_pMfrqgW6Qx5mPZ56QJLyACksXoFACLcB/s400/8_3.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
As a best practice place the feature file in 'Features' folder and step definitions file in 'Step_Definitions' folder.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-wyTO_HC5Vzg/WGdv_jvXyrI/AAAAAAAAEMo/_KRqB0TAf9UUuaWegct5YO3B3zwwWM5yQCLcB/s1600/9.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="206" src="https://4.bp.blogspot.com/-wyTO_HC5Vzg/WGdv_jvXyrI/AAAAAAAAEMo/_KRqB0TAf9UUuaWegct5YO3B3zwwWM5yQCLcB/s400/9.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-_uYTRvXHsKE/WGdwJ1NnNyI/AAAAAAAAEMw/P9FbPWRmNuIjNSdTNAnnkLB6Z8EqDybTACLcB/s1600/9_1.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://3.bp.blogspot.com/-_uYTRvXHsKE/WGdwJ1NnNyI/AAAAAAAAEMw/P9FbPWRmNuIjNSdTNAnnkLB6Z8EqDybTACLcB/s400/9_1.PNG" width="375" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-_gbanuc1jmk/WGdwQjKYUPI/AAAAAAAAEM0/QfOUUZcMfl0WEn6frj0bIuamjxV-jYTSQCLcB/s1600/9_2.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://1.bp.blogspot.com/-_gbanuc1jmk/WGdwQjKYUPI/AAAAAAAAEM0/QfOUUZcMfl0WEn6frj0bIuamjxV-jYTSQCLcB/s400/9_2.PNG" width="363" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<a href="https://automation-home.blogspot.in/2016/12/c-visual-studio-specflow-feature-file.html" target="_blank"><< Previous</a><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"></span></span> </span></span></span></div>
</div>
Praveen Kumarhttp://www.blogger.com/profile/14705482110609285232noreply@blogger.com0tag:blogger.com,1999:blog-8903620123630625488.post-21761228468754076032016-12-28T21:41:00.001-08:002020-11-16T03:18:05.413-08:00C# Visual Studio - SpecFlow Feature file<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="color: #0b5394;"><b><span data-dobid="hdw">Prerequisite:</span></b></span><br />
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">Configure SpecFlow in Visual Studio</span></span><b><span data-dobid="hdw"> </span></b></span><br />
<span style="color: #0b5394;"><a href="https://automation-home.blogspot.com/2016/12/csharp-configuring-specflow-in-visualstudio.html" target="_blank">https://automation-home.blogspot.com/2016/12/csharp-configuring-specflow-in-visualstudio.html</a></span><br />
<div style="text-align: center;">
<br />
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">Create new project, ex: Console Application.</span></span></span></div>
<div style="text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">Select 'Solution Explorer -> <<Project>> -> Add -> New Item' </span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"></span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-kOhK2kMlXTk/WGRxxfGr5-I/AAAAAAAAEIQ/uo70oiLp_1MMqbmPbrH9z3V8FAPKQDLpQCLcB/s1600/2.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="243" src="https://3.bp.blogspot.com/-kOhK2kMlXTk/WGRxxfGr5-I/AAAAAAAAEIQ/uo70oiLp_1MMqbmPbrH9z3V8FAPKQDLpQCLcB/s400/2.PNG" width="400" /></a></div>
<b><span data-dobid="hdw"></span></b><br />
<div style="text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">Select 'SpecFlow Feature File', give some name Ex: 'SampleFirstFeature' and click 'Add' button.</span></span><b><span data-dobid="hdw"></span></b></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-8KhnIZMfEf0/WGRyx0HKerI/AAAAAAAAEIc/R3FrnZl7zHEc1Ij-j0dAL5lR7jXWS8LygCLcB/s1600/3.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="217" src="https://3.bp.blogspot.com/-8KhnIZMfEf0/WGRyx0HKerI/AAAAAAAAEIc/R3FrnZl7zHEc1Ij-j0dAL5lR7jXWS8LygCLcB/s400/3.PNG" width="400" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-lJzko3bxPn8/WGRy6__CQPI/AAAAAAAAEIg/SVzIWPjsMZInt3o4jLTMoAOXSF_rXLffgCLcB/s1600/3_1.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="163" src="https://1.bp.blogspot.com/-lJzko3bxPn8/WGRy6__CQPI/AAAAAAAAEIg/SVzIWPjsMZInt3o4jLTMoAOXSF_rXLffgCLcB/s400/3_1.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">Perform 'Build'. </span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-MU-lODiVXFs/WGRzJhYrFZI/AAAAAAAAEIk/zhuhB6goyZs-LQNrrtRnVOrTu47vZSNXwCLcB/s1600/4.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="136" src="https://2.bp.blogspot.com/-MU-lODiVXFs/WGRzJhYrFZI/AAAAAAAAEIk/zhuhB6goyZs-LQNrrtRnVOrTu47vZSNXwCLcB/s400/4.PNG" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-dqmy7Bm_2mY/WGRzXPUjPmI/AAAAAAAAEIo/nLIPustrHpsHx-9CGpmIVv7U0b0ZwlARwCLcB/s1600/5.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="193" src="https://1.bp.blogspot.com/-dqmy7Bm_2mY/WGRzXPUjPmI/AAAAAAAAEIo/nLIPustrHpsHx-9CGpmIVv7U0b0ZwlARwCLcB/s400/5.PNG" width="400" /></a></div>
<div style="text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">Build failed, since 2 references are missing.</span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-qSVWR0zhpzA/WGRzmNEWirI/AAAAAAAAEIw/yzuQ7O-bBfUYJi8-TJJqh5gg3avg5ZCSgCLcB/s1600/5_1.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="185" src="https://3.bp.blogspot.com/-qSVWR0zhpzA/WGRzmNEWirI/AAAAAAAAEIw/yzuQ7O-bBfUYJi8-TJJqh5gg3avg5ZCSgCLcB/s400/5_1.PNG" width="400" /></a></div>
<div style="text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><br /></span></span></span></div>
<div style="text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">'Add References' for missing references.</span></span></span></div>
<div style="text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">'References' > 'Manage NuGet Packages' > Search for SpecFlow.</span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-WWNfkiixtaw/WGR0SAelGOI/AAAAAAAAEI8/tRz2jLuoQv4i_vHauGSL3YaCcq7koCsmgCLcB/s1600/6.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="398" src="https://2.bp.blogspot.com/-WWNfkiixtaw/WGR0SAelGOI/AAAAAAAAEI8/tRz2jLuoQv4i_vHauGSL3YaCcq7koCsmgCLcB/s400/6.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-AMOGMRaNCWc/WGR0Wj2LpsI/AAAAAAAAEJA/_0chEvcyhPIoVNIOMpflkZQ_gEz8FBcrwCLcB/s1600/7.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="157" src="https://1.bp.blogspot.com/-AMOGMRaNCWc/WGR0Wj2LpsI/AAAAAAAAEJA/_0chEvcyhPIoVNIOMpflkZQ_gEz8FBcrwCLcB/s400/7.PNG" width="400" /></a></div>
<div style="text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><br /></span></span></span></div>
<div style="text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">Install '</span></span></span><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">SpecFlow</span></span></span>'.</span></span></span></div>
<div style="text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"></span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-s1nLqk31QQ4/WGR0szOxvbI/AAAAAAAAEJE/Owc25ciuol4T-6An4iQx66jl_Q4nOAZYgCLcB/s1600/7_1.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="67" src="https://1.bp.blogspot.com/-s1nLqk31QQ4/WGR0szOxvbI/AAAAAAAAEJE/Owc25ciuol4T-6An4iQx66jl_Q4nOAZYgCLcB/s400/7_1.PNG" width="400" /></a></div>
<br />
<div style="text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">Simillarly install 'SpecFlow.NUnit'.</span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-f6zyhEoNNQE/WGR0xllSasI/AAAAAAAAEJI/1vD75tJbeOc4pkczfaPXpx7KOB8NL_ufACLcB/s1600/7_2.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="87" src="https://1.bp.blogspot.com/-f6zyhEoNNQE/WGR0xllSasI/AAAAAAAAEJI/1vD75tJbeOc4pkczfaPXpx7KOB8NL_ufACLcB/s400/7_2.PNG" width="400" /></a></div>
<div style="text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"></span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-TxjblWsBtD0/WGR04EVTMsI/AAAAAAAAEJM/rbql-f0GqFgdppT9F2OijSExSN0POCysQCLcB/s1600/7_3.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="66" src="https://4.bp.blogspot.com/-TxjblWsBtD0/WGR04EVTMsI/AAAAAAAAEJM/rbql-f0GqFgdppT9F2OijSExSN0POCysQCLcB/s400/7_3.PNG" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">SpecFlow references are installed and added to the 'References'.</span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-1jHADjQsOBo/WGR1KYazorI/AAAAAAAAEJU/FrPNJm_rOqkB-cYko10HFzWFpnJQ-yq5wCLcB/s1600/7_4.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://3.bp.blogspot.com/-1jHADjQsOBo/WGR1KYazorI/AAAAAAAAEJU/FrPNJm_rOqkB-cYko10HFzWFpnJQ-yq5wCLcB/s320/7_4.PNG" width="236" /></a></div>
<div style="text-align: center;">
</div>
<div style="text-align: center;">
<br />
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">Now perform the 'Build' again.</span></span></span></span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-n9ywB1wT45A/WGR1YysL9-I/AAAAAAAAEJY/86VAZZElBI4KXe36t5bq30GpGa7rcT78ACLcB/s1600/8.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="136" src="https://3.bp.blogspot.com/-n9ywB1wT45A/WGR1YysL9-I/AAAAAAAAEJY/86VAZZElBI4KXe36t5bq30GpGa7rcT78ACLcB/s400/8.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-0kEhk4vNgXY/WGR1l8C75hI/AAAAAAAAEJg/3Db6tgZayRI3iOfIrgH-CsyIxjOs5dNDgCLcB/s1600/8_1.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="196" src="https://4.bp.blogspot.com/-0kEhk4vNgXY/WGR1l8C75hI/AAAAAAAAEJg/3Db6tgZayRI3iOfIrgH-CsyIxjOs5dNDgCLcB/s400/8_1.PNG" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">Open '</span></span></span></span></span></span><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">Test Explorer</span></span></span></span></span></span>'.</span></span></span></span></span></span></div>
<div style="text-align: center;">
<a href="https://3.bp.blogspot.com/-DhPG7QLSZcA/WGR1im_UycI/AAAAAAAAEJc/v3vShoGrgcsWIW_oARP279MARUuyb-2IQCLcB/s1600/9.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="113" src="https://3.bp.blogspot.com/-DhPG7QLSZcA/WGR1im_UycI/AAAAAAAAEJc/v3vShoGrgcsWIW_oARP279MARUuyb-2IQCLcB/s400/9.PNG" width="400" /></a><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"> </span></span></span></span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-wIrdiNp7IFY/WGR1zgcZNDI/AAAAAAAAEJk/G8CMhQ_sDNQIu1YFIujHCZRZj-8EMn6pwCLcB/s1600/9_1.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="203" src="https://2.bp.blogspot.com/-wIrdiNp7IFY/WGR1zgcZNDI/AAAAAAAAEJk/G8CMhQ_sDNQIu1YFIujHCZRZj-8EMn6pwCLcB/s400/9_1.PNG" width="400" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
Test Explorer is unable to show the tests in Test Explorer.</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
To view the tests in 'Test Explorer' install 'NUnit3 Test Adapter'.</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"></span></span></span></span></span></span><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"></span></span></span></span></span></span><span style="color: #0b5394;"></span>Go to "Tools -> Extensions and Updates -> Online" and search for "NUnit3 Test Adapter" and then install.
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"></span></span></span></span></span></span><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"></span></span></span></span></span></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><a href="https://1.bp.blogspot.com/-k1YgER7h50I/WGR2WRaovOI/AAAAAAAAEJs/-oMnnKWt2ww64kV_zsPmrmtRDieDRf0CwCLcB/s1600/10.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="245" src="https://1.bp.blogspot.com/-k1YgER7h50I/WGR2WRaovOI/AAAAAAAAEJs/-oMnnKWt2ww64kV_zsPmrmtRDieDRf0CwCLcB/s400/10.PNG" width="400" /></a></span></span></span></span></span></span></div>
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">
</span></span></span></span></span></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><a href="https://2.bp.blogspot.com/-IZjQWrIlT1E/WGR2f6tnD0I/AAAAAAAAEJ0/NLDotXJaANUWHC9dhnbIQjG7aRUKSRTHwCLcB/s1600/10_1.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="243" src="https://2.bp.blogspot.com/-IZjQWrIlT1E/WGR2f6tnD0I/AAAAAAAAEJ0/NLDotXJaANUWHC9dhnbIQjG7aRUKSRTHwCLcB/s400/10_1.PNG" width="400" /></a> </span></span></span></span></span></span></div>
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">
</span></span></span></span></span></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><i>Reference:</i> <a href="http://stackoverflow.com/questions/19298347/nunit-unit-tests-not-showing-in-test-explorer-with-test-adapter-is-installed" target="_blank">http://stackoverflow.com/questions/19298347/nunit-unit-tests-not-showing-in-test-explorer-with-test-adapter-is-installed</a></span></span></span></span></span></span></div>
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">
</span></span></span></span></span></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><br /></span></span></span></span></span></span></div>
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">
</span></span></span></span></span></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">Restart Visual Studio.</span></span></span></span></span></span></div>
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">
</span></span></span></span></span></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><a href="https://1.bp.blogspot.com/-1Adq2cIhrTY/WGR3hgB-d5I/AAAAAAAAEKA/d2ZbfpTJ7uY8Kl9shQuJdHRQ0dlcjf5EgCLcB/s1600/10_1.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="243" src="https://1.bp.blogspot.com/-1Adq2cIhrTY/WGR3hgB-d5I/AAAAAAAAEKA/d2ZbfpTJ7uY8Kl9shQuJdHRQ0dlcjf5EgCLcB/s400/10_1.PNG" width="400" /></a></span></span></span></span></span></span></div>
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">
</span></span></span></span></span></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><br /></span></span></span></span></span></span></div>
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">
</span></span></span></span></span></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">Close Test Explorer, perform Build and open the Test Explorer.</span></span></span></span></span></span></div>
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">
</span></span></span></span></span></span>
<div class="separator" style="clear: both; text-align: center;">
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><a href="https://2.bp.blogspot.com/-R15ob-4qdB4/WGR3rDjvzHI/AAAAAAAAEKE/UFsznl3bSnsq9u5bLORbm7kFNgkK_avDgCLcB/s1600/10_2.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="173" src="https://2.bp.blogspot.com/-R15ob-4qdB4/WGR3rDjvzHI/AAAAAAAAEKE/UFsznl3bSnsq9u5bLORbm7kFNgkK_avDgCLcB/s400/10_2.PNG" width="400" /></a></span></span></span></span></span></span></div>
<span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw"><span style="color: #0b5394;"><span style="color: black;"><span data-dobid="hdw">
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Run Selected Tests.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-LUzPlnDigI4/WGR39dKemcI/AAAAAAAAEKI/A0iepsBF41Ay0Z6NXPgIqBlCqmIIsiTfgCLcB/s1600/11.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="386" src="https://3.bp.blogspot.com/-LUzPlnDigI4/WGR39dKemcI/AAAAAAAAEKI/A0iepsBF41Ay0Z6NXPgIqBlCqmIIsiTfgCLcB/s400/11.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-wfZD1VvA4to/WGR4CBuR_kI/AAAAAAAAEKQ/ETHCqJRaIdsrBDyZES6gLFyx36Aj_q_KgCLcB/s1600/11_1.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://3.bp.blogspot.com/-wfZD1VvA4to/WGR4CBuR_kI/AAAAAAAAEKQ/ETHCqJRaIdsrBDyZES6gLFyx36Aj_q_KgCLcB/s400/11_1.PNG" width="207" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-f8KaNndPqzE/WGR4GOM9YQI/AAAAAAAAEKU/Aq-Ln58CxO84SmNVmcrA_6LQn9wioCMAACLcB/s1600/11_2.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://3.bp.blogspot.com/-f8KaNndPqzE/WGR4GOM9YQI/AAAAAAAAEKU/Aq-Ln58CxO84SmNVmcrA_6LQn9wioCMAACLcB/s400/11_2.PNG" width="282" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
Displays structure of step definition methods. </div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://automation-home.blogspot.com/2016/12/c-visual-studio-specflow-step.html" target="_blank">Next >></a> </div>
</span></span></span> </span></span><b><span data-dobid="hdw"></span></b></span></div>
Praveen Kumarhttp://www.blogger.com/profile/14705482110609285232noreply@blogger.com0tag:blogger.com,1999:blog-8903620123630625488.post-45757162297673446222016-12-21T18:17:00.000-08:002016-12-28T21:42:00.452-08:00C# - Configuring SpecFlow in Visual Studio<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="color: #0b5394;"><b>Prerequisite:</b></span><br />
Visual Studio is already installed<br />
Download link for installing Visual Studio Community <a href="https://www.visualstudio.com/vs/community/" target="_blank">https://www.visualstudio.com/vs/community/</a><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-mhLX2ULVdW0/WFs55wtT3XI/AAAAAAAAEH0/TQobUtx9cW8bpsK9JOlLzEAE5BiBuy2rACLcB/s1600/0.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="227" src="https://4.bp.blogspot.com/-mhLX2ULVdW0/WFs55wtT3XI/AAAAAAAAEH0/TQobUtx9cW8bpsK9JOlLzEAE5BiBuy2rACLcB/s320/0.PNG" width="320" /></a></div>
<br />
To Install & configure SpecFlow perform below steps in Visual Studio.<br />
<br />
<div style="text-align: center;">
Select 'Tools -> Extension and Updates'</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-R8_GCCSXuy0/WFsx437_x1I/AAAAAAAAEGA/8nkgpD0SCoUHCzYFAtsSGgsstAlEP9vCACLcB/s1600/1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="270" src="https://1.bp.blogspot.com/-R8_GCCSXuy0/WFsx437_x1I/AAAAAAAAEGA/8nkgpD0SCoUHCzYFAtsSGgsstAlEP9vCACLcB/s400/1.PNG" width="400" /></a></div>
<div style="text-align: center;">
<br />
Click 'Online', search for 'SpecFlow'.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-M4mI2_p1Gpc/WFsyFIimfcI/AAAAAAAAEGE/T8rqsntdnvk8RGC_2ILGp82sOhIAPfyUACLcB/s1600/2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="225" src="https://2.bp.blogspot.com/-M4mI2_p1Gpc/WFsyFIimfcI/AAAAAAAAEGE/T8rqsntdnvk8RGC_2ILGp82sOhIAPfyUACLcB/s400/2.PNG" width="400" /></a></div>
<div style="text-align: center;">
<br />
Click 'Download' button to download and install SpecFlow.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-J7clt2xyec8/WFsyLm6B9SI/AAAAAAAAEGI/nKuvGNxqwRIFAExogSSWcYGurP0AWlowwCLcB/s1600/3.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="225" src="https://3.bp.blogspot.com/-J7clt2xyec8/WFsyLm6B9SI/AAAAAAAAEGI/nKuvGNxqwRIFAExogSSWcYGurP0AWlowwCLcB/s400/3.PNG" width="400" /></a></div>
<div style="text-align: center;">
<br />
Once download is completed click 'Install' button.<br />
<a href="https://1.bp.blogspot.com/-utNX55UTmiw/WFs1bJ3NMsI/AAAAAAAAEHY/v39nPruvr8spycbpLB6vyKnjWyrX7teAQCLcB/s1600/4.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="225" src="https://1.bp.blogspot.com/-utNX55UTmiw/WFs1bJ3NMsI/AAAAAAAAEHY/v39nPruvr8spycbpLB6vyKnjWyrX7teAQCLcB/s400/4.PNG" width="400" /></a> </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-IjbNrud5kUc/WFsyVKAFbPI/AAAAAAAAEGM/2AdPB86tOlkUkcYC7aSiaSn265ljNqYhgCLcB/s1600/4_1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="225" src="https://4.bp.blogspot.com/-IjbNrud5kUc/WFsyVKAFbPI/AAAAAAAAEGM/2AdPB86tOlkUkcYC7aSiaSn265ljNqYhgCLcB/s400/4_1.PNG" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
Simillarly download and install 'Nunit Test Adapter'.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-tOISlzar26w/WFsykKLXWFI/AAAAAAAAEGU/JNTED8GTLQEAdpRyrfpt_DMvBykxqSRiACLcB/s1600/5.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="226" src="https://1.bp.blogspot.com/-tOISlzar26w/WFsykKLXWFI/AAAAAAAAEGU/JNTED8GTLQEAdpRyrfpt_DMvBykxqSRiACLcB/s400/5.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-4gQJY3O0sFc/WFsyofJvzzI/AAAAAAAAEGY/uh-uw4u7sQoBUsfAedeyctYsPFVIQhi7ACLcB/s1600/5_1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="225" src="https://2.bp.blogspot.com/-4gQJY3O0sFc/WFsyofJvzzI/AAAAAAAAEGY/uh-uw4u7sQoBUsfAedeyctYsPFVIQhi7ACLcB/s400/5_1.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-f70wmrCfv-o/WFsysQYRNVI/AAAAAAAAEGc/gbHEgaRBq00TiaBT-gidnCB-05YncMCoACLcB/s1600/5_2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="225" src="https://4.bp.blogspot.com/-f70wmrCfv-o/WFsysQYRNVI/AAAAAAAAEGc/gbHEgaRBq00TiaBT-gidnCB-05YncMCoACLcB/s400/5_2.PNG" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
Restart Visual Studio</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-GemMimuIR_Y/WFsyyQsdWzI/AAAAAAAAEGg/orj3y9p21xwsoMXrtflDqEv2jfms0sHiQCLcB/s1600/6.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="225" src="https://2.bp.blogspot.com/-GemMimuIR_Y/WFsyyQsdWzI/AAAAAAAAEGg/orj3y9p21xwsoMXrtflDqEv2jfms0sHiQCLcB/s400/6.PNG" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
Select 'File -> New -> Project'</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-5BC_nLbRnss/WFsy6-ZrJyI/AAAAAAAAEGk/4dsPlduowOEFyN-AznhCY00ZGuXdaD-6ACLcB/s1600/7.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="243" src="https://4.bp.blogspot.com/-5BC_nLbRnss/WFsy6-ZrJyI/AAAAAAAAEGk/4dsPlduowOEFyN-AznhCY00ZGuXdaD-6ACLcB/s400/7.PNG" width="400" /></a></div>
<div style="text-align: center;">
<a href="https://3.bp.blogspot.com/-OC7ZQC3gzTw/WFs2RP598nI/AAAAAAAAEHo/pGCHS_9xQwsOK_F7yWWGb0R0lRI4Cy4HACLcB/s1600/7_1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="225" src="https://3.bp.blogspot.com/-OC7ZQC3gzTw/WFs2RP598nI/AAAAAAAAEHo/pGCHS_9xQwsOK_F7yWWGb0R0lRI4Cy4HACLcB/s400/7_1.PNG" width="400" /></a> <br />
Search for SpecFlow, there is no project for Specflow</div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
Where does the specflow resides?<br />
to know proceed with creating Console Application.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-9hylkFATHa8/WFszpLrnaTI/AAAAAAAAEGs/RX5tb6Lqza0bJlX-k97ipy92wku2pAS1wCLcB/s1600/8.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="217" src="https://4.bp.blogspot.com/-9hylkFATHa8/WFszpLrnaTI/AAAAAAAAEGs/RX5tb6Lqza0bJlX-k97ipy92wku2pAS1wCLcB/s400/8.PNG" width="400" /></a></div>
<div style="text-align: center;">
ex: Give name- FirstSpecFlowTest and click 'OK' button.</div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
Console Application is created.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-3YNXWN7Q-78/WFszxaKU_QI/AAAAAAAAEGw/sVF3m8hfJicYmmbB7dzvG4RwY1mIpJAwgCLcB/s1600/8_1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="223" src="https://1.bp.blogspot.com/-3YNXWN7Q-78/WFszxaKU_QI/AAAAAAAAEGw/sVF3m8hfJicYmmbB7dzvG4RwY1mIpJAwgCLcB/s400/8_1.PNG" width="400" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Select 'Solution Explorer -> <<Project>> -> Add -> New Item'</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-LcRbD4udWF4/WFs02otyFwI/AAAAAAAAEHM/5pZ2acVrm6MZt2KTVlBcqtrEVjpTbQ5ewCLcB/s1600/9.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="243" src="https://2.bp.blogspot.com/-LcRbD4udWF4/WFs02otyFwI/AAAAAAAAEHM/5pZ2acVrm6MZt2KTVlBcqtrEVjpTbQ5ewCLcB/s400/9.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Three Items displayed</div>
<ul style="text-align: center;">
<li>SpecFlow Feature File</li>
<li>SpecFlow Hooks</li>
<li>SpecFlow Step Definition </li>
</ul>
<div style="text-align: center;">
<a href="https://4.bp.blogspot.com/-GOLwEIm5Fk8/WFsz7yK7zsI/AAAAAAAAEG4/DJILmaO_PRUWUXnT9iKT7RGFSJbdr60WwCLcB/s1600/9_1.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="216" src="https://4.bp.blogspot.com/-GOLwEIm5Fk8/WFsz7yK7zsI/AAAAAAAAEG4/DJILmaO_PRUWUXnT9iKT7RGFSJbdr60WwCLcB/s400/9_1.PNG" width="400" /></a><br />
<br />
<a href="http://automation-home.blogspot.com/2016/12/c-visual-studio-specflow-feature-file.html" target="_blank"><b>Next >></b></a></div>
</div>
Praveen Kumarhttp://www.blogger.com/profile/14705482110609285232noreply@blogger.com0tag:blogger.com,1999:blog-8903620123630625488.post-76017275428005287422016-12-17T20:51:00.002-08:002020-11-16T03:19:01.384-08:00Restful Webservices - Manual Testing<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: center;">
<b>Watch Demo</b></div>
<iframe allowfullscreen="" frameborder="0" height="359" mozallowfullscreen="" src="https://player.vimeo.com/video/196136031" webkitallowfullscreen="" width="640"></iframe><br />
<br />
<b><span style="color: #0b5394;">Prerequisite:</span></b><br />
- Java<br />
- Tomcat<br />
- Chrome Extension : Advanced REST client<br />
- JsonRestfulWebServicesCRUDExample.war<br />
<br />
<b><span style="color: #3d85c6;">Set Path for JAVA_HOME</span></b><br />
<a href="https://automation-home.blogspot.com/2016/08/java-8-installation-and-path-setting.html" target="_blank">https://automation-home.blogspot.com/2016/08/java-8-installation-and-path-setting.html</a><br />
<b><span style="color: #3d85c6;"><br /></span></b>
<b><span style="color: #3d85c6;">Download tomcat and extract the zip file.</span></b><br />
<a href="http://tomcat.apache.org/" target="_blank">http://tomcat.apache.org/</a><br />
<b><br /></b>
<b>Open the Chrome browser and download the Rest Client extension for Chrome-</b> <b><span style="color: #3d85c6;">Advanced REST client</span></b><br />
<a href="https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo" target="_blank">https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo</a><br />
<span style="color: #3d85c6;"><br /></span>
<b><span style="color: #3d85c6;">Download the 'JsonRestfulWebServicesCRUDExample.war' from GitHub</span></b><br />
<a href="https://github.com/automationhome/JsonRestfulWebServicesCRUDExample/tree/master/JsonRestfulWebServicesCRUDExample/target" target="_blank">https://github.com/automationhome/JsonRestfulWebServicesCRUDExample/tree/master/JsonRestfulWebServicesCRUDExample/target</a><br />
<br />
<span style="color: #0b5394;"><b>Once all the above installations are done perform below steps</b></span><br />
- Copy the '<i>JsonRestfulWebServicesCRUDExample.war'</i> to webapps folder of tomcat<br />
- Start tomcat server and verify services are running<br />
- Open the browser and check tomcat server is started by accessing the url http://localhost:8080<br />
<br />
<span style="color: #0b5394;"><b>Open the rest client extension(i.e. Advanced REST client) and access the rest webservices by using below methods(i.e. URL's)</b></span><br />
<b><span style="color: #3d85c6;"><br /></span></b>
<b><span style="color: #3d85c6;">Get Method:</span></b><br />
To retrieve all products: http://localhost:8080/JsonRestfulWebServicesCRUDExample/products<br />
To retrieve product by id: http://localhost:8080/JsonRestfulWebServicesCRUDExample/product/<<NUMBER>><br />
<span style="color: #3d85c6;"><b><br /></b></span>
<span style="color: #3d85c6;"><b>Delete Method: </b></span><br />
To delete the product: http://localhost:8080/JsonRestfulWebServicesCRUDExample/product/<<NUMBER>><br />
<br />
<b><span style="color: #3d85c6;">PUT Method:</span></b><br />
Create the product: http://localhost:8080/JsonRestfulWebServicesCRUDExample/products/<br />
{<br />
"id": 5,<br />
"productName": "Chair Shoe",<br />
"price": 5.8<br />
}<br />
<br />
<b><span style="color: #3d85c6;">POST Method:</span></b><br />
Update the product: http://localhost:8080/JsonRestfulWebServicesCRUDExample/products<br />
{<br />
"id" : 5, <br />
"productName": "Chair Shoe",<br />
"price": 4.8<br />
}</div>
Praveen Kumarhttp://www.blogger.com/profile/14705482110609285232noreply@blogger.com0tag:blogger.com,1999:blog-8903620123630625488.post-29258801378274722182016-11-12T11:38:00.002-08:002016-11-12T11:42:57.187-08:00Maven installation and set path on Windows OS<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="color: #073763;"><b>Prerequisite:</b></span><br />
Set path for Java, click below link for installing and set path for java on windows <br />
<a href="https://automation-home.blogspot.in/2016/08/java-8-installation-and-path-setting.html" target="_blank">https://automation-home.blogspot.in/2016/08/java-8-installation-and-path-setting.html</a><br />
<br />
Follow below steps for installing and set path for maven <br />
Download maven from <a href="https://maven.apache.org/download.cgi" target="_blank">https://maven.apache.org/download.cgi</a><br />
<br />
<div style="text-align: center;">
Click link 'apache-maven-3.3.9-bin.zip'. </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-xSv3mB3Zxpo/WCdoWub5V0I/AAAAAAAAEEg/VOOnYQiOTioKSlCf0AiMo1lqkhKpWgsggCLcB/s1600/11.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="325" src="https://4.bp.blogspot.com/-xSv3mB3Zxpo/WCdoWub5V0I/AAAAAAAAEEg/VOOnYQiOTioKSlCf0AiMo1lqkhKpWgsggCLcB/s400/11.PNG" width="400" /></a></div>
<br />
<div style="text-align: center;">
Click 'OK' button to save the zip file. </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-4OxSI__oSOU/WCdoW2NyBaI/AAAAAAAAEEk/tfRSUW2GEwAo0kbUSRUwnk_RMjIRydaGACLcB/s1600/12.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="303" src="https://2.bp.blogspot.com/-4OxSI__oSOU/WCdoW2NyBaI/AAAAAAAAEEk/tfRSUW2GEwAo0kbUSRUwnk_RMjIRydaGACLcB/s400/12.PNG" width="400" /></a></div>
<br />
<div style="text-align: center;">
zip file is downloaded. </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-boNOI4A_-2Q/WCdoWixm4jI/AAAAAAAAEEc/bBUQC33qWnoh3CDjUht_x-p-C68I_f1lwCLcB/s1600/13.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="123" src="https://3.bp.blogspot.com/-boNOI4A_-2Q/WCdoWixm4jI/AAAAAAAAEEc/bBUQC33qWnoh3CDjUht_x-p-C68I_f1lwCLcB/s400/13.PNG" width="400" /></a></div>
<br />
<div style="text-align: center;">
Consider maven zip file is extracted at '<i>C:\Program Files\apache-maven-3.3.9-bin\apache-maven-3.3.9</i>' </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-ySyTY5rnxHs/WCdpOu5SAWI/AAAAAAAAEEo/8mVC3RsfK0keP6uH3_VHf-17TXzThtGPwCLcB/s1600/14.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="218" src="https://1.bp.blogspot.com/-ySyTY5rnxHs/WCdpOu5SAWI/AAAAAAAAEEo/8mVC3RsfK0keP6uH3_VHf-17TXzThtGPwCLcB/s400/14.PNG" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
Open advanced system settings</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-DaBHgPENMGc/WCdppaL_CpI/AAAAAAAAEEw/aWCKaEPnWaEcBJPqP1ih4EYEwoZ7jFn0ACLcB/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://1.bp.blogspot.com/-DaBHgPENMGc/WCdppaL_CpI/AAAAAAAAEEw/aWCKaEPnWaEcBJPqP1ih4EYEwoZ7jFn0ACLcB/s400/1.png" width="252" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
Above screenshot is captured from Windows 8</div>
<div class="separator" style="clear: both; text-align: center;">
Mouse right click on the start button and select '<i>System</i>'.</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Click 'Advanced system settings'.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-NzCnQ7feCqY/WCdqRBQRL8I/AAAAAAAAEE0/2GVS5MnmzsIGd8SdfMG5C19qT5C99N0oACLcB/s1600/2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="272" src="https://3.bp.blogspot.com/-NzCnQ7feCqY/WCdqRBQRL8I/AAAAAAAAEE0/2GVS5MnmzsIGd8SdfMG5C19qT5C99N0oACLcB/s400/2.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div style="text-align: center;">
Select 'Advanced' tab and click on 'Environment Variables' button.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-wgLgTsIJ5fU/WCdqhuGnbdI/AAAAAAAAEE4/17OET0j48pkSoWnhIn0bKTofUDP6ZqI1wCLcB/s1600/3.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://3.bp.blogspot.com/-wgLgTsIJ5fU/WCdqhuGnbdI/AAAAAAAAEE4/17OET0j48pkSoWnhIn0bKTofUDP6ZqI1wCLcB/s400/3.PNG" width="357" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
Add environment variable for maven.</div>
<div style="text-align: center;">
Click 'New' button.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-jGXadVX-5Vk/WCdq751AwhI/AAAAAAAAEFA/w1az7zStilQJmDyudEuDt_KmNu95GU3BwCLcB/s1600/4.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="318" src="https://3.bp.blogspot.com/-jGXadVX-5Vk/WCdq751AwhI/AAAAAAAAEFA/w1az7zStilQJmDyudEuDt_KmNu95GU3BwCLcB/s400/4.PNG" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-o-pFnsFtmK0/WCdq8CauoOI/AAAAAAAAEFE/F5Ad91Rp5cEy0MY12vvc3-7sB-aYwtLiQCLcB/s1600/5.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="317" src="https://4.bp.blogspot.com/-o-pFnsFtmK0/WCdq8CauoOI/AAAAAAAAEFE/F5Ad91Rp5cEy0MY12vvc3-7sB-aYwtLiQCLcB/s400/5.PNG" width="400" /></a></div>
<br />
<div style="text-align: center;">
Add 'M2_HOME' or 'MAVEN_HOME' variables.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-CDjTmlQCJGg/WCdrS8ac5jI/AAAAAAAAEFM/zwYhzY94lqUQ7_vHrUYTNPKIsIvli0OvQCLcB/s1600/15.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="338" src="https://2.bp.blogspot.com/-CDjTmlQCJGg/WCdrS8ac5jI/AAAAAAAAEFM/zwYhzY94lqUQ7_vHrUYTNPKIsIvli0OvQCLcB/s400/15.png" width="400" /></a></div>
<div style="text-align: center;">
Consider maven zip file is extracted at '<i>C:\Program Files\apache-maven-3.3.9-bin\apache-maven-3.3.9</i>' </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-qvzC0i_ri3s/WCdrS_PxqII/AAAAAAAAEFI/DMz7aFfj5nsGV19Z1XsKu3Trn8-XjMwmACLcB/s1600/16.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="355" src="https://2.bp.blogspot.com/-qvzC0i_ri3s/WCdrS_PxqII/AAAAAAAAEFI/DMz7aFfj5nsGV19Z1XsKu3Trn8-XjMwmACLcB/s400/16.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
According to Maven documentation required only adding 'M2_HOME', but some programs still reference Maven folder with MAVEN_HOME, so it’s safer and better to add both.</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: center;">
Edit Path and add '<i>%M2_HOME%\bin</i>' to Path.</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-2S6pXoNnSas/WCdsiK5wBsI/AAAAAAAAEFU/7S1iYDR2HQwj6f2uwXgO_yruXxITa16WgCLcB/s1600/17.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="260" src="https://2.bp.blogspot.com/-2S6pXoNnSas/WCdsiK5wBsI/AAAAAAAAEFU/7S1iYDR2HQwj6f2uwXgO_yruXxITa16WgCLcB/s400/17.png" width="400" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Verify maven configuration by running the command '<i>mvn –version</i>' in the command prompt.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-97Y3z5Wdcis/WCdtJKjAA5I/AAAAAAAAEFY/7FuGj_eAO5EzJsIP64nwsX8qEYA1HtDlACEw/s1600/18.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://4.bp.blogspot.com/-97Y3z5Wdcis/WCdtJKjAA5I/AAAAAAAAEFY/7FuGj_eAO5EzJsIP64nwsX8qEYA1HtDlACEw/s400/18.png" width="247" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
Mouse right click on the start button and select '<i>Command Prompt</i>'.</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Run the command '<i>mvn –version</i>' in the command prompt.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-Y85wr7bojsQ/WCdtJFmo1mI/AAAAAAAAEFc/0kzt0u1M5XAlbboH1KmZNTnQ1kLCa5UdwCLcB/s1600/19.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="112" src="https://3.bp.blogspot.com/-Y85wr7bojsQ/WCdtJFmo1mI/AAAAAAAAEFc/0kzt0u1M5XAlbboH1KmZNTnQ1kLCa5UdwCLcB/s400/19.PNG" width="400" /></a> </div>
</div>
Praveen Kumarhttp://www.blogger.com/profile/14705482110609285232noreply@blogger.com0tag:blogger.com,1999:blog-8903620123630625488.post-2549704563257065792016-11-02T07:59:00.005-07:002016-11-02T07:59:57.997-07:00Firebug for chrome<div dir="ltr" style="text-align: left;" trbidi="on">
Earlier firebug plugin supports only firefox browser, firebug doesn't support chrome browser.<br />
Now there is 'Firebug Lite' Extension for Chrome browser, using this extension you can inspect the elements in chrome browser.<br />
Firebug Lite for chrome browser is not a substitute for Firebug or Developer tools.<br />
<br />
<div style="text-align: center;">
Access the below url in chrome browser</div>
<div style="text-align: center;">
<a href="http://getfirebug.com/releases/lite/chrome/" target="_blank">http://getfirebug.com/releases/lite/chrome/</a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-Ud6Ucb-Mmac/WBnNqSoEBUI/AAAAAAAAEDE/1z_pIyMrhmwav2lU5OtLGVOagwTk7cdHwCLcB/s1600/1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="182" src="https://3.bp.blogspot.com/-Ud6Ucb-Mmac/WBnNqSoEBUI/AAAAAAAAEDE/1z_pIyMrhmwav2lU5OtLGVOagwTk7cdHwCLcB/s400/1.PNG" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
Click button '<i>Install Firebug Lite</i>' button.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/--P2o4KufpII/WBnNyDqTJGI/AAAAAAAAEDI/x5ocScAUmA4shlPYXBVr9qB6cNEWFI43QCLcB/s1600/2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="182" src="https://3.bp.blogspot.com/--P2o4KufpII/WBnNyDqTJGI/AAAAAAAAEDI/x5ocScAUmA4shlPYXBVr9qB6cNEWFI43QCLcB/s400/2.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Page is navigated to Chrome Extenstions page</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-eSGSogjjNMo/WBnOFXp4BPI/AAAAAAAAEDM/fo9npt1ItWosKiv0VzOC7YqILixKN540ACLcB/s1600/3.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="242" src="https://4.bp.blogspot.com/-eSGSogjjNMo/WBnOFXp4BPI/AAAAAAAAEDM/fo9npt1ItWosKiv0VzOC7YqILixKN540ACLcB/s400/3.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Click 'ADD TO CHROME' button.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-bs-Rl32TZ3Y/WBnONNL4mXI/AAAAAAAAEDQ/9T4sXe3L5cwXW4jV6CY4fs0uHccOM5xnACLcB/s1600/4.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="242" src="https://4.bp.blogspot.com/-bs-Rl32TZ3Y/WBnONNL4mXI/AAAAAAAAEDQ/9T4sXe3L5cwXW4jV6CY4fs0uHccOM5xnACLcB/s400/4.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Click 'Add Extension' button.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-QYuW05H-3zc/WBnOUkdiisI/AAAAAAAAEDU/xdJ0BGEdUOgwJnuqfbdvnzSoBzq_A66DwCLcB/s1600/5.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="245" src="https://4.bp.blogspot.com/-QYuW05H-3zc/WBnOUkdiisI/AAAAAAAAEDU/xdJ0BGEdUOgwJnuqfbdvnzSoBzq_A66DwCLcB/s400/5.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Firebug icon is displayed on top right corner of the chrome browser</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-r-7qM7SKfBg/WBnOcnaCfjI/AAAAAAAAEDc/NJENLgFiN90w2MybBbnP5bUvs30d07SdgCLcB/s1600/6.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="158" src="https://1.bp.blogspot.com/-r-7qM7SKfBg/WBnOcnaCfjI/AAAAAAAAEDc/NJENLgFiN90w2MybBbnP5bUvs30d07SdgCLcB/s400/6.PNG" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-JUy-e4woVWg/WBnOcnYwhnI/AAAAAAAAEDY/uHzUrQij13keUYzAsRmR2zrUfRMzd4tpQCLcB/s1600/6_1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="98" src="https://1.bp.blogspot.com/-JUy-e4woVWg/WBnOcnYwhnI/AAAAAAAAEDY/uHzUrQij13keUYzAsRmR2zrUfRMzd4tpQCLcB/s200/6_1.PNG" width="200" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Click on Firebug icon to open the firebug.</div>
<div class="separator" style="clear: both; text-align: center;">
Firebug is opened</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-GsGsjucZGZI/WBnOrd_kqQI/AAAAAAAAEDk/MGApIh6xrmI9CK6xHks5crv4m6-449Q6ACLcB/s1600/7.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="212" src="https://1.bp.blogspot.com/-GsGsjucZGZI/WBnOrd_kqQI/AAAAAAAAEDk/MGApIh6xrmI9CK6xHks5crv4m6-449Q6ACLcB/s400/7.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Click 'Inspect', move the mouse to the element to which you want to inspect, corresponding html element/elements are displayed(i.e. highlighted) in the firebug.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-SV8nvUQw-u8/WBnO4J1Ub8I/AAAAAAAAEDo/hDauHsuQ0nEZbIM0fvICn-NcaDeV8oXQACLcB/s1600/8.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="213" src="https://3.bp.blogspot.com/-SV8nvUQw-u8/WBnO4J1Ub8I/AAAAAAAAEDo/hDauHsuQ0nEZbIM0fvICn-NcaDeV8oXQACLcB/s400/8.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div style="text-align: center;">
OR</div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
Place the mouse pointer on the element(ex: Google Search button) and right click, from context menu select 'Inspect with Firebug Lite'.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-fUsEyYiYxRQ/WBnPDhaGN7I/AAAAAAAAEDw/isD3nhkyO4Y-NV85_Hb3dHixqH1bBYTUwCLcB/s1600/9.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="236" src="https://4.bp.blogspot.com/-fUsEyYiYxRQ/WBnPDhaGN7I/AAAAAAAAEDw/isD3nhkyO4Y-NV85_Hb3dHixqH1bBYTUwCLcB/s400/9.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Selected html element is displayed(i.e. highlighted) in the firebug.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-g1dOtd4Cnws/WBnPVYvrd0I/AAAAAAAAED0/BSpttwOxF6E7lgZP94c8qSig0xTyeOClwCLcB/s1600/10.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="213" src="https://3.bp.blogspot.com/-g1dOtd4Cnws/WBnPVYvrd0I/AAAAAAAAED0/BSpttwOxF6E7lgZP94c8qSig0xTyeOClwCLcB/s400/10.PNG" width="400" /></a></div>
<br /></div>
Praveen Kumarhttp://www.blogger.com/profile/14705482110609285232noreply@blogger.com0tag:blogger.com,1999:blog-8903620123630625488.post-48031991176248275022016-10-04T19:07:00.000-07:002016-10-04T19:07:44.267-07:00Selenium2Excel plug-in<div dir="ltr" style="text-align: left;" trbidi="on">
With the help of the Selenium2Excel converter plug-in users can easily convert the recorded script(i.e. in Selenium IDE) into Excel file. <br />
Usefull when automating the selenium scripts in Keyword driven or Hybrid driven framework.<br />
<br />
<i><u>Prerequisite: </u></i><br />
- Selenium IDE is already installed.<br />
- Microsoft Excel is already installed.<br />
<br />
Install Selenium2Excel Converter plugin from: <a href="https://addons.mozilla.org/en-US/firefox/addon/selenium2excel-converter/" target="_blank">https://addons.mozilla.org/en-US/firefox/addon/selenium2excel-converter/</a><br />
<br />
<div style="text-align: center;">
Click 'Add to Firefox' button.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-KpUwS7QrQ2g/V_RdzWLyl-I/AAAAAAAAECI/4tJ8PLF9svczEEOYAKhIZjrNiRGErcfqwCLcB/s1600/1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="166" src="https://2.bp.blogspot.com/-KpUwS7QrQ2g/V_RdzWLyl-I/AAAAAAAAECI/4tJ8PLF9svczEEOYAKhIZjrNiRGErcfqwCLcB/s320/1.PNG" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: center;">
Open the firefox browser access any url(eg: Google.com) and launch Selenium IDE.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-j0BRvngR2uU/V_ReJ4FrVuI/AAAAAAAAECM/SV5bwyw8P50KLR2gOO0Eodvihd8Mv1XbQCLcB/s1600/2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="197" src="https://3.bp.blogspot.com/-j0BRvngR2uU/V_ReJ4FrVuI/AAAAAAAAECM/SV5bwyw8P50KLR2gOO0Eodvihd8Mv1XbQCLcB/s320/2.PNG" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: center;">
Record the script in SeleniumIDE and click on 'Excel' button.</div>
<div style="text-align: center;">
<a href="https://1.bp.blogspot.com/-jvHflxAIGfg/V_Repc5vtcI/AAAAAAAAECQ/YgvJLI7Yzq4fn01tZepJxmNidVGiXADLgCLcB/s1600/3.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="161" src="https://1.bp.blogspot.com/-jvHflxAIGfg/V_Repc5vtcI/AAAAAAAAECQ/YgvJLI7Yzq4fn01tZepJxmNidVGiXADLgCLcB/s320/3.PNG" width="320" /></a></div>
<br />
<div style="text-align: center;">
Save the recorded script.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-wR0Gih443kM/V_Re3DTuCUI/AAAAAAAAECY/7mNnNCy6DdIl3-PfUQUVuDrrcWi1evw_gCLcB/s1600/4.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="171" src="https://4.bp.blogspot.com/-wR0Gih443kM/V_Re3DTuCUI/AAAAAAAAECY/7mNnNCy6DdIl3-PfUQUVuDrrcWi1evw_gCLcB/s320/4.PNG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-kvzsWoBSzME/V_Re6zEMmlI/AAAAAAAAECc/HvRodAQMikg9JvfRp76STt6KyBFvNEJKACLcB/s1600/5.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="159" src="https://1.bp.blogspot.com/-kvzsWoBSzME/V_Re6zEMmlI/AAAAAAAAECc/HvRodAQMikg9JvfRp76STt6KyBFvNEJKACLcB/s320/5.PNG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-swExnGLe3jY/V_Re90RO66I/AAAAAAAAECg/uNoNHKAkaek9mUa1VbfXUJxiWm9befjAACLcB/s1600/6.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="142" src="https://1.bp.blogspot.com/-swExnGLe3jY/V_Re90RO66I/AAAAAAAAECg/uNoNHKAkaek9mUa1VbfXUJxiWm9befjAACLcB/s320/6.PNG" width="320" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
Open the Excel file.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-b-Mq8DT0VoU/V_RfH9WjS5I/AAAAAAAAECk/enROw8JLFtISMoD7z0joqEJUPxsASaYUACLcB/s1600/7.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://1.bp.blogspot.com/-b-Mq8DT0VoU/V_RfH9WjS5I/AAAAAAAAECk/enROw8JLFtISMoD7z0joqEJUPxsASaYUACLcB/s320/7.PNG" width="320" /></a></div>
<div style="text-align: center;">
</div>
<div style="text-align: center;">
</div>
<i>Note:</i><br />
To use 'Selenium2Excel' plug-in users should have installed Microsoft Excel, since it works only on Windows.</div>
Praveen Kumarhttp://www.blogger.com/profile/14705482110609285232noreply@blogger.com0tag:blogger.com,1999:blog-8903620123630625488.post-18553075448234117622016-08-10T18:21:00.001-07:002016-08-10T18:21:14.093-07:00Executing the webdriver script using webdriver 3.0.0-beta2 version<div dir="ltr" style="text-align: left;" trbidi="on">
Below steps guides you for executing the java webdriver script with webdriver version '3.0.0-beta2'.<br />
<br />
<span style="color: #0b5394;"><b>Prerequisite:</b></span><br />
- To work with webdriver version '3.0.0-beta2', requires java 1.8 version installed and java path is set to java 1.8.<br />
For installing java 1.8 and path setting, refer link <a href="http://automation-home.blogspot.com/2016/08/java-8-installation-and-path-setting.html" target="_blank">http://automation-home.blogspot.com/2016/08/java-8-installation-and-path-setting.html</a><br />
- Eclipse IDE is already installed. <br />
<br />
<span style="color: #0b5394;"><b>Download java webdriver client libraries:</b></span> <br />
Download java webdriver libraries from <a href="http://www.seleniumhq.org/download" target="_blank">http://www.seleniumhq.org/download</a><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-my1Wahua1S8/V6uvwiQJndI/AAAAAAAAD-Q/HCn-OXTFu6kPALMbc5Wjvtx-JBUrXJuFwCLcB/s1600/39.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="130" src="https://1.bp.blogspot.com/-my1Wahua1S8/V6uvwiQJndI/AAAAAAAAD-Q/HCn-OXTFu6kPALMbc5Wjvtx-JBUrXJuFwCLcB/s400/39.PNG" width="400" /></a></div>
<div style="text-align: center;">
Click 'Download' button for 'java' to download the selenium webdriver java client libraries.</div>
<div style="text-align: left;">
</div>
<div style="text-align: left;">
<span style="color: #0b5394;"><b>Extract the downloaded zip file:</b></span></div>
<div style="text-align: center;">
Extract the downloaded 'selenium-java-3.0.0-beta2.zip' file.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-zArm9lsM-7M/V6u4cUoed_I/AAAAAAAAD-s/cLgsTOk1ZpouCUWSeUG9zzFtZcJdH0U1gCLcB/s1600/36.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="118" src="https://1.bp.blogspot.com/-zArm9lsM-7M/V6u4cUoed_I/AAAAAAAAD-s/cLgsTOk1ZpouCUWSeUG9zzFtZcJdH0U1gCLcB/s400/36.PNG" width="400" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div style="text-align: center;">
<a href="https://1.bp.blogspot.com/-9BJj4vZDSm4/V6u4juAW-MI/AAAAAAAAD-w/pS34nguWv1UPADrERcatImpqLc1zhuusACLcB/s1600/37.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://1.bp.blogspot.com/-9BJj4vZDSm4/V6u4juAW-MI/AAAAAAAAD-w/pS34nguWv1UPADrERcatImpqLc1zhuusACLcB/s400/37.PNG" width="400" /></a> </div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: left;">
<span style="color: #0b5394;"><b>Open the Eclipse IDE:</b></span></div>
<div style="text-align: center;">
Right click on the project and select 'Properties'. </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-NRtrZFw9Veo/V6u3KfYntNI/AAAAAAAAD-g/53AN6uCQqQQVx31-KY-WKE1kOaDxZcprQCLcB/s1600/40.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://4.bp.blogspot.com/-NRtrZFw9Veo/V6u3KfYntNI/AAAAAAAAD-g/53AN6uCQqQQVx31-KY-WKE1kOaDxZcprQCLcB/s400/40.png" width="296" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
set the path for jar files present in the extracted zip file 'selenium-java-3.0.0-beta2.zip'.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-i6_T39UEdbo/V6u34MwJ01I/AAAAAAAAD-k/ztRwIXyOYwcP0JOFvLZo5OSK898nxj0jACLcB/s1600/38.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="303" src="https://2.bp.blogspot.com/-i6_T39UEdbo/V6u34MwJ01I/AAAAAAAAD-k/ztRwIXyOYwcP0JOFvLZo5OSK898nxj0jACLcB/s400/38.PNG" width="400" /></a></div>
<div style="text-align: center;">
<span style="color: #0b5394;"><br /></span></div>
<span style="color: #0b5394;"><b>Sample Program:</b></span><br />
import org.openqa.selenium.WebDriver;<br />
import org.openqa.selenium.firefox.FirefoxDriver;<br />
<br />
public class WSTest {<br />
public static void main(String[] args) throws InterruptedException {<br />
WebDriver driver = new FirefoxDriver();<br />
// driver.manage().window().maximize();<br />
driver.get("http://www.google.com");<br />
<br />
Thread.sleep(3000);<br />
driver.close();<br />
driver.quit();<br />
}<br />
}<br />
<br />
<div style="text-align: center;">
Execute the script.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-_z5dmAqdWzc/V6u6LLgEgNI/AAAAAAAAD-8/iAjv7qRgvuA9vwxdVYSE_A5Lk9nBw4gjwCLcB/s1600/19.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="238" src="https://2.bp.blogspot.com/-_z5dmAqdWzc/V6u6LLgEgNI/AAAAAAAAD-8/iAjv7qRgvuA9vwxdVYSE_A5Lk9nBw4gjwCLcB/s400/19.PNG" width="400" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
Thread.sleep() is added for demo, in real time projects its not recommended to use Thread.sleep().</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-CgnMbs5X2XI/V6u7H9cTUDI/AAAAAAAAD_E/tOST32We88YBNGhwzKIZcNDNOxgaAHNfwCLcB/s1600/20.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="298" src="https://1.bp.blogspot.com/-CgnMbs5X2XI/V6u7H9cTUDI/AAAAAAAAD_E/tOST32We88YBNGhwzKIZcNDNOxgaAHNfwCLcB/s400/20.PNG" width="400" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-RNySo-JmvG8/V6u7N0GFe5I/AAAAAAAAD_M/R7WqqvI58KItI8BjDb3j4EuRYfYy03LnACLcB/s1600/21.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="241" src="https://3.bp.blogspot.com/-RNySo-JmvG8/V6u7N0GFe5I/AAAAAAAAD_M/R7WqqvI58KItI8BjDb3j4EuRYfYy03LnACLcB/s400/21.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
'<i>UnsupportedClassVersionError</i>' is occurred while executing the script, </div>
<div class="separator" style="clear: both; text-align: center;">
even after java 1.8 is installed and path setting is done in environment variables.</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Verify Eclipse IDE is mapping to Java 1.8.</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-5yPT5coaqbE/V6u9Sqb_jCI/AAAAAAAAD_Y/Ki3zkPPZxJAlvErplRaA9HlLnBnfvT0RwCLcB/s1600/15.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="188" src="https://4.bp.blogspot.com/-5yPT5coaqbE/V6u9Sqb_jCI/AAAAAAAAD_Y/Ki3zkPPZxJAlvErplRaA9HlLnBnfvT0RwCLcB/s400/15.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-f7mGRt0eb1E/V6u9Z-WMYcI/AAAAAAAAD_c/O1r0yp31IPsoCbaNdKayS5JedwX-pFD1gCLcB/s1600/16.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="385" src="https://2.bp.blogspot.com/-f7mGRt0eb1E/V6u9Z-WMYcI/AAAAAAAAD_c/O1r0yp31IPsoCbaNdKayS5JedwX-pFD1gCLcB/s400/16.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
If java version is not 1.8, then update java version to 1.8</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-YVojLlRSwO4/V6u-EN9d-1I/AAAAAAAAD_g/FA3EuvutDuUUdGxoTEbyeyLUZWxNpvAIQCLcB/s1600/17.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="355" src="https://2.bp.blogspot.com/-YVojLlRSwO4/V6u-EN9d-1I/AAAAAAAAD_g/FA3EuvutDuUUdGxoTEbyeyLUZWxNpvAIQCLcB/s400/17.PNG" width="400" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-NDoqsdciqH4/V6u-LdQ8L8I/AAAAAAAAD_k/J6dKK_DL3kQy8hqynz7RCnHocy1DziLnQCLcB/s1600/22.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="365" src="https://4.bp.blogspot.com/-NDoqsdciqH4/V6u-LdQ8L8I/AAAAAAAAD_k/J6dKK_DL3kQy8hqynz7RCnHocy1DziLnQCLcB/s400/22.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div style="text-align: center;">
If eclipse ide is mapping to older version of java, then update it to java 1.8 </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-TbIL-n3634c/V6u_qTG3cPI/AAAAAAAAEAE/-t-koFLDz00EoGrceOpEyXK7yOxKx1jiQCLcB/s1600/23.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="356" src="https://1.bp.blogspot.com/-TbIL-n3634c/V6u_qTG3cPI/AAAAAAAAEAE/-t-koFLDz00EoGrceOpEyXK7yOxKx1jiQCLcB/s400/23.PNG" width="400" /></a></div>
<div style="text-align: center;">
</div>
<div style="text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-umqq3a6jm80/V6u-ouRURiI/AAAAAAAAD_w/cB9RZbouzHUSZfqRqJQxuQ_tQmB-ml53wCLcB/s1600/24.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="297" src="https://2.bp.blogspot.com/-umqq3a6jm80/V6u-ouRURiI/AAAAAAAAD_w/cB9RZbouzHUSZfqRqJQxuQ_tQmB-ml53wCLcB/s400/24.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-3damUeiCMjM/V6u-uM0qvqI/AAAAAAAAD_4/Go556UfTkwwYV7vw2mxNt16AAbLba8XdACLcB/s1600/25.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="297" src="https://2.bp.blogspot.com/-3damUeiCMjM/V6u-uM0qvqI/AAAAAAAAD_4/Go556UfTkwwYV7vw2mxNt16AAbLba8XdACLcB/s400/25.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #0b5394;"><b>Re Execute the script: </b></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-_z5dmAqdWzc/V6u6LLgEgNI/AAAAAAAAD_A/gEFGB67Uts0Z9tuoKNtyA7-ao3oojkgCQCEw/s1600/19.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="238" src="https://3.bp.blogspot.com/-_z5dmAqdWzc/V6u6LLgEgNI/AAAAAAAAD_A/gEFGB67Uts0Z9tuoKNtyA7-ao3oojkgCQCEw/s400/19.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<b> </b></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-k0NXwiA2ybs/V6vBSUnvfbI/AAAAAAAAEAQ/JhzgkgW60FggIdOn2e0kyyt_Cqs0OWyPQCLcB/s1600/28.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="211" src="https://1.bp.blogspot.com/-k0NXwiA2ybs/V6vBSUnvfbI/AAAAAAAAEAQ/JhzgkgW60FggIdOn2e0kyyt_Cqs0OWyPQCLcB/s400/28.PNG" width="400" /> </a></div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div class="separator" style="clear: both; text-align: left;">
Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the <i><span style="color: #0b5394;">webdriver.gecko.driver</span> </i>system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from <i><span style="color: #0b5394;">https://github.com/mozilla/geckodriver/releases</span></i></div>
.......<br />
<div class="separator" style="clear: both; text-align: left;">
........ </div>
<div class="separator" style="clear: both; text-align: left;">
will be displayed.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #0b5394;"><b>Re-execute the script: </b></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #0b5394;"><span style="color: black;">Re-execute the script after performing below steps</span><b><br /></b></span></div>
<br />
<div style="text-align: center;">
Download the geckodriver from <a href="https://github.com/mozilla/geckodriver/releases" target="_blank">https://github.com/mozilla/geckodriver/releases</a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-V9ihxkkMm7I/V6vELWheSkI/AAAAAAAAEAc/8-VuETqFRE8Xmv2ijMtKXWnhXtm8s3viACLcB/s1600/41.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="176" src="https://2.bp.blogspot.com/-V9ihxkkMm7I/V6vELWheSkI/AAAAAAAAEAc/8-VuETqFRE8Xmv2ijMtKXWnhXtm8s3viACLcB/s400/41.PNG" width="400" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Extract the downloaded 'geckodriver-v0.10.0-win64.zip' file and copy the 'geckodriver.exe' in your webdriver project.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-A2GbvW1VScg/V6vFDwTcx1I/AAAAAAAAEAo/fU4dHviTnaIYvGhvNDztebI1GOSpHELRwCLcB/s1600/42.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://3.bp.blogspot.com/-A2GbvW1VScg/V6vFDwTcx1I/AAAAAAAAEAo/fU4dHviTnaIYvGhvNDztebI1GOSpHELRwCLcB/s1600/42.PNG" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Add below one line code in your webdriver automation script.</div>
<div class="separator" style="clear: both; text-align: center;">
<i>System.setProperty("<span style="color: purple;">webdriver.gecko.driver</span>", System.getProperty("user.dir") + "\\<span style="color: purple;">geckodriver.exe</span>"); </i></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #0b5394;"><b>Sample Program:</b></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #0b5394;"><span style="color: black;">import org.openqa.selenium.WebDriver;<br />import org.openqa.selenium.firefox.FirefoxDriver;<br /><br />public class WSTest {<br /> public static void main(String[] args) throws InterruptedException {<br /> <i><span style="color: purple;">System.setProperty("webdriver.gecko.driver", System.getProperty("user.dir") + "\\geckodriver.exe");</span></i><br /><br /> WebDriver driver = new FirefoxDriver();<br /> // driver.manage().window().maximize();<br /> driver.get("http://www.google.com");<br /><br /> Thread.sleep(3000);<br /> driver.close();<br /> driver.quit();<br /> }<br />}</span></span></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #0b5394;"><span style="color: black;">Re-execute the script now. </span><b> </b></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-EaZ1RMoIAuY/V6vG9aYZCSI/AAAAAAAAEA0/gKeNGEcNIdsqNE1KRh2fKiCVaj5Iv-YUgCLcB/s1600/30.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="213" src="https://4.bp.blogspot.com/-EaZ1RMoIAuY/V6vG9aYZCSI/AAAAAAAAEA0/gKeNGEcNIdsqNE1KRh2fKiCVaj5Iv-YUgCLcB/s400/30.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
You can observe the 'JavaScript warning' in console, but the script is executed successfully. <br />
<br />
<i>JavaScript warning: https://normandy.cdn.mozilla.net/static/bundles/selfrepair-72948156b77d6ce320e0.1e946d807ad4.js, line 11001: mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create</i><br />
<br />
<div style="text-align: center;">
Check the Firefox version</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-f_H1Ijnb88s/V6vIUG_azPI/AAAAAAAAEBE/2nHnP4seEOQ032UqSbB9QywXcgVR7QlgACLcB/s1600/31.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://4.bp.blogspot.com/-f_H1Ijnb88s/V6vIUG_azPI/AAAAAAAAEBE/2nHnP4seEOQ032UqSbB9QywXcgVR7QlgACLcB/s400/31.PNG" width="400" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Update the Firefox version.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-huIgzt6B1SM/V6vIuyhdkFI/AAAAAAAAEBI/30XNeML_HlIk0OPN28-W0BfzRollzxw4QCLcB/s1600/32.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="203" src="https://3.bp.blogspot.com/-huIgzt6B1SM/V6vIuyhdkFI/AAAAAAAAEBI/30XNeML_HlIk0OPN28-W0BfzRollzxw4QCLcB/s400/32.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Re-execute the script again, after updating the Firefox version</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-wo9tbK6Dg5w/V6vJLY2GkdI/AAAAAAAAEBU/hxq0xsgk4oAarBfbRKK8BUc95M-NR8HGACLcB/s1600/33.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="212" src="https://3.bp.blogspot.com/-wo9tbK6Dg5w/V6vJLY2GkdI/AAAAAAAAEBU/hxq0xsgk4oAarBfbRKK8BUc95M-NR8HGACLcB/s400/33.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
Observe there is no '<i>JavaScript warning</i>' in console and script is executed successfully(i.e. launching </div>
<div class="separator" style="clear: both; text-align: center;">
the firefox browser, access url http://www.google.com and close browser). </div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
By default firefox browser is maximized with out using the statement 'driver.manage().window().maximize();'.</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #0b5394;"><b>Summary: </b><span style="color: black;">To work with latest version of webdriver 3.0.0-beta2, it requires.</span></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #0b5394;"><span style="color: black;">- Install Java 1.8. </span></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #0b5394;"><span style="color: black;">- Open eclipse ide and update the JDK compiler compliance level to java 1.8.</span></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #0b5394;"><span style="color: black;">- Download webdriver java(</span></span><span style="color: #0b5394;"><span style="color: black;"><span style="color: #0b5394;"><span style="color: black;">3.0.0-beta2</span></span>) client libraries and set it in java build path.</span></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #0b5394;"><span style="color: black;">- Download the </span></span><span style="color: #0b5394;"><span style="color: black;"><i><span style="color: purple;">geckodriver.exe </span></i>and set it System.setProperty using '</span></span><span style="color: #0b5394;"><span style="color: black;"><span style="color: #0b5394;"><span style="color: black;"><i><span style="color: purple;">webdriver.gecko.driver</span></i></span></span>'.</span></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #0b5394;"><span style="color: black;"><i><span style="color: purple;">-</span></i> Upgrade the Firefox version to latest version.</span></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #0b5394;"><span style="color: black;">- By default firefox browser is maximized(i.e no need to use statement driver.manage().window().maximize();) </span><span style="color: black;"></span><b> </b></span></div>
</div>
Praveen Kumarhttp://www.blogger.com/profile/14705482110609285232noreply@blogger.com0tag:blogger.com,1999:blog-8903620123630625488.post-39871143601100830622016-08-10T15:38:00.000-07:002016-08-10T15:39:30.771-07:00Java 8 installation and path setting<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-kw09Mh02ps8/V6uhO4WNZXI/AAAAAAAAD8Q/ZIKX2aHeV7s3YV0i1d33_3Mz4u8QksLQwCLcB/s1600/0.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="246" src="https://2.bp.blogspot.com/-kw09Mh02ps8/V6uhO4WNZXI/AAAAAAAAD8Q/ZIKX2aHeV7s3YV0i1d33_3Mz4u8QksLQwCLcB/s400/0.PNG" width="400" /></a></div>
<br />
Install Java 8 from <a href="http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html" target="_blank">http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html</a><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-Kx4d_ayWneo/V6uh7qJITGI/AAAAAAAAD8U/wRD9iiwMGZ8PLdjes6ZLgu7WKY010hYwwCLcB/s1600/2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="277" src="https://4.bp.blogspot.com/-Kx4d_ayWneo/V6uh7qJITGI/AAAAAAAAD8U/wRD9iiwMGZ8PLdjes6ZLgu7WKY010hYwwCLcB/s400/2.PNG" width="400" /></a></div>
<div style="text-align: center;">
Click '<i><a class="download" href="https://www.blogger.com/null" id="jdk-8u101-oth-JPRXXXjdk-8u101-windows-x64.exe" name="jdk-8u101-oth-JPRXXXjdk-8u101-windows-x64.exe">jdk-8u101-windows-x64.exe</a></i>' to install java 8 (64 bit) for Windows OS.</div>
<div style="text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-MPn8R8UrWWg/V6uiTwFDaQI/AAAAAAAAD8c/1qHv4tUUSSYefupm4V6QcGuKjDBpqwETgCLcB/s1600/0_1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="48" src="https://2.bp.blogspot.com/-MPn8R8UrWWg/V6uiTwFDaQI/AAAAAAAAD8c/1qHv4tUUSSYefupm4V6QcGuKjDBpqwETgCLcB/s400/0_1.PNG" width="400" /></a></div>
<div style="text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-eejxYN19kv0/V6uiyeBMYgI/AAAAAAAAD8k/V9h6jnGBjsgBPPD3U56k0OgfqEe_BFiiwCLcB/s1600/3.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="185" src="https://4.bp.blogspot.com/-eejxYN19kv0/V6uiyeBMYgI/AAAAAAAAD8k/V9h6jnGBjsgBPPD3U56k0OgfqEe_BFiiwCLcB/s400/3.PNG" width="400" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
Click 'Save File'</div>
<div class="separator" style="clear: both; text-align: center;">
Click downloaded '<i>jdk-8u101-windows-x64.exe</i>' file to install. </div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-hvTzrBYnHng/V6ujlJw3G8I/AAAAAAAAD8w/X--3pLymMyQ5Nih6FE2KYHjgbjD5-VdlACLcB/s1600/5.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="303" src="https://1.bp.blogspot.com/-hvTzrBYnHng/V6ujlJw3G8I/AAAAAAAAD8w/X--3pLymMyQ5Nih6FE2KYHjgbjD5-VdlACLcB/s400/5.PNG" width="400" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
Click 'Next' button.</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-AY8nXX3ZPHM/V6ujwEfrYGI/AAAAAAAAD80/54mq42O5jJYNWS2xjJ8jT2COaDb2T0tzwCLcB/s1600/6.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="296" src="https://3.bp.blogspot.com/-AY8nXX3ZPHM/V6ujwEfrYGI/AAAAAAAAD80/54mq42O5jJYNWS2xjJ8jT2COaDb2T0tzwCLcB/s400/6.PNG" width="400" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
Click 'Next' button.</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-8SBdK9YaQTw/V6uj6hOi4uI/AAAAAAAAD88/2FuVKw3X-IUHjYQFYmRCup7HdHNN4Ya7wCLcB/s1600/7.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="307" src="https://2.bp.blogspot.com/-8SBdK9YaQTw/V6uj6hOi4uI/AAAAAAAAD88/2FuVKw3X-IUHjYQFYmRCup7HdHNN4Ya7wCLcB/s400/7.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-nz79lGE2XP8/V6ukHPAK9LI/AAAAAAAAD9A/vFwEs8j5VkgTiRtdVs17CawLdoWZMglbwCLcB/s1600/8.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="376" src="https://3.bp.blogspot.com/-nz79lGE2XP8/V6ukHPAK9LI/AAAAAAAAD9A/vFwEs8j5VkgTiRtdVs17CawLdoWZMglbwCLcB/s400/8.PNG" width="400" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
Click 'Next' button.</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-AqD9orpR8vc/V6ukS8Dd6eI/AAAAAAAAD9E/j_8MnQZlSC4kmNxNK-InefYJot1-hGKOwCLcB/s1600/9.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="372" src="https://1.bp.blogspot.com/-AqD9orpR8vc/V6ukS8Dd6eI/AAAAAAAAD9E/j_8MnQZlSC4kmNxNK-InefYJot1-hGKOwCLcB/s400/9.PNG" width="400" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-uOgiu6-T2fY/V6ukeMQpKfI/AAAAAAAAD9I/llyUyv0990o-xm6KA9vfTDWnmd_F1C0LACLcB/s1600/10.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="306" src="https://3.bp.blogspot.com/-uOgiu6-T2fY/V6ukeMQpKfI/AAAAAAAAD9I/llyUyv0990o-xm6KA9vfTDWnmd_F1C0LACLcB/s400/10.PNG" width="400" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
Click 'Close' button.</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Open the command prompt and type command 'java -version' and</div>
<div class="separator" style="clear: both; text-align: center;">
verify java 8 path is set.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-4nQQrjtpyLQ/V6ulGXDtHWI/AAAAAAAAD9U/bKxC3avQt803cCJq4vqJYgW6FsTI0WjRwCLcB/s1600/1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="138" src="https://3.bp.blogspot.com/-4nQQrjtpyLQ/V6ulGXDtHWI/AAAAAAAAD9U/bKxC3avQt803cCJq4vqJYgW6FsTI0WjRwCLcB/s400/1.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<i>Note:</i> In my machine java 7 is already installed and java 7 path is already set.</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
After executing the command 'java -version', if you can't view the </div>
<div class="separator" style="clear: both; text-align: center;">
java version as 1.8 that means java 8 path is not set.</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
You can set the java 8 path in environment path.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-4NPI9nks3vo/V6unHFZ8faI/AAAAAAAAD9k/t4lLJoTsQq8DsxvyDAMQ1gazZJdBopmgwCLcB/s1600/39.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="343" src="https://4.bp.blogspot.com/-4NPI9nks3vo/V6unHFZ8faI/AAAAAAAAD9k/t4lLJoTsQq8DsxvyDAMQ1gazZJdBopmgwCLcB/s400/39.PNG" width="400" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
<i>Note</i>: Above screenshot is captured from Windows 8 OS.</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Click 'Advanced' tab.</div>
<div class="separator" style="clear: both; text-align: center;">
Click 'Environment Variables' button. </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-nh18ESAGPFE/V6unPCg1ilI/AAAAAAAAD9o/R3OGfgCy9uUr8Zskgz0ow0GrBg8CPpZYgCLcB/s1600/40.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://4.bp.blogspot.com/-nh18ESAGPFE/V6unPCg1ilI/AAAAAAAAD9o/R3OGfgCy9uUr8Zskgz0ow0GrBg8CPpZYgCLcB/s400/40.PNG" width="357" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Update the java path to java 8(if java path is set for older version of java). </div>
<div class="separator" style="clear: both; text-align: center;">
If you are setting the java path for first time, then you can create a new variable 'JAVA_HOME' and</div>
<div class="separator" style="clear: both; text-align: center;">
enter variable value referring the '<<Path of java 8 jdk>>'</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-8W27suyGfNo/V6unxsPWGDI/AAAAAAAAD9s/NZsYI3kNWAktL9TQHT1b6-N73xLsxrc8QCLcB/s1600/11.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://4.bp.blogspot.com/-8W27suyGfNo/V6unxsPWGDI/AAAAAAAAD9s/NZsYI3kNWAktL9TQHT1b6-N73xLsxrc8QCLcB/s400/11.PNG" width="337" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-LJCaw8CjfoE/V6uoogMLGnI/AAAAAAAAD94/C7KA2rCh6wQZyvbZpRk2v3Ybcq_ffHR1wCLcB/s1600/12.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://4.bp.blogspot.com/-LJCaw8CjfoE/V6uoogMLGnI/AAAAAAAAD94/C7KA2rCh6wQZyvbZpRk2v3Ybcq_ffHR1wCLcB/s400/12.PNG" width="338" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Open the command prompt, if command prompt is already opened then close </div>
<div class="separator" style="clear: both; text-align: center;">
the command prompt and open the new command prompt.</div>
<div class="separator" style="clear: both; text-align: center;">
After command prompt is opened, execute the command 'java -version'.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-B4jN3uiFfIY/V6upPZt2RVI/AAAAAAAAD98/jRWEuzOQG-IpI7KSYdDKi7JbVDfEn03DwCLcB/s1600/13.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="105" src="https://4.bp.blogspot.com/-B4jN3uiFfIY/V6upPZt2RVI/AAAAAAAAD98/jRWEuzOQG-IpI7KSYdDKi7JbVDfEn03DwCLcB/s400/13.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
If java version 1.8 is displayed, that means java path is set to java 8.</div>
</div>
Praveen Kumarhttp://www.blogger.com/profile/14705482110609285232noreply@blogger.com0tag:blogger.com,1999:blog-8903620123630625488.post-28162072056733421042016-05-28T13:59:00.000-07:002016-05-28T15:14:08.210-07:00Negative scenarios for google search page<div dir="ltr" style="text-align: left;" trbidi="on">
Access the url: <a href="http://www.google.com/" target="_blank">www.google.com</a><br />
<br />
1. Enter negative numbers and click search button.<br />
ex: '-12'<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-njJxxAcY7z8/V0oFqcO_GzI/AAAAAAAAD58/sXepG6SWEiEiUTPWyfnGkBDe5FdAkLwcACLcB/s1600/Negative.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="166" src="https://3.bp.blogspot.com/-njJxxAcY7z8/V0oFqcO_GzI/AAAAAAAAD58/sXepG6SWEiEiUTPWyfnGkBDe5FdAkLwcACLcB/s320/Negative.PNG" width="320" /></a></div>
<br />
2. Special Characters<br />
ex: '#@$'<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-IYrMnmQB0nA/V0oFwhEHFAI/AAAAAAAAD6A/lFZyibayuqkLlN5e16QHKwN3mnpuJ4orgCLcB/s1600/SplChrs.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="141" src="https://4.bp.blogspot.com/-IYrMnmQB0nA/V0oFwhEHFAI/AAAAAAAAD6A/lFZyibayuqkLlN5e16QHKwN3mnpuJ4orgCLcB/s320/SplChrs.PNG" width="320" /></a></div>
<br />
3. Lengthy Characters<br />
ex: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-iCUNzvUZeo0/V0oGgmbu50I/AAAAAAAAD6Q/rz2ClUxIO2IOvnP9m2Ow9Kir0wTKLsELQCLcB/s1600/Long%2Bchars1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="164" src="https://2.bp.blogspot.com/-iCUNzvUZeo0/V0oGgmbu50I/AAAAAAAAD6Q/rz2ClUxIO2IOvnP9m2Ow9Kir0wTKLsELQCLcB/s320/Long%2Bchars1.PNG" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-zT1IwlVdjPg/V0oF1ph7-gI/AAAAAAAAD6E/JeIvVNPVPkgNjKFVFW1PpTGYriZso3OEgCLcB/s1600/Long%2Bchars.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="108" src="https://2.bp.blogspot.com/-zT1IwlVdjPg/V0oF1ph7-gI/AAAAAAAAD6E/JeIvVNPVPkgNjKFVFW1PpTGYriZso3OEgCLcB/s320/Long%2Bchars.PNG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<b>Search by voice:</b></div>
<div class="separator" style="clear: both;">
<i>Prerequisite</i>: Microphone already connected to system.</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
4. Click mic button and <b>don't speak</b> anything.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-jJ1tYbdNh0E/V0oQiwvIyxI/AAAAAAAAD6k/qOG2zhwR_RgGwXHCmmIiZ7cFrXCkLBTUQCLcB/s1600/M1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="166" src="https://3.bp.blogspot.com/-jJ1tYbdNh0E/V0oQiwvIyxI/AAAAAAAAD6k/qOG2zhwR_RgGwXHCmmIiZ7cFrXCkLBTUQCLcB/s320/M1.PNG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-CWg76qtqgGo/V0oQnhIINrI/AAAAAAAAD6o/HPCt1jrCNDcsF3jGidN3knMsFD0tUUCNACLcB/s1600/m1_1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="144" src="https://2.bp.blogspot.com/-CWg76qtqgGo/V0oQnhIINrI/AAAAAAAAD6o/HPCt1jrCNDcsF3jGidN3knMsFD0tUUCNACLcB/s320/m1_1.PNG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-qy4FE3wVNME/V0oQthB1UcI/AAAAAAAAD6s/fxyuRWjxW7QC2Bo2cY0DYGsVNyA6zvpTACLcB/s1600/m2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="172" src="https://4.bp.blogspot.com/-qy4FE3wVNME/V0oQthB1UcI/AAAAAAAAD6s/fxyuRWjxW7QC2Bo2cY0DYGsVNyA6zvpTACLcB/s320/m2.PNG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-m-mOyrGIiU4/V0oQ08PEwiI/AAAAAAAAD6w/QhDHk-DidAMEERntj6nNgtBh-7b3-XXrgCLcB/s1600/m3.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="145" src="https://1.bp.blogspot.com/-m-mOyrGIiU4/V0oQ08PEwiI/AAAAAAAAD6w/QhDHk-DidAMEERntj6nNgtBh-7b3-XXrgCLcB/s320/m3.PNG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
5. Blow air in the microphone, when 'Speak now' message is displayed.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-XDidRWn5IK4/V0oRL_2Bv4I/AAAAAAAAD64/QPaauKkxNSE3XZ-KSjNtopvFBkWqnYBiwCLcB/s1600/M5.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="62" src="https://4.bp.blogspot.com/-XDidRWn5IK4/V0oRL_2Bv4I/AAAAAAAAD64/QPaauKkxNSE3XZ-KSjNtopvFBkWqnYBiwCLcB/s320/M5.PNG" width="320" /></a></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
Below are some of the negative scenarios, related to other functionalities.</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<i>Negative Scenarios for 'Lift':</i></div>
<div class="separator" style="clear: both;">
1. Enter more than the specified person.</div>
<div class="separator" style="clear: both;">
2. press stop before the destination.</div>
<div class="separator" style="clear: both;">
3. press opposite button from the source. </div>
<div class="separator" style="clear: both;">
ex: if on ground floor press down button and vice versa.</div>
<div class="separator" style="clear: both;">
4. Bring obstacle when lift doors are about to close.</div>
<div class="separator" style="clear: both;">
5. Power off when lift moving downwards.</div>
<div class="separator" style="clear: both;">
ex: 5th floor to 4th floor</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<i>Negative Scenarios for 'Glass of water':</i></div>
<div class="separator" style="clear: both;">
- Check by filling the water greater than the capacity, it overflows or not ?</div>
<div class="separator" style="clear: both;">
- Place the glass inverted and to fill the glass, water splits outside or not ?</div>
<br /></div>
Praveen Kumarhttp://www.blogger.com/profile/14705482110609285232noreply@blogger.com0