incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1042629 - in /incubator/isis/trunk/alternatives/objectstore/nosql/src: main/java/org/apache/isis/alternatives/objectstore/nosql/file/server/ test/java/org/apache/isis/alternatives/objectstore/nosql/file/server/
Date Mon, 06 Dec 2010 13:23:49 GMT
Author: danhaywood
Date: Mon Dec  6 13:23:48 2010
New Revision: 1042629

URL: http://svn.apache.org/viewvc?rev=1042629&view=rev
Log:
shutting down resources at end of NoSQL test to ensure passes on Windows.

Modified:
    incubator/isis/trunk/alternatives/objectstore/nosql/src/main/java/org/apache/isis/alternatives/objectstore/nosql/file/server/ServerConnection.java
    incubator/isis/trunk/alternatives/objectstore/nosql/src/test/java/org/apache/isis/alternatives/objectstore/nosql/file/server/FileServerTest.java
    incubator/isis/trunk/alternatives/objectstore/nosql/src/test/java/org/apache/isis/alternatives/objectstore/nosql/file/server/LogWriterTest.java

Modified: incubator/isis/trunk/alternatives/objectstore/nosql/src/main/java/org/apache/isis/alternatives/objectstore/nosql/file/server/ServerConnection.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/alternatives/objectstore/nosql/src/main/java/org/apache/isis/alternatives/objectstore/nosql/file/server/ServerConnection.java?rev=1042629&r1=1042628&r2=1042629&view=diff
==============================================================================
--- incubator/isis/trunk/alternatives/objectstore/nosql/src/main/java/org/apache/isis/alternatives/objectstore/nosql/file/server/ServerConnection.java
(original)
+++ incubator/isis/trunk/alternatives/objectstore/nosql/src/main/java/org/apache/isis/alternatives/objectstore/nosql/file/server/ServerConnection.java
Mon Dec  6 13:23:48 2010
@@ -17,7 +17,6 @@
  *  under the License.
  */
 
-
 package org.apache.isis.alternatives.objectstore.nosql.file.server;
 
 import java.io.BufferedReader;
@@ -28,10 +27,9 @@ import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 
-import org.apache.log4j.Logger;
 import org.apache.isis.alternatives.objectstore.nosql.NoSqlStoreException;
 import org.apache.isis.alternatives.objectstore.nosql.file.RemotingException;
