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