BAEL-611: Minor formatting changes (#1534)

* Add NDC and JBoss Logging to the demo application

* NDC for Log4j, Log4j2 and JBoss Logging

* Simplify NDC example by making it a single operation instead of two

* Make NDC example as RestController, Use JBoss Logging only as a logging bridge

* Fix merge conflicts in pull request - log-mdc pom.xml updated

* BAEL-445 Update to Spring security SpEL example

* BAEL-445: Change tabs to spaces in the updated code

* BAEL-245: Add Enum Serialization exmaple

* BAEL-245: Remove the folder jackson/src/test/java/com/baeldung/jackson/dtos/withEnum as the example is not used anymore

* Add more enum serialization examples to align with previous example and prevent build fail

* BAEL-611: Minor formatting changes

* BAEL-611: Update Test case method names
This commit is contained in:
Sunil Mogadati 2017-03-30 02:54:26 -06:00 committed by GitHub
parent 47dfe6b641
commit ec089be605
9 changed files with 46 additions and 39 deletions

View File

@ -28,7 +28,6 @@
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version> <maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
<maven-war-plugin.version>2.6</maven-war-plugin.version> <maven-war-plugin.version>2.6</maven-war-plugin.version>
<mockito.version>1.10.19</mockito.version>
</properties> </properties>
<prerequisites> <prerequisites>

View File

@ -1,13 +1,14 @@
package com.baeldung.jaxws; package com.baeldung.jaxws;
import java.util.List;
import javax.jws.WebMethod;
import javax.jws.WebService;
import com.baeldung.jaxws.exception.EmployeeAlreadyExists; import com.baeldung.jaxws.exception.EmployeeAlreadyExists;
import com.baeldung.jaxws.exception.EmployeeNotFound; import com.baeldung.jaxws.exception.EmployeeNotFound;
import com.baeldung.jaxws.model.Employee; import com.baeldung.jaxws.model.Employee;
import javax.jws.WebMethod;
import javax.jws.WebService;
import java.util.List;
@WebService @WebService
public interface EmployeeService { public interface EmployeeService {

View File

@ -1,15 +1,16 @@
package com.baeldung.jaxws; package com.baeldung.jaxws;
import java.util.List;
import javax.inject.Inject;
import javax.jws.WebMethod;
import javax.jws.WebService;
import com.baeldung.jaxws.exception.EmployeeAlreadyExists; import com.baeldung.jaxws.exception.EmployeeAlreadyExists;
import com.baeldung.jaxws.exception.EmployeeNotFound; import com.baeldung.jaxws.exception.EmployeeNotFound;
import com.baeldung.jaxws.model.Employee; import com.baeldung.jaxws.model.Employee;
import com.baeldung.jaxws.repository.EmployeeRepository; import com.baeldung.jaxws.repository.EmployeeRepository;
import javax.inject.Inject;
import javax.jws.WebMethod;
import javax.jws.WebService;
import java.util.List;
@WebService(serviceName = "EmployeeService", endpointInterface = "com.baeldung.jaxws.EmployeeService") @WebService(serviceName = "EmployeeService", endpointInterface = "com.baeldung.jaxws.EmployeeService")
public class EmployeeServiceImpl implements EmployeeService { public class EmployeeServiceImpl implements EmployeeService {

View File

@ -1,9 +1,9 @@
package com.baeldung.jaxws.config; package com.baeldung.jaxws.config;
import com.baeldung.jaxws.EmployeeServiceImpl;
import javax.xml.ws.Endpoint; import javax.xml.ws.Endpoint;
import com.baeldung.jaxws.EmployeeServiceImpl;
public class EmployeeServicePublisher { public class EmployeeServicePublisher {
public static void main(String[] args) { public static void main(String[] args) {

View File

@ -1,13 +1,16 @@
package com.baeldung.jaxws.exception; package com.baeldung.jaxws.exception;
import javax.xml.ws.WebFault;
import java.io.Serializable; import java.io.Serializable;
import javax.xml.ws.WebFault;
@WebFault @WebFault
public class EmployeeAlreadyExists extends Exception implements Serializable { public class EmployeeAlreadyExists extends Exception implements Serializable {
private static final long serialVersionUID = 1L;
public EmployeeAlreadyExists() { public EmployeeAlreadyExists() {
super("This employee already exist"); super("This employee already exists");
} }
public EmployeeAlreadyExists(String str) { public EmployeeAlreadyExists(String str) {

View File

@ -3,6 +3,7 @@ package com.baeldung.jaxws.model;
import java.io.Serializable; import java.io.Serializable;
public class Employee implements Serializable { public class Employee implements Serializable {
private static final long serialVersionUID = 1L;
private int id; private int id;
private String firstName; private String firstName;

View File

@ -1,11 +1,11 @@
package com.baeldung.jaxws.repository; package com.baeldung.jaxws.repository;
import java.util.List;
import com.baeldung.jaxws.exception.EmployeeAlreadyExists; import com.baeldung.jaxws.exception.EmployeeAlreadyExists;
import com.baeldung.jaxws.exception.EmployeeNotFound; import com.baeldung.jaxws.exception.EmployeeNotFound;
import com.baeldung.jaxws.model.Employee; import com.baeldung.jaxws.model.Employee;
import java.util.List;
public interface EmployeeRepository { public interface EmployeeRepository {
List<Employee> getAllEmployees(); List<Employee> getAllEmployees();

View File

@ -1,12 +1,12 @@
package com.baeldung.jaxws.repository; package com.baeldung.jaxws.repository;
import java.util.ArrayList;
import java.util.List;
import com.baeldung.jaxws.exception.EmployeeAlreadyExists; import com.baeldung.jaxws.exception.EmployeeAlreadyExists;
import com.baeldung.jaxws.exception.EmployeeNotFound; import com.baeldung.jaxws.exception.EmployeeNotFound;
import com.baeldung.jaxws.model.Employee; import com.baeldung.jaxws.model.Employee;
import java.util.ArrayList;
import java.util.List;
public class EmployeeRepositoryImpl implements EmployeeRepository { public class EmployeeRepositoryImpl implements EmployeeRepository {
private List<Employee> employeeList; private List<Employee> employeeList;

View File

@ -1,9 +1,14 @@
package com.baeldung.jaxws; package com.baeldung.jaxws;
import com.baeldung.jaxws.exception.EmployeeAlreadyExists; import static org.junit.Assert.assertEquals;
import com.baeldung.jaxws.exception.EmployeeNotFound;
import com.baeldung.jaxws.model.Employee; import java.net.MalformedURLException;
import com.baeldung.jaxws.repository.EmployeeRepository; import java.net.URL;
import java.util.List;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.arquillian.test.api.ArquillianResource;
@ -14,13 +19,10 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import javax.xml.namespace.QName; import com.baeldung.jaxws.exception.EmployeeAlreadyExists;
import javax.xml.ws.Service; import com.baeldung.jaxws.exception.EmployeeNotFound;
import java.net.MalformedURLException; import com.baeldung.jaxws.model.Employee;
import java.net.URL; import com.baeldung.jaxws.repository.EmployeeRepository;
import java.util.List;
import static org.junit.Assert.assertEquals;
@RunWith(Arquillian.class) @RunWith(Arquillian.class)
public class EmployeeServiceLiveTest { public class EmployeeServiceLiveTest {
@ -54,54 +56,54 @@ public class EmployeeServiceLiveTest {
} }
@Test @Test
public void givenGetAllEmployees_thenCorrectNumberOfEmployeesReturned() { public void givenEmployees_whenGetCount_thenCorrectNumberOfEmployeesReturned() {
int employeeCount = employeeServiceProxy.countEmployees(); int employeeCount = employeeServiceProxy.countEmployees();
List<Employee> employeeList = employeeServiceProxy.getAllEmployees(); List<Employee> employeeList = employeeServiceProxy.getAllEmployees();
assertEquals(employeeList.size(), employeeCount); assertEquals(employeeList.size(), employeeCount);
} }
@Test @Test
public void givenEmployeeId_whenEmployeeExists_thenCorrectEmployeeReturned() throws EmployeeNotFound { public void givenEmployees_whenGetAvailableEmployee_thenCorrectEmployeeReturned() throws EmployeeNotFound {
Employee employee = employeeServiceProxy.getEmployee(2); Employee employee = employeeServiceProxy.getEmployee(2);
assertEquals(employee.getFirstName(), "Jack"); assertEquals(employee.getFirstName(), "Jack");
} }
@Test(expected = EmployeeNotFound.class) @Test(expected = EmployeeNotFound.class)
public void givenEmployeeId_whenEmployeeNotExists_thenEmployeeNotFoundExceptionReturned() throws EmployeeNotFound { public void givenEmployees_whenGetNonAvailableEmployee_thenEmployeeNotFoundException() throws EmployeeNotFound {
employeeServiceProxy.getEmployee(20); employeeServiceProxy.getEmployee(20);
} }
@Test @Test
public void givenAddEmployee_whenEmployeeDoesntAlreadyExist_thenEmployeeCountIncreased() throws EmployeeAlreadyExists { public void givenEmployees_whenAddNewEmployee_thenEmployeeCountIncreased() throws EmployeeAlreadyExists {
int employeeCount = employeeServiceProxy.countEmployees(); int employeeCount = employeeServiceProxy.countEmployees();
employeeServiceProxy.addEmployee(4, "Anna"); employeeServiceProxy.addEmployee(4, "Anna");
assertEquals(employeeServiceProxy.countEmployees(), employeeCount + 1); assertEquals(employeeServiceProxy.countEmployees(), employeeCount + 1);
} }
@Test(expected = EmployeeAlreadyExists.class) @Test(expected = EmployeeAlreadyExists.class)
public void givenAddEmployee_whenEmployeeAlreadyExist_thenEmployeeAlreadyExistsExceptionReturned() throws EmployeeAlreadyExists { public void givenEmployees_whenAddAlreadyExistingEmployee_thenEmployeeAlreadyExistsException() throws EmployeeAlreadyExists {
employeeServiceProxy.addEmployee(1, "Anna"); employeeServiceProxy.addEmployee(1, "Anna");
} }
@Test @Test
public void givenUpdateEmployee_whenEmployeeExists_thenUpdatedEmployeeReturned() throws EmployeeNotFound { public void givenEmployees_whenUpdateExistingEmployee_thenUpdatedEmployeeReturned() throws EmployeeNotFound {
Employee updated = employeeServiceProxy.updateEmployee(1, "Joan"); Employee updated = employeeServiceProxy.updateEmployee(1, "Joan");
assertEquals(updated.getFirstName(), "Joan"); assertEquals(updated.getFirstName(), "Joan");
} }
@Test(expected = EmployeeNotFound.class) @Test(expected = EmployeeNotFound.class)
public void givenUpdateEmployee_whenEmployeeNotExists_thenUpdatedEmployeeReturned() throws EmployeeNotFound { public void givenEmployees_whenUpdateNonExistingEmployee_thenEmployeeNotFoundException() throws EmployeeNotFound {
employeeServiceProxy.updateEmployee(20, "Joan"); employeeServiceProxy.updateEmployee(20, "Joan");
} }
@Test @Test
public void givenDeleteEmployee_whenEmployeeExists_thenCorrectStatusReturned() throws EmployeeNotFound { public void givenEmployees_whenDeleteExistingEmployee_thenSuccessReturned() throws EmployeeNotFound {
boolean deleteEmployee = employeeServiceProxy.deleteEmployee(3); boolean deleteEmployee = employeeServiceProxy.deleteEmployee(3);
assertEquals(deleteEmployee, true); assertEquals(deleteEmployee, true);
} }
@Test(expected = EmployeeNotFound.class) @Test(expected = EmployeeNotFound.class)
public void givenDeleteEmployee_whenEmployeeNotExists_thenEmployeeNotFoundExceptionReturned() throws EmployeeNotFound { public void givenEmployee_whenDeleteNonExistingEmployee_thenEmployeeNotFoundException() throws EmployeeNotFound {
employeeServiceProxy.deleteEmployee(20); employeeServiceProxy.deleteEmployee(20);
} }