Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions testing/wicket-js-tests/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
* 3) run: npm install (This will use package.json and install grunt and all dependencies)
* 4.1) grunt jshint - checks all JavaScript files with JSHint
* 4.2) grunt jshint:core - checks only the files in wicket-core
* 4.3) grunt - starts the registered tasks: starting a web server and running all tests (Ajax, non-Ajax and AMD)
* 4.3) grunt - starts the registered tasks: starting a web server and running all tests (Ajax, non-Ajax, XML
* replacement and AMD)
*/

/*global module: true */
Expand All @@ -18,19 +19,17 @@ module.exports = function(grunt) {

var
coreJs = [
'../../wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery-debug.js',
'../../wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js',
'../../wicket-core/src/main/java/org/apache/wicket/ajax/res/js/xml-replacement-method.js',
"../../wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckSelector.js",
"../../wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/MultiFileUploadField.js",
"../../wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.js",
"../../wicket-core/src/main/java/org/apache/wicket/markup/html/pages/wicket-browser-info.js"
],
extensionsJs = [
"../../wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/form/upload/progressbar.js",
"../../wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/wicket-ajaxdownload.js",
"../../wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/palette.js",
"../../wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js",
"../../wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/modal.js",
"../../wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/filter/wicket-filterform.js"
],
nativeWebSocketJs = [
Expand All @@ -44,7 +43,8 @@ module.exports = function(grunt) {
"../../wicket-core/src/test/js/channels.js",
"../../wicket-core/src/test/js/event.js",
"../../wicket-core/src/test/js/timer.js",
"../../wicket-core/src/test/js/amd.js"
"../../wicket-core/src/test/js/amd.js",
"../../wicket-core/src/test/js/xml-replacement.js"
],
gymTestsJs = [
"../../wicket-examples/src/main/webapp/js-test/tests/ajax/form.js",
Expand Down Expand Up @@ -121,6 +121,17 @@ module.exports = function(grunt) {
'http://localhost:38887/test/js/amd.html?3.7.1'
]
}
},

/**
* Run XML reaplcement method tests
*/
"xml-replacement": {
options: {
urls: [
'http://localhost:38887/test/js/xml-replacement.html?3.7.1'
]
}
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.net.URI;

import javax.management.MBeanServer;

import org.eclipse.jetty.jmx.MBeanContainer;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory;
Expand Down Expand Up @@ -114,9 +113,9 @@ public static void main(String[] args)
try
{
server.start();

browse();

server.join();
}
catch (Exception e)
Expand All @@ -130,7 +129,7 @@ private static void browse()
{
try
{
Desktop.getDesktop().browse(new URI("http://localhost:8080/ajax-tests/test/js/all.html?3.6.4"));
Desktop.getDesktop().browse(new URI("http://localhost:8080/ajax-tests/test/js/all.html?3.7.1"));
}
catch (Exception e)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.wicket.core.request.handler;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

import java.util.Collection;
import java.util.List;

import org.apache.wicket.Component;
import org.apache.wicket.MarkupContainer;
import org.apache.wicket.Page;
import org.apache.wicket.markup.Markup;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.page.PartialPageUpdate;
import org.apache.wicket.page.XmlPartialPageUpdate;
import org.apache.wicket.request.IRequestCycle;
import org.apache.wicket.util.tester.WicketTestCase;
import org.junit.jupiter.api.Test;

class AbstractPartialPageRequestHandlerTest extends WicketTestCase
{
@Test
void passesNoReplacementMethodToUpdateForComponentWithOverriddenMarkupIdRegisteredWithout()
{
Label label = tester.startComponentInPage(new Label("some ID"));
ReplacementMethodsExposingUpdate update = new ReplacementMethodsExposingUpdate(label.getPage());
AbstractPartialPageRequestHandler handler = new TestPartialPageRequestHandler(label.getPage(), update);

handler.add(label, "the ID");

assertNull(update.getReplacementMethodPublic(label.getMarkupId()));
}

@Test
void passesNoReplacementMethodToUpdateForComponentRegisteredWithout()
{
Component label = tester.startComponentInPage(new Label("the ID").setOutputMarkupId(true));
ReplacementMethodsExposingUpdate update = new ReplacementMethodsExposingUpdate(label.getPage());
AbstractPartialPageRequestHandler handler = new TestPartialPageRequestHandler(label.getPage(), update);

handler.add(label);

assertNull(update.getReplacementMethodPublic(label.getMarkupId()));
}

@Test
void passesNoReplacementMethodToUpdateForChildrenRegisteredWithout()
{
Component label = new Label("the ID").setOutputMarkupId(true).setMarkup(Markup.of("<span wicket:id=\"the ID\"></span>"));
MarkupContainer container = new WebMarkupContainer("some ID").add(label);
tester.startComponentInPage(container.setMarkup(Markup.of("<span wicket:id=\"some ID\"><span wicket:id=\"the ID\"></span></span>")));
ReplacementMethodsExposingUpdate update = new ReplacementMethodsExposingUpdate(container.getPage());
AbstractPartialPageRequestHandler handler = new TestPartialPageRequestHandler(container.getPage(), update);

handler.addChildren(container, Label.class);

assertNull(update.getReplacementMethodPublic(label.getMarkupId()));
}

@Test
void passesReplacementMethodToUpdateForComponentWithOverriddenMarkupIdRegisteredWithOne()
{
Label label = tester.startComponentInPage(new Label("some ID"));
ReplacementMethodsExposingUpdate update = new ReplacementMethodsExposingUpdate(label.getPage());
AbstractPartialPageRequestHandler handler = new TestPartialPageRequestHandler(label.getPage(), update);

handler.add("theReplacementMethod", label, "the ID");

assertEquals("theReplacementMethod", update.getReplacementMethodPublic(label.getMarkupId()));
}

@Test
void passesReplacementMethodToUpdateForComponentRegisteredWithOne()
{
Component label = tester.startComponentInPage(new Label("the ID").setOutputMarkupId(true));
ReplacementMethodsExposingUpdate update = new ReplacementMethodsExposingUpdate(label.getPage());
AbstractPartialPageRequestHandler handler = new TestPartialPageRequestHandler(label.getPage(), update);

handler.add("theReplacementMethod", label);

assertEquals("theReplacementMethod", update.getReplacementMethodPublic(label.getMarkupId()));
}

@Test
void passesReplacementMethodToUpdateForChildrenRegisteredWithOne()
{
Component label = new Label("the ID").setOutputMarkupId(true).setMarkup(Markup.of("<span wicket:id=\"the ID\"></span>"));
MarkupContainer container = new WebMarkupContainer("some ID").add(label);
tester.startComponentInPage(container.setMarkup(Markup.of("<span wicket:id=\"some ID\"><span wicket:id=\"the ID\"></span></span>")));
ReplacementMethodsExposingUpdate update = new ReplacementMethodsExposingUpdate(container.getPage());
AbstractPartialPageRequestHandler handler = new TestPartialPageRequestHandler(container.getPage(), update);

handler.addChildren("theReplacementMethod", container, Label.class);

assertEquals("theReplacementMethod", update.getReplacementMethodPublic(label.getMarkupId()));
}

private static class ReplacementMethodsExposingUpdate extends XmlPartialPageUpdate
{
public ReplacementMethodsExposingUpdate(Page page)
{
super(page);
}

public String getReplacementMethodPublic(String markupId) {
return getReplacementMethod(markupId);
}
}

private static class TestPartialPageRequestHandler extends AbstractPartialPageRequestHandler
{
private final ReplacementMethodsExposingUpdate update;

public TestPartialPageRequestHandler(Page page, ReplacementMethodsExposingUpdate update)
{
super(page);
this.update = update;
}

@Override
protected PartialPageUpdate getUpdate()
{
return update;
}

@Override
public Collection<? extends Component> getComponents()
{
return List.of();
}

@Override
public void respond(IRequestCycle requestCycle)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.wicket.core.request.handler;

import org.apache.wicket.markup.MarkupType;
import org.apache.wicket.markup.html.panel.Panel;

public class MathmlSubexpressionPanel extends Panel
{
public MathmlSubexpressionPanel(String id)
{
super(id);
}

@Override
public MarkupType getMarkupType()
{
return new MarkupType("xml", "application/mathml+xml");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<math xmlns="http://www.w3.org/1998/Math/MathML"><wicket:panel><mn>2</mn></wicket:panel></math>
Loading