Skip to content

Commit 34e7277

Browse files
authored
[JAVA-9021] Clean up uncommitted artifacts (eugenp#11754)
1 parent 49fc854 commit 34e7277

File tree

10 files changed

+382
-329
lines changed

10 files changed

+382
-329
lines changed

apache-poi/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
*.docx
22
temp.xls
33
temp.xlsx
4+
5+
CellStyleTest_output.xlsx
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/target/
22
.settings/
33
.classpath
4-
.project
4+
.project
5+
6+
*.log

core-java-modules/core-java-serialization/src/test/java/com/baeldung/externalizable/ExternalizableUnitTest.java

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
11
package com.baeldung.externalizable;
22

3+
import org.junit.Before;
4+
import org.junit.Rule;
35
import org.junit.Test;
6+
import org.junit.rules.TemporaryFolder;
47

58
import java.io.*;
69

10+
import static org.junit.Assert.assertEquals;
11+
import static org.junit.Assert.assertNull;
712
import static org.junit.Assert.assertTrue;
813

914
public class ExternalizableUnitTest {
1015

11-
private final static String OUTPUT_FILE = "externalizable.txt";
16+
private final static String OUTPUT_FILE_NAME = "externalizable.txt";
17+
18+
@Rule
19+
public TemporaryFolder tempFolder = new TemporaryFolder();
20+
21+
private File outputFile;
22+
23+
@Before
24+
public void setUp() throws Exception {
25+
outputFile = tempFolder.newFile(OUTPUT_FILE_NAME);
26+
}
1227

1328
@Test
1429
public void whenSerializing_thenUseExternalizable() throws IOException, ClassNotFoundException {
@@ -18,15 +33,15 @@ public void whenSerializing_thenUseExternalizable() throws IOException, ClassNot
1833
c.setCode(374);
1934
c.setName("Armenia");
2035

21-
FileOutputStream fileOutputStream = new FileOutputStream(OUTPUT_FILE);
36+
FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
2237
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
2338
c.writeExternal(objectOutputStream);
2439

2540
objectOutputStream.flush();
2641
objectOutputStream.close();
2742
fileOutputStream.close();
2843

29-
FileInputStream fileInputStream = new FileInputStream(OUTPUT_FILE);
44+
FileInputStream fileInputStream = new FileInputStream(outputFile);
3045
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
3146

3247
Country c2 = new Country();
@@ -35,8 +50,8 @@ public void whenSerializing_thenUseExternalizable() throws IOException, ClassNot
3550
objectInputStream.close();
3651
fileInputStream.close();
3752

38-
assertTrue(c2.getCode() == c.getCode());
39-
assertTrue(c2.getName().equals(c.getName()));
53+
assertEquals(c2.getCode(), c.getCode());
54+
assertEquals(c2.getName(), c.getName());
4055
}
4156

4257
@Test
@@ -49,15 +64,15 @@ public void whenInheritanceSerialization_then_UseExternalizable() throws IOExcep
4964
r.setClimate("Mediterranean");
5065
r.setPopulation(120.000);
5166

52-
FileOutputStream fileOutputStream = new FileOutputStream(OUTPUT_FILE);
67+
FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
5368
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
5469
r.writeExternal(objectOutputStream);
5570

5671
objectOutputStream.flush();
5772
objectOutputStream.close();
5873
fileOutputStream.close();
5974

60-
FileInputStream fileInputStream = new FileInputStream(OUTPUT_FILE);
75+
FileInputStream fileInputStream = new FileInputStream(outputFile);
6176
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
6277

6378
Region r2 = new Region();
@@ -66,6 +81,6 @@ public void whenInheritanceSerialization_then_UseExternalizable() throws IOExcep
6681
objectInputStream.close();
6782
fileInputStream.close();
6883

69-
assertTrue(r2.getPopulation() == null);
84+
assertNull(r2.getPopulation());
7085
}
7186
}
Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,54 @@
11
package com.baeldung.serialization;
22

