SlideShare a Scribd company logo
1. JUnit test for method toString() in SalariedEmployee -
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
public class SalariedEmployeeTest {
@Test
public void testToString(){
String name="name";
double salary=3000;
double bonus=1000;
SalariedEmployee employee= new SalariedEmployee(name,salary,bonus);
employee.toString();
}
}
2. JAva program to replace "is" with "was" -
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class StringReplace {
public static void main(String[] args) throws IOException {
BufferedReader br = null;
File file = new File("/My Stuffs/Root/Workspace/TestJava/src/com/test/output.txt");
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
if (!file.exists()) {
file.createNewFile();
}
try {
String sCurrentLine;
br = new BufferedReader(new FileReader("/My
Stuffs/Root/Workspace/TestJava/src/com/test/testing.txt"));
while ((sCurrentLine = br.readLine()) != null) {
System.out.println(sCurrentLine);
String rep=sCurrentLine.replaceAll(" is "," was ");
System.out.println(rep);
bw.write(rep);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (br != null)br.close();
if(bw!=null)bw.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
}
Solution
1. JUnit test for method toString() in SalariedEmployee -
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
public class SalariedEmployeeTest {
@Test
public void testToString(){
String name="name";
double salary=3000;
double bonus=1000;
SalariedEmployee employee= new SalariedEmployee(name,salary,bonus);
employee.toString();
}
}
2. JAva program to replace "is" with "was" -
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class StringReplace {
public static void main(String[] args) throws IOException {
BufferedReader br = null;
File file = new File("/My Stuffs/Root/Workspace/TestJava/src/com/test/output.txt");
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
if (!file.exists()) {
file.createNewFile();
}
try {
String sCurrentLine;
br = new BufferedReader(new FileReader("/My
Stuffs/Root/Workspace/TestJava/src/com/test/testing.txt"));
while ((sCurrentLine = br.readLine()) != null) {
System.out.println(sCurrentLine);
String rep=sCurrentLine.replaceAll(" is "," was ");
System.out.println(rep);
bw.write(rep);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (br != null)br.close();
if(bw!=null)bw.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
}

More Related Content

Similar to 1. JUnit test for method toString() in SalariedEmployee -import or.pdf

Write an example of a unit test for a Class methods using JUnitfr.pdf
Write an example of a unit test for a Class methods using JUnitfr.pdfWrite an example of a unit test for a Class methods using JUnitfr.pdf
Write an example of a unit test for a Class methods using JUnitfr.pdf
arbaazrabs
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ Exams
MuhammadTalha436
 
The sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdfThe sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdf
rajat630669
 
The sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdfThe sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdf
rajat630669
 
Important java programs(collection+file)
Important java programs(collection+file)Important java programs(collection+file)
Important java programs(collection+file)
Alok Kumar
 
Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...
Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...
Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...
solit
 
TestNG vs Junit
TestNG vs JunitTestNG vs Junit
TestNG vs Junit
Büşra İçöz
 
First compile all the classes.But to run the program we have to run .pdf
First compile all the classes.But to run the program we have to run .pdfFirst compile all the classes.But to run the program we have to run .pdf
First compile all the classes.But to run the program we have to run .pdf
aoneonlinestore1
 
The Java Program for the above given isimport java.io.File;impo.pdf
The Java Program for the above given isimport java.io.File;impo.pdfThe Java Program for the above given isimport java.io.File;impo.pdf
The Java Program for the above given isimport java.io.File;impo.pdf
anjanacottonmills
 
FunctionalInterfaces
FunctionalInterfacesFunctionalInterfaces
FunctionalInterfaces
YourVirtual Class
 
FunctionalInterfaces
FunctionalInterfacesFunctionalInterfaces
FunctionalInterfaces
Ralph Lecessi Incorporated
 
package employeeType.employee;public class Employee {   private .pdf
package employeeType.employee;public class Employee {   private .pdfpackage employeeType.employee;public class Employee {   private .pdf
package employeeType.employee;public class Employee {   private .pdf
anwarsadath111
 
Android testing
Android testingAndroid testing
Android testing
Sean Tsai
 
What do you mean it needs to be Java based? How jython saved the day.
What do you mean it needs to be Java based? How jython saved the day.What do you mean it needs to be Java based? How jython saved the day.
What do you mean it needs to be Java based? How jython saved the day.
Mark Rees
 
Creating a Facebook Clone - Part XLVI - Transcript.pdf
Creating a Facebook Clone - Part XLVI - Transcript.pdfCreating a Facebook Clone - Part XLVI - Transcript.pdf
Creating a Facebook Clone - Part XLVI - Transcript.pdf
ShaiAlmog1
 
Junit and testNG
Junit and testNGJunit and testNG
Junit and testNG
Марія Русин
 
T.Y.B.S.CS Advance Java Practicals Sem 5 Mumbai University
T.Y.B.S.CS Advance Java Practicals Sem 5 Mumbai UniversityT.Y.B.S.CS Advance Java Practicals Sem 5 Mumbai University
T.Y.B.S.CS Advance Java Practicals Sem 5 Mumbai University
Niraj Bharambe
 
Oop lecture6
Oop lecture6Oop lecture6
Oop lecture6
Shahriar Robbani
 
Android TDD
Android TDDAndroid TDD
Android TDD
Godfrey Nolan
 
Test-driven Development for TYPO3
Test-driven Development for TYPO3Test-driven Development for TYPO3
Test-driven Development for TYPO3
Oliver Klee
 

Similar to 1. JUnit test for method toString() in SalariedEmployee -import or.pdf (20)

Write an example of a unit test for a Class methods using JUnitfr.pdf
Write an example of a unit test for a Class methods using JUnitfr.pdfWrite an example of a unit test for a Class methods using JUnitfr.pdf
Write an example of a unit test for a Class methods using JUnitfr.pdf
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ Exams
 
The sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdfThe sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdf
 
The sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdfThe sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdf
 
Important java programs(collection+file)
Important java programs(collection+file)Important java programs(collection+file)
Important java programs(collection+file)
 
Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...
Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...
Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...
 
TestNG vs Junit
TestNG vs JunitTestNG vs Junit
TestNG vs Junit
 
First compile all the classes.But to run the program we have to run .pdf
First compile all the classes.But to run the program we have to run .pdfFirst compile all the classes.But to run the program we have to run .pdf
First compile all the classes.But to run the program we have to run .pdf
 
The Java Program for the above given isimport java.io.File;impo.pdf
The Java Program for the above given isimport java.io.File;impo.pdfThe Java Program for the above given isimport java.io.File;impo.pdf
The Java Program for the above given isimport java.io.File;impo.pdf
 
FunctionalInterfaces
FunctionalInterfacesFunctionalInterfaces
FunctionalInterfaces
 
FunctionalInterfaces
FunctionalInterfacesFunctionalInterfaces
FunctionalInterfaces
 
package employeeType.employee;public class Employee {   private .pdf
package employeeType.employee;public class Employee {   private .pdfpackage employeeType.employee;public class Employee {   private .pdf
package employeeType.employee;public class Employee {   private .pdf
 
Android testing
Android testingAndroid testing
Android testing
 
What do you mean it needs to be Java based? How jython saved the day.
What do you mean it needs to be Java based? How jython saved the day.What do you mean it needs to be Java based? How jython saved the day.
What do you mean it needs to be Java based? How jython saved the day.
 
Creating a Facebook Clone - Part XLVI - Transcript.pdf
Creating a Facebook Clone - Part XLVI - Transcript.pdfCreating a Facebook Clone - Part XLVI - Transcript.pdf
Creating a Facebook Clone - Part XLVI - Transcript.pdf
 
Junit and testNG
Junit and testNGJunit and testNG
Junit and testNG
 
T.Y.B.S.CS Advance Java Practicals Sem 5 Mumbai University
T.Y.B.S.CS Advance Java Practicals Sem 5 Mumbai UniversityT.Y.B.S.CS Advance Java Practicals Sem 5 Mumbai University
T.Y.B.S.CS Advance Java Practicals Sem 5 Mumbai University
 
Oop lecture6
Oop lecture6Oop lecture6
Oop lecture6
 
Android TDD
Android TDDAndroid TDD
Android TDD
 
Test-driven Development for TYPO3
Test-driven Development for TYPO3Test-driven Development for TYPO3
Test-driven Development for TYPO3
 

More from arakalamkah11

Particulars $Amount Direct materials 64452 Direct Labour (1332.pdf
    Particulars $Amount   Direct materials 64452   Direct Labour (1332.pdf    Particulars $Amount   Direct materials 64452   Direct Labour (1332.pdf
Particulars $Amount Direct materials 64452 Direct Labour (1332.pdf
arakalamkah11
 
Decrease in inventory Source of cash $   440 Decrease in account.pdf
    Decrease in inventory Source of cash $   440   Decrease in account.pdf    Decrease in inventory Source of cash $   440   Decrease in account.pdf
Decrease in inventory Source of cash $   440 Decrease in account.pdf
arakalamkah11
 
Diamond is sp3 covalent. It makes for bonds to ne.pdf
                     Diamond is sp3 covalent. It makes for bonds to ne.pdf                     Diamond is sp3 covalent. It makes for bonds to ne.pdf
Diamond is sp3 covalent. It makes for bonds to ne.pdf
arakalamkah11
 
Too low. If you do not dry the sodium thiosulfate.pdf
                     Too low. If you do not dry the sodium thiosulfate.pdf                     Too low. If you do not dry the sodium thiosulfate.pdf
Too low. If you do not dry the sodium thiosulfate.pdf
arakalamkah11
 
1. A bus is a bunch of wires used to connect multiple subsystems. Bu.pdf
1. A bus is a bunch of wires used to connect multiple subsystems. Bu.pdf1. A bus is a bunch of wires used to connect multiple subsystems. Bu.pdf
1. A bus is a bunch of wires used to connect multiple subsystems. Bu.pdf
arakalamkah11
 
1. E) The vapor pressure of a liquid.Increasing attractive intermo.pdf
1. E) The vapor pressure of a liquid.Increasing attractive intermo.pdf1. E) The vapor pressure of a liquid.Increasing attractive intermo.pdf
1. E) The vapor pressure of a liquid.Increasing attractive intermo.pdf
arakalamkah11
 
Light is a form of energy that can be released by.pdf
                     Light is a form of energy that can be released by.pdf                     Light is a form of energy that can be released by.pdf
Light is a form of energy that can be released by.pdf
arakalamkah11
 
1) Presence of jaws with paired fins in fish helps to feed them. Fin.pdf
1) Presence of jaws with paired fins in fish helps to feed them. Fin.pdf1) Presence of jaws with paired fins in fish helps to feed them. Fin.pdf
1) Presence of jaws with paired fins in fish helps to feed them. Fin.pdf
arakalamkah11
 
Youre looking for Ka, the dissociation constant.pdf
                     Youre looking for Ka, the dissociation constant.pdf                     Youre looking for Ka, the dissociation constant.pdf
Youre looking for Ka, the dissociation constant.pdf
arakalamkah11
 
Okay so dipole-dipole interactions would occur be.pdf
                     Okay so dipole-dipole interactions would occur be.pdf                     Okay so dipole-dipole interactions would occur be.pdf
Okay so dipole-dipole interactions would occur be.pdf
arakalamkah11
 
remote operating system installationRemote Installation Services (.pdf
remote operating system installationRemote Installation Services (.pdfremote operating system installationRemote Installation Services (.pdf
remote operating system installationRemote Installation Services (.pdf
arakalamkah11
 
Title of this process is The Project Life Cycle (Phases)The pr.pdf
Title of this process is The Project Life Cycle (Phases)The pr.pdfTitle of this process is The Project Life Cycle (Phases)The pr.pdf
Title of this process is The Project Life Cycle (Phases)The pr.pdf
arakalamkah11
 
The answer is A) Pol II, with twelve subunits on its own, is capable.pdf
The answer is A) Pol II, with twelve subunits on its own, is capable.pdfThe answer is A) Pol II, with twelve subunits on its own, is capable.pdf
The answer is A) Pol II, with twelve subunits on its own, is capable.pdf
arakalamkah11
 
solutionA=  1    1    0    4    3    1    2    0 .pdf
solutionA=  1    1    0    4    3    1    2    0 .pdfsolutionA=  1    1    0    4    3    1    2    0 .pdf
solutionA=  1    1    0    4    3    1    2    0 .pdf
arakalamkah11
 
Q1). Gene therapy is an experimental approach to treat the disease b.pdf
Q1). Gene therapy is an experimental approach to treat the disease b.pdfQ1). Gene therapy is an experimental approach to treat the disease b.pdf
Q1). Gene therapy is an experimental approach to treat the disease b.pdf
arakalamkah11
 
Solution Three modes of DNA replication 1) Semi conservative.pdf
Solution Three modes of DNA replication 1) Semi conservative.pdfSolution Three modes of DNA replication 1) Semi conservative.pdf
Solution Three modes of DNA replication 1) Semi conservative.pdf
arakalamkah11
 
package s3; Copy paste this Java Template and save it as Emer.pdf
package s3;  Copy paste this Java Template and save it as Emer.pdfpackage s3;  Copy paste this Java Template and save it as Emer.pdf
package s3; Copy paste this Java Template and save it as Emer.pdf
arakalamkah11
 
Our body is having two line defence system against pathogens.Pathoge.pdf
Our body is having two line defence system against pathogens.Pathoge.pdfOur body is having two line defence system against pathogens.Pathoge.pdf
Our body is having two line defence system against pathogens.Pathoge.pdf
arakalamkah11
 
Once neurons are produced, they migrate and modify to form six layer.pdf
Once neurons are produced, they migrate and modify to form six layer.pdfOnce neurons are produced, they migrate and modify to form six layer.pdf
Once neurons are produced, they migrate and modify to form six layer.pdf
arakalamkah11
 
PDU is called Protocol Data Unit.It consists of user data and protoc.pdf
PDU is called Protocol Data Unit.It consists of user data and protoc.pdfPDU is called Protocol Data Unit.It consists of user data and protoc.pdf
PDU is called Protocol Data Unit.It consists of user data and protoc.pdf
arakalamkah11
 

More from arakalamkah11 (20)

Particulars $Amount Direct materials 64452 Direct Labour (1332.pdf
    Particulars $Amount   Direct materials 64452   Direct Labour (1332.pdf    Particulars $Amount   Direct materials 64452   Direct Labour (1332.pdf
Particulars $Amount Direct materials 64452 Direct Labour (1332.pdf
 
Decrease in inventory Source of cash $   440 Decrease in account.pdf
    Decrease in inventory Source of cash $   440   Decrease in account.pdf    Decrease in inventory Source of cash $   440   Decrease in account.pdf
Decrease in inventory Source of cash $   440 Decrease in account.pdf
 
Diamond is sp3 covalent. It makes for bonds to ne.pdf
                     Diamond is sp3 covalent. It makes for bonds to ne.pdf                     Diamond is sp3 covalent. It makes for bonds to ne.pdf
Diamond is sp3 covalent. It makes for bonds to ne.pdf
 
Too low. If you do not dry the sodium thiosulfate.pdf
                     Too low. If you do not dry the sodium thiosulfate.pdf                     Too low. If you do not dry the sodium thiosulfate.pdf
Too low. If you do not dry the sodium thiosulfate.pdf
 
1. A bus is a bunch of wires used to connect multiple subsystems. Bu.pdf
1. A bus is a bunch of wires used to connect multiple subsystems. Bu.pdf1. A bus is a bunch of wires used to connect multiple subsystems. Bu.pdf
1. A bus is a bunch of wires used to connect multiple subsystems. Bu.pdf
 
1. E) The vapor pressure of a liquid.Increasing attractive intermo.pdf
1. E) The vapor pressure of a liquid.Increasing attractive intermo.pdf1. E) The vapor pressure of a liquid.Increasing attractive intermo.pdf
1. E) The vapor pressure of a liquid.Increasing attractive intermo.pdf
 
Light is a form of energy that can be released by.pdf
                     Light is a form of energy that can be released by.pdf                     Light is a form of energy that can be released by.pdf
Light is a form of energy that can be released by.pdf
 
1) Presence of jaws with paired fins in fish helps to feed them. Fin.pdf
1) Presence of jaws with paired fins in fish helps to feed them. Fin.pdf1) Presence of jaws with paired fins in fish helps to feed them. Fin.pdf
1) Presence of jaws with paired fins in fish helps to feed them. Fin.pdf
 
Youre looking for Ka, the dissociation constant.pdf
                     Youre looking for Ka, the dissociation constant.pdf                     Youre looking for Ka, the dissociation constant.pdf
Youre looking for Ka, the dissociation constant.pdf
 
Okay so dipole-dipole interactions would occur be.pdf
                     Okay so dipole-dipole interactions would occur be.pdf                     Okay so dipole-dipole interactions would occur be.pdf
Okay so dipole-dipole interactions would occur be.pdf
 
remote operating system installationRemote Installation Services (.pdf
remote operating system installationRemote Installation Services (.pdfremote operating system installationRemote Installation Services (.pdf
remote operating system installationRemote Installation Services (.pdf
 
Title of this process is The Project Life Cycle (Phases)The pr.pdf
Title of this process is The Project Life Cycle (Phases)The pr.pdfTitle of this process is The Project Life Cycle (Phases)The pr.pdf
Title of this process is The Project Life Cycle (Phases)The pr.pdf
 
The answer is A) Pol II, with twelve subunits on its own, is capable.pdf
The answer is A) Pol II, with twelve subunits on its own, is capable.pdfThe answer is A) Pol II, with twelve subunits on its own, is capable.pdf
The answer is A) Pol II, with twelve subunits on its own, is capable.pdf
 
solutionA=  1    1    0    4    3    1    2    0 .pdf
solutionA=  1    1    0    4    3    1    2    0 .pdfsolutionA=  1    1    0    4    3    1    2    0 .pdf
solutionA=  1    1    0    4    3    1    2    0 .pdf
 
Q1). Gene therapy is an experimental approach to treat the disease b.pdf
Q1). Gene therapy is an experimental approach to treat the disease b.pdfQ1). Gene therapy is an experimental approach to treat the disease b.pdf
Q1). Gene therapy is an experimental approach to treat the disease b.pdf
 
