(String[] args)
| 12 | static Mongo3Interface jdi = null; |
| 13 | |
| 14 | public static void main(String[] args) { |
| 15 | int rc; |
| 16 | String[] parms = new String[4]; |
| 17 | |
| 18 | jdi = new Mongo3Interface(DEBUG); |
| 19 | |
| 20 | parms[0] = getLine("URI: ", false); |
| 21 | parms[1] = getLine("Database: ", false); |
| 22 | parms[2] = null; |
| 23 | parms[3] = null; |
| 24 | |
| 25 | if (parms[0] == null) |
| 26 | parms[0] = "mongodb://localhost:27017"; |
| 27 | |
| 28 | if (parms[1] == null) |
| 29 | parms[1] = "test"; |
| 30 | |
| 31 | rc = jdi.MongoConnect(parms); |
| 32 | |
| 33 | if (rc == 0) { |
| 34 | Object bdoc = jdi.MakeDocument(); |
| 35 | |
| 36 | if (jdi.DocAdd(bdoc, "_id", (Object) 1, 0)) |
| 37 | System.out.println(jdi.GetErrmsg()); |
| 38 | |
| 39 | if (jdi.DocAdd(bdoc, "Name", (Object) "Smith", 0)) |
| 40 | System.out.println(jdi.GetErrmsg()); |
| 41 | |
| 42 | if (jdi.DocAdd(bdoc, "Age", (Object) 39, 0)) |
| 43 | System.out.println(jdi.GetErrmsg()); |
| 44 | |
| 45 | if (jdi.DocAdd(bdoc, "Pi", (Object) 3.14, 0)) |
| 46 | System.out.println(jdi.GetErrmsg()); |
| 47 | |
| 48 | if (jdi.DocAdd(bdoc, "Phone", (Object) "{\"ext\":[4,5,7]}", 1)) |
| 49 | System.out.println(jdi.GetErrmsg()); |
| 50 | |
| 51 | if (jdi.DocAdd(bdoc, "Scores", (Object) "[24,2,13]", 2)) |
| 52 | System.out.println(jdi.GetErrmsg()); |
| 53 | |
| 54 | Object bar = jdi.MakeArray(); |
| 55 | |
| 56 | for (int i = 0; i < 2; i++) |
| 57 | if (jdi.ArrayAdd(bar, i, (Object) (Math.random() * 10.0), 0)) |
| 58 | System.out.println(jdi.GetErrmsg()); |
| 59 | |
| 60 | if (jdi.DocAdd(bdoc, "Prices", bar, 0)) |
| 61 | System.out.println(jdi.GetErrmsg()); |
| 62 | |
| 63 | Object dat = new Date(); |
| 64 | |
| 65 | if (jdi.DocAdd(bdoc, "Date", dat, 0)) |
| 66 | System.out.println(jdi.GetErrmsg()); |
| 67 | |
| 68 | System.out.println(bdoc); |
| 69 | |
| 70 | // Try to update |
| 71 | if (!jdi.GetCollection("updtest") && !jdi.FindColl(null, null)) { |
nothing calls this directly
no test coverage detected