remove extra serialization ex

This commit is contained in:
Loredana Crusoveanu 2017-12-23 22:36:56 +02:00
parent cc39f18d21
commit b18c4deb3f
2 changed files with 0 additions and 33 deletions

View File

@ -4,31 +4,10 @@ import org.junit.Test;
import static org.assertj.core.api.Assertions.*;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.lang.reflect.InvocationTargetException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class UserTest {
Path userData;
@Before
public void init() throws IOException {
userData = Paths.get("src/test/resources/user.data");
if (!Files.exists(userData))
Files.createFile(userData);
}
@Test
public void givenUserInstance_whenIntializedWithNew_thenInstanceIsNotNull() {
User user = new User("Alice", 1);
@ -49,18 +28,6 @@ public class UserTest {
assertThat(clonedUser).isEqualTo(user);
}
@Test
public void givenFileWithBitsRepresentingUser_whenDeserialized_thenUserIsCreated() throws FileNotFoundException, IOException, ClassNotFoundException {
try (ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(userData.toFile())))) {
User user = new User("Tom", 0);
out.writeObject(user);
}
try (ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(userData.toFile())))) {
User deserializedUser = (User) in.readObject();
assertThat(deserializedUser).isNotNull();
}
}
@Test
public void givenUserInstance_whenValuesAreNotInitialized_thenUserNameAndIdReturnDefault() {
User user = new User();