Skip to content

Instantly share code, notes, and snippets.

Avatar

Parasoft ParasoftExamples

  • Parasoft
View GitHub Profile
@ParasoftExamples
ParasoftExamples / parameterized_test_example_1.java
Last active September 5, 2018 15:14
Junit Parameterized Tests Example 1
View parameterized_test_example_1.java
public LoanResponse requestLoan(float loanAmount, float downPayment, float availableFunds)
{
LoanResponse response = new LoanResponse();
response.setApproved(true);
if (availableFunds < downPayment) {
response.setApproved(false);
response.setMessage("error.insufficient.funds.for.down.payment");
return response;
}
@ParasoftExamples
ParasoftExamples / parameterized_test_example_2.java
Created September 5, 2018 15:21
Expedite the Creation of Junit Parameterized Tests - Example 2
View parameterized_test_example_2.java
@Test
public void testRequestLoan() throws Throwable
{
// Given
LoanProcessor underTest = new LoanProcessor();
// When
LoanResponse result = underTest.requestLoan(1000f, 200f, 250f);
// Then
@ParasoftExamples
ParasoftExamples / parameterized_test_example_3.java
Created September 7, 2018 20:52
Junit Parameterized Tests Example 3
View parameterized_test_example_3.java
@RunWith(Parameterized.class)
public class LoanProcessorParameterizedTest {
float loanAmount;
float downPayment;
float availableFunds;
boolean expectApproved;
String expectedMessage;
public LoanProcessorParameterizedTest(float loanAmount, float downPayment,
@ParasoftExamples
ParasoftExamples / parameterized_test_example_4.java
Created September 7, 2018 21:03
Junit Parameterized Tests Example 4
View parameterized_test_example_4.java
@Parameters(name = "Run {index}: loanAmount={0}, downPayment={1}, availableFunds={2}, expectApproved={3}, expectedMessage={4}")
public static Iterable<Object[]> data() throws Throwable
{
return Arrays.asList(new Object[][] {
{ 1000.0f, 200.0f, 250.0f, true, null }
});
}
@ParasoftExamples
ParasoftExamples / parameterized_test_example_5.java
Created September 7, 2018 21:04
Junit Parameterized Tests Example 5
View parameterized_test_example_5.java
@Parameters(name = "Run {index}: loanAmount={0}, downPayment={1}, availableFunds={2}, expectApproved={3}, expectedMessage={4}")
public static Iterable<Object[]> data() throws Throwable
{
return Arrays.asList(new Object[][] {
{ 1000.0f, 200.0f, 250.0f, true, null },
{ 1000.0f, 50.0f, 250.0f, false, "error.insufficient.down.payment" },
{ 1000.0f, 200.0f, 150.0f, false, "error.insufficient.funds.for.down.payment" }
});
}
@ParasoftExamples
ParasoftExamples / parameterized_test_example_6.java
Created September 7, 2018 21:07
Junit Parameterized Tests Example 6
View parameterized_test_example_6.java
@Test
public void testRequestLoan() throws Throwable
{
// Given
LoanProcessor underTest = new LoanProcessor();
// When
LoanResponse result = underTest.requestLoan(loanAmount, downPayment, availableFunds);
// Then
@ParasoftExamples
ParasoftExamples / parameterized_test_example_7.java
Created September 7, 2018 21:09
Junit Parameterized Tests Example 7
View parameterized_test_example_7.java
@RunWith(JUnitParamsRunner.class)
public class LoanProcessorParameterizedTest2 {
@Test
@Parameters(method = "testRequestLoan_Parameters")
public void testRequestLoan(float loanAmount, float downPayment, float availableFunds,
boolean expectApproved, String expectedMessage) throws Throwable
{
...
}
View Insure++_Heartbleed_5.sh
#!/usr/bin/env bash
OPENSSL_PATH=’/home/USER/heartbleed/env’
INSURE_PATH=’/home/USER/insure’
MY_LIBS=’-linsure -linsure_mt -ldl’
MY_LIB_PATHS="-L${OPENSSL_PATH}/lib -L${INSURE_PATH}/lib"
MY_LD_LIB_PATHS="${OPENSSL_PATH}/lib:${INSURE_PATH}/lib"
MY_FLAGS="$MY_LIB_PATHS $MY_LIBS"
CC="$(command -v gcc)" \
CXX="$(command -v g++)" \
View Insure++_Heartbleed_7.html
<html>
<head>
<title>Heartbleed Demo</title>
</head>
<body>
<h1>Hello world!</h1>
</body>
</html>
View Insure++_Heartbleed_9_lighttpd.conf
server.modules = (
"mod_openssl",
"mod_access",
"mod_accesslog",
)
server.port = 8080
server.username = "USER"
server.groupname = "GROUP"
server.document-root = "/home/USER/heartbleed/srv"
server.errorlog = "/home/USER/heartbleed/lighttpd_error.log"