Solution Three modes of DNA replication 1) Semi conservative.pdf
Solution Three modes of DNA replication 1) Semi conservative.pdfSolution Three modes of DNA replication 1) Semi conservative.pdf
Solution Three modes of DNA replication 1) Semi conservative.pdf
 
package s3; Copy paste this Java Template and save it as Emer.pdf
package s3;  Copy paste this Java Template and save it as Emer.pdfpackage s3;  Copy paste this Java Template and save it as Emer.pdf
package s3; Copy paste this Java Template and save it as Emer.pdf
 
Our body is having two line defence system against pathogens.Pathoge.pdf
Our body is having two line defence system against pathogens.Pathoge.pdfOur body is having two line defence system against pathogens.Pathoge.pdf
Our body is having two line defence system against pathogens.Pathoge.pdf
 
Once neurons are produced, they migrate and modify to form six layer.pdf
Once neurons are produced, they migrate and modify to form six layer.pdfOnce neurons are produced, they migrate and modify to form six layer.pdf
Once neurons are produced, they migrate and modify to form six layer.pdf
 
PDU is called Protocol Data Unit.It consists of user data and protoc.pdf
PDU is called Protocol Data Unit.It consists of user data and protoc.pdfPDU is called Protocol Data Unit.It consists of user data and protoc.pdf
PDU is called Protocol Data Unit.It consists of user data and protoc.pdf
 

