001/* 002 * Copyright 2002-2012 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.mock.web.portlet; 018 019import java.io.Serializable; 020import javax.portlet.Event; 021import javax.xml.namespace.QName; 022 023/** 024 * Mock implementation of the {@link javax.portlet.Event} interface. 025 * 026 * @author Juergen Hoeller 027 * @since 3.0 028 * @see MockEventRequest 029 */ 030public class MockEvent implements Event { 031 032 private final QName name; 033 034 private final Serializable value; 035 036 037 /** 038 * Create a new MockEvent with the given name. 039 * @param name the name of the event 040 */ 041 public MockEvent(QName name) { 042 this.name = name; 043 this.value = null; 044 } 045 046 /** 047 * Create a new MockEvent with the given name and value. 048 * @param name the name of the event 049 * @param value the associated payload of the event 050 */ 051 public MockEvent(QName name, Serializable value) { 052 this.name = name; 053 this.value = value; 054 } 055 056 /** 057 * Create a new MockEvent with the given name. 058 * @param name the name of the event 059 */ 060 public MockEvent(String name) { 061 this.name = new QName(name); 062 this.value = null; 063 } 064 065 /** 066 * Create a new MockEvent with the given name and value. 067 * @param name the name of the event 068 * @param value the associated payload of the event 069 */ 070 public MockEvent(String name, Serializable value) { 071 this.name = new QName(name); 072 this.value = value; 073 } 074 075 076 @Override 077 public QName getQName() { 078 return this.name; 079 } 080 081 @Override 082 public String getName() { 083 return this.name.getLocalPart(); 084 } 085 086 @Override 087 public Serializable getValue() { 088 return this.value; 089 } 090 091}