-
+import org.apache.log4j.Logger;
 
 public class ServerConnection {
 
@@ -39,8 +37,8 @@ public class ServerConnection {
 
     private final BufferedReader reader;
     private final PrintWriter writer;
-    private OutputStream outputStream;
-    private InputStream inputStream;
+    private final OutputStream outputStream;
+    private final InputStream inputStream;
     private int header;
     private String[] headers;
     private char command;
@@ -175,4 +173,3 @@ public class ServerConnection {
     }
 
 }
-

Modified: incubator/isis/trunk/alternatives/objectstore/nosql/src/test/java/org/apache/isis/alternatives/objectstore/nosql/file/server/FileServerTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/alternatives/objectstore/nosql/src/test/java/org/apache/isis/alternatives/objectstore/nosql/file/server/FileServerTest.java?rev=1042629&r1=1042628&r2=1042629&view=diff
==============================================================================
--- incubator/isis/trunk/alternatives/objectstore/nosql/src/test/java/org/apache/isis/alternatives/objectstore/nosql/file/server/FileServerTest.java
(original)
+++ incubator/isis/trunk/alternatives/objectstore/nosql/src/test/java/org/apache/isis/alternatives/objectstore/nosql/file/server/FileServerTest.java
Mon Dec  6 13:23:48 2010
@@ -17,9 +17,17 @@
  *  under the License.
  */
 
-
 package org.apache.isis.alternatives.objectstore.nosql.file.server;
 
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.startsWith;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -27,22 +35,11 @@ import java.io.FileWriter;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 
-import org.apache.isis.alternatives.objectstore.nosql.file.server.FileServerProcessor;
-import org.apache.isis.alternatives.objectstore.nosql.file.server.ServerConnection;
-import org.apache.isis.alternatives.objectstore.nosql.file.server.Util;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.startsWith;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
-
 public class FileServerTest {
     private FileServerProcessor server;
     private File logFile1;
@@ -59,7 +56,8 @@ public class FileServerTest {
     @Before
     public void startup() {
         logFile1 = new File("target/test/logs", "recovery0.log");
-        logFile1.delete();
+        String absolutePath = logFile1.getAbsolutePath();
+        boolean delete = logFile1.delete();
         assertFalse(logFile1.exists());
         logFile2 = new File("target/test/logs", "recovery1.log");
         logFile2.delete();
@@ -72,8 +70,9 @@ public class FileServerTest {
     }
 
     @After
-    public void shutdown() {
-        server.shutdown();
+    public void tearDown() throws Exception {
+        if (server != null)
+            server.shutdown();
     }
 
     @Test
@@ -96,7 +95,8 @@ public class FileServerTest {
         assertFalse(file1.exists());
         assertFalse(file2.exists());
 
-        InputStream in = inputStream("W\nIorg.domain.Class 1025 null 1  \n{data1}\n\nIorg.domain.Class
1026 null 1\n{data2}\n");
+        InputStream in =
+            inputStream("W\nIorg.domain.Class 1025 null 1  \n{data1}\n\nIorg.domain.Class
1026 null 1\n{data2}\n");
         ServerConnection connection = new ServerConnection(in, out);
         server.process(connection);
         assertEquals("ok\n", out.toString());
@@ -118,7 +118,8 @@ public class FileServerTest {
         fileWriter.write(originalData);
         fileWriter.close();
 
-        ServerConnection connection = new ServerConnection(inputStream("W\nUorg.domain.Class
1026 21 22 \n{data2}\n"), out);
+        ServerConnection connection =
+            new ServerConnection(inputStream("W\nUorg.domain.Class 1026 21 22 \n{data2}\n"),
out);
         server.process(connection);
         assertEquals("ok\n", out.toString());
         assertTrue(file2.length() > originalData.length());
@@ -132,14 +133,16 @@ public class FileServerTest {
         fileWriter.write(originalData);
         fileWriter.close();
 
-        ServerConnection connection = new ServerConnection(inputStream("W\nUorg.domain.Class
1026 19 21 \n{data2}\n"), out);
+        ServerConnection connection =
+            new ServerConnection(inputStream("W\nUorg.domain.Class 1026 19 21 \n{data2}\n"),
out);
         server.process(connection);
         assertEquals("error\n{datax}\n", out.toString());
     }
 
     @Test
     public void writeCreatesLogFile() throws Exception {
-        ServerConnection connection = new ServerConnection(inputStream("W\nIorg.domain.Class
1025 6 7\n{data1}\n"), out);
+        ServerConnection connection =
+            new ServerConnection(inputStream("W\nIorg.domain.Class 1025 6 7\n{data1}\n"),
out);
         server.process(connection);
 
         assertEquals("ok\n", out.toString());
@@ -151,11 +154,11 @@ public class FileServerTest {
     public void readNonExistingFileThrowsException() throws Exception {
         File file1 = new File("target/test/org.domain.Class", "2020.data");
         file1.delete();
-            ServerConnection connection = new ServerConnection(inputStream("Rorg.domain.Class
2020"), out);
-            server.process(connection);
-            
-            assertThat(out.toString(), startsWith("error\n"));
-            assertThat(out.toString(), containsString("File not found for org.domain.Class
& 2020"));
+        ServerConnection connection = new ServerConnection(inputStream("Rorg.domain.Class
2020"), out);
+        server.process(connection);
+
+        assertThat(out.toString(), startsWith("error\n"));
+        assertThat(out.toString(), containsString("File not found for org.domain.Class &
2020"));
     }
 
     @Test
@@ -167,8 +170,7 @@ public class FileServerTest {
 
         ServerConnection connection = new ServerConnection(inputStream("Rorg.domain.Class
2025"), out);
         server.process(connection);
-        assertEquals("ok\n{data1}\n", out.toString());
+        assertThat("ok\n{data1}\n".toCharArray(), is(equalTo(new String(out.toString()).toCharArray())));
     }
 
 }
-

Modified: incubator/isis/trunk/alternatives/objectstore/nosql/src/test/java/org/apache/isis/alternatives/objectstore/nosql/file/server/LogWriterTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/alternatives/objectstore/nosql/src/test/java/org/apache/isis/alternatives/objectstore/nosql/file/server/LogWriterTest.java?rev=1042629&r1=1042628&r2=1042629&view=diff
==============================================================================
--- incubator/isis/trunk/alternatives/objectstore/nosql/src/test/java/org/apache/isis/alternatives/objectstore/nosql/file/server/LogWriterTest.java
(original)
+++ incubator/isis/trunk/alternatives/objectstore/nosql/src/test/java/org/apache/isis/alternatives/objectstore/nosql/file/server/LogWriterTest.java
Mon Dec  6 13:23:48 2010
@@ -17,28 +17,23 @@
  *  under the License.
  */
 
-
 package org.apache.isis.alternatives.objectstore.nosql.file.server;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.isis.alternatives.objectstore.nosql.file.server.DataWriter;
-import org.apache.isis.alternatives.objectstore.nosql.file.server.FileContent;
-import org.apache.isis.alternatives.objectstore.nosql.file.server.LogWriter;
-import org.apache.isis.alternatives.objectstore.nosql.file.server.Util;
+import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-
 public class LogWriterTest {
 
     private LogWriter logger;
@@ -66,7 +61,13 @@ public class LogWriterTest {
 
         items = new ArrayList<FileContent>();
         items.add(new FileContent('U', "20", "6", "7", "type", "{data}"));
-       new DataWriter(items);
+        new DataWriter(items);
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        if (logger != null)
+            logger.shutdown();
     }
 
     @Test
@@ -78,12 +79,12 @@ public class LogWriterTest {
     @Test
     public void logsData() throws Exception {
         logger.log(items);
-        
+
         BufferedReader reader = new BufferedReader(new FileReader(logFile1));
         String line = reader.readLine();
         line = reader.readLine();
         reader.close();
-        
+
         Assert.assertEquals("Utype 20 6 {data}", line);
     }
 
@@ -102,4 +103,3 @@ public class LogWriterTest {
         assertTrue(logFile2.exists() && logFile1.length() > 0);
     }
 }
-



Mime
View raw message