diff --git a/.gitignore b/.gitignore index f3fa30f3e3..60c38ed8f5 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,5 @@ spring-openid/src/main/resources/application.properties .recommenders/ /spring-hibernate4/nbproject/ spring-security-openid/src/main/resources/application.properties + +spring-all/*.log diff --git a/apache-cxf/cxf-aegis/src/test/java/com/baeldung/cxf/aegis/BaeldungTest.java b/apache-cxf/cxf-aegis/src/test/java/com/baeldung/cxf/aegis/BaeldungTest.java index 559de037a9..935b283cb4 100644 --- a/apache-cxf/cxf-aegis/src/test/java/com/baeldung/cxf/aegis/BaeldungTest.java +++ b/apache-cxf/cxf-aegis/src/test/java/com/baeldung/cxf/aegis/BaeldungTest.java @@ -3,8 +3,10 @@ package com.baeldung.cxf.aegis; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +import org.junit.After; import org.junit.Test; +import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.lang.reflect.Type; @@ -90,4 +92,12 @@ public class BaeldungTest { xmlReader.close(); return courseRepo; } + + @After + public void cleanup(){ + File testFile = new File(fileName); + if (testFile.exists()) { + testFile.delete(); + } + } } \ No newline at end of file diff --git a/apache-poi/src/test/java/com/baeldung/jexcel/JExcelTest.java b/apache-poi/src/test/java/com/baeldung/jexcel/JExcelTest.java index 8ee465be34..72272913d5 100644 --- a/apache-poi/src/test/java/com/baeldung/jexcel/JExcelTest.java +++ b/apache-poi/src/test/java/com/baeldung/jexcel/JExcelTest.java @@ -19,6 +19,7 @@ import static org.junit.Assert.assertTrue; import org.junit.Test; import org.junit.Before; +import org.junit.After; public class JExcelTest { @@ -53,4 +54,11 @@ public class JExcelTest { .get(1)); } + @After + public void cleanup(){ + File testFile = new File(fileLocation); + if (testFile.exists()) { + testFile.delete(); + } + } } \ No newline at end of file diff --git a/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelTest.java b/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelTest.java index 34fa64dd94..ad36f46f02 100644 --- a/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelTest.java +++ b/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelTest.java @@ -16,6 +16,7 @@ import static org.junit.Assert.assertTrue; import org.junit.Test; import org.junit.Before; +import org.junit.After; public class ExcelTest { @@ -50,4 +51,11 @@ public class ExcelTest { .get(1)); } + @After + public void cleanup(){ + File testFile = new File(fileLocation); + if (testFile.exists()) { + testFile.delete(); + } + } } \ No newline at end of file diff --git a/apache-poi/temp.xls b/apache-poi/temp.xls deleted file mode 100644 index 1fad76d88d..0000000000 Binary files a/apache-poi/temp.xls and /dev/null differ diff --git a/apache-poi/temp.xlsx b/apache-poi/temp.xlsx deleted file mode 100644 index 431a8a662c..0000000000 Binary files a/apache-poi/temp.xlsx and /dev/null differ diff --git a/jaxb/pom.xml b/jaxb/pom.xml index b636a4dc82..75b98c8c51 100644 --- a/jaxb/pom.xml +++ b/jaxb/pom.xml @@ -135,6 +135,9 @@ ${basedir}/src/main/java false + true + true + false diff --git a/jaxb/src/main/java/com/baeldung/jaxb/gen/ObjectFactory.java b/jaxb/src/main/java/com/baeldung/jaxb/gen/ObjectFactory.java new file mode 100644 index 0000000000..0a3da677ce --- /dev/null +++ b/jaxb/src/main/java/com/baeldung/jaxb/gen/ObjectFactory.java @@ -0,0 +1,48 @@ + +package com.baeldung.jaxb.gen; + +import javax.xml.bind.annotation.XmlRegistry; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the com.baeldung.jaxb.gen package. + *

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 { + + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.baeldung.jaxb.gen + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link UserRequest } + * + */ + public UserRequest createUserRequest() { + return new UserRequest(); + } + + /** + * Create an instance of {@link UserResponse } + * + */ + public UserResponse createUserResponse() { + return new UserResponse(); + } + +} diff --git a/jaxb/src/main/java/com/baeldung/jaxb/gen/UserRequest.java b/jaxb/src/main/java/com/baeldung/jaxb/gen/UserRequest.java new file mode 100644 index 0000000000..1c1abc61a6 --- /dev/null +++ b/jaxb/src/main/java/com/baeldung/jaxb/gen/UserRequest.java @@ -0,0 +1,87 @@ + +package com.baeldung.jaxb.gen; + +import java.io.Serializable; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for UserRequest complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="UserRequest">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="id" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *         <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "UserRequest", propOrder = { + "id", + "name" +}) +@XmlRootElement(name = "userRequest") +public class UserRequest + implements Serializable +{ + + private final static long serialVersionUID = -1L; + protected int id; + @XmlElement(required = true) + protected String name; + + /** + * 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; + } + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + +} diff --git a/jaxb/src/main/java/com/baeldung/jaxb/gen/UserResponse.java b/jaxb/src/main/java/com/baeldung/jaxb/gen/UserResponse.java new file mode 100644 index 0000000000..b80405e4a9 --- /dev/null +++ b/jaxb/src/main/java/com/baeldung/jaxb/gen/UserResponse.java @@ -0,0 +1,149 @@ + +package com.baeldung.jaxb.gen; + +import java.io.Serializable; +import java.util.Calendar; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import org.w3._2001.xmlschema.Adapter1; + + +/** + *

Java class for UserResponse complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="UserResponse">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="id" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *         <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="gender" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="created" type="{http://www.w3.org/2001/XMLSchema}dateTime"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "UserResponse", propOrder = { + "id", + "name", + "gender", + "created" +}) +@XmlRootElement(name = "userResponse") +public class UserResponse + implements Serializable +{ + + private final static long serialVersionUID = -1L; + protected int id; + @XmlElement(required = true) + protected String name; + @XmlElement(required = true) + protected String gender; + @XmlElement(required = true, type = String.class) + @XmlJavaTypeAdapter(Adapter1 .class) + @XmlSchemaType(name = "dateTime") + protected Calendar created; + + /** + * 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; + } + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + + /** + * Gets the value of the gender property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getGender() { + return gender; + } + + /** + * Sets the value of the gender property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setGender(String value) { + this.gender = value; + } + + /** + * Gets the value of the created property. + * + * @return + * possible object is + * {@link String } + * + */ + public Calendar getCreated() { + return created; + } + + /** + * Sets the value of the created property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCreated(Calendar value) { + this.created = value; + } + +} diff --git a/jaxb/src/main/java/com/baeldung/jaxb/gen/package-info.java b/jaxb/src/main/java/com/baeldung/jaxb/gen/package-info.java new file mode 100644 index 0000000000..639d00179c --- /dev/null +++ b/jaxb/src/main/java/com/baeldung/jaxb/gen/package-info.java @@ -0,0 +1,2 @@ +@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.baeldung.com/jaxb/gen", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +package com.baeldung.jaxb.gen; diff --git a/jaxb/src/main/java/org/w3/_2001/xmlschema/Adapter1.java b/jaxb/src/main/java/org/w3/_2001/xmlschema/Adapter1.java new file mode 100644 index 0000000000..54b3c360dc --- /dev/null +++ b/jaxb/src/main/java/org/w3/_2001/xmlschema/Adapter1.java @@ -0,0 +1,23 @@ + +package org.w3._2001.xmlschema; + +import java.util.Calendar; +import javax.xml.bind.annotation.adapters.XmlAdapter; + +public class Adapter1 + extends XmlAdapter +{ + + + public Calendar unmarshal(String value) { + return (javax.xml.bind.DatatypeConverter.parseDateTime(value)); + } + + public String marshal(Calendar value) { + if (value == null) { + return null; + } + return (javax.xml.bind.DatatypeConverter.printDateTime(value)); + } + +} diff --git a/spring-all/src/test/java/org/baeldung/shell/simple/SimpleCLIUnitTest.java b/spring-all/src/test/java/org/baeldung/shell/simple/SimpleCLIUnitTest.java index 0353083943..cc5ac863b5 100644 --- a/spring-all/src/test/java/org/baeldung/shell/simple/SimpleCLIUnitTest.java +++ b/spring-all/src/test/java/org/baeldung/shell/simple/SimpleCLIUnitTest.java @@ -1,6 +1,7 @@ package org.baeldung.shell.simple; import java.io.File; + import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -15,13 +16,18 @@ public class SimpleCLIUnitTest { @BeforeClass public static void startUp() throws InterruptedException { - Bootstrap bootstrap = new Bootstrap(); + final Bootstrap bootstrap = new Bootstrap(); shell = bootstrap.getJLineShellComponent(); } @AfterClass public static void shutdown() { shell.stop(); + // delete contents.txt + final File testFile = new File("contents.txt"); + if (testFile.exists()) { + testFile.delete(); + } } public static JLineShellComponent getShell() { @@ -31,7 +37,7 @@ public class SimpleCLIUnitTest { @Test public void givenCommandConfig_whenExecutingWebGetCommand_thenCorrectResult() { - CommandResult resultWebSave = shell.executeCommand("web-get --url https://www.google.com"); + final CommandResult resultWebSave = shell.executeCommand("web-get --url https://www.google.com"); Assert.assertTrue(resultWebSave.isSuccess()); } @@ -40,37 +46,27 @@ public class SimpleCLIUnitTest { public void givenCommandConfig_whenExecutingWebSaveCommand_thenCorrectResult() { shell.executeCommand("admin-enable"); - CommandResult result = shell.executeCommand("web-save --url https://www.google.com --out contents.txt"); + final CommandResult result = shell.executeCommand("web-save --url https://www.google.com --out contents.txt"); - Assert.assertArrayEquals( - new boolean[]{ - result.isSuccess(), - new File("contents.txt").exists()}, - new boolean[]{true, true}); + Assert.assertArrayEquals(new boolean[] { result.isSuccess(), new File("contents.txt").exists() }, new boolean[] { true, true }); } @Test public void givenCommandConfig_whenAdminEnableCommandExecuted_thenCorrectAvailability() { - - CommandResult resultAdminDisable = shell.executeCommand("admin-disable"); - CommandResult resultWebSaveUnavailable = shell.executeCommand("web-save --url https://www.google.com --out contents.txt"); - CommandResult resultAdminEnable = shell.executeCommand("admin-enable"); - CommandResult resultWebSaveAvailable = shell.executeCommand("web-save --url https://www.google.com --out contents.txt"); - Assert.assertArrayEquals( - new boolean[]{ - resultAdminDisable.isSuccess(), - resultWebSaveUnavailable.isSuccess(), - resultAdminEnable.isSuccess(), - resultWebSaveAvailable.isSuccess()}, - new boolean[]{true, false, true, true}); + final CommandResult resultAdminDisable = shell.executeCommand("admin-disable"); + final CommandResult resultWebSaveUnavailable = shell.executeCommand("web-save --url https://www.google.com --out contents.txt"); + final CommandResult resultAdminEnable = shell.executeCommand("admin-enable"); + final CommandResult resultWebSaveAvailable = shell.executeCommand("web-save --url https://www.google.com --out contents.txt"); + + Assert.assertArrayEquals(new boolean[] { resultAdminDisable.isSuccess(), resultWebSaveUnavailable.isSuccess(), resultAdminEnable.isSuccess(), resultWebSaveAvailable.isSuccess() }, new boolean[] { true, false, true, true }); } @Test public void givenCommandConfig_whenWebSaveCommandExecutedNoOutArgument_thenError() { shell.executeCommand("admin-enable"); - CommandResult resultWebSave = shell.executeCommand("web-save --url https://www.google.com"); + final CommandResult resultWebSave = shell.executeCommand("web-save --url https://www.google.com"); Assert.assertEquals(resultWebSave.isSuccess(), false); } @@ -78,7 +74,7 @@ public class SimpleCLIUnitTest { @Test public void givenCommandConfig_whenExecutingWebGetCommandWithDefaultArgument_thenCorrectResult() { - CommandResult result = shell.executeCommand("web-get https://www.google.com"); + final CommandResult result = shell.executeCommand("web-get https://www.google.com"); Assert.assertEquals(result.isSuccess(), true); }