01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: *
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: /**
20: * @author Anton V. Karnachuk
21: * @version $Revision: 1.3 $
22: */
23:
24: /**
25: * Created on 07.02.2005
26: */package org.apache.harmony.jpda.tests.jdwp.StringReference;
27:
28: import java.io.UnsupportedEncodingException;
29:
30: import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
31: import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
32:
33: /**
34: * JDWP Unit test for StringReference.Value command.
35: */
36: public class ValueTest extends JDWPSyncTestCase {
37:
38: protected String getDebuggeeClassName() {
39: return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
40: }
41:
42: public static void main(String[] args) {
43: junit.textui.TestRunner.run(ValueTest.class);
44: }
45:
46: protected void checkString(String testString)
47: throws UnsupportedEncodingException {
48: logWriter.println("=> Test string: \"" + testString + "\"");
49:
50: // create new string
51: long stringID = createString(testString);
52:
53: // get string from StringID
54: String returnedTestString = getStringValue(stringID);
55: logWriter.println("=> Returned string: \"" + returnedTestString
56: + "\"");
57:
58: assertString(
59: "StringReference::Value command returned invalid string,",
60: testString, returnedTestString);
61: }
62:
63: /**
64: * This testcase exercises StringReference.Value command.
65: * <BR>The test starts HelloWorld debuggee, create some strings
66: * with VirtualMachine.CreateString command.
67: * <BR> Then the test checks that for each created string
68: * StringReference.Value command returns string which is
69: * equal to string used for CreateString command.
70: */
71: public void testStringReferenceValueTest001()
72: throws UnsupportedEncodingException {
73: logWriter.println("StringReferenceValueTest001 started");
74: synchronizer
75: .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
76:
77: checkString("");
78: checkString("1234567890");
79: checkString("Some test string with various ASCII symbols "
80: + "~!@#$%^&*()_+|}{\"'?><,./");
81: checkString("Some test string with various national symbols "
82: + "\u00a9\u0436\u0433\u0404\u0490\u00ad\u0408\u0438\u0439\u00a7\u0435"
83: + "\u043a\u043d\u00a6\u00a4\u00ab\u00ae\u0430\u0407\u00a0\u045e\u043b"
84: + "\u0434\u043f\u0437\u0431\u00ac\u0401\u0432\u043c\u040e\u043e.");
85:
86: synchronizer
87: .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
88: }
89:
90: }
|