jaroslav@520
|
1 |
/**
|
jaroslav@520
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
jaroslav@520
|
3 |
*
|
jaroslav@551
|
4 |
* Copyright 2013-2014 Oracle and/or its affiliates. All rights reserved.
|
jaroslav@520
|
5 |
*
|
jaroslav@520
|
6 |
* Oracle and Java are registered trademarks of Oracle and/or its affiliates.
|
jaroslav@520
|
7 |
* Other names may be trademarks of their respective owners.
|
jaroslav@520
|
8 |
*
|
jaroslav@520
|
9 |
* The contents of this file are subject to the terms of either the GNU
|
jaroslav@520
|
10 |
* General Public License Version 2 only ("GPL") or the Common
|
jaroslav@520
|
11 |
* Development and Distribution License("CDDL") (collectively, the
|
jaroslav@520
|
12 |
* "License"). You may not use this file except in compliance with the
|
jaroslav@520
|
13 |
* License. You can obtain a copy of the License at
|
jaroslav@520
|
14 |
* http://www.netbeans.org/cddl-gplv2.html
|
jaroslav@520
|
15 |
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
|
jaroslav@520
|
16 |
* specific language governing permissions and limitations under the
|
jaroslav@520
|
17 |
* License. When distributing the software, include this License Header
|
jaroslav@520
|
18 |
* Notice in each file and include the License file at
|
jaroslav@520
|
19 |
* nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
|
jaroslav@520
|
20 |
* particular file as subject to the "Classpath" exception as provided
|
jaroslav@520
|
21 |
* by Oracle in the GPL Version 2 section of the License file that
|
jaroslav@520
|
22 |
* accompanied this code. If applicable, add the following below the
|
jaroslav@520
|
23 |
* License Header, with the fields enclosed by brackets [] replaced by
|
jaroslav@520
|
24 |
* your own identifying information:
|
jaroslav@520
|
25 |
* "Portions Copyrighted [year] [name of copyright owner]"
|
jaroslav@520
|
26 |
*
|
jaroslav@520
|
27 |
* Contributor(s):
|
jaroslav@520
|
28 |
*
|
jaroslav@520
|
29 |
* The Original Software is NetBeans. The Initial Developer of the Original
|
jaroslav@551
|
30 |
* Software is Oracle. Portions Copyright 2013-2014 Oracle. All Rights Reserved.
|
jaroslav@520
|
31 |
*
|
jaroslav@520
|
32 |
* If you wish your version of this file to be governed by only the CDDL
|
jaroslav@520
|
33 |
* or only the GPL Version 2, indicate your decision by adding
|
jaroslav@520
|
34 |
* "[Contributor] elects to include this software in this distribution
|
jaroslav@520
|
35 |
* under the [CDDL or GPL Version 2] license." If you do not indicate a
|
jaroslav@520
|
36 |
* single choice of license, a recipient has the option to distribute
|
jaroslav@520
|
37 |
* your version of this file under either the CDDL, the GPL Version 2 or
|
jaroslav@520
|
38 |
* to extend the choice of license to its licensees as provided above.
|
jaroslav@520
|
39 |
* However, if you add GPL Version 2 code and therefore, elected the GPL
|
jaroslav@520
|
40 |
* Version 2 license, then the option applies only if the new code is
|
jaroslav@520
|
41 |
* made subject to such option by the copyright holder.
|
jaroslav@520
|
42 |
*/
|
jaroslav@520
|
43 |
package net.java.html.js.tests;
|
jaroslav@520
|
44 |
|
jaroslav@520
|
45 |
import java.io.InputStream;
|
jaroslav@520
|
46 |
import static org.testng.Assert.*;
|
jaroslav@520
|
47 |
import org.testng.annotations.Test;
|
jaroslav@520
|
48 |
|
jaroslav@520
|
49 |
/**
|
jaroslav@520
|
50 |
*
|
jaroslav@520
|
51 |
* @author Jaroslav Tulach <jtulach@netbeans.org>
|
jaroslav@520
|
52 |
*/
|
jaroslav@520
|
53 |
public class BodiesTest {
|
jaroslav@520
|
54 |
|
jaroslav@520
|
55 |
public BodiesTest() {
|
jaroslav@520
|
56 |
}
|
jaroslav@520
|
57 |
|
jaroslav@520
|
58 |
@Test public void annotationIsStillPresent() throws Exception {
|
jaroslav@520
|
59 |
InputStream is = Bodies.class.getResourceAsStream("Bodies.class");
|
jaroslav@520
|
60 |
assertNotNull(is, "Class Stream found");
|
jaroslav@520
|
61 |
|
jaroslav@520
|
62 |
byte[] arr = new byte[is.available()];
|
jaroslav@520
|
63 |
int len = is.read(arr);
|
jaroslav@520
|
64 |
|
jaroslav@520
|
65 |
assertEquals(len, arr.length, "Fully read");
|
jaroslav@520
|
66 |
|
jaroslav@520
|
67 |
String bytes = new String(arr, "UTF-8");
|
jaroslav@520
|
68 |
|
jaroslav@520
|
69 |
{
|
jaroslav@520
|
70 |
int idx = bytes.indexOf("Lnet/java/html/js/JavaScriptBody");
|
jaroslav@520
|
71 |
if (idx == -1) {
|
jaroslav@520
|
72 |
fail("Expecting JavaScriptBody reference in: " + bytes);
|
jaroslav@520
|
73 |
}
|
jaroslav@520
|
74 |
}
|
jaroslav@520
|
75 |
{
|
jaroslav@520
|
76 |
int idx = bytes.indexOf("return a + b");
|
jaroslav@520
|
77 |
if (idx == -1) {
|
jaroslav@520
|
78 |
fail("Expecting 'return a + b' in the class file: " + bytes);
|
jaroslav@520
|
79 |
}
|
jaroslav@520
|
80 |
}
|
jaroslav@520
|
81 |
}
|
jaroslav@520
|
82 |
|
jaroslav@520
|
83 |
}
|