Search in sources :

Example 1 with ObjectStreamException

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());
    }
}
Also used : MyCertPath(org.apache.harmony.security.tests.support.cert.MyCertPath) ObjectStreamException(java.io.ObjectStreamException)

Example 2 with ObjectStreamException

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
    }
}
Also used : MyFailingCertPath(org.apache.harmony.security.tests.support.cert.MyFailingCertPath) ObjectStreamException(java.io.ObjectStreamException)

Example 3 with ObjectStreamException

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());
    }
}
Also used : MyCertificate(org.apache.harmony.security.tests.support.cert.MyCertificate) MyCertificateRep(org.apache.harmony.security.tests.support.cert.MyCertificate.MyCertificateRep) ObjectStreamException(java.io.ObjectStreamException) Certificate(java.security.cert.Certificate) MyCertificate(org.apache.harmony.security.tests.support.cert.MyCertificate)

Example 4 with ObjectStreamException

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;
}
Also used : InputStream(java.io.InputStream) ObjectStreamException(java.io.ObjectStreamException) DateTimeFormatterBuilder(java.time.format.DateTimeFormatterBuilder) ParseException(java.text.ParseException) ObjectStreamException(java.io.ObjectStreamException) DateTimeParseException(java.time.format.DateTimeParseException)

Example 5 with ObjectStreamException

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);
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) Topology(com.ibm.streamsx.topology.Topology) ObjectStreamException(java.io.ObjectStreamException)

Aggregations

ObjectStreamException (java.io.ObjectStreamException)13 Topology (com.ibm.streamsx.topology.Topology)4 Matcher (java.util.regex.Matcher)4 InputStream (java.io.InputStream)2 Certificate (java.security.cert.Certificate)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Pattern (java.util.regex.Pattern)2 MyCertPath (org.apache.harmony.security.tests.support.cert.MyCertPath)2 MyCertificate (org.apache.harmony.security.tests.support.cert.MyCertificate)2 MyCertificateRep (org.apache.harmony.security.tests.support.cert.MyCertificate.MyCertificateRep)2 File (java.io.File)1 IOException (java.io.IOException)1 Serializable (java.io.Serializable)1 Annotation (java.lang.annotation.Annotation)1 ClassFileTransformer (java.lang.instrument.ClassFileTransformer)1 ManagementFactory (java.lang.management.ManagementFactory)1 AnnotatedElement (java.lang.reflect.AnnotatedElement)1 Constructor (java.lang.reflect.Constructor)1 Executable (java.lang.reflect.Executable)1