Gatling vs JMeter vs The Grinder
Issue: BAEL-46
This commit is contained in:
committed by
Josh Cummings
parent
5ad9f285e1
commit
bb00c37151
+12
@@ -0,0 +1,12 @@
|
||||
package com.baeldung.loadtesting;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package com.baeldung.loadtesting;
|
||||
|
||||
import com.baeldung.loadtesting.model.CustomerRewardsAccount;
|
||||
import com.baeldung.loadtesting.model.Transaction;
|
||||
import com.baeldung.loadtesting.repository.CustomerRewardsRepository;
|
||||
import com.baeldung.loadtesting.repository.TransactionRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
public class RewardsController {
|
||||
|
||||
@Autowired
|
||||
private CustomerRewardsRepository customerRewardsRepository;
|
||||
|
||||
@Autowired
|
||||
private TransactionRepository transactionRepository;
|
||||
|
||||
@PostMapping(path="/transactions/add")
|
||||
public @ResponseBody Transaction saveTransactions(@RequestBody Transaction trnsctn){
|
||||
trnsctn.setTransactionDate(Calendar.getInstance().getTime());
|
||||
Transaction result = transactionRepository.save(trnsctn);
|
||||
return result;
|
||||
}
|
||||
|
||||
@GetMapping(path="/transactions/findAll/{rewardId}")
|
||||
public @ResponseBody Iterable<Transaction> getTransactions(@PathVariable Integer rewardId){
|
||||
return transactionRepository.findByCustomerRewardsId(rewardId);
|
||||
}
|
||||
|
||||
@PostMapping(path="/rewards/add")
|
||||
public @ResponseBody CustomerRewardsAccount addRewardsAcount(@RequestBody CustomerRewardsAccount body) {
|
||||
Optional<CustomerRewardsAccount> acct = customerRewardsRepository.findByCustomerId(body.getCustomerId());
|
||||
return !acct.isPresent() ? customerRewardsRepository.save(body) : acct.get();
|
||||
}
|
||||
|
||||
@GetMapping(path="/rewards/find/{customerId}")
|
||||
public @ResponseBody
|
||||
Optional<CustomerRewardsAccount> find(@PathVariable Integer customerId) {
|
||||
return customerRewardsRepository.findByCustomerId(customerId);
|
||||
}
|
||||
|
||||
@GetMapping(path="/rewards/all")
|
||||
public @ResponseBody List<CustomerRewardsAccount> findAll() {
|
||||
return customerRewardsRepository.findAll();
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.baeldung.loadtesting;
|
||||
|
||||
import com.baeldung.loadtesting.model.Transaction;
|
||||
import com.baeldung.loadtesting.repository.TransactionRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@Deprecated
|
||||
public class TransactionController {
|
||||
|
||||
@Autowired
|
||||
private TransactionRepository transactionRepository;
|
||||
|
||||
@PostMapping(path="/addTransaction")
|
||||
public @ResponseBody
|
||||
String saveTransactions(@RequestBody Transaction trnsctn){
|
||||
transactionRepository.save(trnsctn);
|
||||
return "Saved Transaction.";
|
||||
}
|
||||
|
||||
@GetMapping(path="/findAll/{rewardId}")
|
||||
public @ResponseBody Iterable<Transaction> getTransactions(@RequestParam Integer id){
|
||||
return transactionRepository.findByCustomerRewardsId(id);
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.baeldung.loadtesting.model;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class CustomerRewardsAccount {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.AUTO)
|
||||
private Integer id;
|
||||
private Integer customerId;
|
||||
|
||||
public Integer getCustomerId(){
|
||||
return this.customerId;
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.baeldung.loadtesting.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import java.util.Date;
|
||||
import java.util.Calendar;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class Transaction {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.AUTO)
|
||||
private Integer id;
|
||||
private Integer customerRewardsId;
|
||||
private Integer customerId;
|
||||
private Date transactionDate;
|
||||
|
||||
public Transaction(){
|
||||
transactionDate = Calendar.getInstance().getTime();
|
||||
}
|
||||
|
||||
public void setTransactionDate(Date transactionDate){
|
||||
this.transactionDate = transactionDate;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.baeldung.loadtesting.repository;
|
||||
|
||||
import com.baeldung.loadtesting.model.CustomerRewardsAccount;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface CustomerRewardsRepository extends JpaRepository<CustomerRewardsAccount, Integer> {
|
||||
|
||||
Optional<CustomerRewardsAccount> findByCustomerId(Integer customerId);
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.baeldung.loadtesting.repository;
|
||||
|
||||
import com.baeldung.loadtesting.model.Transaction;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TransactionRepository extends JpaRepository<Transaction, Integer> {
|
||||
|
||||
List<Transaction> findByCustomerRewardsId(Integer rewardsId);
|
||||
}
|
||||
Reference in New Issue
Block a user