# HG changeset patch # User Jaroslav Tulach # Date 1380049695 -7200 # Node ID 4dbbfc8310b09d54f59fc937b9f753c6396e7a56 # Parent 7b98c561321d32e72f244354c15c24b82b40e506# Parent 4109cd3a4aa4533fc2767c9e275ee3849d080591 Bringing up to date with most recent default branch diff -r 7b98c561321d -r 4dbbfc8310b0 pom.xml --- a/pom.xml Wed Jul 31 17:04:32 2013 +0200 +++ b/pom.xml Tue Sep 24 21:08:15 2013 +0200 @@ -20,6 +20,8 @@ twitter chat chess + spinningcube + words @@ -79,4 +81,4 @@ - \ No newline at end of file + diff -r 7b98c561321d -r 4dbbfc8310b0 spinningcube/nbactions-iOS.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spinningcube/nbactions-iOS.xml Tue Sep 24 21:08:15 2013 +0200 @@ -0,0 +1,51 @@ + + + + + run + + package + org.netbeans.ios:ios-maven-plugin:0.2:deploy + + + true + + + + debug + + package + org.netbeans.ios:ios-maven-plugin:0.2:deploy + + + true + true + ${jpda.address} + Debug + + + \ No newline at end of file diff -r 7b98c561321d -r 4dbbfc8310b0 spinningcube/nbactions.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spinningcube/nbactions.xml Tue Sep 24 21:08:15 2013 +0200 @@ -0,0 +1,45 @@ + + + + + run + + process-classes + exec:java + + + + debug + + process-classes + exec:java + + + maven + + + diff -r 7b98c561321d -r 4dbbfc8310b0 spinningcube/pom.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spinningcube/pom.xml Tue Sep 24 21:08:15 2013 +0200 @@ -0,0 +1,148 @@ + + + 4.0.0 + + demo + org.apidesign.html + 1.0-SNAPSHOT + + + org.apidesign.demo + spinningcube + 1.0-SNAPSHOT + jar + + Spinning_Cube + + + + ios + NetBeans iOS Maven Plugin + http://beetle.cz.oracle.com/~jtulach/maven/ + + + + + + + UTF-8 + 0.4 + org.apidesign.demo.spinningcube.Main + none + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.7 + 1.7 + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + + ${project.mainclass} + true + lib/ + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + + browser.rootdir + ${basedir}/src/main/webapp/ + + + ${project.mainclass} + + + + maven-assembly-plugin + 2.4 + + + distro-assembly + package + + single + + + + src/main/assembly/html.java.net.xml + + + + + + + + + + org.apidesign.html + net.java.html.json + ${net.java.html.version} + + + org.apidesign.html + net.java.html.boot + ${net.java.html.version} + + + org.apidesign.html + ko-fx + ${net.java.html.version} + runtime + + + org.apidesign.html + boot-fx + ${net.java.html.version} + runtime + + + org.testng + testng + 6.7 + test + + + + + iOS + + + mac + Mac OS X + + + + + + org.netbeans.ios + ios-maven-plugin + 0.2 + + ${project.build.directory}/${project.build.finalName}.jar + ${project.name} + ${project.mainclass} + src/main/webapp/ + + + + + + + diff -r 7b98c561321d -r 4dbbfc8310b0 spinningcube/src/main/assembly/html.java.net.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spinningcube/src/main/assembly/html.java.net.xml Tue Sep 24 21:08:15 2013 +0200 @@ -0,0 +1,57 @@ + + + + + html.java.net + + zip + + ${project.build.finalName}-app + + + false + runtime + lib + + + + + ${project.build.directory}/${project.build.finalName}.jar + / + + + + + src/main/webapp/ + / + + pages/** + + + + \ No newline at end of file diff -r 7b98c561321d -r 4dbbfc8310b0 spinningcube/src/main/java/org/apidesign/demo/spinningcube/DataModel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spinningcube/src/main/java/org/apidesign/demo/spinningcube/DataModel.java Tue Sep 24 21:08:15 2013 +0200 @@ -0,0 +1,46 @@ +/** + * The MIT License (MIT) + * + * Copyright (C) 2013 Jaroslav Tulach + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.apidesign.demo.spinningcube; + +import net.java.html.json.ComputedProperty; +import net.java.html.json.Model; +import net.java.html.json.Property; + +/** Model with one message and cube with six sides. + * + * @author Jaroslav Tulach + */ +@Model(className = "Data", properties = { + @Property(name = "message", type = String.class), +}) +final class DataModel { + @ComputedProperty static String[] sides(String message) { + String[] arr = new String[6]; + String[] words = message == null ? new String[0] : message.split(" ", 6); + for (int i = 0; i < 6; i++) { + arr[i] = words.length > i ? words[i] : "!"; + } + return arr; + } +} diff -r 7b98c561321d -r 4dbbfc8310b0 spinningcube/src/main/java/org/apidesign/demo/spinningcube/Main.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spinningcube/src/main/java/org/apidesign/demo/spinningcube/Main.java Tue Sep 24 21:08:15 2013 +0200 @@ -0,0 +1,58 @@ +/** + * The MIT License (MIT) + * + * Copyright (C) 2013 Jaroslav Tulach + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.apidesign.demo.spinningcube; + +import net.java.html.boot.BrowserBuilder; + + +/** Bootstrap and initialization. + * + * @author Jaroslav Tulach + */ +public final class Main { + private Main() { + } + + /** Launches the browser */ + public static void main(String... args) throws Exception { + try { + Class.forName("java.lang.FunctionalInterface"); + } catch (ClassNotFoundException classNotFoundException) { + throw new IllegalStateException("This application does not run on JDK7, use at least JDK8"); + } + BrowserBuilder.newBrowser(). + loadPage("pages/index.html"). + loadClass(Main.class). + invoke("initialize", args). + showAndWait(); + System.exit(0); + } + + /** Called when page is ready */ + public static void initialize(String... args) throws Exception { + Data d = new Data(); + d.setMessage("Hello World from HTML and Java!"); + d.applyBindings(); + } +} diff -r 7b98c561321d -r 4dbbfc8310b0 spinningcube/src/main/webapp/pages/index.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spinningcube/src/main/webapp/pages/index.html Tue Sep 24 21:08:15 2013 +0200 @@ -0,0 +1,92 @@ + + + + + + + + + + + +

