ttomcat-1778514358873.zip-extract/_dependencies/maven/junit_junit-4.13.2/org/junit/internal/AssumptionViolatedException.java

Path
ttomcat-1778514358873.zip-extract/_dependencies/maven/junit_junit-4.13.2/org/junit/internal/AssumptionViolatedException.java
Status
scanned
Type
file
Name
AssumptionViolatedException.java
Extension
.java
Programming language
Java
Mime type
text/x-java
File type
Java source, ASCII text
Tag

      
    
Rootfs path

      
    
Size
5025 (4.9 KB)
MD5
08ae77bc2fe6fad0e867c1b72f1c2204
SHA1
1737fbb1a73bd61d270a294beb34cc436e710647
SHA256
27c4e49afe7f17cb0351c14e32316ab029b942391c2c0455592be41b91a54ac8
SHA512

      
    
SHA1_git
0e79b562f5f2117bda6ff604c25c44cd2ae0ee54
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
AssumptionViolatedException.java | 4.9 KB |

package org.junit.internal; import java.io.IOException; import java.io.ObjectOutputStream; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hamcrest.SelfDescribing; import org.hamcrest.StringDescription; /** * An exception class used to implement <i>assumptions</i> (state in which a given test * is meaningful and should or should not be executed). A test for which an assumption * fails should not generate a test case failure. * * @see org.junit.Assume */ public class AssumptionViolatedException extends RuntimeException implements SelfDescribing { private static final long serialVersionUID = 2L; /* * We have to use the f prefix until the next major release to ensure * serialization compatibility. * See https://github.com/junit-team/junit4/issues/976 */ private final String fAssumption; private final boolean fValueMatcher; private final Object fValue; private final Matcher<?> fMatcher; /** * @deprecated Please use {@link org.junit.AssumptionViolatedException} instead. */ @Deprecated public AssumptionViolatedException(String assumption, boolean hasValue, Object value, Matcher<?> matcher) { this.fAssumption = assumption; this.fValue = value; this.fMatcher = matcher; this.fValueMatcher = hasValue; if (value instanceof Throwable) { initCause((Throwable) value); } } /** * An assumption exception with the given <i>value</i> (String or * Throwable) and an additional failing {@link Matcher}. * * @deprecated Please use {@link org.junit.AssumptionViolatedException} instead. */ @Deprecated public AssumptionViolatedException(Object value, Matcher<?> matcher) { this(null, true, value, matcher); } /** * An assumption exception with the given <i>value</i> (String or * Throwable) and an additional failing {@link Matcher}. * * @deprecated Please use {@link org.junit.AssumptionViolatedException} instead. */ @Deprecated public AssumptionViolatedException(String assumption, Object value, Matcher<?> matcher) { this(assumption, true, value, matcher); } /** * An assumption exception with the given message only. * * @deprecated Please use {@link org.junit.AssumptionViolatedException} instead. */ @Deprecated public AssumptionViolatedException(String assumption) { this(assumption, false, null, null); } /** * An assumption exception with the given message and a cause. * * @deprecated Please use {@link org.junit.AssumptionViolatedException} instead. */ @Deprecated public AssumptionViolatedException(String assumption, Throwable e) { this(assumption, false, null, null); initCause(e); } @Override public String getMessage() { return StringDescription.asString(this); } public void describeTo(Description description) { if (fAssumption != null) { description.appendText(fAssumption); } if (fValueMatcher) { // a value was passed in when this instance was constructed; print it if (fAssumption != null) { description.appendText(": "); } description.appendText("got: "); description.appendValue(fValue); if (fMatcher != null) { description.appendText(", expected: "); description.appendDescriptionOf(fMatcher); } } } /** * Override default Java object serialization to correctly deal with potentially unserializable matchers or values. * By not implementing readObject, we assure ourselves of backwards compatibility and compatibility with the * standard way of Java serialization. * * @param objectOutputStream The outputStream to write our representation to * @throws IOException When serialization fails */ private void writeObject(ObjectOutputStream objectOutputStream) throws IOException { ObjectOutputStream.PutField putField = objectOutputStream.putFields(); putField.put("fAssumption", fAssumption); putField.put("fValueMatcher", fValueMatcher); // We have to wrap the matcher into a serializable form. putField.put("fMatcher", SerializableMatcherDescription.asSerializableMatcher(fMatcher)); // We have to wrap the value inside a non-String class (instead of serializing the String value directly) as // A Description will handle a String and non-String object differently (1st is surrounded by '"' while the // latter will be surrounded by '<' '>'. Wrapping it makes sure that the description of a serialized and // non-serialized instance produce the exact same description putField.put("fValue", SerializableValueDescription.asSerializableValue(fValue)); objectOutputStream.writeFields(); } }
URL Start line End line
https://github.com/junit-team/junit4/issues/976 24 24