| OLD | NEW |
| 1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
| 2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
| 3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
| 4 // | 4 // |
| 5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
| 6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
| 7 // met: | 7 // met: |
| 8 // | 8 // |
| 9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
| 10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | 30 |
| 31 package com.google.protobuf; | 31 package com.google.protobuf; |
| 32 | 32 |
| 33 import junit.framework.TestCase; | |
| 34 | |
| 35 import java.io.ByteArrayInputStream; | 33 import java.io.ByteArrayInputStream; |
| 36 import java.io.ByteArrayOutputStream; | 34 import java.io.ByteArrayOutputStream; |
| 37 import java.io.EOFException; | 35 import java.io.EOFException; |
| 38 import java.io.IOException; | 36 import java.io.IOException; |
| 39 import java.io.InputStream; | 37 import java.io.InputStream; |
| 40 import java.io.ObjectInputStream; | 38 import java.io.ObjectInputStream; |
| 41 import java.io.ObjectOutputStream; | 39 import java.io.ObjectOutputStream; |
| 42 import java.io.OutputStream; | 40 import java.io.OutputStream; |
| 43 import java.io.UnsupportedEncodingException; | 41 import java.io.UnsupportedEncodingException; |
| 44 import java.nio.ByteBuffer; | 42 import java.nio.ByteBuffer; |
| 45 import java.util.Arrays; | 43 import java.util.Arrays; |
| 46 import java.util.List; | 44 import java.util.List; |
| 47 import java.util.NoSuchElementException; | 45 import java.util.NoSuchElementException; |
| 46 import junit.framework.TestCase; |
| 48 | 47 |
| 49 /** | 48 /** |
| 50 * Test {@code LiteralByteString} by setting up a reference string in {@link #se
tUp()}. | 49 * Test {@code LiteralByteString} by setting up a reference string in {@link #se
tUp()}. |
| 51 * This class is designed to be extended for testing extensions of {@code Litera
lByteString} | 50 * This class is designed to be extended for testing extensions of {@code Litera
lByteString} |
| 52 * such as {@code BoundedByteString}, see {@link BoundedByteStringTest}. | 51 * such as {@code BoundedByteString}, see {@link BoundedByteStringTest}. |
| 53 * | 52 * |
| 54 * @author carlanton@google.com (Carl Haverl) | 53 * @author carlanton@google.com (Carl Haverl) |
| 55 */ | 54 */ |
| 56 public class LiteralByteStringTest extends TestCase { | 55 public class LiteralByteStringTest extends TestCase { |
| 57 protected static final String UTF_8 = "UTF-8"; | 56 protected static final String UTF_8 = "UTF-8"; |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 oos.writeObject(stringUnderTest); | 535 oos.writeObject(stringUnderTest); |
| 537 oos.close(); | 536 oos.close(); |
| 538 byte[] pickled = out.toByteArray(); | 537 byte[] pickled = out.toByteArray(); |
| 539 InputStream in = new ByteArrayInputStream(pickled); | 538 InputStream in = new ByteArrayInputStream(pickled); |
| 540 ObjectInputStream ois = new ObjectInputStream(in); | 539 ObjectInputStream ois = new ObjectInputStream(in); |
| 541 Object o = ois.readObject(); | 540 Object o = ois.readObject(); |
| 542 assertTrue("Didn't get a ByteString back", o instanceof ByteString); | 541 assertTrue("Didn't get a ByteString back", o instanceof ByteString); |
| 543 assertEquals("Should get an equal ByteString back", stringUnderTest, o); | 542 assertEquals("Should get an equal ByteString back", stringUnderTest, o); |
| 544 } | 543 } |
| 545 } | 544 } |
| OLD | NEW |