Test the command line operations.
()
| 50 | * Test the command line operations. |
| 51 | */ |
| 52 | public void testApp() { |
| 53 | try { |
| 54 | // System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", |
| 55 | // "debug"); |
| 56 | |
| 57 | Feed feed; |
| 58 | Entry entry; |
| 59 | |
| 60 | // write test files to temp directory |
| 61 | File tmp = Files.createTempDir(); |
| 62 | tmp.deleteOnExit(); |
| 63 | |
| 64 | URL serviceURL = null; |
| 65 | if (System.getProperty("com.trsst.TrsstTest.server") == null) { |
| 66 | // start a local server for testing |
| 67 | System.setProperty("com.trsst.server.storage", |
| 68 | tmp.getAbsolutePath()); |
| 69 | Server server = new Server(); |
| 70 | serviceURL = server.getServiceURL(); |
| 71 | } else { |
| 72 | serviceURL = new URL( |
| 73 | System.getProperty("com.trsst.TrsstTest.server")); |
| 74 | } |
| 75 | // serviceURL = new URL("http://localhost:8888/trsst"); |
| 76 | assertNotNull(serviceURL); |
| 77 | |
| 78 | String feedId; |
| 79 | Client client = new Client(serviceURL); |
| 80 | KeyPair signingKeys, encryptionKeys; |
| 81 | PublicKey publicKey; |
| 82 | Element signatureElement; |
| 83 | String signatureValue; |
| 84 | |
| 85 | // generate account |
| 86 | signingKeys = Common.generateSigningKeyPair(); |
| 87 | assertNotNull("Generating signing keys", signingKeys); |
| 88 | encryptionKeys = Common.generateEncryptionKeyPair(); |
| 89 | assertNotNull("Generating encryption keys", encryptionKeys); |
| 90 | feedId = Common.toFeedId(signingKeys.getPublic()); |
| 91 | |
| 92 | // public key serialization |
| 93 | publicKey = signingKeys.getPublic(); |
| 94 | assertEquals("Signing keys serialize", |
| 95 | Common.toX509FromPublicKey(publicKey), |
| 96 | Common.toX509FromPublicKey(Common |
| 97 | .toPublicKeyFromX509(Common |
| 98 | .toX509FromPublicKey(publicKey)))); |
| 99 | publicKey = encryptionKeys.getPublic(); |
| 100 | assertEquals("Encryption keys serialize", |
| 101 | Common.toX509FromPublicKey(publicKey), |
| 102 | Common.toX509FromPublicKey(Common |
| 103 | .toPublicKeyFromX509(Common |
| 104 | .toX509FromPublicKey(publicKey)))); |
| 105 | |
| 106 | // generate feed with no entries |
| 107 | feed = client.post(signingKeys, encryptionKeys, new EntryOptions(), |
| 108 | new FeedOptions()); |
| 109 | assertNotNull("Generating empty feed", feed); |
nothing calls this directly
no test coverage detected