use of org.apache.wicket.serialize.java.JavaSerializer in project wicket by apache.
the class TestApp2 method init.
@Override
protected void init() {
getSharedResources().add("cancelButton", new DefaultButtonImageResource("Cancel"));
setPageManagerProvider(new DefaultPageManagerProvider(this) {
@Override
public IPageManager get(IPageManagerContext pageManagerContext) {
IDataStore dataStore = new HttpSessionDataStore(pageManagerContext, new PageNumberEvictionStrategy(100));
IPageStore pageStore = new DefaultPageStore(new JavaSerializer(getApplicationKey()), dataStore, getStoreSettings().getInmemoryCacheSize());
return new PageStoreManager(getName(), pageStore, pageManagerContext);
}
});
}
use of org.apache.wicket.serialize.java.JavaSerializer in project wicket by apache.
the class DifferentPageCheckerTest method serializingAnotherPage.
/**
* https://issues.apache.org/jira/browse/WICKET-5634
*
* Tests that the serialization fails when a checking ObjectOutputStream is
* used with DifferentPageChecker and there is a component in the object tree that
* keeps a reference to a page which is not component.getPage()..
*/
@Test
public void serializingAnotherPage() {
JavaSerializer serializer = new JavaSerializer("JavaSerializerTest") {
@Override
protected ObjectOutputStream newObjectOutputStream(OutputStream out) throws IOException {
IObjectChecker checker = new DifferentPageChecker();
return new CheckingObjectOutputStream(out, checker);
}
};
WebComponent component = new ComponentThatKeepsAReferenceToAnotherPage(MockPageWithLink.LINK_ID);
MockPageWithLink rootPage = new MockPageWithLink();
rootPage.add(component);
byte[] serialized = serializer.serialize(rootPage);
assertNull("The produced byte[] must be null if there was an error", serialized);
}
use of org.apache.wicket.serialize.java.JavaSerializer in project wicket by apache.
the class SessionCheckerTest method serializingTheSession.
/**
* https://issues.apache.org/jira/browse/WICKET-5634
*
* Tests that the serialization fails when a checking ObjectOutputStream is
* used with SessionChecker and there is a component in the object tree that
* keeps a reference to the Wicket Session.
*/
@Test
public void serializingTheSession() {
JavaSerializer serializer = new JavaSerializer("JavaSerializerTest") {
@Override
protected ObjectOutputStream newObjectOutputStream(OutputStream out) throws IOException {
IObjectChecker checker = new SessionChecker();
return new CheckingObjectOutputStream(out, checker);
}
};
WebMarkupContainer container = new WebMarkupContainer("container");
// WICKET-6196 force container#children to be an array
container.add(new Label("id1"));
container.add(new ComponentWithAReferenceToTheSession("id2"));
byte[] serialized = serializer.serialize(container);
assertNull("The produced byte[] must be null if there was an error", serialized);
}
use of org.apache.wicket.serialize.java.JavaSerializer in project wicket by apache.
the class PageIdPoliticTest method setUp.
@Before
public void setUp() throws Exception {
application = new MockApplication();
dataStore = new InMemoryPageStore() {
@Override
public void storeData(String sessionId, int pageId, byte[] pageAsBytes) {
super.storeData(sessionId, pageId, pageAsBytes);
storeCount++;
}
};
tester = new WicketTester(application) {
@Override
protected IPageManagerProvider newTestPageManagerProvider() {
return new IPageManagerProvider() {
@Override
public IPageManager apply(IPageManagerContext pageManagerContext) {
IPageStore pageStore = new DefaultPageStore(new JavaSerializer(application.getApplicationKey()), dataStore, 4);
return new PageStoreManager(application.getName(), pageStore, pageManagerContext);
}
};
}
};
}
use of org.apache.wicket.serialize.java.JavaSerializer in project wicket by apache.
the class PageProviderTest method pageProviderIsSerializeble.
@Test
public void pageProviderIsSerializeble() throws Exception {
TestMapperContext mapperContext = new TestMapperContext();
Page page = new TestPage();
mapperContext.getPageManager().touchPage(page);
mapperContext.getPageManager().commitRequest();
PageProvider pageProvider = new PageProvider(page.getPageId(), page.getRenderCount());
JavaSerializer javaSerializer = new JavaSerializer("app");
byte[] serialized = javaSerializer.serialize(pageProvider);
PageProvider deserialized = (PageProvider) javaSerializer.deserialize(serialized);
deserialized.setPageSource(mapperContext);
assertThat(deserialized.getPageInstance(), is(page));
}
Aggregations