Skip to content

Commit 1340935

Browse files
author
jossonsmith
committed
Update tests for HttpRequest according to http://www.w3.org/TR/XMLHttpRequest/
1 parent 1601986 commit 1340935

File tree

3 files changed

+45
-6
lines changed

3 files changed

+45
-6
lines changed

tests/net.sf.j2s.test.ajax/src/com/ognize/lz77js/ui/LZ77JS.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.ognize.lz77js.ui;
22

3-
import net.sf.j2s.ajax.AJAXServletRequest;
4-
import net.sf.j2s.ajax.AJAXServletSWTRequest;
3+
import net.sf.j2s.ajax.SimpleRPCRequest;
4+
import net.sf.j2s.ajax.SimpleRPCSWTRequest;
55
import org.eclipse.swt.SWT;
66
import org.eclipse.swt.custom.SashForm;
77
import org.eclipse.swt.events.SelectionAdapter;
@@ -91,15 +91,15 @@ public void widgetSelected(SelectionEvent e) {
9191
/*
9292
* Local Java Thread mode is already the default mode for Java client
9393
*/
94-
AJAXServletRequest.switchToLocalJavaThreadMode();
94+
SimpleRPCRequest.switchToLocalJavaThreadMode();
9595
/*
9696
* AJAX mode is only mode for Java2Script client.
9797
* You can uncomment the follow line to call a LZ77JS RPC of bl.ognize.com.
9898
* In JavaScript mode, you should modify LZ77JSSimpleRPCRunnable#url so there
9999
* is no cross site script for XMLHttpRequest.
100100
*/
101101
//AJAXServletRequest.switchToAJAXMode();
102-
AJAXServletSWTRequest.swtRequest(new LZ77JSSimpleRPCRunnable() {
102+
SimpleRPCSWTRequest.swtRequest(new LZ77JSSimpleRPCRunnable() {
103103
public void ajaxIn() {
104104
jsContent = sourceText.getText();
105105
toRegExpCompress = regExpButton.getSelection();
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*******************************************************************************
2+
* Java2Script Pacemaker (http://j2s.sourceforge.net)
3+
*
4+
* Copyright (c) 2006 ognize.com and others.
5+
* All rights reserved. This program and the accompanying materials
6+
* are made available under the terms of the Eclipse Public License v1.0
7+
* which accompanies this distribution, and is available at
8+
* http://www.eclipse.org/legal/epl-v10.html
9+
*
10+
* Contributors:
11+
* ognize.com - initial API and implementation
12+
*******************************************************************************/
13+
14+
package net.sf.j2s.test.ajax;
15+
16+
import net.sf.j2s.ajax.HttpRequest;
17+
import net.sf.j2s.ajax.XHRCallbackAdapter;
18+
19+
20+
/**
21+
* @author josson smith
22+
*
23+
* 2006-2-11
24+
*/
25+
public class Base64UserPasswordTest {
26+
27+
public static void main(String[] args) {
28+
final HttpRequest request = new HttpRequest();
29+
request.open("GET", "http://localhost:8080/manager/html", true, "hello", "hello");
30+
request.registerOnReadyStateChange(new XHRCallbackAdapter() {
31+
public void onLoaded() {
32+
System.out.println(request.getAllResponseHeaders());
33+
System.out.println(request.getResponseText());
34+
}
35+
});
36+
request.send();
37+
System.out.println("continue!");
38+
}
39+
}

tests/net.sf.j2s.test.ajax/src/net/sf/j2s/test/ajax/LoadingRSS.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static void main3(String[] args) {
3131
//http://j2s.sourceforge.net/blog/feed/atom/
3232
request.open("POST", "http://bl.ognize.com:8080/servlets-examples/servlet/RequestParamExample?hello=world", true);
3333
request.registerOnReadyStateChange(new XHRCallbackAdapter() {
34-
public void onComplete() {
34+
public void onLoaded() {
3535
System.out.println(request.getResponseText());
3636
}
3737
});
@@ -44,7 +44,7 @@ public static void main(String[] args) {
4444
//request.open("GET", "http://j2s.sourceforge.net/blog/feed/atom/", true);
4545
request.open("GET", "http://bl.ognize.com/whizznotes/rss/all.xml", true);
4646
request.registerOnReadyStateChange(new XHRCallbackAdapter() {
47-
public void onComplete() {
47+
public void onLoaded() {
4848
//System.out.println(request.getResponseText());
4949
NodeList items = request.getResponseXML().getElementsByTagName("item");
5050
for (int i = 0; i < items.getLength(); i++) {

0 commit comments

Comments
 (0)