3+
import org.junit.Before;
4+
import org.junit.Rule;
35
import org.junit.Test;
6+
import org.junit.rules.TemporaryFolder;
47

8+
import java.io.File;
59
import java.io.FileInputStream;
610
import java.io.FileOutputStream;
711
import java.io.IOException;
812
import java.io.ObjectInputStream;
913
import java.io.ObjectOutputStream;
1014

15+
import static org.junit.Assert.assertEquals;
1116
import static org.junit.Assert.assertTrue;
1217

1318
public class PersonUnitTest {
1419

20+
@Rule
21+
public TemporaryFolder tempFolder = new TemporaryFolder();
22+
23+
private File outputFile;
24+
25+
private File outputFile2;
26+
27+
@Before
28+
public void setUp() throws Exception {
29+
outputFile = tempFolder.newFile("yourfile.txt");
30+
outputFile2 = tempFolder.newFile("yourfile2.txt");
31+
}
32+
1533
@Test
1634
public void whenSerializingAndDeserializing_ThenObjectIsTheSame() throws IOException, ClassNotFoundException {
1735
Person p = new Person();
1836
p.setAge(20);
1937
p.setName("Joe");
2038

21-
FileOutputStream fileOutputStream = new FileOutputStream("yofile.txt");
39+
FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
2240
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
2341
objectOutputStream.writeObject(p);
2442
objectOutputStream.flush();
2543
objectOutputStream.close();
2644

27-
FileInputStream fileInputStream = new FileInputStream("yofile.txt");
45+
FileInputStream fileInputStream = new FileInputStream(outputFile);
2846
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
2947
Person p2 = (Person) objectInputStream.readObject();
3048
objectInputStream.close();
3149

32-
assertTrue(p2.getAge() == p.getAge());
33-
assertTrue(p2.getName().equals(p.getName()));
50+
assertEquals(p2.getAge(), p.getAge());
51+
assertEquals(p2.getName(), p.getName());
3452
}
3553

3654
@Test
@@ -46,19 +64,19 @@ public void whenCustomSerializingAndDeserializing_ThenObjectIsTheSame() throws I
4664
e.setPerson(p);
4765
e.setAddress(a);
4866

49-
FileOutputStream fileOutputStream = new FileOutputStream("yofile2.txt");
67+
FileOutputStream fileOutputStream = new FileOutputStream(outputFile2);
5068
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
5169
objectOutputStream.writeObject(e);
5270
objectOutputStream.flush();
5371
objectOutputStream.close();
5472

55-
FileInputStream fileInputStream = new FileInputStream("yofile2.txt");
73+
FileInputStream fileInputStream = new FileInputStream(outputFile2);
5674
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
5775
Employee e2 = (Employee) objectInputStream.readObject();
5876
objectInputStream.close();
5977

60-
assertTrue(e2.getPerson().getAge() == e.getPerson().getAge());
61-
assertTrue(e2.getAddress().getHouseNumber() == (e.getAddress().getHouseNumber()));
78+
assertEquals(e2.getPerson().getAge(), e.getPerson().getAge());
79+
assertEquals(e2.getAddress().getHouseNumber(), (e.getAddress().getHouseNumber()));
6280
}
6381

6482
}

core-java-modules/core-java-serialization/src/test/java/com/baeldung/serialization/SerializationUnitTest.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import static org.junit.Assert.assertFalse;
55
import static org.junit.jupiter.api.Assertions.assertTrue;
66

7+
import java.io.File;
78
import java.io.FileInputStream;
89
import java.io.FileOutputStream;
910
import java.io.IOException;
@@ -13,17 +14,32 @@
1314
import java.io.Serializable;
1415

1516
import org.apache.commons.lang3.SerializationUtils;
17+
import org.junit.Before;
18+
import org.junit.Rule;
1619
import org.junit.Test;
1720

1821
import com.baeldung.util.MySerializationUtils;
22+
import org.junit.rules.TemporaryFolder;
1923

