1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.properties.internal.converter

File InputStreamConverterTest.java

 

Code metrics

0
4
3
1
63
32
3
0.75
1.33
3
1

Classes

Class Line # Actions
InputStreamConverterTest 38 4 0% 3 0
1.0100%
 

Contributing tests

This file is covered by 2 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.properties.internal.converter;
21   
22    import java.io.IOException;
23    import java.io.InputStream;
24    import java.util.Arrays;
25   
26    import org.apache.commons.io.IOUtils;
27    import org.junit.Assert;
28    import org.junit.Before;
29    import org.junit.Test;
30    import org.xwiki.properties.ConverterManager;
31    import org.xwiki.test.jmock.AbstractComponentTestCase;
32   
33    /**
34    * Validate {@link InputStreamConverter} component.
35    *
36    * @version $Id: bf210447a1e0a2afbe983e3d98f769e4c0ecc524 $
37    */
 
38    public class InputStreamConverterTest extends AbstractComponentTestCase
39    {
40    private ConverterManager converterManager;
41   
 
42  2 toggle @Before
43    @Override
44    public void setUp() throws Exception
45    {
46  2 super.setUp();
47   
48  2 this.converterManager = getComponentManager().getInstance(ConverterManager.class);
49    }
50   
 
51  1 toggle @Test
52    public void testFromString() throws IOException
53    {
54  1 Assert.assertTrue(Arrays.equals(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 },
55    IOUtils.toByteArray(this.converterManager.<InputStream>convert(InputStream.class, "1,2,3,4,5,6,7,8,9"))));
56    }
57   
 
58  1 toggle @Test
59    public void testConvertNull()
60    {
61  1 Assert.assertNull(this.converterManager.convert(InputStream.class, null));
62    }
63    }