This is an alternative to configuring RequireJS module shims for the libraries. As opposed to shimmed libraries, the modules created using the AMDWrapper can be added to JavaScript stacks.
If the library depends on global variables, these can be added as module dependencies. For a library that expects jQuery to be available as $
, the wrapper should be setup calling
require("jQuery", "$")
on the respective wrapper.
@since 5.4
@see JavaScriptModuleConfiguration
@see ModuleManager
{
@Test
public void response_sent() throws IOException
{
String encoding = "UTF-8";
Response response = mockResponse();
CharArrayWriter writer = new CharArrayWriter();
PrintWriter pw = new PrintWriter(writer);
expect(response.getPrintWriter("application/json;charset=UTF-8")).andReturn(pw);
replay();
JSONArray array = new JSONArray(" [ \"fred\", \"barney\" \n\n]");
}
@Test
public void unknown_validator_type()
{
ValidationMessagesSource messagesSource = mockValidationMessagesSource();
Validator validator = mockValidator();
TypeCoercer coercer = mockTypeCoercer();
FieldComponent field = newFieldComponent();
ComponentResources resources = mockComponentResources();
Messages containerMessages = mockMessages();
@SuppressWarnings("unchecked")
@Test
public void validator_with_no_constraint() throws Exception
{
ValidationMessagesSource messagesSource = mockValidationMessagesSource();
Validator validator = mockValidator();
TypeCoercer coercer = mockTypeCoercer();
FieldComponent field = newFieldComponent();
Messages messages = mockMessages();
MessageFormatter formatter = mockMessageFormatter();
@SuppressWarnings("unchecked")
@Test
public void component_messages_overrides_validator_messages() throws Exception
{
ValidationMessagesSource messagesSource = mockValidationMessagesSource();
Validator validator = mockValidator();
TypeCoercer coercer = mockTypeCoercer();
FieldComponent field = newFieldComponent();
MessageFormatter formatter = mockMessageFormatter();
Object inputValue = new Object();
}
@Test
public void component_messages_overrides_validator_messages_per_form() throws Exception
{
ValidationMessagesSource messagesSource = mockValidationMessagesSource();
Validator validator = mockValidator();
TypeCoercer coercer = mockTypeCoercer();
FieldComponent field = newFieldComponent();
MessageFormatter formatter = mockMessageFormatter();
Object inputValue = new Object();
@SuppressWarnings("unchecked")
@Test
public void constraint_value_from_message_catalog_per() throws Exception
{
ValidationMessagesSource messagesSource = mockValidationMessagesSource();
Validator validator = mockValidator();
TypeCoercer coercer = mockTypeCoercer();
FieldComponent field = newFieldComponent();
Messages messages = mockMessages();
MessageFormatter formatter = mockMessageFormatter();
@SuppressWarnings("unchecked")
@Test
public void constraint_value_from_message_catalog_per_form() throws Exception
{
ValidationMessagesSource messagesSource = mockValidationMessagesSource();
Validator validator = mockValidator();
TypeCoercer coercer = mockTypeCoercer();
FieldComponent field = newFieldComponent();
Messages messages = mockMessages();
MessageFormatter formatter = mockMessageFormatter();
@SuppressWarnings("unchecked")
@Test
public void missing_field_validator_constraint() throws Exception
{
ValidationMessagesSource messagesSource = mockValidationMessagesSource();
Validator validator = mockValidator();
TypeCoercer coercer = mockTypeCoercer();
FieldComponent field = newFieldComponent();
ComponentResources resources = mockComponentResources();
Messages containerMessages = mockMessages();
@SuppressWarnings("unchecked")
@Test
public void single_validator_via_specification() throws Exception
{
ValidationMessagesSource messagesSource = mockValidationMessagesSource();
Validator validator = mockValidator();
TypeCoercer coercer = mockTypeCoercer();
FieldComponent field = newFieldComponent();
Messages messages = mockMessages();
MessageFormatter formatter = mockMessageFormatter();
@SuppressWarnings("unchecked")
@Test
public void multiple_validators_via_specification() throws Exception
{
ValidationMessagesSource messagesSource = mockValidationMessagesSource();
Validator required = mockValidator();
Validator minLength = mockValidator();
TypeCoercer coercer = mockTypeCoercer();
FieldComponent field = newFieldComponent();
Messages messages = mockMessages();
Related Classes of org.apache.tapestry5.services.javascript.AMDWrapper
Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.