[1635] | 1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany
|
---|
| 2 | //
|
---|
| 3 | // Licensed under the Apache License, Version 2.0 (the "License");
|
---|
| 4 | // you may not use this file except in compliance with the License.
|
---|
| 5 | // You may obtain a copy of the License at
|
---|
| 6 | //
|
---|
| 7 | // http://www.apache.org/licenses/LICENSE-2.0
|
---|
| 8 | //
|
---|
| 9 | // Unless required by applicable law or agreed to in writing, software
|
---|
| 10 | // distributed under the License is distributed on an "AS IS" BASIS,
|
---|
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
| 12 | // See the License for the specific language governing permissions and
|
---|
| 13 | // limitations under the License.
|
---|
| 14 |
|
---|
| 15 | package de.ugoe.cs.autoquest.http;
|
---|
| 16 |
|
---|
| 17 | import static org.junit.Assert.*;
|
---|
| 18 |
|
---|
| 19 | import java.io.File;
|
---|
| 20 | import java.util.Collection;
|
---|
| 21 | import java.util.Iterator;
|
---|
| 22 | import java.util.List;
|
---|
| 23 |
|
---|
| 24 | import org.junit.Test;
|
---|
| 25 |
|
---|
| 26 | import de.ugoe.cs.autoquest.eventcore.Event;
|
---|
| 27 | import de.ugoe.cs.autoquest.plugin.http.HTTPLogParser;
|
---|
[1925] | 28 | import de.ugoe.cs.autoquest.plugin.http.SOAPUtils;
|
---|
[1635] | 29 | import de.ugoe.cs.autoquest.plugin.http.eventcore.SOAPEventType;
|
---|
| 30 | import de.ugoe.cs.autoquest.plugin.http.eventcore.SimpleSOAPEventType;
|
---|
| 31 |
|
---|
| 32 | /**
|
---|
| 33 | * <p>
|
---|
[1925] | 34 | * Tests for the SOAPUtils
|
---|
[1635] | 35 | * </p>
|
---|
| 36 | *
|
---|
| 37 | * @author Steffen Herbold
|
---|
| 38 | */
|
---|
[1925] | 39 | public class SOAPUtilsTest {
|
---|
[1635] | 40 |
|
---|
| 41 | @Test
|
---|
| 42 | public void testConvertToSimpleSOAPEvent_1() throws Exception {
|
---|
| 43 | HTTPLogParser parser =
|
---|
| 44 | new HTTPLogParser(new File(ClassLoader
|
---|
| 45 | .getSystemResource("testParseFile_3_properties.txt").getFile()));
|
---|
| 46 | parser.parseFile(new File(ClassLoader.getSystemResource("testParseFile_3_logfile.log")
|
---|
| 47 | .getFile()));
|
---|
| 48 | Collection<List<Event>> events = parser.getSequences();
|
---|
| 49 |
|
---|
| 50 | assertNotNull(events);
|
---|
| 51 | assertEquals(1, events.size());
|
---|
| 52 |
|
---|
| 53 | List<Event> sequence = events.iterator().next();
|
---|
| 54 |
|
---|
[1925] | 55 | List<Event> newSequence = SOAPUtils.convertToSimpleSOAPEvent(sequence, false);
|
---|
[1635] | 56 |
|
---|
| 57 | assertNotNull(newSequence);
|
---|
| 58 | assertEquals(sequence.size(), newSequence.size());
|
---|
| 59 |
|
---|
| 60 | Iterator<Event> oldSeqIter = sequence.iterator();
|
---|
| 61 | Iterator<Event> newSeqIter = newSequence.iterator();
|
---|
| 62 |
|
---|
| 63 | while(oldSeqIter.hasNext()) {
|
---|
| 64 | Event oldEvent = oldSeqIter.next();
|
---|
| 65 | Event newEvent = newSeqIter.next();
|
---|
| 66 |
|
---|
| 67 | if( oldEvent.getType() instanceof SOAPEventType ) {
|
---|
| 68 | assertTrue(newEvent.getType() instanceof SimpleSOAPEventType);
|
---|
| 69 | SOAPEventType oldEventType = (SOAPEventType) oldEvent.getType();
|
---|
| 70 | SimpleSOAPEventType newEventType = (SimpleSOAPEventType) newEvent.getType();
|
---|
| 71 | assertEquals(oldEventType.getCalledMethod(), newEventType.getCalledMethod());
|
---|
| 72 | assertEquals(oldEventType.getServiceName(), newEventType.getServiceName());
|
---|
[1925] | 73 | assertEquals(oldEventType.getClientName(), newEventType.getClientName());
|
---|
[1635] | 74 | assertNull(newEvent.getTarget());
|
---|
| 75 | } else {
|
---|
| 76 | assertSame(oldEvent, newEvent);
|
---|
| 77 | }
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | }
|
---|