From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18109 invoked by alias); 24 Jan 2006 15:19:30 -0000 Received: (qmail 18052 invoked by uid 22791); 24 Jan 2006 15:19:28 -0000 X-Spam-Check-By: sourceware.org Received: from gbenson.demon.co.uk (HELO gbenson.demon.co.uk) (80.177.220.214) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 24 Jan 2006 15:19:26 +0000 Received: from slippy.wire.rat ([192.168.1.1]) by gbenson.demon.co.uk with esmtp (Exim 3.36 #1) id 1F1Px6-0001c5-00 for mauve-patches@sources.redhat.com; Tue, 24 Jan 2006 15:19:24 +0000 Received: from slippy.wire.rat (localhost.localdomain [127.0.0.1]) by slippy.wire.rat (8.13.1/8.13.1) with ESMTP id k0OFJNXE010241 for ; Tue, 24 Jan 2006 15:19:23 GMT Received: (from gary@localhost) by slippy.wire.rat (8.13.1/8.13.1/Submit) id k0OFJNf8010240 for mauve-patches@sources.redhat.com; Tue, 24 Jan 2006 15:19:23 GMT Date: Tue, 24 Jan 2006 15:19:00 -0000 From: Gary Benson To: mauve-patches@sources.redhat.com Subject: FYI: SocketPermission serialization tests Message-ID: <20060124151921.GC5123@redhat.com> Mail-Followup-To: mauve-patches@sources.redhat.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="CdrF4e02JqNVZeln" Content-Disposition: inline X-IsSubscribed: yes Mailing-List: contact mauve-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: mauve-patches-owner@sourceware.org X-SW-Source: 2006/txt/msg00045.txt.bz2 --CdrF4e02JqNVZeln Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 95 Hi, This test puts java.net.SocketPermission's serialization through its paces. Cheers, Gary --CdrF4e02JqNVZeln Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch Content-length: 3862 Index: ChangeLog =================================================================== RCS file: /cvs/mauve/mauve/ChangeLog,v retrieving revision 1.1369 diff -u -r1.1369 ChangeLog --- ChangeLog 24 Jan 2006 13:44:45 -0000 1.1369 +++ ChangeLog 24 Jan 2006 15:16:25 -0000 @@ -1,3 +1,7 @@ +2006-01-24 Gary Benson + + * gnu/testlet/java/net/SocketPermission/serialization.java: New test. + 2006-01-24 David Gilbert * gnu/testlet/javax/swing/text/StringContent/BadLocationExceptionTest.java: Updated header and imports, Index: gnu/testlet/java/net/SocketPermission/serialization.java =================================================================== RCS file: gnu/testlet/java/net/SocketPermission/serialization.java diff -N gnu/testlet/java/net/SocketPermission/serialization.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gnu/testlet/java/net/SocketPermission/serialization.java 24 Jan 2006 15:16:25 -0000 @@ -0,0 +1,102 @@ +// Copyright (C) 2006 Red Hat, Inc. +// Written by Gary Benson + +// This file is part of Mauve. + +// Mauve is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or (at your option) +// any later version. + +// Mauve is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Mauve; see the file COPYING. If not, write to +// the Free Software Foundation, 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +package gnu.testlet.java.net.SocketPermission; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInput; +import java.io.ObjectInputStream; +import java.io.ObjectOutput; +import java.io.ObjectOutputStream; +import java.net.SocketPermission; + +import gnu.testlet.Testlet; +import gnu.testlet.TestHarness; + +public class serialization implements Testlet +{ + private String[] hosts = new String[] { + "", + "localhost", + "example.com", + "*.com", + "209.132.177.50", + "[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]", + "[3ffe:2a00:100:7031::1]", + "[::192.9.5.5]", + }; + + private String[] ports = new String[] { + "", + ":", + ":80", + ":-80", + ":80-", + ":70-90", + ":800000", + ":700000-900000", + }; + + public void test(TestHarness harness) + { + harness.checkPoint("serialization checking"); + + for (int i = 0; i < hosts.length; i++) { + for (int j = 0; j < ports.length; j++) { + for (int k = 1; k < 1 << actions.length; k++) { + SocketPermission p1 = new SocketPermission( + hosts[i] + ports[j], makeActions(k)); + SocketPermission p2 = null; + try { + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + ObjectOutput out = new ObjectOutputStream(buffer); + out.writeObject(p1); + out.close(); + + ObjectInput in = new ObjectInputStream( + new ByteArrayInputStream(buffer.toByteArray())); + p2 = (SocketPermission) in.readObject(); + in.close(); + } + catch (Exception e) { + harness.debug(e); + } + harness.check(p1.equals(p2)); + } + } + } + } + + // stuff for actions checking + private static String[] actions = {"accept", "connect", "listen", "resolve"}; + private static String makeActions(int mask) + { + String result = ""; + for (int i = 0; i < actions.length; i++) { + if ((mask & (1 << i)) != 0) { + if (result.length() > 0) + result += ","; + result += actions[i]; + } + } + return result; + } +} --CdrF4e02JqNVZeln--