Added tutorial

This commit is contained in:
Arjen Poutsma
2007-05-12 15:37:36 +00:00
parent 50a063d198
commit 0f8cba7835
11 changed files with 522 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
/*
* Copyright 2007 the original author or authors.
*
* Licensed 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 com.mycompany.hr.ws;
import java.io.InputStream;
import java.util.Calendar;
import com.mycompany.hr.service.HumanResourceService;
import junit.framework.TestCase;
import org.easymock.MockControl;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
public class HolidayEndpointTest extends TestCase {
private Document holidayRequest;
private HolidayEndpoint endpoint;
private MockControl mockControl;
private HumanResourceService serviceMock;
private Calendar startCalendar;
private Calendar endCalendar;
protected void setUp() throws Exception {
mockControl = MockControl.createControl(HumanResourceService.class);
serviceMock = (HumanResourceService) mockControl.getMock();
SAXBuilder builder = new SAXBuilder();
InputStream is = getClass().getResourceAsStream("holidayRequest.xml");
try {
holidayRequest = builder.build(is);
}
finally {
is.close();
}
endpoint = new HolidayEndpoint(serviceMock);
startCalendar = Calendar.getInstance();
startCalendar.clear();
startCalendar.set(2006, Calendar.JULY, 3);
endCalendar = Calendar.getInstance();
endCalendar.clear();
endCalendar.set(2006, Calendar.JULY, 7);
}
public void testInvokeInternal() throws Exception {
serviceMock.bookHoliday(startCalendar.getTime(), endCalendar.getTime(), "John Doe");
mockControl.replay();
Element result = endpoint.invokeInternal(holidayRequest.getRootElement());
assertNull("No result expected", result);
mockControl.verify();
}
}

View File

@@ -0,0 +1,27 @@
<!--
~ Copyright 2007 the original author or authors.
~
~ Licensed 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.
-->
<HolidayRequest xmlns="http://mycompany.com/hr/schemas">
<Holiday>
<StartDate>2006-07-03</StartDate>
<EndDate>2006-07-07</EndDate>
</Holiday>
<Employee>
<Number>42</Number>
<FirstName>John</FirstName>
<LastName>Doe</LastName>
</Employee>
</HolidayRequest>