fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [6845] Some trivial tests


From: Petur Thorsteinsson
Subject: [Fmsystem-commits] [6845] Some trivial tests
Date: Wed, 26 Jan 2011 08:25:55 +0000

Revision: 6845
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=6845
Author:   peturbjorn
Date:     2011-01-26 08:25:55 +0000 (Wed, 26 Jan 2011)
Log Message:
-----------
Some trivial tests

Added Paths:
-----------
    thirdparty/BIM_converter/trunk/src/no/ifc/rest/TestingService.java
    thirdparty/BIM_converter/trunk/src/test/LogTest.java

Added: thirdparty/BIM_converter/trunk/src/no/ifc/rest/TestingService.java
===================================================================
--- thirdparty/BIM_converter/trunk/src/no/ifc/rest/TestingService.java          
                (rev 0)
+++ thirdparty/BIM_converter/trunk/src/no/ifc/rest/TestingService.java  
2011-01-26 08:25:55 UTC (rev 6845)
@@ -0,0 +1,91 @@
+package no.ifc.rest;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.sun.jersey.core.header.FormDataContentDisposition;
+import com.sun.jersey.multipart.FormDataParam;
+
+/*
+ * Used for testing rest service client
+ */
address@hidden("/tests")
+public class TestingService {
+       private Logger logger = 
LoggerFactory.getLogger("no.ifc.rest.TestingService");
+       
+       
+       public TestingService() {
+               
+       }
+       @Path("/testPut")
+       @POST
+       @Consumes("multipart/form-data")
+       @Produces(MediaType.TEXT_HTML)
+       //public String executePutTest( @Context HttpHeaders headers, 
InputStream in) {
+       public String uploadFile(@FormDataParam("file") InputStream in) {
+               logger.info("executePutTest has been called!");
+               System.out.println("stuff");
+               //URI uri = uriInfo.getAbsolutePath();
+        //MediaType mimeType = headers.getMediaType();
+        //logger.info("Mediatype is:"+mimeType.getType());
+        magic(in);
+        
+        
+        return "Put request success";
+       }
+       
+       private void magic(InputStream in) {
+               File destFile = new File("mytestFile.txt");
+               try {
+                       System.out.println(destFile.getCanonicalPath());
+               } catch (IOException e1) {
+                       // TODO Auto-generated catch block
+                       e1.printStackTrace();
+               }
+               
+               // your code here to copy file to destFile
+               
+               
+               OutputStream out;
+               try {
+                       out = new FileOutputStream(destFile);
+                       byte[] buf = new byte[1024];
+                       int len;
+                       while ((len = in.read(buf)) > 0){
+                               out.write(buf, 0, len);
+                       }
+                       //file.close();
+                       in.close();
+                       out.close();
+                       logger.info("Upload success!");
+               } catch (FileNotFoundException e) {
+                       logger.error("Upload failure (fnf)!");
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       logger.error("Upload failure (io)!");
+                       e.printStackTrace();
+               }
+       }
+       
+}

Added: thirdparty/BIM_converter/trunk/src/test/LogTest.java
===================================================================
--- thirdparty/BIM_converter/trunk/src/test/LogTest.java                        
        (rev 0)
+++ thirdparty/BIM_converter/trunk/src/test/LogTest.java        2011-01-26 
08:25:55 UTC (rev 6845)
@@ -0,0 +1,20 @@
+package test;
+
+
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
+
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.core.util.StatusPrinter;
+
+public class LogTest {
+       public static void main(String[] args) {
+               Logger logger = LoggerFactory.getLogger("test.LogTest");
+               logger.debug("Helllooooooooo world");
+               
+               LoggerContext lc = (LoggerContext) 
LoggerFactory.getILoggerFactory();
+           StatusPrinter.print(lc);
+
+       }
+
+}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]