Spinning Cube Demo

+ +
+
+
+
+
+
+
+ + diff -r 7b98c561321d -r 4dbbfc8310b0 spinningcube/src/test/java/org/apidesign/demo/spinningcube/DataModelTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spinningcube/src/test/java/org/apidesign/demo/spinningcube/DataModelTest.java Tue Sep 24 21:08:15 2013 +0200 @@ -0,0 +1,39 @@ +/** + * The MIT License (MIT) + * + * Copyright (C) 2013 Jaroslav Tulach + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.apidesign.demo.spinningcube; + +import static org.testng.Assert.*; +import org.testng.annotations.Test; + +public class DataModelTest { + @Test public void areHelloWorldTwoWords() { + Data model = new Data(); + model.setMessage("Hello World!"); + + String[] arr = model.getSides(); + assertEquals(arr.length, 6, "Cube has six sides"); + assertEquals("Hello", arr[0], "Hello is the first word"); + assertEquals("World!", arr[1], "World is the second word"); + } +} diff -r 7b98c561321d -r 4dbbfc8310b0 twitter/nbactions-bck2brwsr.xml --- a/twitter/nbactions-bck2brwsr.xml Wed Jul 31 17:04:32 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ - - - - - run - - process-classes - bck2brwsr:brwsr - - - diff -r 7b98c561321d -r 4dbbfc8310b0 twitter/nbactions-fxbrwsr.xml --- a/twitter/nbactions-fxbrwsr.xml Wed Jul 31 17:04:32 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ - - - - - run - - process-classes - bck2brwsr:brwsr - - - - debug - - process-classes - bck2brwsr:brwsr - - - maven - - - diff -r 7b98c561321d -r 4dbbfc8310b0 twitter/nbactions.xml --- a/twitter/nbactions.xml Wed Jul 31 17:04:32 2013 +0200 +++ b/twitter/nbactions.xml Tue Sep 24 21:08:15 2013 +0200 @@ -28,15 +28,15 @@ run - process-classes - bck2brwsr:brwsr + package + exec:java debug - process-classes - bck2brwsr:brwsr + package + exec:java maven diff -r 7b98c561321d -r 4dbbfc8310b0 twitter/pom.xml --- a/twitter/pom.xml Wed Jul 31 17:04:32 2013 +0200 +++ b/twitter/pom.xml Tue Sep 24 21:08:15 2013 +0200 @@ -2,8 +2,8 @@ 4.0.0 - org.apidesign.bck2brwsr - demo-twitter + org.apidesign.html.demo + twitter 1.0-SNAPSHOT jar @@ -12,27 +12,18 @@ 1.0-SNAPSHOT - Fx/Bck2Brwsr's Twttr + KO4Java's Twttr - Rewrite of knockout.js example to use model written in Java and - execute using FxBrwsr or Bck2Brwsr. + Rewrite of knockout.js example to use model written in Java displayed + by HTML. UTF-8 - 0.1 - 0.7 - MINIMAL - org/apidesign/html/demo/twitter/index.html + 0.6 + org.apidesign.html.demo.twitter.TwitterMain - - - java.net - Java.net - https://maven.java.net/content/repositories/releases/ - - java.net @@ -44,22 +35,6 @@ - org.apidesign.bck2brwsr - bck2brwsr-maven-plugin - ${bck2brwsr.version} - - - - brwsr - - - - - ${brwsr.startpage} - ${brwsr} - - - org.apache.maven.plugins maven-compiler-plugin 2.3.2 @@ -79,6 +54,20 @@ + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + + browser.rootdir + ${basedir}/src/main/webapp/ + + + ${project.mainclass} + + + org.apache.maven.plugins maven-jar-plugin 2.4 @@ -110,154 +99,28 @@ test - org.apidesign.bck2brwsr - vmtest - ${bck2brwsr.version} - test - - org.apidesign.html net.java.html.json ${net.java.html.version} jar + + org.apidesign.html + net.java.html.boot + ${net.java.html.version} + jar + + + org.apidesign.html + boot-fx + ${net.java.html.version} + runtime + + + org.apidesign.html + ko-fx + ${net.java.html.version} + runtime + - - - fxbrwsr - - true - - - fxbrwsr - - - - - org.apache.maven.plugins - maven-jar-plugin - 2.4 - - - - org.apidesign.bck2brwsr.launcher.FXBrwsrLauncher - true - lib/ - - - ${brwsr.startpage} - - - - - - maven-assembly-plugin - 2.4 - - - distro-assembly - package - - single - - - - src/main/assembly/fxbrwsr.xml - - - - - - - - - - org.apidesign.html - ko-fx - ${net.java.html.version} - - - org.apidesign.bck2brwsr - launcher.fx - ${bck2brwsr.version} - runtime - - - - - bck2brwsr - - - brwsr - bck2brwsr - - - - - - org.apidesign.bck2brwsr - bck2brwsr-maven-plugin - - - - j2js - - - - - ${project.build.directory}/bck2brwsr.js - ${bck2brwsr.obfuscationlevel} - - - - org.apache.maven.plugins - maven-compiler-plugin - - - netbeans.ignore.jdk.bootclasspath - - - - - maven-assembly-plugin - 2.4 - - - distro-assembly - package - - single - - - - src/main/assembly/bck2brwsr.xml - - - - - - - - - - org.apidesign.bck2brwsr - emul - ${bck2brwsr.version} - rt - - - org.apidesign.html - ko-bck2brwsr - ${net.java.html.version} - runtime - - - org.apidesign.bck2brwsr - launcher.http - ${bck2brwsr.version} - test - - - - diff -r 7b98c561321d -r 4dbbfc8310b0 twitter/src/main/assembly/bck2brwsr.xml --- a/twitter/src/main/assembly/bck2brwsr.xml Wed Jul 31 17:04:32 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ - - - - - bck2brwsr - - zip - - public_html - - - false - runtime - lib - - *:jar - *:rt - - - - - - ${project.build.directory}/classes/org/apidesign/html/demo/twitter/ - - **/* - - - **/*.class - - / - - - - - ${project.build.directory}/${project.build.finalName}.jar - / - - - ${project.build.directory}/bck2brwsr.js - / - - - \ No newline at end of file diff -r 7b98c561321d -r 4dbbfc8310b0 twitter/src/main/java/org/apidesign/html/demo/twitter/TwitterClient.java --- a/twitter/src/main/java/org/apidesign/html/demo/twitter/TwitterClient.java Wed Jul 31 17:04:32 2013 +0200 +++ b/twitter/src/main/java/org/apidesign/html/demo/twitter/TwitterClient.java Tue Sep 24 21:08:15 2013 +0200 @@ -26,7 +26,6 @@ import java.util.Arrays; import java.util.List; import net.java.html.json.ComputedProperty; -import net.java.html.json.Context; import net.java.html.json.Function; import net.java.html.json.Model; import net.java.html.json.OnPropertyChange; @@ -45,7 +44,7 @@ @Property(name="currentTweets", type=Tweet.class, array = true), @Property(name="loading", type=boolean.class) }) -public class TwitterClient { +final class TwitterClient { @Model(className = "Tweeters", properties = { @Property(name="name", type = String.class), @Property(name="userNames", type = String.class, array = true) @@ -118,9 +117,8 @@ model.queryTweets("http://search.twitter.com", sb.toString()); } - private static final Context DEFAULT = Context.findDefault(TwitterClient.class); - static { - final TwitterModel model = new TwitterModel(DEFAULT); + static void init() { + final TwitterModel model = new TwitterModel(); final List svdLst = model.getSavedLists(); svdLst.add(newTweeters("API Design", "JaroslavTulach")); svdLst.add(newTweeters("Celebrities", "JohnCleese", "MCHammer", "StephenFry", "algore", "StevenSanderson")); @@ -161,7 +159,7 @@ final List sl = model.getSavedLists(); sl.remove(findByName(sl, model.getActiveTweetersName())); if (sl.isEmpty()) { - final Tweeters t = new Tweeters(DEFAULT); + final Tweeters t = new Tweeters(); t.setName("New"); sl.add(t); } @@ -195,11 +193,11 @@ return l; } } - return list.isEmpty() ? new Tweeters(DEFAULT) : list.get(0); + return list.isEmpty() ? new Tweeters() : list.get(0); } private static Tweeters newTweeters(String listName, String... userNames) { - Tweeters t = new Tweeters(DEFAULT); + Tweeters t = new Tweeters(); t.setName(listName); t.getUserNames().addAll(Arrays.asList(userNames)); return t; diff -r 7b98c561321d -r 4dbbfc8310b0 twitter/src/main/java/org/apidesign/html/demo/twitter/TwitterMain.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/twitter/src/main/java/org/apidesign/html/demo/twitter/TwitterMain.java Tue Sep 24 21:08:15 2013 +0200 @@ -0,0 +1,47 @@ +/** + * The MIT License (MIT) + * + * Copyright (C) 2013 Jaroslav Tulach + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.apidesign.html.demo.twitter; + +import net.java.html.boot.BrowserBuilder; + +/** Boots browser and then performs initialization when the HTML page + * is ready. + * + * @author Jaroslav Tulach + */ +public class TwitterMain { + private TwitterMain() { + } + + public static void main(String... args) { + BrowserBuilder.newBrowser().loadPage("pages/index.html") + .invoke("onPageLoad", args).loadClass(TwitterMain.class) + .showAndWait(); + System.exit(0); + } + + public static void onPageLoad(String... args) { + TwitterClient.init(); + } +} diff -r 7b98c561321d -r 4dbbfc8310b0 twitter/src/main/resources/org/apidesign/html/demo/twitter/index.html --- a/twitter/src/main/resources/org/apidesign/html/demo/twitter/index.html Wed Jul 31 17:04:32 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,105 +0,0 @@ - - - - - - - - - Bck2Brwsr's Twitter - - - - - - - -

