
com.peachapisecurity.tg.junit4.PeachRunBefores Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tg-junit4 Show documentation
Show all versions of tg-junit4 Show documentation
Peach API Security JUnit4 Integration
The newest version!
/*
* Copyright 2017 Peach Tech
* 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.peachapisecurity.tg.junit4;
import com.peachapisecurity.api.PeachState;
import com.peachapisecurity.api.PeachApiException;
import java.util.List;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.Statement;
public class PeachRunBefores extends Statement {
private final Statement next;
private final Object target;
private final List befores;
private final PeachContext context;
public PeachRunBefores(PeachContext context, Statement next, List befores, Object target) {
this.next = next;
this.befores = befores;
this.target = target;
this.context = context;
}
@Override
public void evaluate() throws Throwable {
try
{
if(context.debug)
System.out.println(">> PeachRunBefores.evaluate(): testSetup");
context.proxy.testSetup();
}
catch(PeachApiException ex)
{
context.state = PeachState.Error;
context.ex = ex;
throw ex;
}
for (FrameworkMethod before : befores) {
before.invokeExplosively(target);
}
next.evaluate();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy