org.fabric3.maven.test.SCATestSet Maven / Gradle / Ivy
/*
* Fabric3
* Copyright ? 2008 Metaform Systems Limited
*
* This proprietary software may be used only connection with the Fabric3 license
* (the ?License?), a copy of which is included in the software or may be
* obtained at: http://www.metaformsystems.com/licenses/license.html.
* Software distributed under the License is distributed on an ?as is? basis,
* without warranties or conditions of any kind. See the License for the
* specific language governing permissions and limitations of use of the software.
* This software is distributed in conjunction with other software licensed under
* different terms. See the separate licenses for those programs included in the
* distribution for the permitted and restricted uses of such software.
*
* --- Original Apache License ---
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.fabric3.maven.test;
import org.apache.maven.surefire.report.PojoStackTraceWriter;
import org.apache.maven.surefire.report.ReportEntry;
import org.apache.maven.surefire.report.ReporterManager;
import org.apache.maven.surefire.report.StackTraceWriter;
import org.apache.maven.surefire.testset.SurefireTestSet;
import org.apache.maven.surefire.testset.TestSetFailedException;
import org.fabric3.spi.invocation.CallFrame;
import org.fabric3.spi.invocation.Message;
import org.fabric3.spi.invocation.MessageImpl;
import org.fabric3.spi.invocation.WorkContext;
import org.fabric3.spi.wire.InvocationChain;
import org.fabric3.spi.wire.Wire;
/**
* @version $Rev: 5944 $ $Date: 2008-11-15 09:12:33 -0800 (Sat, 15 Nov 2008) $
*/
public class SCATestSet implements SurefireTestSet {
private final String name;
private Wire wire;
public SCATestSet(String name, Wire wire) {
this.name = name;
this.wire = wire;
}
public void execute(ReporterManager reporterManager, ClassLoader loader) throws TestSetFailedException {
for (InvocationChain chain : wire.getInvocationChains()) {
String operationName = chain.getPhysicalOperation().getName();
reporterManager.testStarting(new ReportEntry(this, operationName, name));
try {
WorkContext workContext = new WorkContext();
CallFrame frame = new CallFrame();
workContext.addCallFrame(frame);
MessageImpl msg = new MessageImpl();
msg.setWorkContext(workContext);
Message response = chain.getHeadInterceptor().invoke(msg);
if (response.isFault()) {
throw new TestSetFailedException(operationName, (Throwable) response.getBody());
}
reporterManager.testSucceeded(new ReportEntry(this, operationName, name));
} catch (TestSetFailedException e) {
StackTraceWriter stw = new PojoStackTraceWriter(name, operationName, e.getCause());
reporterManager.testFailed(new ReportEntry(this, operationName, name, stw));
throw e;
}
}
}
public int getTestCount() {
return wire.getInvocationChains().size();
}
public String getName() {
return name;
}
public Class> getTestClass() {
throw new UnsupportedOperationException();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy