harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r660326 [14/17] - in /harmony/enhanced/microemulator: ./ microemu-android/ microemu-android/src/ microemu-android/src/org/ microemu-android/src/org/microemu/ microemu-android/src/org/microemu/android/ microemu-android/src/org/microemu/andro...
Date Mon, 26 May 2008 22:21:57 GMT
Added: harmony/enhanced/microemulator/microemu-javase/src/main/resources/org/microemu/device/default/device.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase/src/main/resources/org/microemu/device/default/device.xml?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase/src/main/resources/org/microemu/device/default/device.xml (added)
+++ harmony/enhanced/microemulator/microemu-javase/src/main/resources/org/microemu/device/default/device.xml Mon May 26 15:20:19 2008
@@ -0,0 +1,444 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<device name="Default device"
+		xmlns="http://www.microemu.org/2.0.2/"
+		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+		xsi:schemaLocation="http://www.microemu.org/2.0.2/ http://www.microemu.org/2.0.2/device.xsd">
+    <system-properties>
+        <system-property name="microedition.platform" value="MicroEmulator-2.0" />
+    </system-properties>
+	<img name="normal" src="normal.png" />
+	<img name="over" src="over.png" />
+	<img name="pressed" src="pressed.png" />
+	<display>
+		<iscolor>true</iscolor>
+		<numcolors>65536</numcolors>
+		<numalphalevels>256</numalphalevels>
+		<foreground>000000</foreground>
+		<background>ffffff</background>
+		<rectangle>
+			<x>26</x>
+			<y>44</y>
+			<width>176</width>
+			<height>220</height>
+		</rectangle>
+		<paintable>
+			<x>0</x>
+			<y>22</y>
+			<width>176</width>
+			<height>176</height>
+		</paintable>
+		<icon name="up">
+			<paintable>
+				<x>78</x>
+				<y>206</y>
+				<width>12</width>
+				<height>12</height>
+			</paintable>
+			<img name="normal" src="up.png" />
+			<img name="pressed" src="up-pressed.png" />
+		</icon>
+		<icon name="down">
+			<paintable>
+				<x>88</x>
+				<y>206</y>
+				<width>12</width>
+				<height>12</height>
+			</paintable>
+			<img name="normal" src="down.png" />
+			<img name="pressed" src="down-pressed.png" />
+		</icon>
+		<status name="input">
+			<paintable>
+			    <!-- 22/2-7  -->
+				<x>4</x>
+				<y>4</y>
+				<width>14</width>
+				<height>7</height>
+			</paintable>
+			<img name="123" src="123.png" />
+			<img name="ABC" src="abc_upper.png" />
+			<img name="abc" src="abc_lower.png" />
+		</status>
+	</display>
+	<fonts hint="antialiasing">
+		<font face="system" style="plain" size="small">
+			<system name="SansSerif" style="plain" size="9" />
+		</font>
+		<font face="system" style="plain" size="medium">
+			<system name="SansSerif" style="plain" size="11" />
+		</font>
+		<font face="system" style="plain" size="large">
+			<system name="SansSerif" style="plain" size="13" />
+		</font>
+		<font face="system" style="bold" size="small">
+			<system name="SansSerif" style="bold" size="9" />
+		</font>
+		<font face="system" style="bold" size="medium">
+			<system name="SansSerif" style="bold" size="11" />
+		</font>
+		<font face="system" style="bold" size="large">
+			<system name="SansSerif" style="bold" size="13" />
+		</font>
+		<font face="system" style="italic" size="small">
+			<system name="SansSerif" style="italic" size="9" />
+		</font>
+		<font face="system" style="italic" size="medium">
+			<system name="SansSerif" style="italic" size="11" />
+		</font>
+		<font face="system" style="italic" size="large">
+			<system name="SansSerif" style="italic" size="13" />
+		</font>
+		<font face="system" style="bold,italic" size="small">
+			<system name="SansSerif" style="bold,italic" size="9" />
+		</font>
+		<font face="system" style="bold,italic" size="medium">
+			<system name="SansSerif" style="bold,italic" size="11" />
+		</font>
+		<font face="system" style="bold,italic" size="large">
+			<system name="SansSerif" style="bold,italic" size="13" />
+		</font>
+		<font face="monospace" style="plain" size="small">
+			<system name="Monospaced" style="plain" size="9" />
+		</font>
+		<font face="monospace" style="plain" size="medium">
+			<system name="Monospaced" style="plain" size="11" />
+		</font>
+		<font face="monospace" style="plain" size="large">
+			<system name="Monospaced" style="plain" size="13" />
+		</font>
+		<font face="monospace" style="bold" size="small">
+			<system name="Monospaced" style="bold" size="9" />
+		</font>
+		<font face="monospace" style="bold" size="medium">
+			<system name="Monospaced" style="bold" size="11" />
+		</font>
+		<font face="monospace" style="bold" size="large">
+			<system name="Monospaced" style="bold" size="13" />
+		</font>
+		<font face="monospace" style="italic" size="small">
+			<system name="Monospaced" style="italic" size="9" />
+		</font>
+		<font face="monospace" style="italic" size="medium">
+			<system name="Monospaced" style="italic" size="11" />
+		</font>
+		<font face="monospace" style="italic" size="large">
+			<system name="Monospaced" style="italic" size="13" />
+		</font>
+		<font face="monospace" style="bold,italic" size="small">
+			<system name="Monospaced" style="bold,italic" size="9" />
+		</font>
+		<font face="monospace" style="bold,italic" size="medium">
+			<system name="Monospaced" style="bold,italic" size="11" />
+		</font>
+		<font face="monospace" style="bold,italic" size="large">
+			<system name="Monospaced" style="bold,italic" size="13" />
+		</font>
+		<font face="proportional" style="plain" size="small">
+			<system name="SansSerif" style="plain" size="9" />
+		</font>
+		<font face="proportional" style="plain" size="medium">
+			<system name="SansSerif" style="plain" size="11" />
+		</font>
+		<font face="proportional" style="plain" size="large">
+			<system name="SansSerif" style="plain" size="13" />
+		</font>
+		<font face="proportional" style="bold" size="small">
+			<system name="SansSerif" style="bold" size="9" />
+		</font>
+		<font face="proportional" style="bold" size="medium">
+			<system name="SansSerif" style="bold" size="11" />
+		</font>
+		<font face="proportional" style="bold" size="large">
+			<system name="SansSerif" style="bold" size="13" />
+		</font>
+		<font face="proportional" style="italic" size="small">
+			<system name="SansSerif" style="italic" size="9" />
+		</font>
+		<font face="proportional" style="italic" size="medium">
+			<system name="SansSerif" style="italic" size="11" />
+		</font>
+		<font face="proportional" style="italic" size="large">
+			<system name="SansSerif" style="italic" size="13" />
+		</font>
+		<font face="proportional" style="bold,italic" size="small">
+			<system name="SansSerif" style="bold,italic" size="9" />
+		</font>
+		<font face="proportional" style="bold,italic" size="medium">
+			<system name="SansSerif" style="bold,italic" size="11" />
+		</font>
+		<font face="proportional" style="bold,italic" size="large">
+			<system name="SansSerif" style="bold,italic" size="13" />
+		</font>
+	</fonts>
+	<input>
+		<haspointerevents>true</haspointerevents>
+		<haspointermotionevents>true</haspointermotionevents>
+		<hasrepeatevents>true</hasrepeatevents>
+		<softbutton name="SOFT1" alignment="LEFT">
+			<rectangle>
+				<x>16</x>
+				<y>282</y>
+				<width>60</width>
+				<height>35</height>
+			</rectangle>
+			<paintable>
+				<x>1</x>
+				<y>203</y>
+				<width>69</width>
+				<height>16</height>
+			</paintable>
+			<font face="system" style="plain" size="medium" />
+			<command>BACK</command>
+			<command>EXIT</command>
+			<command>CANCEL</command>
+			<command>STOP</command>
+		</softbutton>
+		<softbutton name="SOFT2" alignment="RIGHT">
+			<rectangle>
+				<x>154</x>
+				<y>282</y>
+				<width>60</width>
+				<height>35</height>
+			</rectangle>
+			<paintable>
+				<x>106</x>
+				<y>203</y>
+				<width>69</width>
+				<height>16</height>
+			</paintable>
+			<font face="system" style="plain" size="medium" />
+			<command>OK</command>
+			<command>SCREEN</command>
+			<command>ITEM</command>
+			<command>HELP</command>
+		</softbutton>
+		<button name="LEFT">
+            <polygon>
+				<point x="74" y="301" />
+				<point x="89" y="279" />
+				<point x="103" y="301" />
+				<point x="89" y="322" />
+			</polygon>
+		</button>
+		<button name="RIGHT">
+            <polygon>
+				<point x="140" y="280" />
+				<point x="154" y="300"/>
+				<point x="140" y="320" />
+				<point x="126" y="300"/>
+			</polygon>
+		</button>
+		<button name="UP">
+			<rectangle>
+				<x>97</x>
+				<y>274</y>
+				<width>36</width>
+				<height>14</height>
+			</rectangle>
+		</button>
+		<button name="DOWN">
+			<rectangle>
+				<x>97</x>
+				<y>311</y>
+				<width>36</width>
+				<height>14</height>
+			</rectangle>
+		</button>
+		<button name="SELECT">
+			<rectangle>
+				<x>101</x>
+				<y>288</y>
+				<width>25</width>
+				<height>23</height>
+			</rectangle>
+		</button>
+		<button name="0">
+			<chars>
+				<char></char>
+				<char>0</char>
+			</chars>
+			<rectangle>
+				<x>87</x>
+				<y>432</y>
+				<width>55</width>
+				<height>31</height>
+			</rectangle>
+		</button>
+		<button name="1">
+			<chars>
+				<char>.</char>
+				<char>,</char>
+				<char>?</char>
+				<char>!</char>
+				<char>:</char>
+				<char>;</char>
+				<char>-</char>
+				<char>+</char>
+				<char>#</char>
+				<char>*</char>
+				<char>(</char>
+				<char>)</char>
+				<char>'</char>
+				<char>"</char>
+				<char>_</char>
+				<char>@</char>
+				<char>&amp;</char>
+				<char>$</char>
+				<char>%</char>
+				<char>/</char>
+				<char>&lt;</char>
+				<char>&gt;</char>
+				<char>=</char>
+				<char>1</char>
+			</chars>
+			<chars input="123">
+				<char>1</char>
+				<char>.</char>
+				<char>-</char>
+				<char>(</char>
+				<char>)</char>
+				<char>+</char>
+			</chars>
+			<rectangle>
+				<x>19</x>
+				<y>324</y>
+				<width>55</width>
+				<height>34</height>
+			</rectangle>
+		</button>
+		<button name="2">
+			<chars>
+				<char>a</char>
+				<char>b</char>
+				<char>c</char>
+				<char>2</char>
+			</chars>
+			<rectangle>
+				<x>88</x>
+				<y>328</y>
+				<width>56</width>
+				<height>31</height>
+			</rectangle>
+		</button>
+		<button name="3">
+			<chars>
+				<char>d</char>
+				<char>e</char>
+				<char>f</char>
+				<char>3</char>
+			</chars>
+			<rectangle>
+				<x>156</x>
+				<y>323</y>
+				<width>54</width>
+				<height>32</height>
+			</rectangle>
+		</button>
+		<button name="4">
+			<chars>
+				<char>g</char>
+				<char>h</char>
+				<char>i</char>
+				<char>4</char>
+			</chars>
+			<rectangle>
+				<x>18</x>
+				<y>358</y>
+				<width>58</width>
+				<height>32</height>
+			</rectangle>
+		</button>
+		<button name="5">
+			<chars>
+				<char>j</char>
+				<char>k</char>
+				<char>l</char>
+				<char>5</char>
+			</chars>
+			<rectangle>
+				<x>87</x>
+				<y>362</y>
+				<width>59</width>
+				<height>34</height>
+			</rectangle>
+		</button>
+		<button name="6">
+			<chars>
+				<char>m</char>
+				<char>n</char>
+				<char>o</char>
+				<char>6</char>
+			</chars>
+			<rectangle>
+				<x>155</x>
+				<y>357</y>
+				<width>54</width>
+				<height>33</height>
+			</rectangle>
+		</button>
+		<button name="7">
+			<chars>
+				<char>p</char>
+				<char>q</char>
+				<char>r</char>
+				<char>s</char>
+				<char>7</char>
+			</chars>
+			<rectangle>
+				<x>17</x>
+				<y>393</y>
+				<width>55</width>
+				<height>32</height>
+			</rectangle>
+		</button>
+		<button name="8">
+			<chars>
+				<char>t</char>
+				<char>u</char>
+				<char>v</char>
+				<char>8</char>
+			</chars>
+			<rectangle>
+				<x>87</x>
+				<y>397</y>
+				<width>54</width>
+				<height>31</height>
+			</rectangle>
+		</button>
+		<button name="9">
+			<chars>
+				<char>w</char>
+				<char>x</char>
+				<char>y</char>
+				<char>z</char>
+				<char>9</char>
+			</chars>
+			<rectangle>
+				<x>156</x>
+				<y>393</y>
+				<width>56</width>
+				<height>31</height>
+			</rectangle>
+		</button>
+		<button name="ASTERISK">
+			<chars>
+				<char>*</char>
+				<char>+</char>
+			</chars>
+			<rectangle>
+				<x>18</x>
+				<y>428</y>
+				<width>54</width>
+				<height>32</height>
+			</rectangle>
+		</button>
+		<button name="POUND" modeChange="true">
+			<rectangle>
+				<x>156</x>
+				<y>427</y>
+				<width>55</width>
+				<height>32</height>
+			</rectangle>
+		</button>
+	</input>
+</device>

Propchange: harmony/enhanced/microemulator/microemu-javase/src/main/resources/org/microemu/device/default/device.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase/src/main/resources/org/microemu/device/default/down-pressed.png
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase/src/main/resources/org/microemu/device/default/down-pressed.png?rev=660326&view=auto
==============================================================================
Binary file - no diff available.

Propchange: harmony/enhanced/microemulator/microemu-javase/src/main/resources/org/microemu/device/default/down-pressed.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: harmony/enhanced/microemulator/microemu-javase/src/main/resources/org/microemu/device/default/down.png
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase/src/main/resources/org/microemu/device/default/down.png?rev=660326&view=auto
==============================================================================
Binary file - no diff available.

Propchange: harmony/enhanced/microemulator/microemu-javase/src/main/resources/org/microemu/device/default/down.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: harmony/enhanced/microemulator/microemu-javase/src/main/resources/org/microemu/device/default/up-pressed.png
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase/src/main/resources/org/microemu/device/default/up-pressed.png?rev=660326&view=auto
==============================================================================
Binary file - no diff available.

Propchange: harmony/enhanced/microemulator/microemu-javase/src/main/resources/org/microemu/device/default/up-pressed.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: harmony/enhanced/microemulator/microemu-javase/src/main/resources/org/microemu/device/default/up.png
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase/src/main/resources/org/microemu/device/default/up.png?rev=660326&view=auto
==============================================================================
Binary file - no diff available.

Propchange: harmony/enhanced/microemulator/microemu-javase/src/main/resources/org/microemu/device/default/up.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/BaseGCFTestCase.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/BaseGCFTestCase.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/BaseGCFTestCase.java (added)
+++ harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/BaseGCFTestCase.java Mon May 26 15:20:19 2008
@@ -0,0 +1,67 @@
+/*
+ *  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 javax.microedition.io;
+
+import org.microemu.SSLContextSetup;
+import org.microemu.TestEnvPropertiesHelper;
+
+import junit.framework.TestCase;
+
+/**
+ * @author vlads
+ *
+ */
+public class BaseGCFTestCase extends TestCase {
+
+	/**
+	 * This is the server where I keep HTTPS and Socket test response server.
+	 * If change add server to test-servers.keystore if it self-signed certificate.
+	 * 
+	 * War sources here https://pyx4j.com/svn/pyx4me/pyx4me-host/pyx4me-test-server
+	 * 
+	 */
+	public static final String TEST_HOST = findNoProxyTestHost();
+
+	/**
+	 * File  ${home}/.microemulator/tests.properties is used for configuration
+	 * @return
+	 */
+	private static String findNoProxyTestHost() {
+		return TestEnvPropertiesHelper.getProperty("gcf.no-proxy-test-host", "pyx4j.com");
+	}
+
+	/**
+	 * TODO Support proxy configuration.
+	 */
+	protected void setUp() throws Exception {
+		// Some tests may run via proxy but not all.
+		if (System.getProperty("http.proxyHost") == null) {
+			//System.setProperty("http.proxyHost", "genproxy");
+			//System.setProperty("http.proxyPort", String.valueOf(8900));
+		}
+	}
+
+	/**
+	 * Trust our self-signed test-servers
+	 */
+	protected void setupSSLContext() {
+	    SSLContextSetup.setUp();
+	}
+}

Propchange: harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/BaseGCFTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/BaseTestHttpConnection.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/BaseTestHttpConnection.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/BaseTestHttpConnection.java (added)
+++ harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/BaseTestHttpConnection.java Mon May 26 15:20:19 2008
@@ -0,0 +1,225 @@
+/*
+ *  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 javax.microedition.io;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Calendar;
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+public abstract class BaseTestHttpConnection extends BaseGCFTestCase {
+
+	protected static final String testFile = "/robots.txt";
+
+	protected static final String testServlet = "/pyx4me-test-server/";
+	
+	protected abstract HttpConnection openHttpConnection(String query) throws IOException;
+
+
+    private String getData(HttpConnection hc) throws IOException {
+        InputStream is = hc.openInputStream();
+        StringBuffer buf = new StringBuffer();
+        try {
+            int ch;
+            while ((ch = is.read()) != -1) {
+                buf.append((char)ch);
+            }
+            return buf.toString();
+        } catch (IOException e) {
+            if ("socket closed".equals(e.getMessage())) {
+                System.out.println("InputStream socket closed");
+                return buf.toString();
+            } else {
+                throw e;
+            }
+        } finally {
+            is.close();
+        }
+    }
+    
+    protected void assertHttpConnectionMethods(HttpConnection hc) throws IOException {
+		assertEquals("getHost()", TEST_HOST, hc.getHost());
+		assertEquals("getFile()", testFile, hc.getFile());
+		assertEquals("getRequestMethod()", HttpConnection.GET, hc.getRequestMethod());
+		String server = hc.getHeaderField("Server");
+		assertTrue("getHeaderField()", ((server.indexOf("Apache") != -1) || (server.indexOf("Sun-ONE") != -1)) );
+		Calendar year2005 = Calendar.getInstance();
+		year2005.set(Calendar.YEAR, 2005);
+		long past2005 = year2005.getTime().getTime();
+		assertTrue("getDate()", hc.getDate() > past2005);
+		assertTrue("getExpiration()", hc.getDate() > past2005);
+		assertTrue("getLastModified()", hc.getDate() > past2005);
+		assertTrue("getResponseMessage()", hc.getResponseMessage().endsWith("OK"));
+    }
+    
+    public void testResponseCode() throws IOException {
+    	HttpConnection hc = openHttpConnection(testFile + ".gone");
+        try {
+			assertEquals("getResponseCode()", HttpConnection.HTTP_NOT_FOUND, hc.getResponseCode());
+		} finally {
+			hc.close();
+		}
+    }
+    
+    public void testInputStream() throws IOException {
+    	HttpConnection hc = openHttpConnection(testFile);
+        try {
+			assertEquals("getResponseCode()", HttpConnection.HTTP_OK, hc.getResponseCode());
+			String data = getData(hc);
+			assertTrue("data recived", data.startsWith("User-agent: *"));
+		} finally {
+			hc.close();
+		}
+    }
+
+    private String getDataVIADataInputStream(DataInputStream is) throws IOException {
+        StringBuffer buf = new StringBuffer();
+        try {
+            int ch;
+            while ((ch = is.read()) != -1) {
+                buf.append((char)ch);
+            }
+            return buf.toString();
+        } catch (IOException e) {
+            if ("socket closed".equals(e.getMessage())) {
+                System.out.println("InputStream socket closed");
+                return buf.toString();
+            } else {
+                throw e;
+            }
+        } finally {
+            is.close();
+        }
+    }
+    
+    public void testDataInputStream() throws IOException {
+    	HttpConnection hc = openHttpConnection(testFile);
+        try {
+			assertEquals("getResponseCode()", HttpConnection.HTTP_OK, hc.getResponseCode());
+			String data = getDataVIADataInputStream(hc.openDataInputStream());
+			assertTrue("data recived", data.startsWith("User-agent: *"));
+		} finally {
+			hc.close();
+		}
+    }
+    
+    public void testContentConnection() throws IOException {
+    	HttpConnection hc = openHttpConnection(testFile);
+        try {
+			assertEquals("getResponseCode()", HttpConnection.HTTP_OK, hc.getResponseCode());
+			ContentConnection c = hc;
+			 int len = (int)c.getLength();
+			 assertTrue("getLength()", len > 10);
+			String data = getDataVIADataInputStream(hc.openDataInputStream());
+			assertTrue("data recived", data.startsWith("User-agent: *"));
+		} finally {
+			hc.close();
+		}
+    }
+    
+    public void testHeaders() throws IOException {
+		HttpConnection hc = openHttpConnection(testServlet + "header");
+		try {
+			hc.setRequestMethod(HttpConnection.POST);
+			Hashtable r = new Hashtable();
+			r.put("tkey1", "tvalue1");
+			r.put("Test-Key-Val", "t-value-1");
+			r.put("tkey2", "t; value: =/../");
+			r.put("tkey3", "X=DQAAG4AADTwpw:yj=b4m4G9DWbK-es8VnRXfT1w:gmproxy=GUG9jB5Ph9g:gmyj=SRs7Qh_KFZc;");
+			for (Enumeration e = r.keys(); e.hasMoreElements();) {
+				String name = (String) e.nextElement();
+				String value = (String) r.get(name);
+				hc.setRequestProperty(name, value);
+			}
+			assertEquals(HttpConnection.HTTP_OK, hc.getResponseCode());
+
+			for (Enumeration e = r.keys(); e.hasMoreElements();) {
+				String name = (String) e.nextElement();
+				String value = (String) r.get(name);
+				assertEquals(value, hc.getHeaderField("Re-" + name));
+			}
+
+			assertEquals(HttpConnection.POST, hc.getHeaderField("test-method"));
+			hc.close();
+
+			// Test GET
+			hc = openHttpConnection(testServlet + "header");
+			hc.setRequestMethod(HttpConnection.GET);
+			for (Enumeration e = r.keys(); e.hasMoreElements();) {
+				String name = (String) e.nextElement();
+				String value = (String) r.get(name);
+				hc.setRequestProperty(name, value);
+			}
+			assertEquals(HttpConnection.HTTP_OK, hc.getResponseCode());
+			for (Enumeration e = r.keys(); e.hasMoreElements();) {
+				String name = (String) e.nextElement();
+				String value = (String) r.get(name);
+				assertEquals(value, hc.getHeaderField("Re-" + name));
+			}
+
+			assertEquals(HttpConnection.GET, hc.getHeaderField("test-method"));
+		} finally {
+			hc.close();
+		}
+	}
+    
+    private String sendData(HttpConnection hc) throws IOException {
+        String msg = "Sending\n " + " Some$$Data\r\n\rend";
+        hc.setRequestProperty("X-Wap-Proxy-Cookie", "none");
+        hc.setRequestProperty("Cache-Control", "no-cache, no-transform");
+        hc.setRequestProperty("Content-Type", "application/binary");
+        hc.setRequestProperty("Content-Length", "" + (msg.getBytes().length));
+        hc.setRequestProperty("User-agent", "UNTRUSTED/1.0");
+        hc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+        hc.setRequestProperty("Test-data-crc", String.valueOf(msg.hashCode()));
+        OutputStream os = hc.openOutputStream();
+        try {
+            os.write(msg.getBytes());
+        } finally {
+            os.close();
+        }
+        return msg;
+    }
+    
+    public void testBody() throws IOException {
+		String msg;
+		HttpConnection hc = openHttpConnection(testServlet + "body");
+		try {
+			msg = sendData(hc);
+			assertEquals(HttpConnection.HTTP_OK, hc.getResponseCode());
+			assertNull("No Data error", hc.getHeaderField("Test-data-crc-error"));
+			assertEquals("Data crc", String.valueOf(msg.hashCode()), hc.getHeaderField("Test-data-crc"));
+			assertEquals(msg, getData(hc));
+			hc.close();
+
+			hc = openHttpConnection(testServlet + "body");
+			msg = sendData(hc);
+			assertEquals(HttpConnection.HTTP_OK, hc.getResponseCode());
+			assertNull("No Data error", hc.getHeaderField("Test-data-crc-error"));
+			assertEquals("Data crc", String.valueOf(msg.hashCode()), hc.getHeaderField("Test-data-crc"));
+			assertEquals(msg, getData(hc));
+		} finally {
+			hc.close();
+		}
+	}
+}

Propchange: harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/BaseTestHttpConnection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/HttpConnectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/HttpConnectionTest.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/HttpConnectionTest.java (added)
+++ harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/HttpConnectionTest.java Mon May 26 15:20:19 2008
@@ -0,0 +1,44 @@
+/*
+ *  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 javax.microedition.io;
+
+import java.io.IOException;
+
+public class HttpConnectionTest extends BaseTestHttpConnection {
+
+	private static final String testInetHTTPUrl = "http://" + TEST_HOST + testFile;
+
+    public void testConnection() throws IOException {
+    	HttpConnection hc = (HttpConnection)Connector.open(testInetHTTPUrl, Connector.READ, true);
+        try {
+			assertEquals("getResponseCode()", HttpConnection.HTTP_OK, hc.getResponseCode());
+			assertEquals("getPort()", 80, hc.getPort());
+			assertEquals("getProtocol()", "http", hc.getProtocol());
+			assertEquals("getURL()", testInetHTTPUrl, hc.getURL());
+			assertHttpConnectionMethods(hc);
+		} finally {
+			hc.close();
+		}
+    }
+    
+    protected HttpConnection openHttpConnection(String query) throws IOException {
+    	return (HttpConnection)Connector.open("http://" + TEST_HOST + query, Connector.READ, true);
+    }
+}

Propchange: harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/HttpConnectionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/HttpsConnectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/HttpsConnectionTest.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/HttpsConnectionTest.java (added)
+++ harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/HttpsConnectionTest.java Mon May 26 15:20:19 2008
@@ -0,0 +1,88 @@
+/*
+ *  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 javax.microedition.io;
+
+import java.io.IOException;
+
+import javax.microedition.pki.Certificate;
+
+public class HttpsConnectionTest extends BaseTestHttpConnection {
+	
+	private static final String testInetHTTPUrl = "https://" + TEST_HOST + testFile;
+	
+	protected void setUp() throws Exception {
+		super.setUp();
+		super.setupSSLContext();
+	}
+	
+    protected HttpConnection openHttpConnection(String query) throws IOException {
+    	return (HttpsConnection)Connector.open("https://" + TEST_HOST + query, Connector.READ, true);
+    }
+    
+    public void testConnection() throws IOException {
+    	HttpsConnection hc = (HttpsConnection)Connector.open(testInetHTTPUrl, Connector.READ, true);
+        try {
+			assertEquals("getResponseCode()", HttpConnection.HTTP_OK, hc.getResponseCode());
+			assertEquals("getPort()", 443, hc.getPort());
+			assertEquals("getProtocol()", "https", hc.getProtocol());
+			assertEquals("getURL()", testInetHTTPUrl, hc.getURL());
+			assertHttpConnectionMethods(hc);
+		} finally {
+			hc.close();
+		}
+    }
+    
+    public void testSecurityInfo() throws IOException {
+    	HttpsConnection hc = (HttpsConnection)Connector.open(testInetHTTPUrl, Connector.READ, true);
+        try {
+			assertEquals("getResponseCode()", HttpConnection.HTTP_OK, hc.getResponseCode());
+			SecurityInfo si = hc.getSecurityInfo();
+			assertNotNull("HttpsConnection.getSecurityInfo()", si);
+			assertNotNull("SecurityInfo.getProtocolVersion()", si.getProtocolVersion());
+			assertNotNull("SecurityInfo.getProtocolName()", si.getProtocolName());
+			assertNotNull("SecurityInfo.getCipherSuite()", si.getCipherSuite());
+			Certificate cert = si.getServerCertificate(); 
+			assertNotNull("SecurityInfo.getServerCertificate()", cert);
+			assertNotNull("Certificate.getSubject()", cert.getSubject());
+			assertNotNull("Certificate.getIssuer()", cert.getIssuer());
+			assertNotNull("Certificate.getType()", cert.getType());
+			assertNotNull("Certificate.getVersion()", cert.getVersion());
+			assertNotNull("Certificate.getSigAlgName()", cert.getSigAlgName());
+			assertTrue("Certificate.getNotBefore()", cert.getNotBefore() >= 0);
+			assertTrue("Certificate.getNotAfter()", cert.getNotAfter() >= 0);
+			String serialNumber = cert.getSerialNumber();
+			assertNotNull("Certificate.getSerialNumber()", serialNumber);
+		} finally {
+			hc.close();
+		}
+    }
+    
+    public void testWrongCertificate() throws IOException {
+    	HttpsConnection hc = (HttpsConnection)Connector.open("https://www.pyx4me.com" + testFile, Connector.READ, true);
+        try {
+        	// Produce java.io.IOException: HTTPS hostname wrong:  should be <www.pyx4me.com>
+        	hc.getResponseCode();
+        	fail("Should produce IOException");
+        } catch (IOException e) {
+		} finally {
+			hc.close();
+		}
+    }
+}
\ No newline at end of file

Propchange: harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/HttpsConnectionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/SSLConnectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/SSLConnectionTest.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/SSLConnectionTest.java (added)
+++ harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/SSLConnectionTest.java Mon May 26 15:20:19 2008
@@ -0,0 +1,117 @@
+/*
+ *  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 javax.microedition.io;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.microedition.pki.Certificate;
+
+public class SSLConnectionTest extends BaseGCFTestCase {
+
+	private static final String TEST_PORT = "443";
+	
+	public static final String CRLF = "\r\n";
+	
+	
+	private void write(OutputStream os, String txt) throws IOException {
+		os.write(txt.getBytes());
+		os.write(CRLF.getBytes());
+	}
+	
+	private void validateHTTPReply(InputStream is) throws IOException {
+		StringBuffer buf = new StringBuffer();
+		int ch, ch1 = 0;
+		while ((ch = is.read()) != -1) {
+			if ((ch == '\n') && (ch1 == '\r')) {
+				break;
+			}
+			buf.append((char) ch);
+			ch1 = ch;
+		}
+		if ((!buf.toString().startsWith("HTTP/1.0 200")) &&
+		     (!buf.toString().startsWith("HTTP/1.1 200"))){
+			buf.append("[EOF]");
+			throw new IOException(buf.toString());
+		}
+		if (ch == -1) {
+			throw new EOFException("No http header from proxy");
+		}
+		int crCount = 0;
+		while ((ch = is.read()) != -1) {
+			if ((ch == '\n') && (ch1 == '\r')) {
+				crCount++;
+				if (crCount == 2) {
+					break;
+				}
+			} else if (ch != '\r') {
+				crCount = 0;
+			}
+			ch1 = ch;
+		}
+		if (ch == -1) {
+			throw new EOFException("No data after http header from proxy");
+		}
+	}
+	
+	public void testSecureConnection() throws IOException {
+		// Basicaly Performs HTTPS GET
+		SecureConnection sc = (SecureConnection) Connector.open("ssl://" + TEST_HOST + ":" + TEST_PORT);
+		
+		sc.setSocketOption(SocketConnection.LINGER, 5);
+
+		OutputStream os = sc.openOutputStream();
+		write(os, "GET /robots.txt HTTP/1.0");
+		write(os, "User-Agent: UNTRUSTED/1.0");
+		write(os, "Host: " + TEST_HOST);
+		os.write(CRLF.getBytes());
+		os.flush();
+		
+		InputStream is = sc.openInputStream();
+		validateHTTPReply(is);
+		sc.close();
+	}
+
+    public void testSecurityInfo() throws IOException {
+    	SecureConnection sc = (SecureConnection) Connector.open("ssl://" + TEST_HOST + ":" + TEST_PORT);
+        try {
+			SecurityInfo si = sc.getSecurityInfo();
+			assertNotNull("SecureConnection.getSecurityInfo()", si);
+			assertNotNull("SecurityInfo.getProtocolVersion()", si.getProtocolVersion());
+			assertNotNull("SecurityInfo.getProtocolName()", si.getProtocolName());
+			assertNotNull("SecurityInfo.getCipherSuite()", si.getCipherSuite());
+			Certificate cert = si.getServerCertificate(); 
+			assertNotNull("SecurityInfo.getServerCertificate()", cert);
+			//TODO assertNotNull("Certificate.getSubject()", cert.getSubject());
+			assertNotNull("Certificate.getIssuer()", cert.getIssuer());
+			assertNotNull("Certificate.getType()", cert.getType());
+			assertNotNull("Certificate.getVersion()", cert.getVersion());
+			//TODO assertNotNull("Certificate.getSigAlgName()", cert.getSigAlgName());
+			//TODO assertTrue("Certificate.getNotBefore()", cert.getNotBefore() >= 0);
+			//TODO assertTrue("Certificate.getNotAfter()", cert.getNotAfter() >= 0);
+			//TODO String serialNumber = cert.getSerialNumber();
+			//TODO assertNotNull("Certificate.getSerialNumber()", serialNumber);
+		} finally {
+			sc.close();
+		}
+    }
+}

Propchange: harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/SSLConnectionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/SocketConnectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/SocketConnectionTest.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/SocketConnectionTest.java (added)
+++ harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/SocketConnectionTest.java Mon May 26 15:20:19 2008
@@ -0,0 +1,141 @@
+/*
+ *  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 javax.microedition.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class SocketConnectionTest extends BaseGCFTestCase {
+
+	private static final String loopbackHost = TEST_HOST;
+	//private static final String loopbackHost = "localhost";
+	
+	private static final String loopbackPort = "9127";
+	
+	private static final String serverPort = "7127";
+	
+	
+	private void runLoopbackTest(String url) throws IOException {
+		System.out.println("Connecting to " + url);
+		SocketConnection sc = (SocketConnection) Connector.open(url);
+		
+		try {
+			sc.setSocketOption(SocketConnection.LINGER, 5);
+
+			InputStream is = sc.openInputStream();
+			OutputStream os = sc.openOutputStream();
+
+			String testData = "OK\r\n"; 
+			
+			os.write(testData.getBytes());
+			os.flush();
+			
+			StringBuffer buf = new StringBuffer(); 
+			
+			int ch = 0;
+			int count = 0;
+			while (ch != -1) {
+				ch = is.read();
+				buf.append((char)ch);
+				count ++;
+				if (count >= testData.length()) {
+					break;
+				}
+			}
+
+			assertEquals("Data received", buf.toString(), testData);
+			
+			is.close();
+			os.close();
+		} finally {
+			sc.close();
+		}
+
+	}
+	
+	public void testLoopback() throws IOException {
+		runLoopbackTest("socket://" + loopbackHost + ":" + loopbackPort);
+	}
+	
+	private class ServerThread extends Thread {
+		
+		ServerSocketConnection scn;
+		
+		boolean started = true;
+		
+		boolean finished = true;
+		
+		ServerThread(ServerSocketConnection scn) {
+			super.setDaemon(true);
+			this.scn = scn;
+		}
+		
+		public void run() {
+			try {
+				// Wait for a connection.
+				SocketConnection sc = (SocketConnection) scn.acceptAndOpen();
+				
+				InputStream is = sc.openInputStream();
+				OutputStream os = sc.openOutputStream();
+				
+				int ch = 0;
+				int count = 0;
+				while (ch != -1) {
+					ch = is.read();
+					if (ch == -1) {
+						break;
+					}
+					os.write(ch);
+					os.flush();
+					count ++;
+				}
+			} catch(IOException e) {
+				e.printStackTrace();
+			} finally {
+				finished = true;
+			}
+		}
+	}
+	
+	static public void assertNotEquals(String message, String expected, String actual) {
+		assertFalse(message + " [" + expected + " == "+ actual + "]", expected.equals(actual));
+	}
+	
+	public void testServerSocketConnection() throws IOException, InterruptedException {
+		ServerSocketConnection scn = (ServerSocketConnection) Connector.open("socket://:" + serverPort);
+
+		try {
+			ServerThread t = new ServerThread(scn);
+			t.start();
+			while (!t.started) {
+				Thread.sleep(20);
+			}
+			assertEquals("Server Port", Integer.valueOf(serverPort).intValue(), scn.getLocalPort());
+			assertNotEquals("Server Host", "0.0.0.0", scn.getLocalAddress());
+			assertNotEquals("Server Host", "localhost", scn.getLocalAddress());
+			//assertNotEquals("Server Host", "127.0.0.1", scn.getLocalAddress());
+			
+			runLoopbackTest("socket://" + scn.getLocalAddress() + ":" + scn.getLocalPort());
+		} finally {
+			scn.close();
+		}
+	}
+}

Propchange: harmony/enhanced/microemulator/microemu-javase/src/test/java/javax/microedition/io/SocketConnectionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/SSLContextSetup.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/SSLContextSetup.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/SSLContextSetup.java (added)
+++ harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/SSLContextSetup.java Mon May 26 15:20:19 2008
@@ -0,0 +1,74 @@
+/*
+ *  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.microemu;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.KeyStore;
+import java.security.SecureRandom;
+
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactory;
+
+/**
+ * @author vlads
+ * 
+ * See src/test/ssl/read-me.txt
+ * 
+ */
+public class SSLContextSetup {
+	
+	private static boolean initialized = false;
+	
+	public static synchronized void setUp() {
+    	if (initialized) {
+    		return;
+    	}
+    	InputStream is = null;
+        try {
+            KeyStore trustStore = KeyStore.getInstance("JKS");
+            is = SSLContextSetup.class.getResourceAsStream("/test-servers.keystore"); 
+            if (is == null) {
+            	new Error("keystore not found");
+            }
+            trustStore.load(is, "microemu2006".toCharArray());
+            TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance("SunX509");  
+            trustManagerFactory.init(trustStore);  
+            TrustManager[] trustManagers = trustManagerFactory.getTrustManagers();
+            
+            SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG");
+            SSLContext context = SSLContext.getInstance("TLS");
+            context.init(null, trustManagers, secureRandom);
+            HttpsURLConnection.setDefaultSSLSocketFactory(context.getSocketFactory());
+            initialized = true;
+        } catch (Throwable e) {
+            throw new Error(e);
+        } finally {
+        	if (is != null) {
+        		try {
+					is.close();
+				} catch (IOException ignore) {
+				}
+        	}
+        }
+    }
+}

Propchange: harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/SSLContextSetup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/TestEnvPropertiesHelper.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/TestEnvPropertiesHelper.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/TestEnvPropertiesHelper.java (added)
+++ harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/TestEnvPropertiesHelper.java Mon May 26 15:20:19 2008
@@ -0,0 +1,65 @@
+/*
+ *  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.microemu;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.microemu.app.Config;
+
+public class TestEnvPropertiesHelper {
+
+	static final Properties utProperties = loadProperties(); 
+	
+	static final String FILE_NAME = "tests.properties";
+	
+	/**
+	 * File  ${home}/.microemulator/test.properties is used for configuration
+	 * @return
+	 */
+	public static String getProperty(String key, String defaultValue) {
+		return utProperties.getProperty(key, defaultValue);
+	}
+
+	private static Properties loadProperties() {
+		Properties prop = new Properties();
+		
+		File meHomeRoot = Config.getConfigPath();
+		if (meHomeRoot == null) {
+			return prop;
+		}
+		
+		File file = new File(meHomeRoot, FILE_NAME);
+		if (!file.exists() || !file.canRead()) {
+			return prop;
+		}
+		
+		FileInputStream input;
+        try {
+            input = new FileInputStream(file);
+            prop.load((InputStream) input);
+        } catch (Exception e) {
+            System.err.println("Error reading properties " + e.toString());
+        }
+		return prop;
+	}
+}

Propchange: harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/TestEnvPropertiesHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/app/classloader/MIDletClassLoaderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/app/classloader/MIDletClassLoaderTest.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/app/classloader/MIDletClassLoaderTest.java (added)
+++ harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/app/classloader/MIDletClassLoaderTest.java Mon May 26 15:20:19 2008
@@ -0,0 +1,147 @@
+/*
+ *  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.microemu.app.classloader;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import junit.framework.TestCase;
+
+import org.microemu.Injected;
+import org.microemu.app.util.EventCatureLoggerAppender;
+import org.microemu.app.util.IOUtils;
+import org.microemu.app.util.MIDletResourceLoader;
+import org.microemu.app.util.MIDletSystemProperties;
+import org.microemu.log.Logger;
+import org.microemu.log.LoggingEvent;
+
+/**
+ * @author vlads
+ *
+ */
+public class MIDletClassLoaderTest extends TestCase {
+
+	public static final String TEST_APP_JAR = "bytecode-test-app.jar"; 
+	
+	public static final String TEST_CLASS = "org.TestMain";
+	
+	EventCatureLoggerAppender capture;
+
+	private boolean enhanceCatchBlockSave;
+	
+	protected void setUp() throws Exception {
+		super.setUp();
+		capture = new EventCatureLoggerAppender();
+		Logger.addAppender(capture);
+		enhanceCatchBlockSave = MIDletClassLoader.enhanceCatchBlock;
+	}
+	
+	protected void tearDown() throws Exception {
+		super.tearDown();
+		Logger.removeAppender(capture);
+		MIDletClassLoader.enhanceCatchBlock = enhanceCatchBlockSave; 
+	}
+	
+	public void testGetResourceAsStream() throws Exception {
+		
+		ClassLoader parent = MIDletClassLoaderTest.class.getClassLoader();
+		
+		URL jarURL = parent.getResource(TEST_APP_JAR);
+		assertNotNull("Can't find app jar", jarURL);
+		
+		URLClassLoader ucl = new URLClassLoader(new URL[]{jarURL});
+		
+		final String testFile = "META-INF/MANIFEST.MF";
+		
+		InputStream is = null;
+		try {
+			is = ucl.getResourceAsStream(testFile);
+			assertNotNull("URLClassLoader", is);
+		} finally {
+			IOUtils.closeQuietly(is);
+		}
+		
+		MIDletClassLoader mcl = new MIDletClassLoader(parent);
+		mcl.addURL(jarURL);
+		try {
+			is = ucl.getResourceAsStream(testFile);
+			assertNotNull("MIDletClassLoader", is);
+		} finally {
+			IOUtils.closeQuietly(is);
+		}
+		
+	}
+	
+	public void testApplication() throws Exception {
+		ClassLoader parent = MIDletClassLoaderTest.class.getClassLoader();
+		URL jarURL = parent.getResource(TEST_APP_JAR);
+		assertNotNull("Can't find app jar", jarURL);
+		
+		System.setProperty("test.verbose", "1");
+		
+		MIDletSystemProperties.setProperty("test.property1", "1");
+		MIDletSystemProperties.setProperty("microedition.platform", null);
+		
+		MIDletClassLoader.enhanceCatchBlock = false;
+		MIDletClassLoader mcl = new MIDletClassLoader(parent);
+		mcl.disableClassPreporcessing(Injected.class);
+		MIDletResourceLoader.classLoader = mcl;
+		mcl.addURL(jarURL);
+		
+		Class instrumentedClass = mcl.loadClass(TEST_CLASS);
+		Runnable instrumentedInstance = (Runnable) instrumentedClass.newInstance();
+		instrumentedInstance.run();
+		
+		LoggingEvent lastEvent = capture.getLastEvent();
+		assertNotNull("got event", lastEvent);
+		assertEquals("All tests OK", lastEvent.getMessage());
+		StackTraceElement ste = lastEvent.getLocation();
+		assertEquals("MethodName", "run", ste.getMethodName());
+		assertEquals("ClassName", TEST_CLASS, ste.getClassName());
+
+	}
+	
+	private void runEnhanceCatchBlock(MIDletClassLoader mcl, String name) throws Exception {
+		Class instrumentedClass = mcl.loadClass(name);
+		Runnable instrumentedInstance = (Runnable) instrumentedClass.newInstance();
+		instrumentedInstance.run();
+		
+		LoggingEvent lastEvent = capture.getLastEvent();
+		assertNotNull("got event", lastEvent);
+		assertNotNull("got message", lastEvent.getMessage());
+		System.out.println("[" +lastEvent.getMessage() + "]");
+		assertTrue("error message", lastEvent.getMessage().indexOf("MIDlet caught") != -1);
+	}
+	
+	public void x_testEnhanceCatchBlock() throws Exception {
+		ClassLoader parent = MIDletClassLoaderTest.class.getClassLoader();
+		URL jarURL = parent.getResource(TEST_APP_JAR);
+		assertNotNull("Can't find app jar", jarURL);
+		
+		System.setProperty("test.verbose", "1");
+		
+		MIDletClassLoader.enhanceCatchBlock = true;
+		MIDletClassLoader mcl = new MIDletClassLoader(parent);
+		mcl.disableClassPreporcessing(Injected.class);
+		mcl.addURL(jarURL);
+		runEnhanceCatchBlock(mcl, "org.catchBlock.CatchThrowable");
+	}
+}

Propchange: harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/app/classloader/MIDletClassLoaderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/app/util/EventCatureLoggerAppender.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/app/util/EventCatureLoggerAppender.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/app/util/EventCatureLoggerAppender.java (added)
+++ harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/app/util/EventCatureLoggerAppender.java Mon May 26 15:20:19 2008
@@ -0,0 +1,43 @@
+/*
+ *  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.microemu.app.util;
+
+import org.microemu.log.LoggerAppender;
+import org.microemu.log.LoggingEvent;
+
+public class EventCatureLoggerAppender implements LoggerAppender {
+
+	private LoggingEvent lastEvent; 
+	
+	public void append(LoggingEvent event) {
+		lastEvent = event;
+	}
+
+	public void clearLastEvent() {
+		lastEvent = null;
+	}
+	
+	public LoggingEvent getLastEvent() {
+		LoggingEvent ev = lastEvent;
+		lastEvent = null;
+		return ev;
+	}
+
+}

Propchange: harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/app/util/EventCatureLoggerAppender.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/app/util/IOUtilsTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/app/util/IOUtilsTest.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/app/util/IOUtilsTest.java (added)
+++ harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/app/util/IOUtilsTest.java Mon May 26 15:20:19 2008
@@ -0,0 +1,110 @@
+/*
+ *  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.microemu.app.util;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import org.microemu.app.classloader.MIDletClassLoaderTest;
+
+import junit.framework.TestCase;
+
+public class IOUtilsTest extends TestCase {
+
+	private static final String TEST_JAR = MIDletClassLoaderTest.TEST_APP_JAR; 
+
+	public void testCanonicalFileURL() throws Exception {
+		
+		ClassLoader parent = IOUtilsTest.class.getClassLoader();
+		
+		URL jarURL = parent.getResource(TEST_JAR);
+		assertNotNull("Can't find jar", jarURL);
+		
+		File file = new File(jarURL.getPath());
+		
+		assertTrue("is real file",  file.canRead());
+		
+		String urlString = IOUtils.getCanonicalFileURL(file);
+		System.out.println("local file url [" + urlString + "]");
+		URL testURL = new URL(urlString);
+		
+		InputStream is = testURL.openStream();
+		assertNotNull("Can't openStream jar", is);
+		IOUtils.closeQuietly(is);
+		
+		URLClassLoader ucl = new URLClassLoader(new URL[]{testURL});
+		
+		final String testFile = "META-INF/MANIFEST.MF";
+		
+		is = null;
+		try {
+			is = ucl.getResourceAsStream(testFile);
+			assertNotNull("URLClassLoader", is);
+		} finally {
+			IOUtils.closeQuietly(is);
+		}
+	}
+	
+	
+	/**
+	 * This manual tests. Just remove x_ to test on your system
+	 * @throws Exception
+	 */
+	public void x_testCanonicalNetworkFileURL() throws Exception {
+	
+		File file;
+		
+		/*  tested on Windows */
+		//file = new File("//vladsdesk/test/dir/" + TEST_JAR);
+		/*  tested on Windows */
+		//file = new File("//linux/vlads/test/dir/" + TEST_JAR);
+		
+		// Can't make this work on Linux connectin to XP!
+		//file = new File("//vladsdesk/test/dir/" + TEST_JAR);
+		//file = new File("//linux/vlads/test/dir/" + TEST_JAR);
+		file = new File("//localhost/home/vlads/test/dir/" + TEST_JAR);
+		
+		assertTrue("is real file",  file.canRead());
+		
+		String urlString = IOUtils.getCanonicalFileURL(file);
+		
+		System.out.println("network URL [" + urlString + "]");
+		
+		URL testURL = new URL(urlString);
+		
+		InputStream is = testURL.openStream();
+		assertNotNull("Can't openStream jar", is);
+		IOUtils.closeQuietly(is);
+		
+		URLClassLoader ucl = new URLClassLoader(new URL[]{testURL});
+		
+		final String testFile = "META-INF/MANIFEST.MF";
+		
+		is = null;
+		try {
+			is = ucl.getResourceAsStream(testFile);
+			assertNotNull("URLClassLoader", is);
+		} finally {
+			IOUtils.closeQuietly(is);
+		}
+	}
+}

Propchange: harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/app/util/IOUtilsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/app/util/MIDletOutputStreamRedirectorTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/app/util/MIDletOutputStreamRedirectorTest.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/app/util/MIDletOutputStreamRedirectorTest.java (added)
+++ harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/app/util/MIDletOutputStreamRedirectorTest.java Mon May 26 15:20:19 2008
@@ -0,0 +1,248 @@
+/*
+ *  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.microemu.app.util;
+
+import org.microemu.Injected;
+import org.microemu.log.Logger;
+import org.microemu.log.LoggingEvent;
+
+import junit.framework.TestCase;
+
+public class MIDletOutputStreamRedirectorTest extends TestCase {
+
+	EventCatureLoggerAppender capture;
+	
+	protected void setUp() throws Exception {
+		super.setUp();
+		capture = new EventCatureLoggerAppender();
+		Logger.addAppender(capture);
+	}
+	
+	protected void tearDown() throws Exception {
+		super.tearDown();
+		Logger.removeAppender(capture);
+	}
+	
+	private void verify(LoggingEvent event, StackTraceElement b4call, final String message) {
+		assertNotNull("got event", event);
+		assertEquals(message, event.getMessage());
+		StackTraceElement ste = event.getLocation();
+		assertNotNull("Has location info", ste);
+		assertEquals("MethodName", b4call.getMethodName(), ste.getMethodName());
+		assertEquals("ClassName", b4call.getClassName(), ste.getClassName());
+		assertEquals("LineNumber", b4call.getLineNumber() + 1, ste.getLineNumber());
+	}
+	
+	public void testRedirectStack() throws Exception {
+		final String message = "Test text";
+		capture.clearLastEvent();
+		
+		StackTraceElement b4call = new Throwable().getStackTrace()[0];
+		Injected.out.println(message);
+		
+		verify(capture.getLastEvent(), b4call, message);
+		
+		b4call = new Throwable().getStackTrace()[0];
+		Injected.out.print(message + "\n");
+		
+		verify(capture.getLastEvent(), b4call, message);
+	}
+	
+	private class LogginThread extends Thread {
+
+		private boolean success = false;
+
+		public void run() {
+			try {
+				final String message = "Test text from LogginThread";
+				capture.clearLastEvent();
+
+				StackTraceElement b4call = new Throwable().getStackTrace()[0];
+				Injected.out.println(message);
+
+				verify(capture.getLastEvent(), b4call, message);
+
+				b4call = new Throwable().getStackTrace()[0];
+				Injected.out.print(message + "\n");
+
+				verify(capture.getLastEvent(), b4call, message);
+				
+				success = true;
+				
+			} finally {
+				synchronized (this) {
+					notifyAll();
+				}
+			}
+		}
+
+	}
+	
+	public void testRedirectStackFromThread() throws Exception {
+		LogginThread thread = new LogginThread();
+		synchronized (thread) {
+			thread.start();
+			thread.wait();
+		}
+		assertTrue("Log from Thread", thread.success);
+	}
+	
+	private class MIDletInternlaLogger {
+		
+		public void debug(String message) {
+			Injected.out.println(message);
+		}
+		
+		public void error(String message) {
+			Injected.out.println(message);
+		}
+		
+		public void log(String message) {
+			Injected.out.println(message);	
+		}
+	}
+	
+	public void testMIDletInternalLogger() throws Exception {
+		final String message = "Test text";
+		capture.clearLastEvent();
+		MIDletInternlaLogger log = new MIDletInternlaLogger();
+		
+		StackTraceElement b4call = new Throwable().getStackTrace()[0];
+		log.debug(message);
+		
+		verify(capture.getLastEvent(), b4call, message);
+		
+		b4call = new Throwable().getStackTrace()[0];
+		log.error(message);
+		
+		verify(capture.getLastEvent(), b4call, message);
+		
+		b4call = new Throwable().getStackTrace()[0];
+		log.log(message);
+		
+		verify(capture.getLastEvent(), b4call, message);
+		
+	}
+	
+	private class SubClass {
+		
+		void runTests(MIDletInternlaLogger log) {
+			final String message = "Sub class Test text";
+			StackTraceElement b4call = new Throwable().getStackTrace()[0];
+			log.debug(message);
+			
+			verify(capture.getLastEvent(), b4call, message);
+			
+			b4call = new Throwable().getStackTrace()[0];
+			log.error(message);
+			
+			verify(capture.getLastEvent(), b4call, message);
+			
+			b4call = new Throwable().getStackTrace()[0];
+			log.log(message);
+			
+			verify(capture.getLastEvent(), b4call, message);
+		}
+	}
+
+	public void testMIDletInternalLoggerSubClass() throws Exception {
+		capture.clearLastEvent();
+		MIDletInternlaLogger log = new MIDletInternlaLogger();
+		SubClass subtest = new SubClass();
+		subtest.runTests(log);
+	}
+	
+	private static class StaticLogger {
+		
+		public static void debug(String message) {
+			Injected.out.println(message);
+		}
+		
+		public static void error(String message) {
+			Injected.out.println(message);
+		}
+		
+		public static void log(String message) {
+			Injected.out.println(message);	
+		}
+	}
+	
+	public void testMIDletInternalStaticLogger() throws Exception {
+		final String message = "Test text Static logger";
+		capture.clearLastEvent();
+		
+		StackTraceElement b4call = new Throwable().getStackTrace()[0];
+		StaticLogger.debug(message);
+		
+		verify(capture.getLastEvent(), b4call, message);
+		
+		b4call = new Throwable().getStackTrace()[0];
+		StaticLogger.error(message);
+		
+		verify(capture.getLastEvent(), b4call, message);
+		
+		b4call = new Throwable().getStackTrace()[0];
+		StaticLogger.log(message);
+		
+		verify(capture.getLastEvent(), b4call, message);
+		
+	}
+	
+	private class LogginThreadStaticLogger extends Thread {
+
+		private boolean success = false;
+
+		public void run() {
+			try {
+				final String message = "Test text from LogginThread";
+				capture.clearLastEvent();
+
+				StackTraceElement b4call = new Throwable().getStackTrace()[0];
+				StaticLogger.debug(message);
+
+				verify(capture.getLastEvent(), b4call, message);
+
+				b4call = new Throwable().getStackTrace()[0];
+				StaticLogger.log(message + "\n");
+
+				verify(capture.getLastEvent(), b4call, message);
+				
+				success = true;
+				
+			} finally {
+				synchronized (this) {
+					notifyAll();
+				}
+			}
+		}
+
+	}
+	
+	public void testMIDletInternalStaticLoggerFromThread() throws Exception {
+		LogginThreadStaticLogger thread = new LogginThreadStaticLogger();
+		synchronized (thread) {
+			thread.start();
+			thread.wait();
+		}
+		assertTrue("Log from Thread", thread.success);
+	}
+
+}
+

Propchange: harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/app/util/MIDletOutputStreamRedirectorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/device/impl/DeviceXMLInheritTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/device/impl/DeviceXMLInheritTest.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/device/impl/DeviceXMLInheritTest.java (added)
+++ harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/device/impl/DeviceXMLInheritTest.java Mon May 26 15:20:19 2008
@@ -0,0 +1,104 @@
+/*
+ *  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.microemu.device.impl;
+
+import org.microemu.device.impl.DeviceImpl;
+
+import nanoxml.XMLElement;
+
+import junit.framework.TestCase;
+
+/**
+ * @author vlads
+ *
+ */
+public class DeviceXMLInheritTest extends TestCase {
+
+	public void verifyXML(String parentXML, String childXML, String expectedXML) {
+		XMLElement child = new XMLElement();
+		child.parseString(childXML);
+		XMLElement parent = new XMLElement();
+		parent.parseString(parentXML);
+		XMLElement expected = new XMLElement();
+		expected.parseString(expectedXML);
+		
+		XMLElement result = DeviceImpl.inheritXML(parent, child, "/");
+		
+		//System.out.println("expected:" + expected.toString());
+		//System.out.println(" result:" + result.toString());
+		
+		assertEquals(result.toString(), expected.toString());
+	}
+	
+	public void testValueOverride() {
+		verifyXML("<device><display><numcolors>2</numcolors><vp>vpv</vp></display></device>", 
+				  "<device><display><numcolors>65536</numcolors><v>v1</v></display></device>", 
+				  "<device><display><numcolors>65536</numcolors><vp>vpv</vp><v>v1</v></display></device>");
+	}
+
+	public void testValueOverrideByName() {
+		verifyXML("<device><v>v1</v><v name=\"2\">v2</v><v name=\"3\">v3</v></device>", 
+				  "<device><v>v1m</v><v name=\"3\">v3m</v></device>", 
+				  "<device><v>v1m</v><v name=\"2\">v2</v><v name=\"3\">v3m</v></device>");
+
+		verifyXML("<device><v>v1</v><v name=\"2\">v2</v><v name=\"3\">v3</v></device>", 
+				  "<device><v name=\"3\">v3m</v><v>v1m</v></device>", 
+				  "<device><v>v1m</v><v name=\"2\">v2</v><v name=\"3\">v3m</v></device>");
+		
+		verifyXML("<device><v>v1</v><v name=\"2\">v2</v><v name=\"3\">v3</v></device>", 
+				  "<device><v>v1m</v><v name=\"3\" attrm=\"am\">v3m</v></device>", 
+				  "<device><v>v1m</v><v name=\"2\">v2</v><v name=\"3\" attrm=\"am\">v3m</v></device>");
+		
+		verifyXML("<device><v attrm=\"am\">v1</v><v name=\"2\">v2</v><v name=\"3\">v3</v></device>", 
+				  "<device><v>v1m</v><v name=\"3\">v3m</v></device>", 
+				  "<device><v attrm=\"am\">v1m</v><v name=\"2\">v2</v><v name=\"3\">v3m</v></device>");
+	}
+	
+	public void testValueOverrideByNameWithCase() {
+		verifyXML("<device><v>v1</v><v name=\"a\">v2</v><v name=\"b\">v3</v></device>", 
+				  "<device><v>v1m</v><v name=\"B\">v3m</v></device>", 
+				  "<device><v>v1m</v><v name=\"a\">v2</v><v name=\"b\">v3</v><v name=\"B\">v3m</v></device>");
+
+	}
+
+	public void testValueOverrideNoName() {
+		verifyXML("<device><v name=\"A\">v1</v></device>", 
+				  "<device><v name=\"B\">v2</v></device>", 
+				  "<device><v name=\"A\">v1</v><v name=\"B\">v2</v></device>");
+
+	}
+	
+	public void testValueOverrideFonts() {
+		verifyXML("<device><fonts>" +
+				   "<font face=\"system\" style=\"plain\" size=\"small\">F1</font>" +
+				   "<font face=\"system\" style=\"plain\" size=\"medium\">F2</font>" +
+				   "</fonts></device>",
+				   
+				   "<device><fonts>" +
+				   "<font face=\"system\" style=\"plain\" size=\"medium\">F2m</font>" +
+				   "</fonts></device>",
+				   
+				   "<device><fonts>" +
+				   "<font face=\"system\" style=\"plain\" size=\"small\">F1</font>" +
+				   "<font face=\"system\" style=\"plain\" size=\"medium\">F2m</font>" +
+				   "</fonts></device>");
+	}
+	
+}

Propchange: harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/device/impl/DeviceXMLInheritTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/device/impl/PolygonTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/device/impl/PolygonTest.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/device/impl/PolygonTest.java (added)
+++ harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/device/impl/PolygonTest.java Mon May 26 15:20:19 2008
@@ -0,0 +1,106 @@
+/*
+ *  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.microemu.device.impl;
+
+import junit.framework.TestCase;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author vlads
+ *
+ */
+public class PolygonTest extends TestCase {
+	
+	private static final boolean debug = false;
+
+	Pattern rx = Pattern.compile("(?:(\\d+)\\s?[,]\\s?(\\d+)(?:\\s?[;]\\s?)?)");
+	
+	private void verify(String polygon, String points, boolean expected) {
+		Polygon pl = new Polygon();
+		//This is know to work fine.
+		java.awt.Polygon awt = new java.awt.Polygon();
+
+		
+		Matcher mp = rx.matcher(polygon);
+		while (mp.find()) {
+			int px = Integer.parseInt(mp.group(1));
+			int py = Integer.parseInt(mp.group(2));
+			pl.addPoint(px, py);
+			awt.addPoint(px, py);
+		}
+		Matcher mxy = rx.matcher(points);
+		while (mxy.find()) {
+			int x = Integer.parseInt(mxy.group(1));
+			int y = Integer.parseInt(mxy.group(2));
+			String xy = "[" + x + ", " + y + "]";
+			assertEquals("awt " + polygon + " contains " + xy, expected, awt.contains(x, y));
+			
+			if (debug && expected != pl.contains(x, y)) {
+				System.out.println("error impl " + polygon + " contains " + xy + "? expected:" + expected);
+				pl.contains(x, y);
+				awt.contains(x, y);
+			} else if (debug) {
+				System.out.println("OK impl " + polygon + " contains " + xy + "? expected:" + expected);
+			}
+			assertEquals("impl " + polygon + " contains " + xy, expected, pl.contains(x, y));
+		}
+		
+		// Test other point
+		int x = pl.getBounds().x - 2;
+		int y= pl.getBounds().y - 2;
+		int w = pl.getBounds().width + 4;
+		int h = pl.getBounds().height + 4;
+		for(int xx = x ; xx <= w; xx ++) {
+			for(int yy = y ; yy <= h; yy ++) {
+				int xt = x + xx;
+				int yt = y + yy;
+				boolean exp = awt.contains(xt, yt);
+				String xy = "[" + xt + ", " + yt + "]";
+				assertEquals("impl " + polygon + " contains " + xy, exp, pl.contains(xt, yt));
+			}
+		}
+	}
+	
+	
+	public void testTriangleContains() {
+		String triangle = "4,10; 10,5; 12,14";
+		String pointIn = "9,9; 9,7; 10,11; 11,12; 7,11";
+		String pointOut = "6,6;  10,4; 13,7; 13,15; 10,14; 5,12";
+		verify(triangle, pointIn , true);
+		verify(triangle, pointOut , false);
+		
+		String triangleBack = "4,10; 12,14; 10,5;";
+		verify(triangleBack, pointIn , true);
+		verify(triangleBack, pointOut , false);
+		
+		String triangleBack2 = "12,14; 10,5; 4,10; ";
+		verify(triangleBack2, pointIn , true);
+		verify(triangleBack2, pointOut , false);
+	}
+	
+	public void testComplexContains() {
+		verify("4,10; 10,5; 17,3; 19,6; 14,8; 12,14; 7,12", "", true);
+		verify("4,10; 10,5; 17,3; 19,6; 17,12; 12,14; 7,12", "", true);
+		verify("7,12; 12,14; 17,12; 19,6; 17,3; 10,5; 4,10;", "", true);
+	}
+	
+}

Propchange: harmony/enhanced/microemulator/microemu-javase/src/test/java/org/microemu/device/impl/PolygonTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase/src/test/resources/container-internal.txt
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase/src/test/resources/container-internal.txt?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase/src/test/resources/container-internal.txt (added)
+++ harmony/enhanced/microemulator/microemu-javase/src/test/resources/container-internal.txt Mon May 26 15:20:19 2008
@@ -0,0 +1 @@
+container internal not avalble to app
\ No newline at end of file

Propchange: harmony/enhanced/microemulator/microemu-javase/src/test/resources/container-internal.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase/src/test/resources/strings.txt
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase/src/test/resources/strings.txt?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase/src/test/resources/strings.txt (added)
+++ harmony/enhanced/microemulator/microemu-javase/src/test/resources/strings.txt Mon May 26 15:20:19 2008
@@ -0,0 +1 @@
+internal resources strings
\ No newline at end of file

Propchange: harmony/enhanced/microemulator/microemu-javase/src/test/resources/strings.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase/src/test/ssl/read-me.txt
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase/src/test/ssl/read-me.txt?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase/src/test/ssl/read-me.txt (added)
+++ harmony/enhanced/microemulator/microemu-javase/src/test/ssl/read-me.txt Mon May 26 15:20:19 2008
@@ -0,0 +1,29 @@
+This is uses during UnitTests for SSL
+
+ When using SSLFactory to talk SSL with a server, or using the URL class
+to open an https connection we need to make the server certificate be trusted by SSLSocketFactory.
+
+1. You must have the server certificate. If you don't have this
+handy, navigate to the secure website, click on the lock icon
+(in Internet Explorer). Click on "Details" tab and then click
+the "Copy to File..." button. Export the certificate to a DER
+encoded binary X.509 (.CER) file. Let's say you chose the
+filename test-server.cer
+
+ Java 1.4 do not acept key len above the normal 2048 bits.
+
+2. Import the file test-server.cer to our keystore  Create src\test\resources\test-servers.keystore
+
+   keytool -keystore test-servers.keystore -storepass microemu2006 -import -alias test-server.host.net -file test-server.cer -trustcacerts
+
+Done:
+   keytool -printcert -file pyx4j.com-der-X509.cer
+   keytool -keystore ../resources/test-servers.keystore -storepass microemu2006 -import -alias pyx4j.com -file pyx4j.com-der-X509.cer -trustcacerts
+
+# torvspocweb Server used for tests on Windows build server
+    keytool -keystore ../resources/test-servers.keystore -storepass microemu2006 -import -alias torvspocweb -file torvspocweb-der-X509.cer -trustcacerts
+    keytool -keystore ../resources/test-servers.keystore -storepass microemu2006 -delete -alias pyx4j.com
+    keytool -keystore ../resources/test-servers.keystore -storepass microemu2006 -list
+
+3. Unit test will load this keystore automaticaly during build
+

Propchange: harmony/enhanced/microemulator/microemu-javase/src/test/ssl/read-me.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-tests/bytecode-test-app/pom.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-tests/bytecode-test-app/pom.xml?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-tests/bytecode-test-app/pom.xml (added)
+++ harmony/enhanced/microemulator/microemu-tests/bytecode-test-app/pom.xml Mon May 26 15:20:19 2008
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns="http://maven.apache.org/POM/4.0.0">
+    <!-- @version $Revision: 1626 $ ($Author: vlads $) $Date: 2008-03-04 21:47:36 -0500 (Tue, 04 Mar 2008) $ -->
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.microemu</groupId>
+        <artifactId>microemu-tests</artifactId>
+        <version>2.0.3-SNAPSHOT</version><!--me-version-->
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>bytecode-test-app</artifactId>
+    <name>bytecode-test-app</name>
+
+    <description>bytecode-test-app</description>
+
+    <build>
+
+        <plugins>
+
+            <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.4</source>
+                    <target>1.4</target>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <artifactId>maven-jar-plugin</artifactId>
+                <configuration>
+                    <finalName>bytecode-test-app</finalName>
+                </configuration>
+            </plugin>
+
+        </plugins>
+
+    </build>
+
+</project>
\ No newline at end of file

Propchange: harmony/enhanced/microemulator/microemu-tests/bytecode-test-app/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-tests/bytecode-test-app/src/main/java/javax/microedition/NotAccessible.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-tests/bytecode-test-app/src/main/java/javax/microedition/NotAccessible.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-tests/bytecode-test-app/src/main/java/javax/microedition/NotAccessible.java (added)
+++ harmony/enhanced/microemulator/microemu-tests/bytecode-test-app/src/main/java/javax/microedition/NotAccessible.java Mon May 26 15:20:19 2008
@@ -0,0 +1,32 @@
+/*
+ *  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 javax.microedition;
+
+/**
+ * @author vlads
+ *
+ */
+public class NotAccessible {
+
+	public static void doStuff() {
+		throw new RuntimeException("Should not be able to acess this class");
+	}
+	
+}

Propchange: harmony/enhanced/microemulator/microemu-tests/bytecode-test-app/src/main/java/javax/microedition/NotAccessible.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-tests/bytecode-test-app/src/main/java/org/DynamicallyLoadedRunner.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-tests/bytecode-test-app/src/main/java/org/DynamicallyLoadedRunner.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-tests/bytecode-test-app/src/main/java/org/DynamicallyLoadedRunner.java (added)
+++ harmony/enhanced/microemulator/microemu-tests/bytecode-test-app/src/main/java/org/DynamicallyLoadedRunner.java Mon May 26 15:20:19 2008
@@ -0,0 +1,32 @@
+/*
+ *  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;
+
+/**
+ * @author vlads
+ *
+ */
+public class DynamicallyLoadedRunner implements Runnable {
+
+	public void run() {
+		DynamicallyLoadedStatus.runnerSuccess = true;
+	}
+
+}

Propchange: harmony/enhanced/microemulator/microemu-tests/bytecode-test-app/src/main/java/org/DynamicallyLoadedRunner.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message