3ea135bb |
1 | /**\r |
2 | * Copyright (C) 2003 <a href="http://www.lohndirekt.de/">lohndirekt.de</a>\r |
3 | *\r |
4 | * This library is free software; you can redistribute it and/or\r |
5 | * modify it under the terms of the GNU Lesser General Public\r |
6 | * License as published by the Free Software Foundation; either\r |
7 | * version 2.1 of the License, or (at your option) any later version.\r |
8 | * \r |
9 | * This library is distributed in the hope that it will be useful,\r |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of\r |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r |
12 | * Lesser General Public License for more details.\r |
13 | * \r |
14 | * You should have received a copy of the GNU Lesser General Public\r |
15 | * License along with this library; if not, write to the Free Software\r |
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r |
17 | * \r |
18 | */\r |
19 | package de.lohndirekt.print.test;\r |
20 | \r |
21 | import java.io.IOException;\r |
22 | import java.net.URI;\r |
23 | import java.net.URISyntaxException;\r |
24 | import java.util.Iterator;\r |
25 | import java.util.Locale;\r |
26 | import java.util.Map;\r |
27 | import java.util.Set;\r |
28 | \r |
29 | import javax.print.attribute.Attribute;\r |
30 | \r |
31 | import junit.framework.TestCase;\r |
32 | import de.lohndirekt.print.IppRequest;\r |
33 | import de.lohndirekt.print.attribute.IppAttributeName;\r |
34 | import de.lohndirekt.print.attribute.ipp.UnknownAttribute;\r |
35 | import de.lohndirekt.print.attribute.ipp.printerdesc.supported.OperationsSupported;\r |
36 | \r |
37 | /**\r |
38 | * @author bpusch\r |
39 | *\r |
40 | * \r |
41 | */\r |
42 | public class IppRequestTestImplTest extends TestCase {\r |
43 | \r |
44 | public void testSendGetPrinterAttributes() throws URISyntaxException, IOException {\r |
45 | Class unknownAttributeCategory = new UnknownAttribute("x", Locale.getDefault()).getCategory();\r |
46 | IppRequest request = new IppRequestTestImpl(new URI("http://127.0.0.1"), OperationsSupported.GET_PRINTER_ATTRIBUTES);\r |
47 | Map attributes = request.send().getAttributes();\r |
48 | for (Iterator iter = attributes.keySet().iterator(); iter.hasNext();) {\r |
49 | Class category = (Class) iter.next();\r |
50 | //Should not return any unknown Attributes\r |
51 | assertFalse(category.equals(unknownAttributeCategory));\r |
52 | Set attrs = (Set) attributes.get(category);\r |
53 | assertNotNull(attrs);\r |
54 | for (Iterator iterator = attrs.iterator(); iterator.hasNext();) {\r |
55 | Attribute element = (Attribute) iterator.next();\r |
56 | assertEquals(category, element.getCategory());\r |
57 | }\r |
58 | }\r |
59 | }\r |
60 | \r |
61 | public void testSendCupsGetPrinter() throws URISyntaxException, IOException {\r |
62 | IppRequest request = new IppRequestTestImpl(new URI("http://127.0.0.1"), OperationsSupported.CUPS_GET_PRINTERS);\r |
63 | Map attributes = request.send().getAttributes();\r |
64 | assertTrue("Response must contain an attribute of category printer-uri-spported",attributes.containsKey(IppAttributeName.PRINTER_URI_SUPPORTED.getCategory()));\r |
65 | }\r |
66 | \r |
67 | public void testGetResponse() throws URISyntaxException, IOException {\r |
68 | //response is now returned by send()\r |
69 | }\r |
70 | \r |
71 | }\r |