Initial import.
[clinton/mirror/jspi/.git] / jspi / src / main / java / de / lohndirekt / print / IppPrintServiceLookupTest.java
diff --git a/jspi/src/main/java/de/lohndirekt/print/IppPrintServiceLookupTest.java b/jspi/src/main/java/de/lohndirekt/print/IppPrintServiceLookupTest.java
new file mode 100644 (file)
index 0000000..e0d7643
--- /dev/null
@@ -0,0 +1,68 @@
+package de.lohndirekt.print;\r
+\r
+import java.util.Locale;\r
+\r
+import javax.print.DocFlavor;\r
+import javax.print.PrintService;\r
+import javax.print.attribute.AttributeSet;\r
+import javax.print.attribute.HashAttributeSet;\r
+import javax.print.attribute.standard.RequestingUserName;\r
+\r
+import de.lohndirekt.print.attribute.auth.RequestingUserPassword;\r
+\r
+import junit.framework.TestCase;\r
+\r
+/**\r
+ * @author bpusch\r
+ *\r
+ */\r
+public class IppPrintServiceLookupTest extends TestCase {\r
+\r
+       /**\r
+        * Constructor for IppPrintServiceLookupTest.\r
+        * @param name\r
+        */\r
+       public IppPrintServiceLookupTest(String name) {\r
+               super(name);\r
+       }\r
+\r
+       /*\r
+        * @see TestCase#setUp()\r
+        */\r
+       protected void setUp() throws Exception {\r
+               super.setUp();\r
+               //setting cups properties\r
+               System.getProperties().setProperty(IppPrintServiceLookup.URI_KEY, Messages.getString("cups.uri")); //$NON-NLS-1$\r
+               System.getProperties().setProperty(IppPrintServiceLookup.USERNAME_KEY, Messages.getString("cups.username")); //$NON-NLS-1$\r
+               System.getProperties().setProperty(IppPrintServiceLookup.PASSWORD_KEY, Messages.getString("cups.password")); //$NON-NLS-1$\r
+               System.getProperties().setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog"); //$NON-NLS-1$\r
+               System.getProperties().setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");\r
+               System.getProperties().setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug");\r
+               System.getProperties().setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");\r
+       }\r
+\r
+//     public void testGetServices(){\r
+//             PrintService[] services = new IppPrintServiceLookup().getPrintServices(DocFlavor.INPUT_STREAM.POSTSCRIPT ,null);\r
+//             assertTrue(services.length>0);\r
+//             \r
+//             //IppPrintServiceLookup must not return any pageable enabled services\r
+//             services = new IppPrintServiceLookup().getPrintServices(DocFlavor.SERVICE_FORMATTED.PAGEABLE, null);\r
+//             assertEquals(0,services.length);\r
+//     }\r
+       \r
+       \r
+       \r
+       public void testGetServicesAuthenticated(){\r
+               RequestingUserName user = new RequestingUserName(Messages.getString("cups.username"), Locale.GERMANY);\r
+               RequestingUserPassword pass = new RequestingUserPassword(Messages.getString("cups.password"), Locale.GERMANY);\r
+               \r
+               AttributeSet set = new HashAttributeSet();\r
+               set.add(user);\r
+               set.add(pass);\r
+               \r
+               PrintService[] services = new IppPrintServiceLookup().getPrintServices(DocFlavor.INPUT_STREAM.POSTSCRIPT ,null);\r
+               assertTrue(services.length>0);\r
+               \r
+               \r
+       }\r
+}\r