Package org.jemmy

Examples of org.jemmy.JemmyException


                            if (line == null) {
                                break;
                            }
                            System.out.println("SERVER: " + line);
                        } catch (IOException ex) {
                            throw new JemmyException("Exception during other JVM output processing", ex);
                        }
                    }
                }
            }.start();
        } catch (IOException ex) {
            throw new JemmyException("Failed to start other JVM", ex);
        }
    }
View Full Code Here


                                    "with other JVM (" + connectionHost
                                    + ":" + connectionPort + ", exception: " + ex + ")";
                        }
                    });
                } else {
                    throw new JemmyException("Failed to establish socket " +
                            "connection with other JVM (" + connectionHost
                            + ":" + connectionPort + ")", ex);
                }
            }
            outputStream = new ObjectOutputStream(socket.getOutputStream());
            inputStream = new ObjectInputStream(socket.getInputStream());

            connectionEstablished = true;
            ready = true;

            System.out.println("Connection established!");
            setAutoDelay(autoDelay);
        } catch (IOException ex) {
            throw new JemmyException("Failed to establish socket connection " +
                    "with other JVM (" + connectionHost + ":" + connectionPort
                    + ")", ex);
        }
    }
View Full Code Here

            outputStream.writeObject("getProperty");
            outputStream.writeObject(name);
            Object result = inputStream.readObject();
            String response = (String)(inputStream.readObject());
            if (!"OK".equals(response)) {
                throw new JemmyException("Remote operation didn't succeed");
            }
//            System.out.println("Operation successful!");
            return result;
        } catch (ClassNotFoundException ex) {
            throw new JemmyException("Socket communication with other JVM failed", ex);
        } catch (OptionalDataException ex) {
            throw new JemmyException("Socket communication with other JVM " +
                    "failed: OptionalDataException eof = " + ex.eof + ", " +
                    "length = " + ex.length, ex);
        } catch (IOException ex) {
            throw new JemmyException("Socket communication with other JVM failed", ex);
        }
    }
View Full Code Here

            String response = (String)(inputStream.readObject());
            if ("image".equals(response)) {
                result = PNGDecoder.decode(inputStream, false);
            } else {
                if (!"OK".equals(response)) {
                    throw new JemmyException("Remote operation didn't succeed");
                }
                result = inputStream.readObject();
            }
//            System.out.println("Operation successful!");
            return result;
        } catch (ClassNotFoundException ex) {
            throw new JemmyException("Socket communication with other JVM failed", ex);
        } catch (OptionalDataException ex) {
            throw new JemmyException("Socket communication with other JVM " +
                    "failed: OptionalDataException eof = " + ex.eof + ", " +
                    "length = " + ex.length, ex);
        } catch (IOException ex) {
            throw new JemmyException("Socket communication with other JVM failed", ex);
        }
    }
View Full Code Here

        return(true);
    }

    void checkEquality(byte[] b1, byte[] b2) {
        if(!compare(b1, b2)) {
            throw(new JemmyException("Format error"));
        }
    }
View Full Code Here

        } else if(compare(head, new byte[]{8, 0, 0, 0, 0})) {
            mode = PNGEncoder.GREYSCALE_MODE;
        } else if(compare(head, new byte[]{8, 2, 0, 0, 0})) {
            mode = PNGEncoder.COLOR_MODE;
        } else {
            throw(new JemmyException("Format error"));
        }

        readInt();//!!crc

        int size = readInt();

        byte[] idat = read(4);
        checkEquality(idat, "IDAT".getBytes());

        byte[] data = read(size);


        Inflater inflater = new Inflater();
        inflater.setInput(data, 0, size);

        int color;

        try {
            switch (mode) {
            case PNGEncoder.BW_MODE:
                {
                    int bytes = (int)(width / 8);
                    if((width % 8) != 0) {
                        bytes++;
                    }
                    byte colorset;
                    byte[] row = new byte[bytes];
                    for (int y = 0; y < height; y++) {
                        inflater.inflate(new byte[1]);
                        inflater.inflate(row);
                        for (int x = 0; x < bytes; x++) {
                            colorset = row[x];
                            for (int sh = 0; sh < 8; sh++) {
                                if(x * 8 + sh >= width) {
                                    break;
                                }
                                if((colorset & 0x80) == 0x80) {
                                    result.setRGB(x * 8 + sh, y, Color.white.getRGB());
                                } else {
                                    result.setRGB(x * 8 + sh, y, Color.black.getRGB());
                                }
                                colorset <<= 1;
                            }
                        }
                    }
                }
                break;
            case PNGEncoder.GREYSCALE_MODE:
                {
                    byte[] row = new byte[width];
                    for (int y = 0; y < height; y++) {
                        inflater.inflate(new byte[1]);
                        inflater.inflate(row);
                        for (int x = 0; x < width; x++) {
                            color = row[x];
                            result.setRGB(x, y, (color << 16) + (color << 8) + color);
                        }
                    }
                }
                break;
            case PNGEncoder.COLOR_MODE:
                {
                    byte[] row = new byte[width * 3];
                    for (int y = 0; y < height; y++) {
                        inflater.inflate(new byte[1]);
                        inflater.inflate(row);
                        for (int x = 0; x < width; x++) {
                            result.setRGB(x, y,
                                          ((row[x * 3 + 0]&0xff) << 16) +
                                          ((row[x * 3 + 1]&0xff) << 8) +
                                          ((row[x * 3 + 2]&0xff)));
                        }
                    }
                }
            }
        } catch(DataFormatException e) {
            throw(new JemmyException("ZIP error", e));
        }

        readInt();//!!crc
        readInt();//0

View Full Code Here

     */
    public static BufferedImage decode(String fileName) {
        try {
            return(new PNGDecoder(new FileInputStream(fileName)).decode());
        } catch(IOException e) {
            throw(new JemmyException("IOException during image reading", e));
        }
    }
View Full Code Here

     */
    public static BufferedImage decode(InputStream inputStream, boolean closeStream) {
        try {
            return(new PNGDecoder(inputStream).decode(closeStream));
        } catch(IOException e) {
            throw(new JemmyException("IOException during image reading", e));
        }
    }
View Full Code Here

     */
    public static BufferedImage decode(ClassLoader loader, String resource) {
        try {
            InputStream resourceStream = loader.getResourceAsStream(resource);
            if (resourceStream == null) {
                throw new JemmyException("Resouce '" + resource + "' could not be found!");
            }
            return(new PNGDecoder(resourceStream).decode());
        } catch(IOException e) {
            throw(new JemmyException("IOException during image reading", e));
        }
    }
View Full Code Here

                fullPath += ".png";
            }
            new PNGImageSaver().save(image, fullPath);
            Environment.getEnvironment().getOutput(OUTPUT).println("Image saved to " + fullPath);
        } catch (IOException ex) {
            throw new JemmyException("Unable to save image", ex, fileName);
        }
    }
View Full Code Here

TOP

Related Classes of org.jemmy.JemmyException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.