Bck2Brwsr's Twitter

- -

- This code is based on original knockout.js Twitter example and - uses almost unmodified HTML page. It just changes the model. It - is written in Java language and it is executed using Bck2Brwsr - virtual machine. The Java source code has about 190 lines and is available - here - - in fact it may even be more dense than the original JavaScript model. -

- -
-
-
- - - -
- -

Currently viewing user(s):

-
-
    -
  • - -
    -
  • -
-
- -
- - - -
-
-
-
Loading...
- - - - - -
- - -
-
-
-
- - - - - - - diff -r 7b98c561321d -r 4dbbfc8310b0 twitter/src/main/resources/org/apidesign/html/demo/twitter/twitterExample.css --- a/twitter/src/main/resources/org/apidesign/html/demo/twitter/twitterExample.css Wed Jul 31 17:04:32 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -/** - * The MIT License (MIT) - * - * Copyright (C) 2013 Jaroslav Tulach - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - - - -/* - Copied from knockout.js Twitter example: - http://knockoutjs.com/examples/twitter.html -*/ - -.configuration, .tweets, .tweets td { font-family: Verdana; font-size: 13px; } -.configuration { background-color: #DEDEDE; border: 2px solid gray; float:left; height: 40em; width: 40%; padding: 0.5em; border-right-width:0; } -.tweets { width: 55%; border: 2px solid gray; height: 40em; overflow: scroll; overflow-x: hidden; background-color: Black; color: White; padding: 0.5em; position: relative; } -.tweets table { border-width: 0;} -.tweets tr { vertical-align: top; } -.tweets td { padding: 0.4em 0.3em 1em 0.4em; border-width: 0; } -.tweets img { width: 4em; } -.tweetInfo { color: Gray; font-size: 0.9em; } -.twitterUser { color: #77AAFF; text-decoration: none; font-size: 1.1em; font-weight: bold; } -input.invalid { border: 1px solid red !important; background-color: #FFAAAA !important; } - -.listChooser select, .listChooser button { vertical-align:top; } -.listChooser select { width: 60%; font-size:1.2em; height:1.4em; } -.listChooser button { width: 19%; height:1.68em; float:right; } - -.currentUsers { height: 28em; overflow-y: auto; overflow-x: hidden; } -.currentUsers button { float: right; height: 2.5em; margin: 0.1em; padding-left: 1em; padding-right: 1em; } -.currentUsers ul, .configuration li { list-style: none; margin: 0; padding: 0 } -.currentUsers li { height: 2.4em; font-size: 1.2em; background-color: #A7D0E3; border: 1px solid gray; margin-bottom: 0.3em; -webkit-border-radius: 5px; -moz-border-radius: 5px; -webkit-box-shadow: 0 0.2em 0.5em gray; -moz-box-shadow: 0 0.2em 0.5em gray; } -.currentUsers li div { padding: 0.6em; } -.currentUsers li:hover { background-color: #EEC; } - -.configuration form label { width: 25%; display: inline-block; text-align:right; overflow: hidden; } -.configuration form input { width:40%; font-size: 1.3em; border:1px solid silver; background-color: White; padding: 0.1em; } -.configuration form button { width: 20%; margin-left: 0.3em; height: 2em; } - -.loadingIndicator { position: absolute; top: 0.1em; left: 0.1em; font: 0.8em Arial; background-color: #229; color: White; padding: 0.2em 0.5em 0.2em 0.5em; } diff -r 7b98c561321d -r 4dbbfc8310b0 twitter/src/main/webapp/pages/index.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/twitter/src/main/webapp/pages/index.html Tue Sep 24 21:08:15 2013 +0200 @@ -0,0 +1,97 @@ + + + + + + + + + Html and Java Twitter + + + + + + + +

Bck2Brwsr's Twitter

+ +

+ This code is based on original knockout.js Twitter example and + uses almost unmodified HTML page. It just changes the model. It + is written in Java language and it is executed using the HotSpot + virtual machine. The Java source code has about 190 lines and is available + here + - in fact it may even be more dense than the original JavaScript model. +

+ +
+
+
+ + + +
+ +

Currently viewing user(s):

+
+
    +
  • + +
    +
  • +
+
+ +
+ + + +
+
+
+
Loading...
+ + + + + +
+ + +
+
+
+
+ + diff -r 7b98c561321d -r 4dbbfc8310b0 twitter/src/main/webapp/pages/twitterExample.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/twitter/src/main/webapp/pages/twitterExample.css Tue Sep 24 21:08:15 2013 +0200 @@ -0,0 +1,58 @@ +/** + * The MIT License (MIT) + * + * Copyright (C) 2013 Jaroslav Tulach + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + + + +/* + Copied from knockout.js Twitter example: + http://knockoutjs.com/examples/twitter.html +*/ + +.configuration, .tweets, .tweets td { font-family: Verdana; font-size: 13px; } +.configuration { background-color: #DEDEDE; border: 2px solid gray; float:left; height: 40em; width: 40%; padding: 0.5em; border-right-width:0; } +.tweets { width: 55%; border: 2px solid gray; height: 40em; overflow: scroll; overflow-x: hidden; background-color: Black; color: White; padding: 0.5em; position: relative; } +.tweets table { border-width: 0;} +.tweets tr { vertical-align: top; } +.tweets td { padding: 0.4em 0.3em 1em 0.4em; border-width: 0; } +.tweets img { width: 4em; } +.tweetInfo { color: Gray; font-size: 0.9em; } +.twitterUser { color: #77AAFF; text-decoration: none; font-size: 1.1em; font-weight: bold; } +input.invalid { border: 1px solid red !important; background-color: #FFAAAA !important; } + +.listChooser select, .listChooser button { vertical-align:top; } +.listChooser select { width: 60%; font-size:1.2em; height:1.4em; } +.listChooser button { width: 19%; height:1.68em; float:right; } + +.currentUsers { height: 28em; overflow-y: auto; overflow-x: hidden; } +.currentUsers button { float: right; height: 2.5em; margin: 0.1em; padding-left: 1em; padding-right: 1em; } +.currentUsers ul, .configuration li { list-style: none; margin: 0; padding: 0 } +.currentUsers li { height: 2.4em; font-size: 1.2em; background-color: #A7D0E3; border: 1px solid gray; margin-bottom: 0.3em; -webkit-border-radius: 5px; -moz-border-radius: 5px; -webkit-box-shadow: 0 0.2em 0.5em gray; -moz-box-shadow: 0 0.2em 0.5em gray; } +.currentUsers li div { padding: 0.6em; } +.currentUsers li:hover { background-color: #EEC; } + +.configuration form label { width: 25%; display: inline-block; text-align:right; overflow: hidden; } +.configuration form input { width:40%; font-size: 1.3em; border:1px solid silver; background-color: White; padding: 0.1em; } +.configuration form button { width: 20%; margin-left: 0.3em; height: 2em; } + +.loadingIndicator { position: absolute; top: 0.1em; left: 0.1em; font: 0.8em Arial; background-color: #229; color: White; padding: 0.2em 0.5em 0.2em 0.5em; } diff -r 7b98c561321d -r 4dbbfc8310b0 twitter/src/test/java/org/apidesign/html/demo/twitter/TwitterClientTest.java --- a/twitter/src/test/java/org/apidesign/html/demo/twitter/TwitterClientTest.java Wed Jul 31 17:04:32 2013 +0200 +++ b/twitter/src/test/java/org/apidesign/html/demo/twitter/TwitterClientTest.java Tue Sep 24 21:08:15 2013 +0200 @@ -23,9 +23,7 @@ */ package org.apidesign.html.demo.twitter; -import org.apidesign.html.demo.twitter.TwitterClient; import java.util.List; -import net.java.html.json.Context; import static org.testng.Assert.*; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -40,12 +38,12 @@ @BeforeMethod public void initModel() { - model = new TwitterModel(Context.EMPTY); + model = new TwitterModel(); } @Test public void testIsValidToAdd() { model.setUserNameToAdd("Joe"); - Tweeters t = new Tweeters(Context.EMPTY); + Tweeters t = new Tweeters(); t.setName("test"); model.getSavedLists().add(t); model.setActiveTweetersName("test"); diff -r 7b98c561321d -r 4dbbfc8310b0 twitter/src/test/java/org/apidesign/html/demo/twitter/TwitterProtocolTest.java --- a/twitter/src/test/java/org/apidesign/html/demo/twitter/TwitterProtocolTest.java Wed Jul 31 17:04:32 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,101 +0,0 @@ -/** - * The MIT License (MIT) - * - * Copyright (C) 2013 Jaroslav Tulach - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.apidesign.html.demo.twitter; - -import net.java.html.json.Context; -import org.apidesign.bck2brwsr.vmtest.BrwsrTest; -import org.apidesign.bck2brwsr.vmtest.Http; -import org.apidesign.bck2brwsr.vmtest.VMTest; -import org.testng.annotations.Factory; - -/** - * - * @author Jaroslav Tulach - */ -public class TwitterProtocolTest { - private TwitterModel page; - @Http(@Http.Resource( - path = "/search.json", - mimeType = "application/json", - parameters = {"callback"}, - content = "$0({\"completed_in\":0.04,\"max_id\":320055706885689344,\"max_id_str\"" - + ":\"320055706885689344\",\"page\":1,\"query\":\"from%3AJaroslavTulach\",\"refresh_url\":" - + "\"?since_id=320055706885689344&q=from%3AJaroslavTulach\"," - + "\"results\":[{\"created_at\":\"Fri, 05 Apr 2013 06:10:01 +0000\"," - + "\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,\"from_user_id_str\":" - + "\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,\"id\":320055706885689344," - + "\"id_str\":\"320055706885689344\",\"iso_language_code\":\"en\",\"metadata\":{\"result_type\":" - + "\"recent\"},\"profile_image_url\":\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\"," - + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\"," - + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":" - + "\"@tom_enebo Amzng! Not that I would like #ruby, but I am really glad you guys stabilized the plugin + " - + "made it work in #netbeans 7.3! Gd wrk.\",\"to_user\":\"tom_enebo\",\"to_user_id\":14498747," - + "\"to_user_id_str\":\"14498747\",\"to_user_name\":\"tom_enebo\",\"in_reply_to_status_id\":319832359509839872," - + "\"in_reply_to_status_id_str\":\"319832359509839872\"},{\"created_at\":\"Thu, 04 Apr 2013 07:33:06 +0000\"," - + "\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,\"from_user_id_str\":" - + "\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,\"id\":319714227088678913," - + "\"id_str\":\"319714227088678913\",\"iso_language_code\":\"en\",\"metadata\":{\"result_type\":" - + "\"recent\"},\"profile_image_url\":\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\"," - + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\"," - + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":" - + "\"RT @drkrab: At #erlangfactory @joerl: Frameworks grow in complexity until nobody can use them.\"}," - + "{\"created_at\":\"Tue, 02 Apr 2013 07:44:34 +0000\",\"from_user\":\"JaroslavTulach\"," - + "\"from_user_id\":420944648,\"from_user_id_str\":\"420944648\",\"from_user_name\":\"Jaroslav Tulach\"," - + "\"geo\":null,\"id\":318992336145248256,\"id_str\":\"318992336145248256\",\"iso_language_code\":\"en\"," - + "\"metadata\":{\"result_type\":\"recent\"},\"profile_image_url\":" - + "\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\"," - + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\"," - + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":" - + "\"Twitter renamed to twttr http:\\/\\/t.co\\/tqaN4T1xlZ - good, I don't have to rename #bck2brwsr!\"}," - + "{\"created_at\":\"Sun, 31 Mar 2013 03:52:04 +0000\",\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648," - + "\"from_user_id_str\":\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null," - + "\"id\":318209051223789568,\"id_str\":\"318209051223789568\",\"iso_language_code\":\"en\",\"metadata\":" - + "{\"result_type\":\"recent\"},\"profile_image_url\":" - + "\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\"," - + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\"," - + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":" - + "\"Math proofs without words. Ingenious: http:\\/\\/t.co\\/sz7yVbfpGw\"}],\"results_per_page\":100," - + "\"since_id\":0,\"since_id_str\":\"0\"})" - )) - @BrwsrTest public void readFromTwttr() throws InterruptedException { - if (page == null) { - page = new TwitterModel(Context.findDefault(TwitterProtocolTest.class)); - page.applyBindings(); - page.queryTweets("", "q=xyz"); - } - - if (page.getCurrentTweets().isEmpty()) { - throw new InterruptedException(); - } - - assert 4 == page.getCurrentTweets().size() : "Four tweets: " + page.getCurrentTweets(); - - String firstDate = page.getCurrentTweets().get(0).getCreated_at(); - assert "Fri, 05 Apr 2013 06:10:01 +0000".equals(firstDate) : "Date is OK: " + firstDate; - } - - @Factory public static Object[] create() { - return VMTest.create(TwitterProtocolTest.class); - } -} diff -r 7b98c561321d -r 4dbbfc8310b0 words/nbactions-iOS.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/words/nbactions-iOS.xml Tue Sep 24 21:08:15 2013 +0200 @@ -0,0 +1,51 @@ + + + + + run + + package + org.netbeans.ios:ios-maven-plugin:0.2:deploy + + + true + + + + debug + + package + org.netbeans.ios:ios-maven-plugin:0.2:deploy + + + true + true + ${jpda.address} + Debug + + + \ No newline at end of file diff -r 7b98c561321d -r 4dbbfc8310b0 words/nbactions.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/words/nbactions.xml Tue Sep 24 21:08:15 2013 +0200 @@ -0,0 +1,45 @@ + + + + + run + + process-classes + exec:java + + + + debug + + process-classes + exec:java + + + maven + + + diff -r 7b98c561321d -r 4dbbfc8310b0 words/pom.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/words/pom.xml Tue Sep 24 21:08:15 2013 +0200 @@ -0,0 +1,148 @@ + + + 4.0.0 + + demo + org.apidesign.html + 1.0-SNAPSHOT + + + org.apidesign.demo + words + 1.0-SNAPSHOT + jar + + Words + + + + ios + NetBeans iOS Maven Plugin + http://beetle.cz.oracle.com/~jtulach/maven/ + + + + + + + UTF-8 + 0.4 + org.apidesign.demo.words.Main + none + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.7 + 1.7 + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + + ${project.mainclass} + true + lib/ + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + + browser.rootdir + ${basedir}/src/main/webapp/ + + + ${project.mainclass} + + + + maven-assembly-plugin + 2.4 + + + distro-assembly + package + + single + + + + src/main/assembly/html.java.net.xml + + + + + + + + + + org.apidesign.html + net.java.html.json + ${net.java.html.version} + + + org.apidesign.html + net.java.html.boot + ${net.java.html.version} + + + org.apidesign.html + ko-fx + ${net.java.html.version} + runtime + + + org.apidesign.html + boot-fx + ${net.java.html.version} + runtime + + + org.testng + testng + 6.7 + test + + + + + iOS + + + mac + Mac OS X + + + + + + org.netbeans.ios + ios-maven-plugin + 0.2 + + ${project.build.directory}/${project.build.finalName}.jar + ${project.name} + ${project.mainclass} + src/main/webapp/ + + + + + + + diff -r 7b98c561321d -r 4dbbfc8310b0 words/src/main/assembly/html.java.net.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/words/src/main/assembly/html.java.net.xml Tue Sep 24 21:08:15 2013 +0200 @@ -0,0 +1,57 @@ + + + + + html.java.net + + zip + + ${project.build.finalName}-app + + + false + runtime + lib + + + + + ${project.build.directory}/${project.build.finalName}.jar + / + + + + + src/main/webapp/ + / + + pages/** + + + + \ No newline at end of file diff -r 7b98c561321d -r 4dbbfc8310b0 words/src/main/java/org/apidesign/demo/words/DataModel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/words/src/main/java/org/apidesign/demo/words/DataModel.java Tue Sep 24 21:08:15 2013 +0200 @@ -0,0 +1,55 @@ +/** + * The MIT License (MIT) + * + * Copyright (C) 2013 Jaroslav Tulach + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.apidesign.demo.words; + +import net.java.html.json.ComputedProperty; +import net.java.html.json.Function; +import net.java.html.json.Model; +import net.java.html.json.Property; + +/** Model with one message and cube with six sides. + * + * @author Jaroslav Tulach + */ +@Model(className = "Data", properties = { + @Property(name = "message", type = String.class), + @Property(name = "on", type = boolean.class) +}) +final class DataModel { + @ComputedProperty static String[] sides(String message) { + String[] arr = new String[6]; + String[] words = message == null ? new String[0] : message.split(" ", 6); + for (int i = 0; i < 6; i++) { + arr[i] = words.length > i ? words[i] : "!"; + } + return arr; + } + + @Function static void turnOn(Data model) { + model.setOn(true); + } + @Function static void turnOff(Data model) { + model.setOn(false); + } +} diff -r 7b98c561321d -r 4dbbfc8310b0 words/src/main/java/org/apidesign/demo/words/Main.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/words/src/main/java/org/apidesign/demo/words/Main.java Tue Sep 24 21:08:15 2013 +0200 @@ -0,0 +1,53 @@ +/** + * The MIT License (MIT) + * + * Copyright (C) 2013 Jaroslav Tulach + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.apidesign.demo.words; + +import net.java.html.boot.BrowserBuilder; + + +/** Bootstrap and initialization. + * + * @author Jaroslav Tulach + */ +public final class Main { + private Main() { + } + + /** Launches the browser */ + public static void main(String... args) throws Exception { + BrowserBuilder.newBrowser(). + loadPage("pages/index.html"). + loadClass(Main.class). + invoke("onPageLoad", args). + showAndWait(); + System.exit(0); + } + + /** Called when page is ready */ + public static void onPageLoad(String... args) throws Exception { + Data d = new Data(); + d.setMessage("Hello World from HTML and Java!"); + d.applyBindings(); + } +} diff -r 7b98c561321d -r 4dbbfc8310b0 words/src/main/webapp/pages/index.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/words/src/main/webapp/pages/index.html Tue Sep 24 21:08:15 2013 +0200 @@ -0,0 +1,83 @@ + + + + + + + + + + + +

Words Demo

+ +
+ + + +
+ + + +
+ + diff -r 7b98c561321d -r 4dbbfc8310b0 words/src/test/java/org/apidesign/demo/words/DataModelTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/words/src/test/java/org/apidesign/demo/words/DataModelTest.java Tue Sep 24 21:08:15 2013 +0200 @@ -0,0 +1,39 @@ +/** + * The MIT License (MIT) + * + * Copyright (C) 2013 Jaroslav Tulach + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.apidesign.demo.words; + +import static org.testng.Assert.*; +import org.testng.annotations.Test; + +public class DataModelTest { + @Test public void areHelloWorldTwoWords() { + Data model = new Data(); + model.setMessage("Hello World!"); + + String[] arr = model.getSides(); + assertEquals(arr.length, 6, "Cube has six sides"); + assertEquals("Hello", arr[0], "Hello is the first word"); + assertEquals("World!", arr[1], "World is the second word"); + } +}