2024
public class SerializationUnitTest {
2125

26+
private final static String OUTPUT_FILE_NAME = "yourfile.txt";
27+
28+
@Rule
29+
public TemporaryFolder tempFolder = new TemporaryFolder();
30+
31+
private File outputFile;
32+
33+
@Before
34+
public void setUp() throws Exception {
35+
outputFile = tempFolder.newFile(OUTPUT_FILE_NAME);
36+
}
37+
2238
@Test(expected = NotSerializableException.class)
2339
public void whenSerializing_ThenThrowsError() throws IOException {
2440
Address address = new Address();
2541
address.setHouseNumber(10);
26-
FileOutputStream fileOutputStream = new FileOutputStream("yofile.txt");
42+
FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
2743
try (ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream)) {
2844
objectOutputStream.writeObject(address);
2945
}
@@ -35,12 +51,12 @@ public void whenSerializingAndDeserializing_ThenObjectIsTheSame() throws IOExcep
3551
p.setAge(20);
3652
p.setName("Joe");
3753

38-
FileOutputStream fileOutputStream = new FileOutputStream("yofile.txt");
54+
FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
3955
try (ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream)) {
4056
objectOutputStream.writeObject(p);
4157
}
4258

43-
FileInputStream fileInputStream = new FileInputStream("yofile.txt");
59+
FileInputStream fileInputStream = new FileInputStream(outputFile);
4460
try (ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream)) {
4561
Person p2 = (Person) objectInputStream.readObject();
4662
assertEquals(p2.getAge(), p.getAge());
Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
1-
2-
package com.baeldung.jaxb.gen;
3-
4-
import javax.xml.bind.annotation.XmlRegistry;
5-
6-
7-
/**
8-
* This object contains factory methods for each
9-
* Java content interface and Java element interface
10-
* generated in the com.baeldung.jaxb.gen package.
11-
* <p>An ObjectFactory allows you to programatically
12-
* construct new instances of the Java representation
13-
* for XML content. The Java representation of XML
14-
* content can consist of schema derived interfaces
15-
* and classes representing the binding of schema
16-
* type definitions, element declarations and model
17-
* groups. Factory methods for each of these are
18-
* provided in this class.
19-
*
20-
*/
21-
@XmlRegistry
22-
public class ObjectFactory {
23-
24-
25-
/**
26-
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.baeldung.jaxb.gen
27-
*
28-
*/
29-
public ObjectFactory() {
30-
}
31-
32-
/**
33-
* Create an instance of {@link UserRequest }
34-
*
35-
*/
36-
public UserRequest createUserRequest() {
37-
return new UserRequest();
38-
}
39-
40-
/**
41-
* Create an instance of {@link UserResponse }
42-
*
43-
*/
44-
public UserResponse createUserResponse() {
45-
return new UserResponse();
46-
}
47-
48-
}
1+
2+
package com.baeldung.jaxb.gen;
3+
4+
import javax.xml.bind.annotation.XmlRegistry;
5+
6+
7+
/**
8+
* This object contains factory methods for each
9+
* Java content interface and Java element interface
10+
* generated in the com.baeldung.jaxb.gen package.
11+
* <p>An ObjectFactory allows you to programatically
12+
* construct new instances of the Java representation
13+
* for XML content. The Java representation of XML
14+
* content can consist of schema derived interfaces
15+
* and classes representing the binding of schema
16+
* type definitions, element declarations and model
17+
* groups. Factory methods for each of these are
18+
* provided in this class.
19+
*
20+
*/
21+
@XmlRegistry
22+
public class ObjectFactory {
23+
24+
25+
/**
26+
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.baeldung.jaxb.gen
27+
*
28+
*/
29+
public ObjectFactory() {
30+
}
31+
32+
/**
33+
* Create an instance of {@link UserRequest }
34+
*
35+
*/
36+
public UserRequest createUserRequest() {
37+
return new UserRequest();
38+
}
39+
40+
/**
41+
* Create an instance of {@link UserResponse }
42+
*
43+
*/
44+
public UserResponse createUserResponse() {
45+
return new UserResponse();
46+
}
47+
48+
}

0 commit comments

Comments
 (0)