Initial import.
[clinton/mirror/jspi/.git] / jspi / src / main / java / de / lohndirekt / print / IppPrintServiceLookupTest.java
CommitLineData
3ea135bb 1package de.lohndirekt.print;\r
2\r
3import java.util.Locale;\r
4\r
5import javax.print.DocFlavor;\r
6import javax.print.PrintService;\r
7import javax.print.attribute.AttributeSet;\r
8import javax.print.attribute.HashAttributeSet;\r
9import javax.print.attribute.standard.RequestingUserName;\r
10\r
11import de.lohndirekt.print.attribute.auth.RequestingUserPassword;\r
12\r
13import junit.framework.TestCase;\r
14\r
15/**\r
16 * @author bpusch\r
17 *\r
18 */\r
19public class IppPrintServiceLookupTest extends TestCase {\r
20\r
21 /**\r
22 * Constructor for IppPrintServiceLookupTest.\r
23 * @param name\r
24 */\r
25 public IppPrintServiceLookupTest(String name) {\r
26 super(name);\r
27 }\r
28\r
29 /*\r
30 * @see TestCase#setUp()\r
31 */\r
32 protected void setUp() throws Exception {\r
33 super.setUp();\r
34 //setting cups properties\r
35 System.getProperties().setProperty(IppPrintServiceLookup.URI_KEY, Messages.getString("cups.uri")); //$NON-NLS-1$\r
36 System.getProperties().setProperty(IppPrintServiceLookup.USERNAME_KEY, Messages.getString("cups.username")); //$NON-NLS-1$\r
37 System.getProperties().setProperty(IppPrintServiceLookup.PASSWORD_KEY, Messages.getString("cups.password")); //$NON-NLS-1$\r
38 System.getProperties().setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog"); //$NON-NLS-1$\r
39 System.getProperties().setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");\r
40 System.getProperties().setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug");\r
41 System.getProperties().setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");\r
42 }\r
43\r
44// public void testGetServices(){\r
45// PrintService[] services = new IppPrintServiceLookup().getPrintServices(DocFlavor.INPUT_STREAM.POSTSCRIPT ,null);\r
46// assertTrue(services.length>0);\r
47// \r
48// //IppPrintServiceLookup must not return any pageable enabled services\r
49// services = new IppPrintServiceLookup().getPrintServices(DocFlavor.SERVICE_FORMATTED.PAGEABLE, null);\r
50// assertEquals(0,services.length);\r
51// }\r
52 \r
53 \r
54 \r
55 public void testGetServicesAuthenticated(){\r
56 RequestingUserName user = new RequestingUserName(Messages.getString("cups.username"), Locale.GERMANY);\r
57 RequestingUserPassword pass = new RequestingUserPassword(Messages.getString("cups.password"), Locale.GERMANY);\r
58 \r
59 AttributeSet set = new HashAttributeSet();\r
60 set.add(user);\r
61 set.add(pass);\r
62 \r
63 PrintService[] services = new IppPrintServiceLookup().getPrintServices(DocFlavor.INPUT_STREAM.POSTSCRIPT ,null);\r
64 assertTrue(services.length>0);\r
65 \r
66 \r
67 }\r
68}\r