Clover coverage report - Dependency Finder
Coverage timestamp: Mon Nov 29 2010 15:00:50 PST
file stats: LOC: 133   Methods: 5
NCLOC: 80   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
TestExtractAction.java - 100% 100% 100%
coverage
 1    /*
 2    * Copyright (c) 2001-2009, Jean Tessier
 3    * All rights reserved.
 4    *
 5    * Redistribution and use in source and binary forms, with or without
 6    * modification, are permitted provided that the following conditions
 7    * are met:
 8    *
 9    * * Redistributions of source code must retain the above copyright
 10    * notice, this list of conditions and the following disclaimer.
 11    *
 12    * * Redistributions in binary form must reproduce the above copyright
 13    * notice, this list of conditions and the following disclaimer in the
 14    * documentation and/or other materials provided with the distribution.
 15    *
 16    * * Neither the name of Jean Tessier nor the names of his contributors
 17    * may be used to endorse or promote products derived from this software
 18    * without specific prior written permission.
 19    *
 20    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 21    * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 22    * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 23    * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
 24    * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 25    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 26    * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 27    * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 28    * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 29    * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 30    * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 31    */
 32   
 33    package com.jeantessier.dependencyfinder.webwork;
 34   
 35    import java.io.*;
 36    import java.util.*;
 37   
 38    import com.opensymphony.xwork.*;
 39    import static org.hamcrest.Matchers.*;
 40    import static org.jmock.Expectations.*;
 41    import org.jmock.*;
 42    import org.jmock.integration.junit4.*;
 43    import static org.junit.Assert.*;
 44    import org.junit.*;
 45    import org.junit.runner.*;
 46   
 47    import com.jeantessier.classreader.*;
 48    import com.jeantessier.dependency.*;
 49   
 50    @RunWith(JMock.class)
 51    public class TestExtractAction {
 52    private Mockery context;
 53   
 54    private Map<String, Object> application;
 55   
 56    private ExtractAction sut;
 57   
 58  4 @Before
 59    public void setUp() throws Exception {
 60  4 context = new Mockery();
 61   
 62  4 application = new HashMap<String, Object>();
 63  4 application.put("source", "classes" + File.separator + "test.class");
 64   
 65  4 sut = new ExtractAction();
 66    }
 67   
 68  1 @Test
 69    public void testExecute() throws Exception {
 70  1 sut.setApplication(application);
 71  1 String result = sut.execute();
 72   
 73  1 assertThat("Result", result, is(equal(Action.INPUT)));
 74  1 assertThat("Unexpected dispatcher", (ClassfileLoaderDispatcher) application.get("dispatcher"), is(aNull(ClassfileLoaderDispatcher.class)));
 75  1 assertThat("Unexpected factory", (NodeFactory) application.get("factory"), is(aNull(NodeFactory.class)));
 76  1 assertThat("Unexpected monitor", (Monitor) application.get("monitor"), is(aNull(Monitor.class)));
 77  1 assertThat("Unexpected start", (Date) sut.getStart(), is(aNull(Date.class)));
 78  1 assertThat("Unexpected stop", (Date) sut.getStop(), is(aNull(Date.class)));
 79    }
 80   
 81  1 @Test
 82    public void testFirstExtract() {
 83  1 sut.setApplication(application);
 84  1 String result = sut.doExtract();
 85   
 86  1 assertThat("Result", result, is(equal(Action.SUCCESS)));
 87  1 assertThat("Missing dispatcher", (ClassfileLoaderDispatcher) application.get("dispatcher"), is(aNonNull(ClassfileLoaderDispatcher.class)));
 88  1 assertThat("Missing factory", (NodeFactory) application.get("factory"), is(aNonNull(NodeFactory.class)));
 89  1 assertThat("Missing monitor", (Monitor) application.get("monitor"), is(aNonNull(Monitor.class)));
 90    }
 91   
 92  1 @Test
 93    public void testSecondExtract() {
 94  1 ClassfileLoaderDispatcher dispatcher = new ModifiedOnlyDispatcher(ClassfileLoaderEventSource.DEFAULT_DISPATCHER);
 95  1 NodeFactory factory = new NodeFactory();
 96  1 CodeDependencyCollector collector = new CodeDependencyCollector(factory);
 97  1 DeletingVisitor deletingVisitor = new DeletingVisitor(factory);
 98  1 Monitor monitor = new Monitor(collector, deletingVisitor);
 99   
 100  1 application.put("dispatcher", dispatcher);
 101  1 application.put("factory", factory);
 102  1 application.put("monitor", monitor);
 103   
 104  1 sut.setApplication(application);
 105  1 String result = sut.doExtract();
 106   
 107  1 assertThat("Result", result, is(equal(Action.SUCCESS)));
 108  1 assertThat("Dispatcher", (ClassfileLoaderDispatcher) application.get("dispatcher"), is(not(same(dispatcher))));
 109  1 assertThat("Factory", (NodeFactory) application.get("factory"), is(not(same(factory))));
 110  1 assertThat("Monitor", (Monitor) application.get("monitor"), is(not(same(monitor))));
 111    }
 112   
 113  1 @Test
 114    public void testUpdate() {
 115  1 ClassfileLoaderDispatcher dispatcher = new ModifiedOnlyDispatcher(ClassfileLoaderEventSource.DEFAULT_DISPATCHER);
 116  1 NodeFactory factory = new NodeFactory();
 117  1 CodeDependencyCollector collector = new CodeDependencyCollector(factory);
 118  1 DeletingVisitor deletingVisitor = new DeletingVisitor(factory);
 119  1 Monitor monitor = new Monitor(collector, deletingVisitor);
 120   
 121  1 application.put("dispatcher", dispatcher);
 122  1 application.put("factory", factory);
 123  1 application.put("monitor", monitor);
 124   
 125  1 sut.setApplication(application);
 126  1 String result = sut.doUpdate();
 127   
 128  1 assertThat("Result", result, is(equal(Action.SUCCESS)));
 129  1 assertThat("Dispatcher", (ClassfileLoaderDispatcher) application.get("dispatcher"), is(same(dispatcher)));
 130  1 assertThat("Factory", (NodeFactory) application.get("factory"), is(same(factory)));
 131  1 assertThat("Monitor", (Monitor) application.get("monitor"), is(same(monitor)));
 132    }
 133    }