forked from wicketstuff/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
KryoSerializerTest.java
55 lines (44 loc) · 1.42 KB
/
KryoSerializerTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package org.wicketstuff.pageserializer.kryo;
import org.apache.wicket.serialize.ISerializer;
import org.apache.wicket.util.tester.WicketTester;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
/**
* Simple test using the WicketTester
*/
public class KryoSerializerTest
{
private WicketTester tester;
@Before
public void setUp()
{
tester = new WicketTester(new WicketApplication());
}
@After
public void tearDown()
{
tester.destroy();
}
@Test
public void homepageRendersSuccessfully()
{
// start and render the test page
HomePage page = tester.startPage(HomePage.class);
// assert rendered page class
tester.assertRenderedPage(HomePage.class);
ISerializer pageSerializer = tester.getApplication().getFrameworkSettings().getSerializer();
Assert.assertTrue(
"The configured IObjectSerializer is not instance of KryoSerializer! Type: " +
pageSerializer.getClass(), pageSerializer instanceof KryoSerializer);
byte[] data = pageSerializer.serialize(page);
Assert.assertNotNull("The produced data should not be null!", data);
// data length can fluctuate based on the object field values
Assert.assertEquals("The produced data length is not correct!", 401, data.length);
Object object = pageSerializer.deserialize(data);
Assert.assertTrue(
"The deserialized page must be of type HomePage. Type: " + object.getClass(),
object instanceof HomePage);
}
}