Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
94c6de1962
|
@ -11,13 +11,7 @@
|
|||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
|
|
|
@ -165,19 +165,61 @@
|
|||
<groupId>org.javamoney</groupId>
|
||||
<artifactId>moneta</artifactId>
|
||||
<version>1.1</version>
|
||||
</dependency>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.owasp.esapi</groupId>
|
||||
<artifactId>esapi</artifactId>
|
||||
<version>2.1.0.1</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- JDO -->
|
||||
<dependency>
|
||||
<groupId>org.datanucleus</groupId>
|
||||
<artifactId>javax.jdo</artifactId>
|
||||
<version>3.2.0-m6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.datanucleus</groupId>
|
||||
<artifactId>datanucleus-core</artifactId>
|
||||
<version>5.1.0-m1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.datanucleus</groupId>
|
||||
<artifactId>datanucleus-api-jdo</artifactId>
|
||||
<version>5.1.0-m1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.datanucleus</groupId>
|
||||
<artifactId>datanucleus-rdbms</artifactId>
|
||||
<version>5.1.0-m1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.datanucleus</groupId>
|
||||
<artifactId>datanucleus-maven-plugin</artifactId>
|
||||
<version>5.0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>1.4.194</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.owasp.esapi</groupId>
|
||||
<artifactId>esapi</artifactId>
|
||||
<version>2.1.0.1</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.owasp.esapi</groupId>
|
||||
<artifactId>esapi</artifactId>
|
||||
<version>2.1.0.1</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
@ -191,7 +233,6 @@
|
|||
</resources>
|
||||
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
|
@ -201,7 +242,6 @@
|
|||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
|
@ -214,7 +254,6 @@
|
|||
<testFailureIgnore>true</testFailureIgnore>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
|
@ -245,7 +284,6 @@
|
|||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
|
@ -269,7 +307,6 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
|
@ -290,7 +327,6 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>com.jolira</groupId>
|
||||
<artifactId>onejar-maven-plugin</artifactId>
|
||||
|
@ -307,7 +343,6 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
|
@ -323,6 +358,28 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- JDO Plugin -->
|
||||
|
||||
<plugin>
|
||||
<groupId>org.datanucleus</groupId>
|
||||
<artifactId>datanucleus-maven-plugin</artifactId>
|
||||
<version>5.0.2</version>
|
||||
<configuration>
|
||||
<api>JDO</api>
|
||||
<props>${basedir}/datanucleus.properties</props>
|
||||
<log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration>
|
||||
<verbose>true</verbose>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>process-classes</phase>
|
||||
<goals>
|
||||
<goal>enhance</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
package com.baeldung.jdo;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.jdo.JDOHelper;
|
||||
import javax.jdo.PersistenceManager;
|
||||
import javax.jdo.PersistenceManagerFactory;
|
||||
import javax.jdo.Query;
|
||||
import javax.jdo.Transaction;
|
||||
|
||||
public class GuideToJDO {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(GuideToJDO.class.getName());
|
||||
private Random rnd = new Random();
|
||||
|
||||
public static void main(String[] args) {
|
||||
new GuideToJDO();
|
||||
}
|
||||
|
||||
public GuideToJDO() {
|
||||
CreateProducts();
|
||||
ListProducts();
|
||||
}
|
||||
|
||||
public void CreateProducts() {
|
||||
PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory("Tutorial");
|
||||
PersistenceManager pm = pmf.getPersistenceManager();
|
||||
Transaction tx = pm.currentTransaction();
|
||||
try {
|
||||
tx.begin();
|
||||
Product product = new Product("Tablet", 80.0);
|
||||
pm.makePersistent(product);
|
||||
Product product2 = new Product("Phone", 20.0);
|
||||
pm.makePersistent(product2);
|
||||
Product product3 = new Product("Laptop", 200.0);
|
||||
pm.makePersistent(product3);
|
||||
for (int i = 0; i < 100; i++) {
|
||||
String nam = "Product-" + i;
|
||||
double price = rnd.nextDouble();
|
||||
Product productx = new Product(nam, price);
|
||||
pm.makePersistent(productx);
|
||||
}
|
||||
tx.commit();
|
||||
} finally {
|
||||
if (tx.isActive()) {
|
||||
tx.rollback();
|
||||
}
|
||||
pm.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void ListProducts() {
|
||||
PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory("Tutorial");
|
||||
PersistenceManager pm = pmf.getPersistenceManager();
|
||||
Transaction tx = pm.currentTransaction();
|
||||
try {
|
||||
tx.begin();
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
Query q = pm.newQuery("SELECT FROM " + Product.class.getName() + " WHERE price < 1");
|
||||
List<Product> products = (List<Product>) q.execute();
|
||||
Iterator<Product> iter = products.iterator();
|
||||
while (iter.hasNext()) {
|
||||
Product p = iter.next();
|
||||
LOGGER.log(Level.WARNING, "Product name: {0} - Price: {1}", new Object[] { p.name, p.price });
|
||||
}
|
||||
|
||||
tx.commit();
|
||||
} finally {
|
||||
if (tx.isActive()) {
|
||||
tx.rollback();
|
||||
}
|
||||
|
||||
pm.close();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.baeldung.jdo;
|
||||
|
||||
import javax.jdo.annotations.IdGeneratorStrategy;
|
||||
import javax.jdo.annotations.PersistenceCapable;
|
||||
import javax.jdo.annotations.Persistent;
|
||||
import javax.jdo.annotations.PrimaryKey;
|
||||
|
||||
@PersistenceCapable
|
||||
public class Product {
|
||||
|
||||
@PrimaryKey
|
||||
@Persistent(valueStrategy = IdGeneratorStrategy.INCREMENT)
|
||||
long id;
|
||||
String name = null;
|
||||
Double price = 0.0;
|
||||
|
||||
public Product() {
|
||||
this.name = null;
|
||||
this.price = 0.0;
|
||||
}
|
||||
|
||||
public Product(String name, Double price) {
|
||||
this.name = name;
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Double getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(Double price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
}
|
|
@ -22,11 +22,11 @@ public class Producer implements Runnable {
|
|||
try {
|
||||
System.out.println("Producer: " + name + " is waiting to transfer...");
|
||||
boolean added = transferQueue.tryTransfer("A" + i, 4000, TimeUnit.MILLISECONDS);
|
||||
if (!added) {
|
||||
System.out.println("can not add an element due to the timeout");
|
||||
} else {
|
||||
if (added) {
|
||||
numberOfProducedMessages.incrementAndGet();
|
||||
System.out.println("Producer: " + name + " transferred element: A" + i);
|
||||
} else {
|
||||
System.out.println("can not add an element due to the timeout");
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
|
||||
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd" version="2.1">
|
||||
|
||||
<!-- JDO tutorial "unit" -->
|
||||
<persistence-unit name="Tutorial">
|
||||
<exclude-unlisted-classes/>
|
||||
<properties>
|
||||
<property name="javax.jdo.PersistenceManagerFactoryClass" value="org.datanucleus.api.jdo.JDOPersistenceManagerFactory"/>
|
||||
<property name="javax.jdo.option.ConnectionURL" value="jdbc:h2:mem:mypersistence"/>
|
||||
<property name="javax.jdo.option.ConnectionDriverName" value="org.h2.Driver"/>
|
||||
<property name="javax.jdo.option.ConnectionUserName" value="sa"/>
|
||||
<property name="javax.jdo.option.ConnectionPassword" value=""/>
|
||||
<property name="datanucleus.schema.autoCreateAll" value="true"/>
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
</persistence>
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
package com.baeldung.java.set;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class SetTest {
|
||||
|
||||
@Test
|
||||
public void givenTreeSet_whenRetrievesObjects_thenNaturalOrder() {
|
||||
Set<String> set = new TreeSet<>();
|
||||
set.add("Baeldung");
|
||||
set.add("is");
|
||||
set.add("Awesome");
|
||||
assertEquals(3, set.size());
|
||||
assertTrue(set.iterator()
|
||||
.next()
|
||||
.equals("Awesome"));
|
||||
}
|
||||
|
||||
@Test(expected = NullPointerException.class)
|
||||
public void givenTreeSet_whenAddNullObject_thenNullPointer() {
|
||||
Set<String> set = new TreeSet<>();
|
||||
set.add("Baeldung");
|
||||
set.add("is");
|
||||
set.add(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenHashSet_whenAddNullObject_thenOK() {
|
||||
Set<String> set = new HashSet<>();
|
||||
set.add("Baeldung");
|
||||
set.add("is");
|
||||
set.add(null);
|
||||
assertEquals(3, set.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenHashSetAndTreeSet_whenAddObjects_thenHashSetIsFaster() {
|
||||
Set<String> set = new HashSet<>();
|
||||
long startTime = System.nanoTime();
|
||||
set.add("Baeldung");
|
||||
set.add("is");
|
||||
set.add("Awesome");
|
||||
long endTime = System.nanoTime();
|
||||
long duration1 = (endTime - startTime);
|
||||
|
||||
Set<String> set2 = new TreeSet<>();
|
||||
startTime = System.nanoTime();
|
||||
set2.add("Baeldung");
|
||||
set2.add("is");
|
||||
set2.add("Awesome");
|
||||
endTime = System.nanoTime();
|
||||
long duration2 = (endTime - startTime);
|
||||
assertTrue(duration1 < duration2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenHashSetAndTreeSet_whenAddDuplicates_thenOnlyUnique() {
|
||||
Set<String> set = new HashSet<>();
|
||||
set.add("Baeldung");
|
||||
set.add("Baeldung");
|
||||
assertTrue(set.size() == 1);
|
||||
|
||||
Set<String> set2 = new TreeSet<>();
|
||||
set2.add("Baeldung");
|
||||
set2.add("Baeldung");
|
||||
assertTrue(set2.size() == 1);
|
||||
}
|
||||
|
||||
@Test(expected = ConcurrentModificationException.class)
|
||||
public void givenHashSet_whenModifyWhenIterator_thenFailFast() {
|
||||
Set<String> set = new HashSet<>();
|
||||
set.add("Baeldung");
|
||||
Iterator<String> it = set.iterator();
|
||||
|
||||
while (it.hasNext()) {
|
||||
set.add("Awesome");
|
||||
it.next();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
package com.baeldung.java8.comparator;
|
||||
/*
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
@ -15,9 +16,10 @@ public class Employee implements Comparable<Employee>{
|
|||
double salary;
|
||||
long mobile;
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(Employee argEmployee) {
|
||||
return name.compareTo(argEmployee.getName());
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
|
@ -1,5 +1,5 @@
|
|||
package com.baeldung.java8.comparator;
|
||||
|
||||
/*
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
||||
|
@ -165,3 +165,4 @@ public class Java8ComparatorTest {
|
|||
|
||||
}
|
||||
|
||||
*/
|
|
@ -0,0 +1,96 @@
|
|||
package com.baeldung.jdo;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.jdo.JDOHelper;
|
||||
import javax.jdo.PersistenceManager;
|
||||
import javax.jdo.PersistenceManagerFactory;
|
||||
import javax.jdo.Query;
|
||||
import javax.jdo.Transaction;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class GuideToJDOTest {
|
||||
@Test
|
||||
public void givenProduct_WhenNewThenPerformTransaction() {
|
||||
PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory("Tutorial");
|
||||
PersistenceManager pm = pmf.getPersistenceManager();
|
||||
Transaction tx = pm.currentTransaction();
|
||||
try {
|
||||
tx.begin();
|
||||
for (int i = 0; i < 100; i++){
|
||||
String nam = "Product-" + i;
|
||||
double price = i;
|
||||
Product productx = new Product(nam, price);
|
||||
pm.makePersistent(productx);
|
||||
}
|
||||
tx.commit();
|
||||
} catch (Throwable thr) {
|
||||
fail("Failed test : " + thr.getMessage());
|
||||
} finally {
|
||||
if (tx.isActive()) {
|
||||
tx.rollback();
|
||||
}
|
||||
pm.close();
|
||||
}
|
||||
|
||||
pmf.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenProduct_WhenQueryThenExist() {
|
||||
PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory("Tutorial");
|
||||
PersistenceManager pm = pmf.getPersistenceManager();
|
||||
Transaction tx = pm.currentTransaction();
|
||||
try {
|
||||
tx.begin();
|
||||
Product product = new Product("Tablet", 80.0);
|
||||
pm.makePersistent(product);
|
||||
Product product2 = new Product("Phone", 20.0);
|
||||
pm.makePersistent(product2);
|
||||
Product product3 = new Product("Laptop", 200.0);
|
||||
pm.makePersistent(product3);
|
||||
tx.commit();
|
||||
} catch (Throwable thr) {
|
||||
fail("Failed test : " + thr.getMessage());
|
||||
} finally {
|
||||
if (tx.isActive()) {
|
||||
tx.rollback();
|
||||
}
|
||||
pm.close();
|
||||
}
|
||||
|
||||
pmf.close();
|
||||
|
||||
PersistenceManagerFactory pmf2 = JDOHelper.getPersistenceManagerFactory("Tutorial");
|
||||
PersistenceManager pm2 = pmf2.getPersistenceManager();
|
||||
Transaction tx2 = pm2.currentTransaction();
|
||||
try {
|
||||
tx2.begin();
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
Query q = pm2.newQuery("SELECT FROM " + Product.class.getName() + " WHERE price == 200");
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Product> products = (List<Product>) q.execute();
|
||||
Iterator<Product> iter = products.iterator();
|
||||
while (iter.hasNext()) {
|
||||
Product p = iter.next();
|
||||
assertEquals("Laptop", p.name);
|
||||
}
|
||||
|
||||
tx2.commit();
|
||||
} finally {
|
||||
if (tx2.isActive()) {
|
||||
tx2.rollback();
|
||||
}
|
||||
|
||||
pm2.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -12,7 +12,7 @@ import static junit.framework.TestCase.assertEquals;
|
|||
public class TransferQueueTest {
|
||||
|
||||
@Test
|
||||
public void givenTransferQueue_whenUseMultipleConsumersAndMultipleProducers_thenShouldProcessAllMessages() throws InterruptedException {
|
||||
public void whenMultipleConsumersAndProducers_thenProcessAllMessages() throws InterruptedException {
|
||||
//given
|
||||
TransferQueue<String> transferQueue = new LinkedTransferQueue<>();
|
||||
ExecutorService exService = Executors.newFixedThreadPool(3);
|
||||
|
@ -28,7 +28,7 @@ public class TransferQueueTest {
|
|||
exService.execute(consumer2);
|
||||
|
||||
//then
|
||||
exService.awaitTermination(10_000, TimeUnit.MILLISECONDS);
|
||||
exService.awaitTermination(5000, TimeUnit.MILLISECONDS);
|
||||
exService.shutdown();
|
||||
|
||||
assertEquals(producer1.numberOfProducedMessages.intValue(), 3);
|
||||
|
@ -36,7 +36,7 @@ public class TransferQueueTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void givenTransferQueue_whenUseOneConsumerAndOneProducer_thenShouldProcessAllMessages() throws InterruptedException {
|
||||
public void whenUseOneConsumerAndOneProducer_thenShouldProcessAllMessages() throws InterruptedException {
|
||||
//given
|
||||
TransferQueue<String> transferQueue = new LinkedTransferQueue<>();
|
||||
ExecutorService exService = Executors.newFixedThreadPool(2);
|
||||
|
@ -56,7 +56,7 @@ public class TransferQueueTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void givenTransferQueue_whenUseOneProducerAndNoConsumers_thenShouldFailWithTimeout() throws InterruptedException {
|
||||
public void whenUseOneProducerAndNoConsumers_thenShouldFailWithTimeout() throws InterruptedException {
|
||||
//given
|
||||
TransferQueue<String> transferQueue = new LinkedTransferQueue<>();
|
||||
ExecutorService exService = Executors.newFixedThreadPool(2);
|
||||
|
|
|
@ -171,6 +171,7 @@
|
|||
<exclude>**/*IntegrationTest.java</exclude>
|
||||
<exclude>**/*LongRunningUnitTest.java</exclude>
|
||||
<exclude>**/*ManualTest.java</exclude>
|
||||
<exclude>**/*LiveTest.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
|
||||
package com.baeldung.jaxws.client;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for addEmployee complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="addEmployee">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="arg0" type="{http://www.w3.org/2001/XMLSchema}int"/>
|
||||
* <element name="arg1" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "addEmployee", propOrder = {
|
||||
"arg0",
|
||||
"arg1"
|
||||
})
|
||||
public class AddEmployee {
|
||||
|
||||
protected int arg0;
|
||||
protected String arg1;
|
||||
|
||||
/**
|
||||
* Gets the value of the arg0 property.
|
||||
*
|
||||
*/
|
||||
public int getArg0() {
|
||||
return arg0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the arg0 property.
|
||||
*
|
||||
*/
|
||||
public void setArg0(int value) {
|
||||
this.arg0 = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the arg1 property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getArg1() {
|
||||
return arg1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the arg1 property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setArg1(String value) {
|
||||
this.arg1 = value;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
|
||||
package com.baeldung.jaxws.client;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for addEmployeeResponse complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="addEmployeeResponse">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="return" type="{http://bottomup.server.jaxws.baeldung.com/}employee" minOccurs="0"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "addEmployeeResponse", propOrder = {
|
||||
"_return"
|
||||
})
|
||||
public class AddEmployeeResponse {
|
||||
|
||||
@XmlElement(name = "return")
|
||||
protected Employee _return;
|
||||
|
||||
/**
|
||||
* Gets the value of the return property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Employee }
|
||||
*
|
||||
*/
|
||||
public Employee getReturn() {
|
||||
return _return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the return property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Employee }
|
||||
*
|
||||
*/
|
||||
public void setReturn(Employee value) {
|
||||
this._return = value;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
|
||||
package com.baeldung.jaxws.client;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for countEmployees complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="countEmployees">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "countEmployees")
|
||||
public class CountEmployees {
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
|
||||
package com.baeldung.jaxws.client;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for countEmployeesResponse complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="countEmployeesResponse">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="return" type="{http://www.w3.org/2001/XMLSchema}int"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "countEmployeesResponse", propOrder = {
|
||||
"_return"
|
||||
})
|
||||
public class CountEmployeesResponse {
|
||||
|
||||
@XmlElement(name = "return")
|
||||
protected int _return;
|
||||
|
||||
/**
|
||||
* Gets the value of the return property.
|
||||
*
|
||||
*/
|
||||
public int getReturn() {
|
||||
return _return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the return property.
|
||||
*
|
||||
*/
|
||||
public void setReturn(int value) {
|
||||
this._return = value;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
|
||||
package com.baeldung.jaxws.client;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for deleteEmployee complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="deleteEmployee">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="arg0" type="{http://www.w3.org/2001/XMLSchema}int"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "deleteEmployee", propOrder = {
|
||||
"arg0"
|
||||
})
|
||||
public class DeleteEmployee {
|
||||
|
||||
protected int arg0;
|
||||
|
||||
/**
|
||||
* Gets the value of the arg0 property.
|
||||
*
|
||||
*/
|
||||
public int getArg0() {
|
||||
return arg0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the arg0 property.
|
||||
*
|
||||
*/
|
||||
public void setArg0(int value) {
|
||||
this.arg0 = value;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
|
||||
package com.baeldung.jaxws.client;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for deleteEmployeeResponse complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="deleteEmployeeResponse">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="return" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "deleteEmployeeResponse", propOrder = {
|
||||
"_return"
|
||||
})
|
||||
public class DeleteEmployeeResponse {
|
||||
|
||||
@XmlElement(name = "return")
|
||||
protected boolean _return;
|
||||
|
||||
/**
|
||||
* Gets the value of the return property.
|
||||
*
|
||||
*/
|
||||
public boolean isReturn() {
|
||||
return _return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the return property.
|
||||
*
|
||||
*/
|
||||
public void setReturn(boolean value) {
|
||||
this._return = value;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
|
||||
package com.baeldung.jaxws.client;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for employee complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="employee">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="firstName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
|
||||
* <element name="id" type="{http://www.w3.org/2001/XMLSchema}int"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "employee", propOrder = {
|
||||
"firstName",
|
||||
"id"
|
||||
})
|
||||
public class Employee {
|
||||
|
||||
protected String firstName;
|
||||
protected int id;
|
||||
|
||||
/**
|
||||
* Gets the value of the firstName property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the firstName property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setFirstName(String value) {
|
||||
this.firstName = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the id property.
|
||||
*
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the id property.
|
||||
*
|
||||
*/
|
||||
public void setId(int value) {
|
||||
this.id = value;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
|
||||
package com.baeldung.jaxws.client;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for EmployeeAlreadyExists complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="EmployeeAlreadyExists">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="message" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "EmployeeAlreadyExists", propOrder = {
|
||||
"message"
|
||||
})
|
||||
public class EmployeeAlreadyExists {
|
||||
|
||||
protected String message;
|
||||
|
||||
/**
|
||||
* Gets the value of the message property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the message property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setMessage(String value) {
|
||||
this.message = value;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
|
||||
package com.baeldung.jaxws.client;
|
||||
|
||||
import javax.xml.ws.WebFault;
|
||||
|
||||
|
||||
/**
|
||||
* This class was generated by the JAX-WS RI.
|
||||
* JAX-WS RI 2.2.9-b130926.1035
|
||||
* Generated source version: 2.2
|
||||
*
|
||||
*/
|
||||
@WebFault(name = "EmployeeAlreadyExists", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/")
|
||||
public class EmployeeAlreadyExists_Exception
|
||||
extends Exception
|
||||
{
|
||||
|
||||
/**
|
||||
* Java type that goes as soapenv:Fault detail element.
|
||||
*
|
||||
*/
|
||||
private EmployeeAlreadyExists faultInfo;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param faultInfo
|
||||
* @param message
|
||||
*/
|
||||
public EmployeeAlreadyExists_Exception(String message, EmployeeAlreadyExists faultInfo) {
|
||||
super(message);
|
||||
this.faultInfo = faultInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param faultInfo
|
||||
* @param cause
|
||||
* @param message
|
||||
*/
|
||||
public EmployeeAlreadyExists_Exception(String message, EmployeeAlreadyExists faultInfo, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.faultInfo = faultInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* returns fault bean: com.baeldung.jaxws.client.EmployeeAlreadyExists
|
||||
*/
|
||||
public EmployeeAlreadyExists getFaultInfo() {
|
||||
return faultInfo;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
|
||||
package com.baeldung.jaxws.client;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for EmployeeNotFound complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="EmployeeNotFound">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="message" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "EmployeeNotFound", propOrder = {
|
||||
"message"
|
||||
})
|
||||
public class EmployeeNotFound {
|
||||
|
||||
protected String message;
|
||||
|
||||
/**
|
||||
* Gets the value of the message property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the message property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setMessage(String value) {
|
||||
this.message = value;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
|
||||
package com.baeldung.jaxws.client;
|
||||
|
||||
import javax.xml.ws.WebFault;
|
||||
|
||||
|
||||
/**
|
||||
* This class was generated by the JAX-WS RI.
|
||||
* JAX-WS RI 2.2.9-b130926.1035
|
||||
* Generated source version: 2.2
|
||||
*
|
||||
*/
|
||||
@WebFault(name = "EmployeeNotFound", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/")
|
||||
public class EmployeeNotFound_Exception
|
||||
extends Exception
|
||||
{
|
||||
|
||||
/**
|
||||
* Java type that goes as soapenv:Fault detail element.
|
||||
*
|
||||
*/
|
||||
private EmployeeNotFound faultInfo;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param faultInfo
|
||||
* @param message
|
||||
*/
|
||||
public EmployeeNotFound_Exception(String message, EmployeeNotFound faultInfo) {
|
||||
super(message);
|
||||
this.faultInfo = faultInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param faultInfo
|
||||
* @param cause
|
||||
* @param message
|
||||
*/
|
||||
public EmployeeNotFound_Exception(String message, EmployeeNotFound faultInfo, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.faultInfo = faultInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* returns fault bean: com.baeldung.jaxws.client.EmployeeNotFound
|
||||
*/
|
||||
public EmployeeNotFound getFaultInfo() {
|
||||
return faultInfo;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
|
||||
package com.baeldung.jaxws.client;
|
||||
|
||||
import java.util.List;
|
||||
import javax.jws.WebMethod;
|
||||
import javax.jws.WebParam;
|
||||
import javax.jws.WebResult;
|
||||
import javax.jws.WebService;
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
import javax.xml.ws.Action;
|
||||
import javax.xml.ws.FaultAction;
|
||||
import javax.xml.ws.RequestWrapper;
|
||||
import javax.xml.ws.ResponseWrapper;
|
||||
|
||||
|
||||
/**
|
||||
* This class was generated by the JAX-WS RI.
|
||||
* JAX-WS RI 2.2.9-b130926.1035
|
||||
* Generated source version: 2.2
|
||||
*
|
||||
*/
|
||||
@WebService(name = "EmployeeService", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/")
|
||||
@XmlSeeAlso({
|
||||
ObjectFactory.class
|
||||
})
|
||||
public interface EmployeeService {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param arg0
|
||||
* @return
|
||||
* returns com.baeldung.jaxws.client.Employee
|
||||
* @throws EmployeeNotFound_Exception
|
||||
*/
|
||||
@WebMethod
|
||||
@WebResult(targetNamespace = "")
|
||||
@RequestWrapper(localName = "getEmployee", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.GetEmployee")
|
||||
@ResponseWrapper(localName = "getEmployeeResponse", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.GetEmployeeResponse")
|
||||
@Action(input = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/getEmployeeRequest", output = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/getEmployeeResponse", fault = {
|
||||
@FaultAction(className = EmployeeNotFound_Exception.class, value = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/getEmployee/Fault/EmployeeNotFound")
|
||||
})
|
||||
public Employee getEmployee(
|
||||
@WebParam(name = "arg0", targetNamespace = "")
|
||||
int arg0)
|
||||
throws EmployeeNotFound_Exception
|
||||
;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param arg1
|
||||
* @param arg0
|
||||
* @return
|
||||
* returns com.baeldung.jaxws.client.Employee
|
||||
* @throws EmployeeNotFound_Exception
|
||||
*/
|
||||
@WebMethod
|
||||
@WebResult(targetNamespace = "")
|
||||
@RequestWrapper(localName = "updateEmployee", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.UpdateEmployee")
|
||||
@ResponseWrapper(localName = "updateEmployeeResponse", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.UpdateEmployeeResponse")
|
||||
@Action(input = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/updateEmployeeRequest", output = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/updateEmployeeResponse", fault = {
|
||||
@FaultAction(className = EmployeeNotFound_Exception.class, value = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/updateEmployee/Fault/EmployeeNotFound")
|
||||
})
|
||||
public Employee updateEmployee(
|
||||
@WebParam(name = "arg0", targetNamespace = "")
|
||||
int arg0,
|
||||
@WebParam(name = "arg1", targetNamespace = "")
|
||||
String arg1)
|
||||
throws EmployeeNotFound_Exception
|
||||
;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* returns java.util.List<com.baeldung.jaxws.client.Employee>
|
||||
*/
|
||||
@WebMethod
|
||||
@WebResult(targetNamespace = "")
|
||||
@RequestWrapper(localName = "getAllEmployees", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.GetAllEmployees")
|
||||
@ResponseWrapper(localName = "getAllEmployeesResponse", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.GetAllEmployeesResponse")
|
||||
@Action(input = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/getAllEmployeesRequest", output = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/getAllEmployeesResponse")
|
||||
public List<Employee> getAllEmployees();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param arg0
|
||||
* @return
|
||||
* returns boolean
|
||||
* @throws EmployeeNotFound_Exception
|
||||
*/
|
||||
@WebMethod
|
||||
@WebResult(targetNamespace = "")
|
||||
@RequestWrapper(localName = "deleteEmployee", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.DeleteEmployee")
|
||||
@ResponseWrapper(localName = "deleteEmployeeResponse", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.DeleteEmployeeResponse")
|
||||
@Action(input = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/deleteEmployeeRequest", output = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/deleteEmployeeResponse", fault = {
|
||||
@FaultAction(className = EmployeeNotFound_Exception.class, value = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/deleteEmployee/Fault/EmployeeNotFound")
|
||||
})
|
||||
public boolean deleteEmployee(
|
||||
@WebParam(name = "arg0", targetNamespace = "")
|
||||
int arg0)
|
||||
throws EmployeeNotFound_Exception
|
||||
;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param arg1
|
||||
* @param arg0
|
||||
* @return
|
||||
* returns com.baeldung.jaxws.client.Employee
|
||||
* @throws EmployeeAlreadyExists_Exception
|
||||
*/
|
||||
@WebMethod
|
||||
@WebResult(targetNamespace = "")
|
||||
@RequestWrapper(localName = "addEmployee", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.AddEmployee")
|
||||
@ResponseWrapper(localName = "addEmployeeResponse", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.AddEmployeeResponse")
|
||||
@Action(input = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/addEmployeeRequest", output = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/addEmployeeResponse", fault = {
|
||||
@FaultAction(className = EmployeeAlreadyExists_Exception.class, value = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/addEmployee/Fault/EmployeeAlreadyExists")
|
||||
})
|
||||
public Employee addEmployee(
|
||||
@WebParam(name = "arg0", targetNamespace = "")
|
||||
int arg0,
|
||||
@WebParam(name = "arg1", targetNamespace = "")
|
||||
String arg1)
|
||||
throws EmployeeAlreadyExists_Exception
|
||||
;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* returns int
|
||||
*/
|
||||
@WebMethod
|
||||
@WebResult(targetNamespace = "")
|
||||
@RequestWrapper(localName = "countEmployees", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.CountEmployees")
|
||||
@ResponseWrapper(localName = "countEmployeesResponse", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.CountEmployeesResponse")
|
||||
@Action(input = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/countEmployeesRequest", output = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/countEmployeesResponse")
|
||||
public int countEmployees();
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.baeldung.jaxws.client;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
public class EmployeeServiceClient {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
URL url = new URL("http://localhost:8080/employeeservice?wsdl");
|
||||
|
||||
EmployeeService_Service employeeService_Service = new EmployeeService_Service(url);
|
||||
EmployeeService employeeServiceProxy = employeeService_Service.getEmployeeServiceImplPort();
|
||||
|
||||
List<Employee> allEmployees = employeeServiceProxy.getAllEmployees();
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
|
||||
package com.baeldung.jaxws.client;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.ws.Service;
|
||||
import javax.xml.ws.WebEndpoint;
|
||||
import javax.xml.ws.WebServiceClient;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
|
||||
|
||||
/**
|
||||
* This class was generated by the JAX-WS RI.
|
||||
* JAX-WS RI 2.2.9-b130926.1035
|
||||
* Generated source version: 2.2
|
||||
*
|
||||
*/
|
||||
@WebServiceClient(name = "EmployeeService", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", wsdlLocation = "http://localhost:8080/employeeservice?wsdl")
|
||||
public class EmployeeService_Service
|
||||
extends Service
|
||||
{
|
||||
|
||||
private final static URL EMPLOYEESERVICE_WSDL_LOCATION;
|
||||
private final static WebServiceException EMPLOYEESERVICE_EXCEPTION;
|
||||
private final static QName EMPLOYEESERVICE_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "EmployeeService");
|
||||
|
||||
static {
|
||||
URL url = null;
|
||||
WebServiceException e = null;
|
||||
try {
|
||||
url = new URL("http://localhost:8080/employeeservice?wsdl");
|
||||
} catch (MalformedURLException ex) {
|
||||
e = new WebServiceException(ex);
|
||||
}
|
||||
EMPLOYEESERVICE_WSDL_LOCATION = url;
|
||||
EMPLOYEESERVICE_EXCEPTION = e;
|
||||
}
|
||||
|
||||
public EmployeeService_Service() {
|
||||
super(__getWsdlLocation(), EMPLOYEESERVICE_QNAME);
|
||||
}
|
||||
|
||||
public EmployeeService_Service(WebServiceFeature... features) {
|
||||
super(__getWsdlLocation(), EMPLOYEESERVICE_QNAME, features);
|
||||
}
|
||||
|
||||
public EmployeeService_Service(URL wsdlLocation) {
|
||||
super(wsdlLocation, EMPLOYEESERVICE_QNAME);
|
||||
}
|
||||
|
||||
public EmployeeService_Service(URL wsdlLocation, WebServiceFeature... features) {
|
||||
super(wsdlLocation, EMPLOYEESERVICE_QNAME, features);
|
||||
}
|
||||
|
||||
public EmployeeService_Service(URL wsdlLocation, QName serviceName) {
|
||||
super(wsdlLocation, serviceName);
|
||||
}
|
||||
|
||||
public EmployeeService_Service(URL wsdlLocation, QName serviceName, WebServiceFeature... features) {
|
||||
super(wsdlLocation, serviceName, features);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* returns EmployeeService
|
||||
*/
|
||||
@WebEndpoint(name = "EmployeeServiceImplPort")
|
||||
public EmployeeService getEmployeeServiceImplPort() {
|
||||
return super.getPort(new QName("http://bottomup.server.jaxws.baeldung.com/", "EmployeeServiceImplPort"), EmployeeService.class);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param features
|
||||
* A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values.
|
||||
* @return
|
||||
* returns EmployeeService
|
||||
*/
|
||||
@WebEndpoint(name = "EmployeeServiceImplPort")
|
||||
public EmployeeService getEmployeeServiceImplPort(WebServiceFeature... features) {
|
||||
return super.getPort(new QName("http://bottomup.server.jaxws.baeldung.com/", "EmployeeServiceImplPort"), EmployeeService.class, features);
|
||||
}
|
||||
|
||||
private static URL __getWsdlLocation() {
|
||||
if (EMPLOYEESERVICE_EXCEPTION!= null) {
|
||||
throw EMPLOYEESERVICE_EXCEPTION;
|
||||
}
|
||||
return EMPLOYEESERVICE_WSDL_LOCATION;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
|
||||
package com.baeldung.jaxws.client;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for getAllEmployees complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="getAllEmployees">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "getAllEmployees")
|
||||
public class GetAllEmployees {
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
|
||||
package com.baeldung.jaxws.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for getAllEmployeesResponse complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="getAllEmployeesResponse">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="return" type="{http://bottomup.server.jaxws.baeldung.com/}employee" maxOccurs="unbounded" minOccurs="0"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "getAllEmployeesResponse", propOrder = {
|
||||
"_return"
|
||||
})
|
||||
public class GetAllEmployeesResponse {
|
||||
|
||||
@XmlElement(name = "return")
|
||||
protected List<Employee> _return;
|
||||
|
||||
/**
|
||||
* Gets the value of the return property.
|
||||
*
|
||||
* <p>
|
||||
* This accessor method returns a reference to the live list,
|
||||
* not a snapshot. Therefore any modification you make to the
|
||||
* returned list will be present inside the JAXB object.
|
||||
* This is why there is not a <CODE>set</CODE> method for the return property.
|
||||
*
|
||||
* <p>
|
||||
* For example, to add a new item, do as follows:
|
||||
* <pre>
|
||||
* getReturn().add(newItem);
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Objects of the following type(s) are allowed in the list
|
||||
* {@link Employee }
|
||||
*
|
||||
*
|
||||
*/
|
||||
public List<Employee> getReturn() {
|
||||
if (_return == null) {
|
||||
_return = new ArrayList<Employee>();
|
||||
}
|
||||
return this._return;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
|
||||
package com.baeldung.jaxws.client;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for getEmployee complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="getEmployee">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="arg0" type="{http://www.w3.org/2001/XMLSchema}int"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "getEmployee", propOrder = {
|
||||
"arg0"
|
||||
})
|
||||
public class GetEmployee {
|
||||
|
||||
protected int arg0;
|
||||
|
||||
/**
|
||||
* Gets the value of the arg0 property.
|
||||
*
|
||||
*/
|
||||
public int getArg0() {
|
||||
return arg0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the arg0 property.
|
||||
*
|
||||
*/
|
||||
public void setArg0(int value) {
|
||||
this.arg0 = value;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
|
||||
package com.baeldung.jaxws.client;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for getEmployeeResponse complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="getEmployeeResponse">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="return" type="{http://bottomup.server.jaxws.baeldung.com/}employee" minOccurs="0"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "getEmployeeResponse", propOrder = {
|
||||
"_return"
|
||||
})
|
||||
public class GetEmployeeResponse {
|
||||
|
||||
@XmlElement(name = "return")
|
||||
protected Employee _return;
|
||||
|
||||
/**
|
||||
* Gets the value of the return property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Employee }
|
||||
*
|
||||
*/
|
||||
public Employee getReturn() {
|
||||
return _return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the return property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Employee }
|
||||
*
|
||||
*/
|
||||
public void setReturn(Employee value) {
|
||||
this._return = value;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,295 @@
|
|||
|
||||
package com.baeldung.jaxws.client;
|
||||
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.annotation.XmlElementDecl;
|
||||
import javax.xml.bind.annotation.XmlRegistry;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
|
||||
/**
|
||||
* This object contains factory methods for each
|
||||
* Java content interface and Java element interface
|
||||
* generated in the com.baeldung.jaxws.client package.
|
||||
* <p>An ObjectFactory allows you to programatically
|
||||
* construct new instances of the Java representation
|
||||
* for XML content. The Java representation of XML
|
||||
* content can consist of schema derived interfaces
|
||||
* and classes representing the binding of schema
|
||||
* type definitions, element declarations and model
|
||||
* groups. Factory methods for each of these are
|
||||
* provided in this class.
|
||||
*
|
||||
*/
|
||||
@XmlRegistry
|
||||
public class ObjectFactory {
|
||||
|
||||
private final static QName _AddEmployeeResponse_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "addEmployeeResponse");
|
||||
private final static QName _EmployeeAlreadyExists_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "EmployeeAlreadyExists");
|
||||
private final static QName _GetEmployeeResponse_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "getEmployeeResponse");
|
||||
private final static QName _EmployeeNotFound_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "EmployeeNotFound");
|
||||
private final static QName _CountEmployees_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "countEmployees");
|
||||
private final static QName _UpdateEmployee_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "updateEmployee");
|
||||
private final static QName _DeleteEmployeeResponse_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "deleteEmployeeResponse");
|
||||
private final static QName _GetAllEmployeesResponse_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "getAllEmployeesResponse");
|
||||
private final static QName _DeleteEmployee_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "deleteEmployee");
|
||||
private final static QName _UpdateEmployeeResponse_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "updateEmployeeResponse");
|
||||
private final static QName _AddEmployee_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "addEmployee");
|
||||
private final static QName _GetAllEmployees_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "getAllEmployees");
|
||||
private final static QName _CountEmployeesResponse_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "countEmployeesResponse");
|
||||
private final static QName _GetEmployee_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "getEmployee");
|
||||
|
||||
/**
|
||||
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.baeldung.jaxws.client
|
||||
*
|
||||
*/
|
||||
public ObjectFactory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link EmployeeNotFound }
|
||||
*
|
||||
*/
|
||||
public EmployeeNotFound createEmployeeNotFound() {
|
||||
return new EmployeeNotFound();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link CountEmployees }
|
||||
*
|
||||
*/
|
||||
public CountEmployees createCountEmployees() {
|
||||
return new CountEmployees();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link AddEmployeeResponse }
|
||||
*
|
||||
*/
|
||||
public AddEmployeeResponse createAddEmployeeResponse() {
|
||||
return new AddEmployeeResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link EmployeeAlreadyExists }
|
||||
*
|
||||
*/
|
||||
public EmployeeAlreadyExists createEmployeeAlreadyExists() {
|
||||
return new EmployeeAlreadyExists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link GetEmployeeResponse }
|
||||
*
|
||||
*/
|
||||
public GetEmployeeResponse createGetEmployeeResponse() {
|
||||
return new GetEmployeeResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link DeleteEmployeeResponse }
|
||||
*
|
||||
*/
|
||||
public DeleteEmployeeResponse createDeleteEmployeeResponse() {
|
||||
return new DeleteEmployeeResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link GetAllEmployeesResponse }
|
||||
*
|
||||
*/
|
||||
public GetAllEmployeesResponse createGetAllEmployeesResponse() {
|
||||
return new GetAllEmployeesResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link UpdateEmployee }
|
||||
*
|
||||
*/
|
||||
public UpdateEmployee createUpdateEmployee() {
|
||||
return new UpdateEmployee();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link CountEmployeesResponse }
|
||||
*
|
||||
*/
|
||||
public CountEmployeesResponse createCountEmployeesResponse() {
|
||||
return new CountEmployeesResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link GetEmployee }
|
||||
*
|
||||
*/
|
||||
public GetEmployee createGetEmployee() {
|
||||
return new GetEmployee();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link DeleteEmployee }
|
||||
*
|
||||
*/
|
||||
public DeleteEmployee createDeleteEmployee() {
|
||||
return new DeleteEmployee();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link UpdateEmployeeResponse }
|
||||
*
|
||||
*/
|
||||
public UpdateEmployeeResponse createUpdateEmployeeResponse() {
|
||||
return new UpdateEmployeeResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link AddEmployee }
|
||||
*
|
||||
*/
|
||||
public AddEmployee createAddEmployee() {
|
||||
return new AddEmployee();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link GetAllEmployees }
|
||||
*
|
||||
*/
|
||||
public GetAllEmployees createGetAllEmployees() {
|
||||
return new GetAllEmployees();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link Employee }
|
||||
*
|
||||
*/
|
||||
public Employee createEmployee() {
|
||||
return new Employee();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link AddEmployeeResponse }{@code >}}
|
||||
*
|
||||
*/
|
||||
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "addEmployeeResponse")
|
||||
public JAXBElement<AddEmployeeResponse> createAddEmployeeResponse(AddEmployeeResponse value) {
|
||||
return new JAXBElement<AddEmployeeResponse>(_AddEmployeeResponse_QNAME, AddEmployeeResponse.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link EmployeeAlreadyExists }{@code >}}
|
||||
*
|
||||
*/
|
||||
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "EmployeeAlreadyExists")
|
||||
public JAXBElement<EmployeeAlreadyExists> createEmployeeAlreadyExists(EmployeeAlreadyExists value) {
|
||||
return new JAXBElement<EmployeeAlreadyExists>(_EmployeeAlreadyExists_QNAME, EmployeeAlreadyExists.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link GetEmployeeResponse }{@code >}}
|
||||
*
|
||||
*/
|
||||
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "getEmployeeResponse")
|
||||
public JAXBElement<GetEmployeeResponse> createGetEmployeeResponse(GetEmployeeResponse value) {
|
||||
return new JAXBElement<GetEmployeeResponse>(_GetEmployeeResponse_QNAME, GetEmployeeResponse.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link EmployeeNotFound }{@code >}}
|
||||
*
|
||||
*/
|
||||
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "EmployeeNotFound")
|
||||
public JAXBElement<EmployeeNotFound> createEmployeeNotFound(EmployeeNotFound value) {
|
||||
return new JAXBElement<EmployeeNotFound>(_EmployeeNotFound_QNAME, EmployeeNotFound.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link CountEmployees }{@code >}}
|
||||
*
|
||||
*/
|
||||
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "countEmployees")
|
||||
public JAXBElement<CountEmployees> createCountEmployees(CountEmployees value) {
|
||||
return new JAXBElement<CountEmployees>(_CountEmployees_QNAME, CountEmployees.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link UpdateEmployee }{@code >}}
|
||||
*
|
||||
*/
|
||||
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "updateEmployee")
|
||||
public JAXBElement<UpdateEmployee> createUpdateEmployee(UpdateEmployee value) {
|
||||
return new JAXBElement<UpdateEmployee>(_UpdateEmployee_QNAME, UpdateEmployee.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link DeleteEmployeeResponse }{@code >}}
|
||||
*
|
||||
*/
|
||||
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "deleteEmployeeResponse")
|
||||
public JAXBElement<DeleteEmployeeResponse> createDeleteEmployeeResponse(DeleteEmployeeResponse value) {
|
||||
return new JAXBElement<DeleteEmployeeResponse>(_DeleteEmployeeResponse_QNAME, DeleteEmployeeResponse.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link GetAllEmployeesResponse }{@code >}}
|
||||
*
|
||||
*/
|
||||
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "getAllEmployeesResponse")
|
||||
public JAXBElement<GetAllEmployeesResponse> createGetAllEmployeesResponse(GetAllEmployeesResponse value) {
|
||||
return new JAXBElement<GetAllEmployeesResponse>(_GetAllEmployeesResponse_QNAME, GetAllEmployeesResponse.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link DeleteEmployee }{@code >}}
|
||||
*
|
||||
*/
|
||||
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "deleteEmployee")
|
||||
public JAXBElement<DeleteEmployee> createDeleteEmployee(DeleteEmployee value) {
|
||||
return new JAXBElement<DeleteEmployee>(_DeleteEmployee_QNAME, DeleteEmployee.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link UpdateEmployeeResponse }{@code >}}
|
||||
*
|
||||
*/
|
||||
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "updateEmployeeResponse")
|
||||
public JAXBElement<UpdateEmployeeResponse> createUpdateEmployeeResponse(UpdateEmployeeResponse value) {
|
||||
return new JAXBElement<UpdateEmployeeResponse>(_UpdateEmployeeResponse_QNAME, UpdateEmployeeResponse.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link AddEmployee }{@code >}}
|
||||
*
|
||||
*/
|
||||
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "addEmployee")
|
||||
public JAXBElement<AddEmployee> createAddEmployee(AddEmployee value) {
|
||||
return new JAXBElement<AddEmployee>(_AddEmployee_QNAME, AddEmployee.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link GetAllEmployees }{@code >}}
|
||||
*
|
||||
*/
|
||||
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "getAllEmployees")
|
||||
public JAXBElement<GetAllEmployees> createGetAllEmployees(GetAllEmployees value) {
|
||||
return new JAXBElement<GetAllEmployees>(_GetAllEmployees_QNAME, GetAllEmployees.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link CountEmployeesResponse }{@code >}}
|
||||
*
|
||||
*/
|
||||
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "countEmployeesResponse")
|
||||
public JAXBElement<CountEmployeesResponse> createCountEmployeesResponse(CountEmployeesResponse value) {
|
||||
return new JAXBElement<CountEmployeesResponse>(_CountEmployeesResponse_QNAME, CountEmployeesResponse.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link GetEmployee }{@code >}}
|
||||
*
|
||||
*/
|
||||
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "getEmployee")
|
||||
public JAXBElement<GetEmployee> createGetEmployee(GetEmployee value) {
|
||||
return new JAXBElement<GetEmployee>(_GetEmployee_QNAME, GetEmployee.class, null, value);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
|
||||
package com.baeldung.jaxws.client;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for updateEmployee complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="updateEmployee">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="arg0" type="{http://www.w3.org/2001/XMLSchema}int"/>
|
||||
* <element name="arg1" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "updateEmployee", propOrder = {
|
||||
"arg0",
|
||||
"arg1"
|
||||
})
|
||||
public class UpdateEmployee {
|
||||
|
||||
protected int arg0;
|
||||
protected String arg1;
|
||||
|
||||
/**
|
||||
* Gets the value of the arg0 property.
|
||||
*
|
||||
*/
|
||||
public int getArg0() {
|
||||
return arg0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the arg0 property.
|
||||
*
|
||||
*/
|
||||
public void setArg0(int value) {
|
||||
this.arg0 = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the arg1 property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getArg1() {
|
||||
return arg1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the arg1 property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setArg1(String value) {
|
||||
this.arg1 = value;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
|
||||
package com.baeldung.jaxws.client;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for updateEmployeeResponse complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="updateEmployeeResponse">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="return" type="{http://bottomup.server.jaxws.baeldung.com/}employee" minOccurs="0"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "updateEmployeeResponse", propOrder = {
|
||||
"_return"
|
||||
})
|
||||
public class UpdateEmployeeResponse {
|
||||
|
||||
@XmlElement(name = "return")
|
||||
protected Employee _return;
|
||||
|
||||
/**
|
||||
* Gets the value of the return property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Employee }
|
||||
*
|
||||
*/
|
||||
public Employee getReturn() {
|
||||
return _return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the return property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Employee }
|
||||
*
|
||||
*/
|
||||
public void setReturn(Employee value) {
|
||||
this._return = value;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
@javax.xml.bind.annotation.XmlSchema(namespace = "http://bottomup.server.jaxws.baeldung.com/")
|
||||
package com.baeldung.jaxws.client;
|
|
@ -1,12 +0,0 @@
|
|||
package com.baeldung.jaxws.config;
|
||||
|
||||
import javax.xml.ws.Endpoint;
|
||||
|
||||
import com.baeldung.jaxws.EmployeeServiceImpl;
|
||||
|
||||
public class EmployeeServicePublisher {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Endpoint.publish("http://localhost:8080/employeeservice", new EmployeeServiceImpl());
|
||||
}
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package com.baeldung.jaxws;
|
||||
package com.baeldung.jaxws.server.bottomup;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.jws.WebMethod;
|
||||
import javax.jws.WebService;
|
||||
|
||||
import com.baeldung.jaxws.exception.EmployeeAlreadyExists;
|
||||
import com.baeldung.jaxws.exception.EmployeeNotFound;
|
||||
import com.baeldung.jaxws.model.Employee;
|
||||
import com.baeldung.jaxws.server.bottomup.exception.EmployeeAlreadyExists;
|
||||
import com.baeldung.jaxws.server.bottomup.exception.EmployeeNotFound;
|
||||
import com.baeldung.jaxws.server.bottomup.model.Employee;
|
||||
|
||||
@WebService
|
||||
public interface EmployeeService {
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.jaxws;
|
||||
package com.baeldung.jaxws.server.bottomup;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -6,12 +6,12 @@ import javax.inject.Inject;
|
|||
import javax.jws.WebMethod;
|
||||
import javax.jws.WebService;
|
||||
|
||||
import com.baeldung.jaxws.exception.EmployeeAlreadyExists;
|
||||
import com.baeldung.jaxws.exception.EmployeeNotFound;
|
||||
import com.baeldung.jaxws.model.Employee;
|
||||
import com.baeldung.jaxws.repository.EmployeeRepository;
|
||||
import com.baeldung.jaxws.server.bottomup.exception.EmployeeAlreadyExists;
|
||||
import com.baeldung.jaxws.server.bottomup.exception.EmployeeNotFound;
|
||||
import com.baeldung.jaxws.server.bottomup.model.Employee;
|
||||
import com.baeldung.jaxws.server.repository.EmployeeRepository;
|
||||
|
||||
@WebService(serviceName = "EmployeeService", endpointInterface = "com.baeldung.jaxws.EmployeeService")
|
||||
@WebService(serviceName = "EmployeeService", endpointInterface = "com.baeldung.jaxws.server.bottomup.EmployeeService")
|
||||
public class EmployeeServiceImpl implements EmployeeService {
|
||||
|
||||
@Inject
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.jaxws.exception;
|
||||
package com.baeldung.jaxws.server.bottomup.exception;
|
||||
|
||||
import javax.xml.ws.WebFault;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.jaxws.exception;
|
||||
package com.baeldung.jaxws.server.bottomup.exception;
|
||||
|
||||
import javax.xml.ws.WebFault;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.jaxws.model;
|
||||
package com.baeldung.jaxws.server.bottomup.model;
|
||||
|
||||
public class Employee {
|
||||
private int id;
|
|
@ -0,0 +1,14 @@
|
|||
package com.baeldung.jaxws.server.config;
|
||||
|
||||
import javax.xml.ws.Endpoint;
|
||||
|
||||
import com.baeldung.jaxws.server.bottomup.EmployeeServiceImpl;
|
||||
import com.baeldung.jaxws.server.topdown.EmployeeServiceTopDownImpl;
|
||||
|
||||
public class EmployeeServicePublisher {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Endpoint.publish("http://localhost:8080/employeeservicetopdown", new EmployeeServiceTopDownImpl());
|
||||
Endpoint.publish("http://localhost:8080/employeeservice", new EmployeeServiceImpl());
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
package com.baeldung.jaxws.repository;
|
||||
package com.baeldung.jaxws.server.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baeldung.jaxws.exception.EmployeeAlreadyExists;
|
||||
import com.baeldung.jaxws.exception.EmployeeNotFound;
|
||||
import com.baeldung.jaxws.model.Employee;
|
||||
import com.baeldung.jaxws.server.bottomup.exception.EmployeeAlreadyExists;
|
||||
import com.baeldung.jaxws.server.bottomup.exception.EmployeeNotFound;
|
||||
import com.baeldung.jaxws.server.bottomup.model.Employee;
|
||||
|
||||
public interface EmployeeRepository {
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
package com.baeldung.jaxws.repository;
|
||||
package com.baeldung.jaxws.server.repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.baeldung.jaxws.exception.EmployeeAlreadyExists;
|
||||
import com.baeldung.jaxws.exception.EmployeeNotFound;
|
||||
import com.baeldung.jaxws.model.Employee;
|
||||
import com.baeldung.jaxws.server.bottomup.exception.EmployeeAlreadyExists;
|
||||
import com.baeldung.jaxws.server.bottomup.exception.EmployeeNotFound;
|
||||
import com.baeldung.jaxws.server.bottomup.model.Employee;
|
||||
|
||||
public class EmployeeRepositoryImpl implements EmployeeRepository {
|
||||
private List<Employee> employeeList;
|
|
@ -0,0 +1,34 @@
|
|||
|
||||
package com.baeldung.jaxws.server.topdown;
|
||||
|
||||
import javax.jws.WebMethod;
|
||||
import javax.jws.WebResult;
|
||||
import javax.jws.WebService;
|
||||
import javax.jws.soap.SOAPBinding;
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
|
||||
|
||||
/**
|
||||
* This class was generated by the JAX-WS RI.
|
||||
* JAX-WS RI 2.2.4-b01
|
||||
* Generated source version: 2.2
|
||||
*
|
||||
*/
|
||||
@WebService(name = "EmployeeServiceTopDown", targetNamespace = "http://topdown.server.jaxws.baeldung.com/")
|
||||
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
|
||||
@XmlSeeAlso({
|
||||
ObjectFactory.class
|
||||
})
|
||||
public interface EmployeeServiceTopDown {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* returns int
|
||||
*/
|
||||
@WebMethod(action = "http://topdown.server.jaxws.baeldung.com/EmployeeServiceTopDown/countEmployees")
|
||||
@WebResult(name = "countEmployeesResponse", targetNamespace = "http://topdown.server.jaxws.baeldung.com/", partName = "parameters")
|
||||
public int countEmployees();
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.baeldung.jaxws.server.topdown;
|
||||
|
||||
import com.baeldung.jaxws.server.repository.EmployeeRepository;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.jws.WebMethod;
|
||||
import javax.jws.WebService;
|
||||
|
||||
|
||||
@WebService(name = "EmployeeServiceTopDown", targetNamespace = "http://topdown.server.jaxws.baeldung.com/", endpointInterface = "com.baeldung.jaxws.server.topdown.EmployeeServiceTopDown")
|
||||
public class EmployeeServiceTopDownImpl implements EmployeeServiceTopDown {
|
||||
|
||||
@Inject private EmployeeRepository employeeRepositoryImpl;
|
||||
|
||||
@WebMethod
|
||||
public int countEmployees() {
|
||||
return employeeRepositoryImpl.count();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
|
||||
package com.baeldung.jaxws.server.topdown;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.ws.Service;
|
||||
import javax.xml.ws.WebEndpoint;
|
||||
import javax.xml.ws.WebServiceClient;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
|
||||
|
||||
/**
|
||||
* This class was generated by the JAX-WS RI.
|
||||
* JAX-WS RI 2.2.4-b01
|
||||
* Generated source version: 2.2
|
||||
*
|
||||
*/
|
||||
@WebServiceClient(name = "EmployeeServiceTopDown", targetNamespace = "http://topdown.server.jaxws.baeldung.com/", wsdlLocation = "file:/Users/do-enr-lap-4/Developer/baeldung/source/tutorials/jee7/src/main/java/com/baeldung/jaxws/server/topdown/wsdl/employeeservicetopdown.wsdl")
|
||||
public class EmployeeServiceTopDown_Service
|
||||
extends Service
|
||||
{
|
||||
|
||||
private final static URL EMPLOYEESERVICETOPDOWN_WSDL_LOCATION;
|
||||
private final static WebServiceException EMPLOYEESERVICETOPDOWN_EXCEPTION;
|
||||
private final static QName EMPLOYEESERVICETOPDOWN_QNAME = new QName("http://topdown.server.jaxws.baeldung.com/", "EmployeeServiceTopDown");
|
||||
|
||||
static {
|
||||
URL url = null;
|
||||
WebServiceException e = null;
|
||||
try {
|
||||
url = new URL("file:/Users/do-enr-lap-4/Developer/baeldung/source/tutorials/jee7/src/main/java/com/baeldung/jaxws/server/topdown/wsdl/employeeservicetopdown.wsdl");
|
||||
} catch (MalformedURLException ex) {
|
||||
e = new WebServiceException(ex);
|
||||
}
|
||||
EMPLOYEESERVICETOPDOWN_WSDL_LOCATION = url;
|
||||
EMPLOYEESERVICETOPDOWN_EXCEPTION = e;
|
||||
}
|
||||
|
||||
public EmployeeServiceTopDown_Service() {
|
||||
super(__getWsdlLocation(), EMPLOYEESERVICETOPDOWN_QNAME);
|
||||
}
|
||||
|
||||
public EmployeeServiceTopDown_Service(WebServiceFeature... features) {
|
||||
super(__getWsdlLocation(), EMPLOYEESERVICETOPDOWN_QNAME, features);
|
||||
}
|
||||
|
||||
public EmployeeServiceTopDown_Service(URL wsdlLocation) {
|
||||
super(wsdlLocation, EMPLOYEESERVICETOPDOWN_QNAME);
|
||||
}
|
||||
|
||||
public EmployeeServiceTopDown_Service(URL wsdlLocation, WebServiceFeature... features) {
|
||||
super(wsdlLocation, EMPLOYEESERVICETOPDOWN_QNAME, features);
|
||||
}
|
||||
|
||||
public EmployeeServiceTopDown_Service(URL wsdlLocation, QName serviceName) {
|
||||
super(wsdlLocation, serviceName);
|
||||
}
|
||||
|
||||
public EmployeeServiceTopDown_Service(URL wsdlLocation, QName serviceName, WebServiceFeature... features) {
|
||||
super(wsdlLocation, serviceName, features);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* returns EmployeeServiceTopDown
|
||||
*/
|
||||
@WebEndpoint(name = "EmployeeServiceTopDownSOAP")
|
||||
public EmployeeServiceTopDown getEmployeeServiceTopDownSOAP() {
|
||||
return super.getPort(new QName("http://topdown.server.jaxws.baeldung.com/", "EmployeeServiceTopDownSOAP"), EmployeeServiceTopDown.class);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param features
|
||||
* A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values.
|
||||
* @return
|
||||
* returns EmployeeServiceTopDown
|
||||
*/
|
||||
@WebEndpoint(name = "EmployeeServiceTopDownSOAP")
|
||||
public EmployeeServiceTopDown getEmployeeServiceTopDownSOAP(WebServiceFeature... features) {
|
||||
return super.getPort(new QName("http://topdown.server.jaxws.baeldung.com/", "EmployeeServiceTopDownSOAP"), EmployeeServiceTopDown.class, features);
|
||||
}
|
||||
|
||||
private static URL __getWsdlLocation() {
|
||||
if (EMPLOYEESERVICETOPDOWN_EXCEPTION!= null) {
|
||||
throw EMPLOYEESERVICETOPDOWN_EXCEPTION;
|
||||
}
|
||||
return EMPLOYEESERVICETOPDOWN_WSDL_LOCATION;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
|
||||
package com.baeldung.jaxws.server.topdown;
|
||||
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.annotation.XmlElementDecl;
|
||||
import javax.xml.bind.annotation.XmlRegistry;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
|
||||
/**
|
||||
* This object contains factory methods for each
|
||||
* Java content interface and Java element interface
|
||||
* generated in the com.baeldung.jaxws.server.topdown package.
|
||||
* <p>An ObjectFactory allows you to programatically
|
||||
* construct new instances of the Java representation
|
||||
* for XML content. The Java representation of XML
|
||||
* content can consist of schema derived interfaces
|
||||
* and classes representing the binding of schema
|
||||
* type definitions, element declarations and model
|
||||
* groups. Factory methods for each of these are
|
||||
* provided in this class.
|
||||
*
|
||||
*/
|
||||
@XmlRegistry
|
||||
public class ObjectFactory {
|
||||
|
||||
private final static QName _CountEmployeesResponse_QNAME = new QName("http://topdown.server.jaxws.baeldung.com/", "countEmployeesResponse");
|
||||
|
||||
/**
|
||||
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.baeldung.jaxws.server.topdown
|
||||
*
|
||||
*/
|
||||
public ObjectFactory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link Integer }{@code >}}
|
||||
*
|
||||
*/
|
||||
@XmlElementDecl(namespace = "http://topdown.server.jaxws.baeldung.com/", name = "countEmployeesResponse")
|
||||
public JAXBElement<Integer> createCountEmployeesResponse(Integer value) {
|
||||
return new JAXBElement<Integer>(_CountEmployeesResponse_QNAME, Integer.class, null, value);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
||||
xmlns:tns="http://topdown.server.jaxws.baeldung.com/"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns="http://schemas.xmlsoap.org/wsdl/"
|
||||
targetNamespace="http://topdown.server.jaxws.baeldung.com/"
|
||||
name="EmployeeServiceTopDown">
|
||||
<types>
|
||||
<xsd:schema targetNamespace="http://topdown.server.jaxws.baeldung.com/">
|
||||
<xsd:element name="countEmployeesResponse" type="xsd:int"/>
|
||||
</xsd:schema>
|
||||
</types>
|
||||
|
||||
<message name="countEmployees">
|
||||
</message>
|
||||
<message name="countEmployeesResponse">
|
||||
<part name="parameters" element="tns:countEmployeesResponse"/>
|
||||
</message>
|
||||
<portType name="EmployeeServiceTopDown">
|
||||
<operation name="countEmployees">
|
||||
<input message="tns:countEmployees"/>
|
||||
<output message="tns:countEmployeesResponse"/>
|
||||
</operation>
|
||||
</portType>
|
||||
<binding name="EmployeeServiceTopDownSOAP" type="tns:EmployeeServiceTopDown">
|
||||
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
|
||||
<operation name="countEmployees">
|
||||
<soap:operation soapAction="http://topdown.server.jaxws.baeldung.com/EmployeeServiceTopDown/countEmployees"/>
|
||||
<input>
|
||||
<soap:body use="literal"/>
|
||||
</input>
|
||||
<output>
|
||||
<soap:body use="literal"/>
|
||||
</output>
|
||||
</operation>
|
||||
</binding>
|
||||
<service name="EmployeeServiceTopDown">
|
||||
<port name="EmployeeServiceTopDownSOAP" binding="tns:EmployeeServiceTopDownSOAP">
|
||||
<soap:address location="http://localhost:8080/employeeservicetopdown"/>
|
||||
</port>
|
||||
</service>
|
||||
</definitions>
|
|
@ -1,4 +1,4 @@
|
|||
/*package com.baeldung.jaxws;
|
||||
package com.baeldung.jaxws;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
@ -7,7 +7,6 @@ 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.junit.Arquillian;
|
||||
|
@ -19,17 +18,18 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import com.baeldung.jaxws.exception.EmployeeAlreadyExists;
|
||||
import com.baeldung.jaxws.exception.EmployeeNotFound;
|
||||
import com.baeldung.jaxws.model.Employee;
|
||||
import com.baeldung.jaxws.repository.EmployeeRepository;
|
||||
import com.baeldung.jaxws.client.Employee;
|
||||
import com.baeldung.jaxws.client.EmployeeAlreadyExists_Exception;
|
||||
import com.baeldung.jaxws.client.EmployeeNotFound_Exception;
|
||||
import com.baeldung.jaxws.client.EmployeeService;
|
||||
import com.baeldung.jaxws.client.EmployeeService_Service;
|
||||
|
||||
@RunWith(Arquillian.class)
|
||||
public class EmployeeServiceLiveTest {
|
||||
|
||||
private static final String APP_NAME = "jee7";
|
||||
private static final String WSDL_PATH = "EmployeeService?wsdl";
|
||||
private static QName SERVICE_NAME = new QName("http://jaxws.baeldung.com/", "EmployeeService");
|
||||
private static QName SERVICE_NAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "EmployeeService");
|
||||
private static URL wsdlUrl;
|
||||
|
||||
@ArquillianResource
|
||||
|
@ -39,8 +39,12 @@ public class EmployeeServiceLiveTest {
|
|||
|
||||
@Deployment(testable = false)
|
||||
public static WebArchive createDeployment() {
|
||||
return ShrinkWrap.create(WebArchive.class, APP_NAME + ".war").addPackage(EmployeeService.class.getPackage()).addPackage(Employee.class.getPackage()).addPackage(EmployeeNotFound.class.getPackage()).addPackage(EmployeeRepository.class.getPackage())
|
||||
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
|
||||
return ShrinkWrap.create(WebArchive.class, APP_NAME + ".war")
|
||||
.addPackage(com.baeldung.jaxws.server.bottomup.EmployeeService.class.getPackage())
|
||||
.addPackage(com.baeldung.jaxws.server.bottomup.model.Employee.class.getPackage())
|
||||
.addPackage(com.baeldung.jaxws.server.bottomup.exception.EmployeeNotFound.class.getPackage())
|
||||
.addPackage(com.baeldung.jaxws.server.repository.EmployeeRepository.class.getPackage())
|
||||
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
|
||||
}
|
||||
|
||||
@Before
|
||||
|
@ -51,8 +55,8 @@ public class EmployeeServiceLiveTest {
|
|||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Service service = Service.create(wsdlUrl, SERVICE_NAME);
|
||||
employeeServiceProxy = service.getPort(EmployeeService.class);
|
||||
EmployeeService_Service employeeService_Service = new EmployeeService_Service(wsdlUrl);
|
||||
employeeServiceProxy = employeeService_Service.getEmployeeServiceImplPort();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -63,49 +67,48 @@ public class EmployeeServiceLiveTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void givenEmployees_whenGetAvailableEmployee_thenCorrectEmployeeReturned() throws EmployeeNotFound {
|
||||
public void givenEmployees_whenGetAvailableEmployee_thenCorrectEmployeeReturned() throws EmployeeNotFound_Exception {
|
||||
Employee employee = employeeServiceProxy.getEmployee(2);
|
||||
assertEquals(employee.getFirstName(), "Jack");
|
||||
}
|
||||
|
||||
@Test(expected = EmployeeNotFound.class)
|
||||
public void givenEmployees_whenGetNonAvailableEmployee_thenEmployeeNotFoundException() throws EmployeeNotFound {
|
||||
@Test(expected = EmployeeNotFound_Exception.class)
|
||||
public void givenEmployees_whenGetNonAvailableEmployee_thenEmployeeNotFoundException() throws EmployeeNotFound_Exception {
|
||||
employeeServiceProxy.getEmployee(20);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenEmployees_whenAddNewEmployee_thenEmployeeCountIncreased() throws EmployeeAlreadyExists {
|
||||
public void givenEmployees_whenAddNewEmployee_thenEmployeeCountIncreased() throws EmployeeAlreadyExists_Exception {
|
||||
int employeeCount = employeeServiceProxy.countEmployees();
|
||||
employeeServiceProxy.addEmployee(4, "Anna");
|
||||
assertEquals(employeeServiceProxy.countEmployees(), employeeCount + 1);
|
||||
}
|
||||
|
||||
@Test(expected = EmployeeAlreadyExists.class)
|
||||
public void givenEmployees_whenAddAlreadyExistingEmployee_thenEmployeeAlreadyExistsException() throws EmployeeAlreadyExists {
|
||||
@Test(expected = EmployeeAlreadyExists_Exception.class)
|
||||
public void givenEmployees_whenAddAlreadyExistingEmployee_thenEmployeeAlreadyExistsException() throws EmployeeAlreadyExists_Exception {
|
||||
employeeServiceProxy.addEmployee(1, "Anna");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenEmployees_whenUpdateExistingEmployee_thenUpdatedEmployeeReturned() throws EmployeeNotFound {
|
||||
public void givenEmployees_whenUpdateExistingEmployee_thenUpdatedEmployeeReturned() throws EmployeeNotFound_Exception {
|
||||
Employee updated = employeeServiceProxy.updateEmployee(1, "Joan");
|
||||
assertEquals(updated.getFirstName(), "Joan");
|
||||
}
|
||||
|
||||
@Test(expected = EmployeeNotFound.class)
|
||||
public void givenEmployees_whenUpdateNonExistingEmployee_thenEmployeeNotFoundException() throws EmployeeNotFound {
|
||||
@Test(expected = EmployeeNotFound_Exception.class)
|
||||
public void givenEmployees_whenUpdateNonExistingEmployee_thenEmployeeNotFoundException() throws EmployeeNotFound_Exception {
|
||||
employeeServiceProxy.updateEmployee(20, "Joan");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenEmployees_whenDeleteExistingEmployee_thenSuccessReturned() throws EmployeeNotFound {
|
||||
public void givenEmployees_whenDeleteExistingEmployee_thenSuccessReturned() throws EmployeeNotFound_Exception {
|
||||
boolean deleteEmployee = employeeServiceProxy.deleteEmployee(3);
|
||||
assertEquals(deleteEmployee, true);
|
||||
}
|
||||
|
||||
@Test(expected = EmployeeNotFound.class)
|
||||
public void givenEmployee_whenDeleteNonExistingEmployee_thenEmployeeNotFoundException() throws EmployeeNotFound {
|
||||
@Test(expected = EmployeeNotFound_Exception.class)
|
||||
public void givenEmployee_whenDeleteNonExistingEmployee_thenEmployeeNotFoundException() throws EmployeeNotFound_Exception {
|
||||
employeeServiceProxy.deleteEmployee(20);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
|
@ -26,6 +26,12 @@
|
|||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-reflect</artifactId>
|
||||
<version>${kotlin-reflect.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
@ -93,6 +99,7 @@
|
|||
<kotlin-maven-plugin.version>1.1.1</kotlin-maven-plugin.version>
|
||||
<kotlin-test-junit.version>1.1.1</kotlin-test-junit.version>
|
||||
<kotlin-stdlib.version>1.1.1</kotlin-stdlib.version>
|
||||
<kotlin-reflect.version>1.1.1</kotlin-reflect.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,24 @@
|
|||
package com.baeldung.java;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
public class ArrayExample {
|
||||
|
||||
public int sumValues(int[] nums) {
|
||||
int res = 0;
|
||||
|
||||
for (int x:nums) {
|
||||
res += x;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public void writeList() throws IOException {
|
||||
File file = new File("E://file.txt");
|
||||
FileReader fr = new FileReader(file);
|
||||
fr.close();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.baeldung.java;
|
||||
|
||||
public class Customer {
|
||||
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package com.baeldung.kotlin
|
||||
|
||||
import com.baeldung.java.ArrayExample
|
||||
import com.baeldung.java.Customer
|
||||
import org.junit.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class ArrayTest {
|
||||
|
||||
@Test
|
||||
fun givenArray_whenValidateArrayType_thenComplete () {
|
||||
val ex = ArrayExample()
|
||||
val numArray = intArrayOf(1, 2, 3)
|
||||
|
||||
assertEquals(ex.sumValues(numArray), 6)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenCustomer_whenGetSuperType_thenComplete() {
|
||||
val instance = Customer::class
|
||||
val supertypes = instance.supertypes
|
||||
|
||||
assertEquals(supertypes[0].toString(), "kotlin.Any")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenCustomer_whenGetConstructor_thenComplete() {
|
||||
val instance = Customer::class.java
|
||||
val constructors = instance.constructors
|
||||
|
||||
assertEquals(constructors.size, 1)
|
||||
assertEquals(constructors[0].name, "com.baeldung.java.Customer")
|
||||
}
|
||||
|
||||
fun makeReadFile() {
|
||||
val ax = ArrayExample()
|
||||
ax.writeList()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.baeldung.kotlin
|
||||
|
||||
import com.baeldung.java.Customer
|
||||
import org.junit.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class CustomerTest {
|
||||
|
||||
@Test
|
||||
fun givenCustomer_whenNameAndLastNameAreAssigned_thenComplete() {
|
||||
val customer = Customer()
|
||||
|
||||
// Setter method is being called
|
||||
customer.firstName = "Frodo"
|
||||
customer.lastName = "Baggins"
|
||||
|
||||
// Getter method is being called
|
||||
assertEquals(customer.firstName, "Frodo")
|
||||
assertEquals(customer.lastName, "Baggins")
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -45,6 +45,20 @@
|
|||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>net.serenity-bdd.maven.plugins</groupId>
|
||||
<artifactId>serenity-maven-plugin</artifactId>
|
||||
<version>${serenity.plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>serenity-reports</id>
|
||||
<phase>post-integration-test</phase>
|
||||
<goals>
|
||||
<goal>aggregate</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
@ -123,26 +137,6 @@
|
|||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons.io.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-server</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>${httpclient.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons.io.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.flink</groupId>
|
||||
<artifactId>flink-core</artifactId>
|
||||
|
@ -176,6 +170,36 @@
|
|||
<artifactId>commons-math3</artifactId>
|
||||
<version>3.6.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.serenity-bdd</groupId>
|
||||
<artifactId>serenity-core</artifactId>
|
||||
<version>${serenity.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.serenity-bdd</groupId>
|
||||
<artifactId>serenity-junit</artifactId>
|
||||
<version>${serenity.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.serenity-bdd</groupId>
|
||||
<artifactId>serenity-jbehave</artifactId>
|
||||
<version>${serenity.jbehave.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.serenity-bdd</groupId>
|
||||
<artifactId>serenity-rest-assured</artifactId>
|
||||
<version>${serenity.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.serenity-bdd</groupId>
|
||||
<artifactId>serenity-jira-requirements-provider</artifactId>
|
||||
<version>${serenity.jira.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
|
@ -195,6 +219,11 @@
|
|||
<httpclient.version>4.5.3</httpclient.version>
|
||||
<commons.io.version>2.5</commons.io.version>
|
||||
<flink.version>1.2.0</flink.version>
|
||||
<jackson.version>2.8.5</jackson.version>
|
||||
<serenity.version>1.2.5-rc.11</serenity.version>
|
||||
<serenity.jbehave.version>1.24.0</serenity.jbehave.version>
|
||||
<serenity.jira.version>1.1.3-rc.5</serenity.jira.version>
|
||||
<serenity.plugin.version>1.2.5-rc.6</serenity.plugin.version>
|
||||
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
||||
</properties>
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
jira.url=<jira-url>
|
||||
jira.project=<jira-project>
|
||||
jira.username=<jira-username>
|
||||
jira.password=<jira-password>
|
|
@ -0,0 +1,49 @@
|
|||
package com.baeldung.http;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class HttpRequestBuilder {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(HttpRequestBuilder.class);
|
||||
|
||||
public HttpResponseWrapper sendRequest(String urlString, String method, Map<String, String> parameters, Map<String, String> properties) throws IOException{
|
||||
URL url = new URL(urlString);
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod(method);
|
||||
if (properties != null) {
|
||||
properties.forEach((key, value) -> con.setRequestProperty(key, value));
|
||||
}
|
||||
if (parameters != null) {
|
||||
con.setDoOutput(true);
|
||||
DataOutputStream out = new DataOutputStream(con.getOutputStream());
|
||||
out.writeBytes(ParameterStringBuilder.getParamsString(parameters));
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
|
||||
int status = con.getResponseCode();
|
||||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
|
||||
HttpResponseWrapper responseWrapper = new HttpResponseWrapper();
|
||||
responseWrapper.setStatus(status);
|
||||
responseWrapper.setContent(content.toString());
|
||||
|
||||
return responseWrapper;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.baeldung.http;
|
||||
|
||||
public class HttpResponseWrapper {
|
||||
private int status;
|
||||
private String content;
|
||||
|
||||
public HttpResponseWrapper(){ }
|
||||
|
||||
public HttpResponseWrapper(int status, String content) {
|
||||
super();
|
||||
this.status = status;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.baeldung.http;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Map;
|
||||
|
||||
public class ParameterStringBuilder {
|
||||
public static String getParamsString(Map<String, String> params) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
params.forEach((key, value) -> {
|
||||
try {
|
||||
result.append(URLEncoder.encode(key, "UTF-8"));
|
||||
result.append("=");
|
||||
result.append(URLEncoder.encode(value, "UTF-8"));
|
||||
result.append("&");
|
||||
} catch (UnsupportedEncodingException exc) {
|
||||
}
|
||||
});
|
||||
|
||||
String resultString = result.toString();
|
||||
if (resultString.length() > 0) {
|
||||
resultString = resultString.substring(0, resultString.length() - 1);
|
||||
}
|
||||
return resultString;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
package com.baeldung.httpclient;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
|
||||
import com.baeldung.http.HttpResponseWrapper;
|
||||
import com.baeldung.http.ParameterStringBuilder;
|
||||
|
||||
public class HttpClientRequestBuilder {
|
||||
|
||||
public HttpResponseWrapper sendGetRequest(String url, Map<String, String> parameters) {
|
||||
HttpClient client = HttpClientBuilder.create()
|
||||
.build();
|
||||
if (parameters != null) {
|
||||
url += "?" + ParameterStringBuilder.getParamsString(parameters);
|
||||
}
|
||||
HttpGet request = new HttpGet(url);
|
||||
try {
|
||||
HttpResponse response = client.execute(request);
|
||||
|
||||
HttpResponseWrapper responseWrapper = new HttpResponseWrapper();
|
||||
responseWrapper.setStatus(response.getStatusLine()
|
||||
.getStatusCode());
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(response.getEntity()
|
||||
.getContent()));
|
||||
|
||||
String line = "", content = "";
|
||||
while ((line = in.readLine()) != null) {
|
||||
content += line;
|
||||
}
|
||||
responseWrapper.setContent(content);
|
||||
return responseWrapper;
|
||||
} catch (ClientProtocolException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public HttpResponseWrapper sendPostRequestWithParameters(String url, Map<String, String> parameters) {
|
||||
HttpClient client = HttpClientBuilder.create()
|
||||
.build();
|
||||
HttpPost request = new HttpPost(url);
|
||||
|
||||
try {
|
||||
if (parameters != null) {
|
||||
List<NameValuePair> nameValuePairs = new ArrayList<>();
|
||||
parameters.forEach((key, value) -> nameValuePairs.add(new BasicNameValuePair(key, value)));
|
||||
request.setEntity(new UrlEncodedFormEntity(nameValuePairs));
|
||||
}
|
||||
|
||||
HttpResponse response = client.execute(request);
|
||||
|
||||
HttpResponseWrapper responseWrapper = new HttpResponseWrapper();
|
||||
responseWrapper.setStatus(response.getStatusLine()
|
||||
.getStatusCode());
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(response.getEntity()
|
||||
.getContent()));
|
||||
|
||||
String line = "", content = "";
|
||||
while ((line = in.readLine()) != null) {
|
||||
content += line;
|
||||
}
|
||||
responseWrapper.setContent(content);
|
||||
return responseWrapper;
|
||||
} catch (ClientProtocolException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public HttpResponseWrapper sendPostRequestWithJson(String url, String json) {
|
||||
HttpClient client = HttpClientBuilder.create()
|
||||
.build();
|
||||
HttpPost request = new HttpPost(url);
|
||||
|
||||
try {
|
||||
request.addHeader("Content-Type", "application/json");
|
||||
request.setEntity(new StringEntity(json));
|
||||
|
||||
HttpResponse response = client.execute(request);
|
||||
|
||||
HttpResponseWrapper responseWrapper = new HttpResponseWrapper();
|
||||
responseWrapper.setStatus(response.getStatusLine()
|
||||
.getStatusCode());
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(response.getEntity()
|
||||
.getContent()));
|
||||
|
||||
String line = "", content = "";
|
||||
while ((line = in.readLine()) != null) {
|
||||
content += line;
|
||||
}
|
||||
responseWrapper.setContent(content);
|
||||
return responseWrapper;
|
||||
} catch (ClientProtocolException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.baeldung.serenity.github;
|
||||
|
||||
public class GitHubUser {
|
||||
|
||||
private String login;
|
||||
|
||||
public GitHubUser() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getLogin() {
|
||||
return login;
|
||||
}
|
||||
|
||||
public void setLogin(final String login) {
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.baeldung.serenity.membership;
|
||||
|
||||
/**
|
||||
* @author aiet
|
||||
*/
|
||||
public enum Commodity {
|
||||
|
||||
MacBookPro(1499), GoProHero5(400);
|
||||
|
||||
public final int price;
|
||||
|
||||
Commodity(int price){
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.baeldung.serenity.membership;
|
||||
|
||||
import static com.baeldung.serenity.membership.MemberGrade.Bronze;
|
||||
import static com.baeldung.serenity.membership.MemberGrade.Gold;
|
||||
import static com.baeldung.serenity.membership.MemberGrade.Silver;
|
||||
|
||||
/**
|
||||
* @author aiet
|
||||
*/
|
||||
public class Member {
|
||||
|
||||
private int points;
|
||||
|
||||
private Member(int points) {
|
||||
if (points < 0) throw new IllegalArgumentException("points must not be negative!");
|
||||
this.points = points;
|
||||
|
||||
}
|
||||
|
||||
public static Member withInitialPoints(int initialPoints) {
|
||||
return new Member(initialPoints);
|
||||
}
|
||||
|
||||
public MemberGrade getGrade() {
|
||||
if (points < 1000) return Bronze;
|
||||
else if (points >= 1000 && points < 5000) return Silver;
|
||||
else return Gold;
|
||||
}
|
||||
|
||||
public void spend(int moneySpent) {
|
||||
points += moneySpent / 10;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.baeldung.serenity.membership;
|
||||
|
||||
/**
|
||||
* @author aiet
|
||||
*/
|
||||
public enum MemberGrade {
|
||||
|
||||
Bronze, Silver, Gold;
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.baeldung.http;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class HttpRequestBuilderTest {
|
||||
|
||||
private HttpRequestBuilder requestPerformer;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
requestPerformer = new HttpRequestBuilder();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetRequest_thenOk() throws IOException {
|
||||
HttpResponseWrapper response = requestPerformer.sendRequest("http://www.example.com", "GET", null, null);
|
||||
assertEquals("status code incorrect", response.getStatus(), 200);
|
||||
assertTrue("content incorrect", response.getContent()
|
||||
.contains("Example Domain"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenPostRequest_thenOk() throws IOException {
|
||||
Map<String, String> parameters = new HashMap<>();
|
||||
parameters.put("param1", "val");
|
||||
Map<String, String> properties = new HashMap<>();
|
||||
properties.put("Content-Type", "application/json");
|
||||
HttpResponseWrapper response = requestPerformer.sendRequest("http://www.example.com", "POST", parameters, properties);
|
||||
assertEquals("status code incorrect", response.getStatus(), 200);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.baeldung.httpclient;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.http.HttpResponseWrapper;
|
||||
|
||||
public class HttpClientRequestBuilderTest {
|
||||
private HttpClientRequestBuilder requestBuilder;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
requestBuilder = new HttpClientRequestBuilder();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetRequest_thenOk() {
|
||||
Map<String, String> parameters = new HashMap<>();
|
||||
parameters.put("param1", "val");
|
||||
HttpResponseWrapper response = requestBuilder.sendGetRequest("http://www.example.com",parameters);
|
||||
assertEquals("status code incorrect", response.getStatus(), 200);
|
||||
assertTrue("content incorrect", response.getContent()
|
||||
.contains("Example Domain"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenPostRequestWithParameters_thenOk() {
|
||||
Map<String, String> parameters = new HashMap<>();
|
||||
parameters.put("param1", "val");
|
||||
HttpResponseWrapper response = requestBuilder.sendPostRequestWithParameters("http://www.example.com", parameters);
|
||||
assertEquals("status code incorrect", response.getStatus(), 200);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenPostRequestWithJson_thenOk() {
|
||||
String json = "{\"id\":\"1\"}";
|
||||
HttpResponseWrapper response = requestBuilder.sendPostRequestWithJson("http://www.example.com",json);
|
||||
assertEquals("status code incorrect", response.getStatus(), 200);
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ import java.nio.charset.StandardCharsets;
|
|||
|
||||
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
|
||||
|
||||
public class JettyTest {
|
||||
public class JettyIntegrationTest {
|
||||
private JettyServer jettyServer;
|
||||
|
||||
@Before
|
|
@ -0,0 +1,10 @@
|
|||
package com.baeldung.serenity;
|
||||
|
||||
import net.serenitybdd.jbehave.SerenityStory;
|
||||
|
||||
/**
|
||||
* @author aiet
|
||||
*/
|
||||
public class GithubUserProfilePayloadIntegrationTest extends SerenityStory {
|
||||
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package com.baeldung.serenity;
|
||||
|
||||
import com.baeldung.serenity.membership.MemberStatusSteps;
|
||||
import net.serenitybdd.junit.runners.SerenityRunner;
|
||||
import net.thucydides.core.annotations.Steps;
|
||||
import net.thucydides.core.annotations.Title;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static com.baeldung.serenity.membership.Commodity.MacBookPro;
|
||||
import static com.baeldung.serenity.membership.MemberGrade.Bronze;
|
||||
import static com.baeldung.serenity.membership.MemberGrade.Gold;
|
||||
import static com.baeldung.serenity.membership.MemberGrade.Silver;
|
||||
|
||||
@RunWith(SerenityRunner.class)
|
||||
public class MemberStatusIntegrationTest {
|
||||
|
||||
@Steps MemberStatusSteps memberSteps;
|
||||
|
||||
@Test
|
||||
public void membersShouldStartWithBronzeStatus() {
|
||||
memberSteps.aClientJoinsTheMemberProgram();
|
||||
memberSteps.theMemberShouldHaveAStatusOf(Bronze);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Title("Members earn Silver grade after 1000 points ($10,000)")
|
||||
public void earnsSilverAfterSpends$10000() {
|
||||
memberSteps.aClientJoinsTheMemberProgram();
|
||||
memberSteps.theMemberSpends(10_000);
|
||||
memberSteps.theMemberShouldHaveAStatusOf(Silver);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Title("Members with 2,000 points should earn Gold grade when added 3,000 points ($30,000)")
|
||||
public void memberWith2000PointsEarnsGoldAfterSpends$30000() {
|
||||
memberSteps.aMemberHasPointsOf(2000);
|
||||
memberSteps.theMemberSpends(30_000);
|
||||
memberSteps.theMemberShouldHaveAStatusOf(Gold);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Title("Members with 50,000 points can exchange a MacBook Pro")
|
||||
public void memberWith50000PointsCanExchangeAMacbookpro(){
|
||||
memberSteps.aMemberHasPointsOf(50_000);
|
||||
memberSteps.aMemberExchangeA(MacBookPro);
|
||||
memberSteps.memberShouldHavePointsLeft();
|
||||
}
|
||||
|
||||
/**
|
||||
* This test should fail, comment out <code>@Ignore</code> to see how failed test can be reflected in Serenity report. <br/>
|
||||
* Remember to add <code><testFailureIgnore>true</testFailureIgnore></code> under maven-surefire-plugin configuration.
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
@Title("Members with 500 points should have a Gold status when added 4,000 points ($40,000)")
|
||||
public void memberWith500PointsEarnsGoldAfterSpends$40000(){
|
||||
memberSteps.aMemberHasPointsOf(500);
|
||||
memberSteps.theMemberSpends(40_000);
|
||||
memberSteps.theMemberShouldHaveAStatusOf(Gold);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Title("Members with 100 points would have a Gold status when added 10,000 points ($100,000)")
|
||||
public void memberWith100EarnsGoldAfterSpends$100000(){
|
||||
memberSteps.aMemberHasPointsOf(100);
|
||||
memberSteps.theMemberSpends(100_000);
|
||||
memberSteps.theMemberShouldHaveAStatusOf(Gold);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.baeldung.serenity.github;
|
||||
|
||||
import net.thucydides.core.annotations.Step;
|
||||
import org.hamcrest.Matchers;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static net.serenitybdd.rest.SerenityRest.rest;
|
||||
import static net.serenitybdd.rest.SerenityRest.then;
|
||||
|
||||
/**
|
||||
* @author aiet
|
||||
*/
|
||||
public class GithubRestAssuredUserAPISteps {
|
||||
|
||||
private String api;
|
||||
|
||||
@Step("Given the github REST API for user profile")
|
||||
public void withUserProfileAPIEndpoint() {
|
||||
api = "https://api.github.com/users/{username}";
|
||||
}
|
||||
|
||||
@Step("When looking for {0} via the api")
|
||||
public void getProfileOfUser(String username) throws IOException {
|
||||
rest().get(api, username);
|
||||
}
|
||||
|
||||
@Step("Then there should be a login field with value {0} in payload of user {0}")
|
||||
public void profilePayloadShouldContainLoginValue(String username) {
|
||||
then().body("login", Matchers.equalTo(username));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package com.baeldung.serenity.github;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import net.thucydides.core.annotations.Step;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.hamcrest.Matchers;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
/**
|
||||
* @author aiet
|
||||
*/
|
||||
public class GithubRestUserAPISteps {
|
||||
|
||||
private String api;
|
||||
private GitHubUser resource;
|
||||
|
||||
@Step("Given the github REST API for user profile")
|
||||
public void withUserProfileAPIEndpoint() {
|
||||
api = "https://api.github.com/users/%s";
|
||||
}
|
||||
|
||||
@Step("When looking for {0} via the api")
|
||||
public void getProfileOfUser(String username) throws IOException {
|
||||
HttpResponse httpResponse = getGithubUserProfile(api, username);
|
||||
resource = retrieveResourceFromResponse(httpResponse, GitHubUser.class);
|
||||
}
|
||||
|
||||
@Step("Then there should be a login field with value {0} in payload of user {0}")
|
||||
public void profilePayloadShouldContainLoginValue(String username) {
|
||||
assertThat(username, Matchers.is(resource.getLogin()));
|
||||
}
|
||||
|
||||
private static <T> T retrieveResourceFromResponse(final HttpResponse response, final Class<T> clazz) throws IOException {
|
||||
final String jsonFromResponse = EntityUtils.toString(response.getEntity());
|
||||
final ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
return mapper.readValue(jsonFromResponse, clazz);
|
||||
}
|
||||
|
||||
private static HttpResponse getGithubUserProfile(String api, String username) throws IOException {
|
||||
HttpUriRequest request = new HttpGet(String.format(api, username));
|
||||
return HttpClientBuilder
|
||||
.create()
|
||||
.build()
|
||||
.execute(request);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.baeldung.serenity.github;
|
||||
|
||||
import net.thucydides.core.annotations.Steps;
|
||||
import org.jbehave.core.annotations.Given;
|
||||
import org.jbehave.core.annotations.Then;
|
||||
import org.jbehave.core.annotations.When;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class GithubUserProfilePayloadStepDefinitions {
|
||||
|
||||
// @Steps
|
||||
// GithubRestUserAPISteps userAPISteps;
|
||||
|
||||
@Steps
|
||||
GithubRestAssuredUserAPISteps userAPISteps;
|
||||
|
||||
@Given("github user profile api")
|
||||
public void givenGithubUserProfileApi() {
|
||||
userAPISteps.withUserProfileAPIEndpoint();
|
||||
}
|
||||
|
||||
@When("looking for $user via the api")
|
||||
public void whenLookingForProfileOf(String user) throws IOException {
|
||||
userAPISteps.getProfileOfUser(user);
|
||||
}
|
||||
|
||||
@Then("github's response contains a 'login' payload same as $user")
|
||||
public void thenGithubsResponseContainsAloginPayloadSameAs(String user) {
|
||||
userAPISteps.profilePayloadShouldContainLoginValue(user);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.baeldung.serenity.membership;
|
||||
|
||||
import net.thucydides.core.annotations.Pending;
|
||||
import net.thucydides.core.annotations.Step;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* @author aiet
|
||||
*/
|
||||
public class MemberStatusSteps {
|
||||
|
||||
Member member;
|
||||
|
||||
@Step("Given a member has {0} points")
|
||||
public void aMemberHasPointsOf(int points) {
|
||||
member = Member.withInitialPoints(points);
|
||||
}
|
||||
|
||||
@Step("Then the member grade should be {0}")
|
||||
public void theMemberShouldHaveAStatusOf(MemberGrade grade) {
|
||||
assertThat(member.getGrade(), equalTo(grade));
|
||||
}
|
||||
|
||||
@Step("When the member spends ${0} ")
|
||||
public void theMemberSpends(int moneySpent) {
|
||||
member.spend(moneySpent);
|
||||
}
|
||||
|
||||
@Step("Given client joins membership program")
|
||||
public void aClientJoinsTheMemberProgram() {
|
||||
member = Member.withInitialPoints(0);
|
||||
}
|
||||
|
||||
@Pending
|
||||
@Step("When the member exchange {}")
|
||||
public void aMemberExchangeA(Commodity commodity){
|
||||
//TODO
|
||||
}
|
||||
|
||||
@Pending
|
||||
@Step("Then the member should have points left")
|
||||
public void memberShouldHavePointsLeft() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
Meta:
|
||||
|
||||
Narrative:
|
||||
As a user
|
||||
I want to look up a valid user's profile on github
|
||||
So that I can know the login payload should be the same as username
|
||||
|
||||
Scenario: Github user's profile should have a login payload same as username
|
||||
|
||||
Given github user profile api
|
||||
When looking for eugenp via the api
|
||||
Then github's response contains a 'login' payload same as eugenp
|
|
@ -31,13 +31,7 @@
|
|||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>${springframework.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<version>${springframework.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
|
|
|
@ -144,13 +144,7 @@
|
|||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>${httpclient.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<version>${httpclient.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -183,13 +177,7 @@
|
|||
<dependency>
|
||||
<groupId>com.github.fge</groupId>
|
||||
<artifactId>json-schema-core</artifactId>
|
||||
<version>${json-schema-core.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<version>${json-schema-core.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
|
|
@ -11,13 +11,7 @@
|
|||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<artifactId>spring-context</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
|
|
@ -20,3 +20,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
|
|||
- [Dynamic DTO Validation Config Retrieved from DB](http://www.baeldung.com/spring-dynamic-dto-validation)
|
||||
- [Custom Information in Spring Boot Info Endpoint](http://www.baeldung.com/spring-boot-info-actuator-custom)
|
||||
- [Using @JsonComponent in Spring Boot](http://www.baeldung.com/spring-boot-jsoncomponent)
|
||||
- [Create a Custom Auto-Configuration with Spring Boot](http://www.baeldung.com/spring-boot-custom-auto-configuration)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.baeldung.boot.boottest;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
|
@ -12,9 +11,9 @@ import org.springframework.stereotype.Repository;
|
|||
@Transactional
|
||||
public interface EmployeeRepository extends JpaRepository<Employee, Long> {
|
||||
|
||||
public Optional<Employee> findByName(String name);
|
||||
public Employee findByName(String name);
|
||||
|
||||
public Optional<Employee> findById(Long id);
|
||||
public Employee findById(Long id);
|
||||
|
||||
public List<Employee> findAll();
|
||||
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package org.baeldung.boot.boottest;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface EmployeeService {
|
||||
|
||||
public Optional<Employee> getEmployeeById(Long id);
|
||||
public Employee getEmployeeById(Long id);
|
||||
|
||||
public Optional<Employee> getEmployeeByName(String name);
|
||||
public Employee getEmployeeByName(String name);
|
||||
|
||||
public List<Employee> getAllEmployees();
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.baeldung.boot.boottest;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
|
@ -16,12 +15,12 @@ public class EmployeeServiceImpl implements EmployeeService {
|
|||
private EmployeeRepository employeeRepository;
|
||||
|
||||
@Override
|
||||
public Optional<Employee> getEmployeeById(Long id) {
|
||||
public Employee getEmployeeById(Long id) {
|
||||
return employeeRepository.findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Employee> getEmployeeByName(String name) {
|
||||
public Employee getEmployeeByName(String name) {
|
||||
return employeeRepository.findByName(name);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
package org.baeldung.properties;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@Configuration
|
||||
@PropertySource("classpath:configprops.properties")
|
||||
@ConfigurationProperties(prefix = "mail")
|
||||
@Validated
|
||||
public class ConfigProperties {
|
||||
|
||||
@Validated
|
||||
public static class Credentials {
|
||||
|
||||
@Length(max = 4, min = 1)
|
||||
private String authMethod;
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
public String getAuthMethod() {
|
||||
return authMethod;
|
||||
}
|
||||
|
||||
public void setAuthMethod(String authMethod) {
|
||||
this.authMethod = authMethod;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
}
|
||||
|
||||
@NotBlank
|
||||
private String host;
|
||||
|
||||
@Min(1025)
|
||||
@Max(65536)
|
||||
private int port;
|
||||
|
||||
@Pattern(regexp = "^[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,6}$")
|
||||
private String from;
|
||||
|
||||
private Credentials credentials;
|
||||
private List<String> defaultRecipients;
|
||||
private Map<String, String> additionalHeaders;
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public void setFrom(String from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public Credentials getCredentials() {
|
||||
return credentials;
|
||||
}
|
||||
|
||||
public void setCredentials(Credentials credentials) {
|
||||
this.credentials = credentials;
|
||||
}
|
||||
|
||||
public List<String> getDefaultRecipients() {
|
||||
return defaultRecipients;
|
||||
}
|
||||
|
||||
public void setDefaultRecipients(List<String> defaultRecipients) {
|
||||
this.defaultRecipients = defaultRecipients;
|
||||
}
|
||||
|
||||
public Map<String, String> getAdditionalHeaders() {
|
||||
return additionalHeaders;
|
||||
}
|
||||
|
||||
public void setAdditionalHeaders(Map<String, String> additionalHeaders) {
|
||||
this.additionalHeaders = additionalHeaders;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package org.baeldung.properties;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
import com.baeldung.autoconfiguration.MySQLAutoconfiguration;
|
||||
|
||||
@EnableAutoConfiguration(exclude = MySQLAutoconfiguration.class)
|
||||
@ComponentScan(basePackageClasses = ConfigProperties.class)
|
||||
public class ConfigPropertiesDemoApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ConfigPropertiesDemoApplication.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
#Simple properties
|
||||
mail.host=mailer@mail.com
|
||||
mail.port=9000
|
||||
mail.from=mailer@mail.com
|
||||
|
||||
#List properties
|
||||
mail.defaultRecipients[0]=admin@mail.com
|
||||
mail.defaultRecipients[1]=owner@mail.com
|
||||
|
||||
#Map Properties
|
||||
mail.additionalHeaders.redelivery=true
|
||||
mail.additionalHeaders.secure=true
|
||||
mail.additionalHeaders.p3=value
|
||||
|
||||
#Object properties
|
||||
mail.credentials.username=john
|
||||
mail.credentials.password=password
|
||||
mail.credentials.authMethod=SHA1
|
||||
|
||||
|
|
@ -3,11 +3,7 @@ package org.baeldung.boot.boottest;
|
|||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.baeldung.boot.boottest.Employee;
|
||||
import org.baeldung.boot.boottest.EmployeeRepository;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -27,18 +23,17 @@ public class EmployeeRepositoryIntegrationTest {
|
|||
|
||||
@Test
|
||||
public void whenFindByName_thenReturnEmployee() {
|
||||
Employee emp = new Employee("test");
|
||||
entityManager.persistAndFlush(emp);
|
||||
Employee alex = new Employee("alex");
|
||||
entityManager.persistAndFlush(alex);
|
||||
|
||||
Optional<Employee> fromDb = employeeRepository.findByName(emp.getName());
|
||||
assertThat(fromDb.get()
|
||||
.getName()).isEqualTo(emp.getName());
|
||||
Employee found = employeeRepository.findByName(alex.getName());
|
||||
assertThat(found.getName()).isEqualTo(alex.getName());
|
||||
}
|
||||
|
||||
@Test(expected = NoSuchElementException.class)
|
||||
public void whenInvalidName_thenNoSuchElementException() {
|
||||
Optional<Employee> fromDb = employeeRepository.findByName("doesNotExist");
|
||||
fromDb.get();
|
||||
@Test
|
||||
public void whenInvalidName_thenReturnNull() {
|
||||
Employee fromDb = employeeRepository.findByName("doesNotExist");
|
||||
assertThat(fromDb).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -46,15 +41,14 @@ public class EmployeeRepositoryIntegrationTest {
|
|||
Employee emp = new Employee("test");
|
||||
entityManager.persistAndFlush(emp);
|
||||
|
||||
Optional<Employee> fromDb = employeeRepository.findById(emp.getId());
|
||||
assertThat(fromDb.get()
|
||||
.getName()).isEqualTo(emp.getName());
|
||||
Employee fromDb = employeeRepository.findById(emp.getId());
|
||||
assertThat(fromDb.getName()).isEqualTo(emp.getName());
|
||||
}
|
||||
|
||||
@Test(expected = NoSuchElementException.class)
|
||||
public void whenInvalidId_thenNoSuchElementException() {
|
||||
Optional<Employee> fromDb = employeeRepository.findById(-11L);
|
||||
fromDb.get();
|
||||
@Test
|
||||
public void whenInvalidId_thenReturnNull() {
|
||||
Employee fromDb = employeeRepository.findById(-11L);
|
||||
assertThat(fromDb).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -74,5 +68,4 @@ public class EmployeeRepositoryIntegrationTest {
|
|||
.extracting(Employee::getName)
|
||||
.containsOnly(alex.getName(), ron.getName(), bob.getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,13 +4,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.baeldung.boot.boottest.Employee;
|
||||
import org.baeldung.boot.boottest.EmployeeRepository;
|
||||
import org.baeldung.boot.boottest.EmployeeService;
|
||||
import org.baeldung.boot.boottest.EmployeeServiceImpl;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -44,38 +38,38 @@ public class EmployeeServiceImplIntegrationTest {
|
|||
Employee john = new Employee("john");
|
||||
john.setId(11L);
|
||||
|
||||
Optional<Employee> emp = Optional.of(john);
|
||||
|
||||
Employee bob = new Employee("bob");
|
||||
Employee alex = new Employee("alex");
|
||||
|
||||
List<Employee> allEmployees = Arrays.asList(john, bob, alex);
|
||||
|
||||
Mockito.when(employeeRepository.findByName(john.getName()))
|
||||
.thenReturn(emp);
|
||||
.thenReturn(john);
|
||||
Mockito.when(employeeRepository.findByName(alex.getName()))
|
||||
.thenReturn(alex);
|
||||
Mockito.when(employeeRepository.findByName("wrong_name"))
|
||||
.thenReturn(Optional.empty());
|
||||
.thenReturn(null);
|
||||
Mockito.when(employeeRepository.findById(john.getId()))
|
||||
.thenReturn(emp);
|
||||
.thenReturn(john);
|
||||
Mockito.when(employeeRepository.findAll())
|
||||
.thenReturn(allEmployees);
|
||||
Mockito.when(employeeRepository.findById(-99L))
|
||||
.thenReturn(Optional.empty());
|
||||
.thenReturn(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenValidName_thenEmployeeShouldBeFound() {
|
||||
Optional<Employee> fromDb = employeeService.getEmployeeByName("john");
|
||||
assertThat(fromDb.get()
|
||||
.getName()).isEqualTo("john");
|
||||
String name = "alex";
|
||||
Employee found = employeeService.getEmployeeByName(name);
|
||||
|
||||
assertThat(found.getName())
|
||||
.isEqualTo(name);
|
||||
}
|
||||
|
||||
verifyFindByNameIsCalledOnce("john");
|
||||
}
|
||||
|
||||
@Test(expected = NoSuchElementException.class)
|
||||
@Test
|
||||
public void whenInValidName_thenEmployeeShouldNotBeFound() {
|
||||
Optional<Employee> fromDb = employeeService.getEmployeeByName("wrong_name");
|
||||
fromDb.get();
|
||||
Employee fromDb = employeeService.getEmployeeByName("wrong_name");
|
||||
assertThat(fromDb).isNull();
|
||||
|
||||
verifyFindByNameIsCalledOnce("wrong_name");
|
||||
}
|
||||
|
@ -97,19 +91,18 @@ public class EmployeeServiceImplIntegrationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void whenValidI_thendEmployeeShouldBeFound() {
|
||||
Optional<Employee> fromDb = employeeService.getEmployeeById(11L);
|
||||
assertThat(fromDb.get()
|
||||
.getName()).isEqualTo("john");
|
||||
public void whenValidId_thenEmployeeShouldBeFound() {
|
||||
Employee fromDb = employeeService.getEmployeeById(11L);
|
||||
assertThat(fromDb.getName()).isEqualTo("john");
|
||||
|
||||
verifyFindByIdIsCalledOnce();
|
||||
}
|
||||
|
||||
@Test(expected = NoSuchElementException.class)
|
||||
@Test
|
||||
public void whenInValidId_thenEmployeeShouldNotBeFound() {
|
||||
Optional<Employee> fromDb = employeeService.getEmployeeById(-99L);
|
||||
Employee fromDb = employeeService.getEmployeeById(-99L);
|
||||
verifyFindByIdIsCalledOnce();
|
||||
fromDb.get();
|
||||
assertThat(fromDb).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
package org.baeldung.properties;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = ConfigPropertiesDemoApplication.class)
|
||||
@TestPropertySource("classpath:configprops-test.properties")
|
||||
public class ConfigPropertiesIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private ConfigProperties properties;
|
||||
|
||||
@Test
|
||||
public void whenSimplePropertyQueriedthenReturnsProperty() throws Exception {
|
||||
Assert.assertTrue("From address is read as null!", properties.getFrom() != null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenListPropertyQueriedthenReturnsProperty() throws Exception {
|
||||
Assert.assertTrue("Couldn't bind list property!", properties.getDefaultRecipients()
|
||||
.size() == 2);
|
||||
Assert.assertTrue("Incorrectly bound list property. Expected 2 entries!", properties.getDefaultRecipients()
|
||||
.size() == 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenMapPropertyQueriedthenReturnsProperty() throws Exception {
|
||||
Assert.assertTrue("Couldn't bind map property!", properties.getAdditionalHeaders() != null);
|
||||
Assert.assertTrue("Incorrectly bound map property. Expected 3 Entries!", properties.getAdditionalHeaders()
|
||||
.size() == 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenObjectPropertyQueriedthenReturnsProperty() throws Exception {
|
||||
Assert.assertTrue("Couldn't bind map property!", properties.getCredentials() != null);
|
||||
Assert.assertTrue("Incorrectly bound object property!", properties.getCredentials()
|
||||
.getAuthMethod()
|
||||
.equals("SHA1"));
|
||||
Assert.assertTrue("Incorrectly bound object property!", properties.getCredentials()
|
||||
.getUsername()
|
||||
.equals("john"));
|
||||
Assert.assertTrue("Incorrectly bound object property!", properties.getCredentials()
|
||||
.getPassword()
|
||||
.equals("password"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
#Simple properties
|
||||
mail.host=mailer@mail.com
|
||||
mail.port=9000
|
||||
mail.from=mailer@mail.com
|
||||
|
||||
#List properties
|
||||
mail.defaultRecipients[0]=admin@mail.com
|
||||
mail.defaultRecipients[1]=owner@mail.com
|
||||
|
||||
#Map Properties
|
||||
mail.additionalHeaders.redelivery=true
|
||||
mail.additionalHeaders.secure=true
|
||||
mail.additionalHeaders.p3=value
|
||||
|
||||
#Object properties
|
||||
mail.credentials.username=john
|
||||
mail.credentials.password=password
|
||||
mail.credentials.authMethod=SHA1
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
<parent>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<version>1.4.4.RELEASE</version>
|
||||
<version>1.5.3.RELEASE</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
|||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-releasetrain</artifactId>
|
||||
<version>Gosling-SR1</version>
|
||||
<version>Hopper-SR10</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
|
|
@ -13,8 +13,7 @@ import org.junit.Ignore;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
@ -25,9 +24,8 @@ import java.util.List;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringApplicationConfiguration(classes = Application.class)
|
||||
@SpringBootTest(classes = Application.class)
|
||||
@WebAppConfiguration
|
||||
@IntegrationTest
|
||||
@ActiveProfiles("local")
|
||||
@TestPropertySource(properties = { "amazon.dynamodb.endpoint=http://localhost:8000/", "amazon.aws.accesskey=test1", "amazon.aws.secretkey=test231" })
|
||||
public class ProductInfoRepositoryIntegrationTest {
|
||||
|
|
|
@ -13,13 +13,7 @@
|
|||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>${org.springframework.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<version>${org.springframework.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- persistence -->
|
||||
|
|
|
@ -95,13 +95,7 @@
|
|||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-core</artifactId>
|
||||
<version>${spring.integration.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<version>${spring.integration.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.activation</groupId>
|
||||
|
|
|
@ -25,13 +25,7 @@
|
|||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
<version>${org.springframework.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<version>${org.springframework.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
### Relevant Articles
|
||||
- [Intro to Spring Remoting with HTTP Invokers](http://www.baeldung.com/spring-remoting-http-invoker)
|
||||
- [Spring Remoting with Hessian and Burlap](http://www.baeldung.com/spring-remoting-hessian-burlap)
|
||||
- [Spring Remoting with AMQP](http://www.baeldung.com/spring-remoting-amqp)
|
||||
|
||||
### Overview
|
||||
This Maven project contains the Java source code for various modules used in the Spring Remoting series of articles.
|
||||
|
|
|
@ -30,13 +30,7 @@
|
|||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>${springframework.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<version>${springframework.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
|
|
|
@ -8,8 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import static org.springframework.web.bind.annotation.RequestMethod.POST;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
@Log
|
||||
@Controller
|
||||
|
@ -18,7 +17,7 @@ public class ChargeController {
|
|||
@Autowired
|
||||
StripeService paymentsService;
|
||||
|
||||
@RequestMapping(value = "/charge", method = POST)
|
||||
@PostMapping("/charge")
|
||||
public String charge(ChargeRequest chargeRequest, Model model) throws StripeException {
|
||||
chargeRequest.setDescription("Example charge");
|
||||
chargeRequest.setCurrency(Currency.EUR);
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
package com.baeldung.stripe;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.Data;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(includeFieldNames = false)
|
||||
@Data
|
||||
public class ChargeRequest {
|
||||
|
||||
public enum Currency {
|
||||
|
|
Loading…
Reference in New Issue