You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by de...@apache.org on 2013/11/21 20:50:03 UTC

svn commit: r1544301 - in /uima/sandbox/uima-ducc/trunk/uima-ducc-common/src: main/java/org/apache/uima/ducc/common/crypto/ test/java/org/ test/java/org/apache/ test/java/org/apache/uima/ test/java/org/apache/uima/ducc/ test/java/org/apache/uima/ducc/c...

Author: degenaro
Date: Thu Nov 21 19:50:03 2013
New Revision: 1544301

URL: http://svn.apache.org/r1544301
Log:
UIMA-3442 DUCC pre-R1.0 has classes that look like tests in the main?

Added:
    uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/test/java/org/
    uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/test/java/org/apache/
    uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/test/java/org/apache/uima/
    uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/test/java/org/apache/uima/ducc/
    uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/test/java/org/apache/uima/ducc/common/
    uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/test/java/org/apache/uima/ducc/common/test/
    uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/test/java/org/apache/uima/ducc/common/test/CryptoTest.java
Modified:
    uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/crypto/Crypto.java

Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/crypto/Crypto.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/crypto/Crypto.java?rev=1544301&r1=1544300&r2=1544301&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/crypto/Crypto.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/crypto/Crypto.java Thu Nov 21 19:50:03 2013
@@ -381,25 +381,4 @@ public class Crypto implements ICrypto {
 		}
 	}
 	
-	/* <test> */
-	
-	public static void main(String[] args) {
-		try {
-			Crypto crypto = new Crypto(System.getProperty("user"),System.getProperty("user.home"));
-			String message = "Hello DUCC!";
-			byte[] cypheredMessage = crypto.encrypt(message);
-			Properties properties = new Properties();
-			String key_signature = "signature";
-			properties.put(key_signature, cypheredMessage);
-			cypheredMessage = (byte[]) properties.get(key_signature);
-			Object decypheredMessage = crypto.decrypt(cypheredMessage);
-			System.out.println((String)decypheredMessage);
-		}
-		catch(CryptoException e) {
-			e.printStackTrace();
-		}
-	}
-
-	/* </test> */
-	
 }

Added: uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/test/java/org/apache/uima/ducc/common/test/CryptoTest.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/test/java/org/apache/uima/ducc/common/test/CryptoTest.java?rev=1544301&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/test/java/org/apache/uima/ducc/common/test/CryptoTest.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/test/java/org/apache/uima/ducc/common/test/CryptoTest.java Thu Nov 21 19:50:03 2013
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.uima.ducc.common.test;
+
+import static org.junit.Assert.*;
+
+import java.util.Properties;
+
+import org.apache.uima.ducc.common.crypto.Crypto;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class CryptoTest {
+
+	@BeforeClass
+	public static void setUpBeforeClass() throws Exception {
+	}
+
+	@AfterClass
+	public static void tearDownAfterClass() throws Exception {
+	}
+
+	@Before
+	public void setUp() throws Exception {
+	}
+
+	@After
+	public void tearDown() throws Exception {
+	}
+
+	@Test
+	public void test() {
+		try {
+			String user = System.getProperty("user.name");
+			String home = System.getProperty("user.home");
+			Crypto crypto = new Crypto(user,home);
+			String message = "Hello DUCC!";
+			byte[] cypheredMessage = crypto.encrypt(message);
+			Properties properties = new Properties();
+			String key_signature = "signature";
+			properties.put(key_signature, cypheredMessage);
+			cypheredMessage = (byte[]) properties.get(key_signature);
+			Object decypheredMessage = crypto.decrypt(cypheredMessage);
+			if(!message.equals(decypheredMessage)) {
+				System.out.println("user="+user);
+				System.out.println("home="+home);
+				System.out.println("message="+(String)message);
+				System.out.println("decypher="+(String)decypheredMessage);
+				fail("decypher mismatch?!");
+			}
+		}
+		catch(Exception e) {
+			e.printStackTrace();
+			fail("Exception");
+		}
+	}
+
+}