andrewsbrown | 4dddd47 | 2015-04-01 14:28:46 -0700 | [diff] [blame] | 1 | /* |
| 2 | * jndn-utils |
| 3 | * Copyright (c) 2015, Intel Corporation. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms and conditions of the GNU Lesser General Public License, |
| 7 | * version 3, as published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope it will be useful, but WITHOUT ANY |
| 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| 12 | * more details. |
| 13 | */ |
| 14 | package com.intel.jndn.utils; |
| 15 | |
| 16 | import com.intel.jndn.mock.MockFace; |
| 17 | import java.io.IOException; |
| 18 | import net.named_data.jndn.Data; |
| 19 | import net.named_data.jndn.Name; |
| 20 | import net.named_data.jndn.util.Blob; |
| 21 | import static org.junit.Assert.*; |
| 22 | import org.junit.Test; |
| 23 | |
| 24 | /** |
| 25 | * |
| 26 | * @author Andrew Brown <andrew.brown@intel.com> |
| 27 | */ |
| 28 | public class SegmentedServerTest { |
| 29 | |
| 30 | MockFace face = new MockFace(); |
| 31 | SegmentedServer instance = new SegmentedServer(face, new Name("/test/prefix")); |
| 32 | |
| 33 | @Test |
| 34 | public void testGetPrefix() { |
| 35 | assertNotNull(instance.getPrefix()); |
| 36 | } |
| 37 | |
| 38 | @Test |
| 39 | public void testAddPipelineStage() { |
| 40 | instance.addPipelineStage(null); |
| 41 | } |
| 42 | |
| 43 | @Test |
| 44 | public void testProcessPipeline() throws Exception { |
| 45 | Data in = new Data(new Name("/test")); |
| 46 | Data out = instance.processPipeline(in); |
| 47 | assertEquals(out, in); |
| 48 | } |
| 49 | |
| 50 | @Test |
| 51 | public void testServe() throws IOException { |
| 52 | Data in = new Data(new Name("/test/prefix/serve")); |
| 53 | in.setContent(new Blob("1234")); |
| 54 | instance.serve(in); |
| 55 | Data out = SegmentedClient.getDefault().getSync(face, new Name("/test/prefix/serve")); |
| 56 | assertEquals(in.getContent(), out.getContent()); |
| 57 | assertEquals(in.getName().toUri(), out.getName().toUri()); |
| 58 | assertEquals("1234", out.getContent().toString()); |
| 59 | } |
| 60 | } |