Recently uploaded

Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 

Recently uploaded (20)

Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 

1. JUnit test for method toString() in SalariedEmployee -import or.pdf

  • 1. 1. JUnit test for method toString() in SalariedEmployee - import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.runners.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class SalariedEmployeeTest { @Test public void testToString(){ String name="name"; double salary=3000; double bonus=1000; SalariedEmployee employee= new SalariedEmployee(name,salary,bonus); employee.toString(); } } 2. JAva program to replace "is" with "was" - import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class StringReplace { public static void main(String[] args) throws IOException { BufferedReader br = null; File file = new File("/My Stuffs/Root/Workspace/TestJava/src/com/test/output.txt"); FileWriter fw = new FileWriter(file.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw); if (!file.exists()) { file.createNewFile(); } try { String sCurrentLine; br = new BufferedReader(new FileReader("/My
  • 2. Stuffs/Root/Workspace/TestJava/src/com/test/testing.txt")); while ((sCurrentLine = br.readLine()) != null) { System.out.println(sCurrentLine); String rep=sCurrentLine.replaceAll(" is "," was "); System.out.println(rep); bw.write(rep); } } catch (IOException e) { e.printStackTrace(); } finally { try { if (br != null)br.close(); if(bw!=null)bw.close(); } catch (IOException ex) { ex.printStackTrace(); } } } } Solution 1. JUnit test for method toString() in SalariedEmployee - import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.runners.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class SalariedEmployeeTest { @Test public void testToString(){ String name="name"; double salary=3000; double bonus=1000; SalariedEmployee employee= new SalariedEmployee(name,salary,bonus); employee.toString();
  • 3. } } 2. JAva program to replace "is" with "was" - import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class StringReplace { public static void main(String[] args) throws IOException { BufferedReader br = null; File file = new File("/My Stuffs/Root/Workspace/TestJava/src/com/test/output.txt"); FileWriter fw = new FileWriter(file.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw); if (!file.exists()) { file.createNewFile(); } try { String sCurrentLine; br = new BufferedReader(new FileReader("/My Stuffs/Root/Workspace/TestJava/src/com/test/testing.txt")); while ((sCurrentLine = br.readLine()) != null) { System.out.println(sCurrentLine); String rep=sCurrentLine.replaceAll(" is "," was "); System.out.println(rep); bw.write(rep); } } catch (IOException e) { e.printStackTrace(); } finally { try { if (br != null)br.close(); if(bw!=null)bw.close(); } catch (IOException ex) { ex.printStackTrace();