use of java.io.ObjectStreamException in project robovm by robovm.
the class CertPathTest method testWriteReplace.
/**
* This test just calls <code>writeReplace()</code> method<br>
*/
public final void testWriteReplace() {
try {
MyCertPath cp1 = new MyCertPath(testEncoding);
Object obj = cp1.writeReplace();
assertTrue(obj.toString().contains("java.security.cert.CertPath$CertPathRep"));
} catch (ObjectStreamException e) {
fail("Unexpected ObjectStreamException " + e.getMessage());
}
}
use of java.io.ObjectStreamException in project robovm by robovm.
the class CertPathTest method testWriteReplace_ObjectStreamException.
public final void testWriteReplace_ObjectStreamException() {
try {
MyFailingCertPath cp = new MyFailingCertPath(testEncoding);
Object obj = cp.writeReplace();
fail("expected ObjectStreamException");
} catch (ObjectStreamException e) {
// ok
}
}
use of java.io.ObjectStreamException in project robovm by robovm.
the class CertificateCertificateRepTest method testReadResolve.
/**
* Test for <code>readResolve()</code> method<br>
*/
public final void testReadResolve() {
MyCertificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
MyCertificateRep rep = c1.new MyCertificateRep("TEST_TYPE", new byte[] { (byte) 1, (byte) 2, (byte) 3 });
try {
rep.readResolve();
fail("ObjectStreamException expected");
} catch (ObjectStreamException e) {
// expected
}
MyCertificateRep rep1 = c1.new MyCertificateRep("X509", TestUtils.getX509Certificate_v3());
try {
Certificate obj = (Certificate) rep1.readResolve();
assertEquals("0.3.5", obj.getPublicKey().getAlgorithm());
assertEquals("X.509", obj.getPublicKey().getFormat());
assertEquals("X.509", obj.getType());
} catch (ObjectStreamException e) {
fail("Unexpected ObjectStreamException " + e.getMessage());
}
}
use of java.io.ObjectStreamException in project streamsx.health by IBMStreams.
the class VinesToObservationParser method readResolve.
public Object readResolve() throws ObjectStreamException {
formatter = new DateTimeFormatterBuilder().appendPattern(DATE_TIME_PATTERN).toFormatter(Locale.ENGLISH);
isMappingEnabled = Boolean.parseBoolean(mappingEnabledSupplier.get());
try {
InputStream inputStream = Resources.getResource(MAPPING_FILE).openStream();
lookupTable = new VinesToStreamsCodeLookupTable(inputStream);
} catch (Exception e) {
ObjectStreamException ose = new ObjectStreamException() {
private static final long serialVersionUID = 1L;
};
ose.addSuppressed(e);
throw ose;
}
return this;
}
use of java.io.ObjectStreamException in project streamsx.topology by IBMStreams.
the class ParallelRegexGrep method main.
@SuppressWarnings("serial")
public static void main(String[] args) throws Exception {
String contextType = args[0];
String directory = args[1];
final Pattern pattern = Pattern.compile(args[2]);
// Define the topology
Topology topology = new Topology("ParallelRegexGrep");
// All streams with tuples that are Java String objects
TStream<String> files = directoryWatcher(topology, directory);
// Create a stream of lines from each file.
TStream<String> lines = textFileReader(files);
// Count the total number of lines before they are split between
// different parallel channels.
TStream<String> lines_counter = lines.transform(new Function<String, String>() {
private int numSentStrings = 0;
@Override
public String apply(String v1) {
trace.info("Have sent " + (++numSentStrings) + "to be filtered.");
return v1;
}
});
// Parallelize the Stream.
// Since there are 5 channels of the stream, the approximate number of
// lines sent to each channel should be numSentStrings/5. This can be
// verified by comparing the outputs of the lines_counter stream to that
// of the parallel channels.
TStream<String> lines_parallel = lines_counter.parallel(5);
// Filter for the matched string, and print the number strings that have
// been tested. This is happening in parallel.
TStream<String> filtered_parallel = lines_parallel.filter(new Predicate<String>() {
private int numReceivedStrings = 0;
@Override
public boolean test(String v1) {
trace.info("Have received " + (++numReceivedStrings) + "strings on this parallel channel.");
// regular expression pattern
return matcher.reset(v1).matches();
}
transient Matcher matcher;
private Object readResolve() throws ObjectStreamException {
matcher = pattern.matcher("");
return this;
}
});
// Join the results of each parallel filter into one stream,
// merging the parallel streams back into one stream.
TStream<String> filtered_condensed = filtered_parallel.endParallel();
// Print the combined results
filtered_condensed.print();
// Execute the topology
StreamsContextFactory.getStreamsContext(contextType).submit(topology);
}
Aggregations