List of usage examples for java.util List size
int size();
From source file:io.s4.MainApp.java
public static void main(String args[]) throws Exception { Options options = new Options(); options.addOption(OptionBuilder.withArgName("corehome").hasArg().withDescription("core home").create("c")); options.addOption(// ww w. j a va 2 s . c om OptionBuilder.withArgName("appshome").hasArg().withDescription("applications home").create("a")); options.addOption(OptionBuilder.withArgName("s4clock").hasArg().withDescription("s4 clock").create("d")); options.addOption(OptionBuilder.withArgName("seedtime").hasArg() .withDescription("event clock initialization time").create("s")); options.addOption( OptionBuilder.withArgName("extshome").hasArg().withDescription("extensions home").create("e")); options.addOption( OptionBuilder.withArgName("instanceid").hasArg().withDescription("instance id").create("i")); options.addOption( OptionBuilder.withArgName("configtype").hasArg().withDescription("configuration type").create("t")); CommandLineParser parser = new GnuParser(); CommandLine commandLine = null; String clockType = "wall"; try { commandLine = parser.parse(options, args); } catch (ParseException pe) { System.err.println(pe.getLocalizedMessage()); System.exit(1); } int instanceId = -1; if (commandLine.hasOption("i")) { String instanceIdStr = commandLine.getOptionValue("i"); try { instanceId = Integer.parseInt(instanceIdStr); } catch (NumberFormatException nfe) { System.err.println("Bad instance id: %s" + instanceIdStr); System.exit(1); } } if (commandLine.hasOption("c")) { coreHome = commandLine.getOptionValue("c"); } if (commandLine.hasOption("a")) { appsHome = commandLine.getOptionValue("a"); } if (commandLine.hasOption("d")) { clockType = commandLine.getOptionValue("d"); } if (commandLine.hasOption("e")) { extsHome = commandLine.getOptionValue("e"); } String configType = "typical"; if (commandLine.hasOption("t")) { configType = commandLine.getOptionValue("t"); } long seedTime = 0; if (commandLine.hasOption("s")) { seedTime = Long.parseLong(commandLine.getOptionValue("s")); } File coreHomeFile = new File(coreHome); if (!coreHomeFile.isDirectory()) { System.err.println("Bad core home: " + coreHome); System.exit(1); } File appsHomeFile = new File(appsHome); if (!appsHomeFile.isDirectory()) { System.err.println("Bad applications home: " + appsHome); System.exit(1); } if (instanceId > -1) { System.setProperty("instanceId", "" + instanceId); } else { System.setProperty("instanceId", "" + S4Util.getPID()); } List loArgs = commandLine.getArgList(); if (loArgs.size() < 1) { // System.err.println("No bean configuration file specified"); // System.exit(1); } // String s4ConfigXml = (String) loArgs.get(0); // System.out.println("s4ConfigXml is " + s4ConfigXml); ClassPathResource propResource = new ClassPathResource("s4-core.properties"); Properties prop = new Properties(); if (propResource.exists()) { prop.load(propResource.getInputStream()); } else { System.err.println("Unable to find s4-core.properties. It must be available in classpath"); System.exit(1); } ApplicationContext coreContext = null; String configBase = coreHome + File.separatorChar + "conf" + File.separatorChar + configType; String configPath = ""; List<String> coreConfigUrls = new ArrayList<String>(); File configFile = null; // load clock configuration configPath = configBase + File.separatorChar + clockType + "-clock.xml"; coreConfigUrls.add(configPath); // load core config xml configPath = configBase + File.separatorChar + "s4-core-conf.xml"; configFile = new File(configPath); if (!configFile.exists()) { System.err.printf("S4 core config file %s does not exist\n", configPath); System.exit(1); } coreConfigUrls.add(configPath); String[] coreConfigFiles = new String[coreConfigUrls.size()]; coreConfigUrls.toArray(coreConfigFiles); String[] coreConfigFileUrls = new String[coreConfigFiles.length]; for (int i = 0; i < coreConfigFiles.length; i++) { coreConfigFileUrls[i] = "file:" + coreConfigFiles[i]; } coreContext = new FileSystemXmlApplicationContext(coreConfigFileUrls, coreContext); ApplicationContext context = coreContext; Clock s4Clock = (Clock) context.getBean("clock"); if (s4Clock instanceof EventClock && seedTime > 0) { EventClock s4EventClock = (EventClock) s4Clock; s4EventClock.updateTime(seedTime); System.out.println("Intializing event clock time with seed time " + s4EventClock.getCurrentTime()); } PEContainer peContainer = (PEContainer) context.getBean("peContainer"); Watcher w = (Watcher) context.getBean("watcher"); w.setConfigFilename(configPath); // load extension modules String[] configFileNames = getModuleConfigFiles(extsHome, prop); if (configFileNames.length > 0) { String[] configFileUrls = new String[configFileNames.length]; for (int i = 0; i < configFileNames.length; i++) { configFileUrls[i] = "file:" + configFileNames[i]; } context = new FileSystemXmlApplicationContext(configFileUrls, context); } // load application modules configFileNames = getModuleConfigFiles(appsHome, prop); if (configFileNames.length > 0) { String[] configFileUrls = new String[configFileNames.length]; for (int i = 0; i < configFileNames.length; i++) { configFileUrls[i] = "file:" + configFileNames[i]; } context = new FileSystemXmlApplicationContext(configFileUrls, context); // attach any beans that implement ProcessingElement to the PE // Container String[] processingElementBeanNames = context.getBeanNamesForType(ProcessingElement.class); for (String processingElementBeanName : processingElementBeanNames) { Object bean = context.getBean(processingElementBeanName); try { Method getS4ClockMethod = bean.getClass().getMethod("getS4Clock"); if (getS4ClockMethod.getReturnType().equals(Clock.class)) { if (getS4ClockMethod.invoke(bean) == null) { Method setS4ClockMethod = bean.getClass().getMethod("setS4Clock", Clock.class); setS4ClockMethod.invoke(bean, coreContext.getBean("clock")); } } } catch (NoSuchMethodException mnfe) { // acceptable } System.out.println("Adding processing element with bean name " + processingElementBeanName + ", id " + ((ProcessingElement) bean).getId()); peContainer.addProcessor((ProcessingElement) bean, processingElementBeanName); } } }
From source file:org.apache.s4.MainApp.java
public static void main(String args[]) throws Exception { Options options = new Options(); options.addOption(OptionBuilder.withArgName("corehome").hasArg().withDescription("core home").create("c")); options.addOption(/*from w w w . j a va2 s . co m*/ OptionBuilder.withArgName("appshome").hasArg().withDescription("applications home").create("a")); options.addOption(OptionBuilder.withArgName("s4clock").hasArg().withDescription("s4 clock").create("d")); options.addOption(OptionBuilder.withArgName("seedtime").hasArg() .withDescription("event clock initialization time").create("s")); options.addOption( OptionBuilder.withArgName("extshome").hasArg().withDescription("extensions home").create("e")); options.addOption( OptionBuilder.withArgName("instanceid").hasArg().withDescription("instance id").create("i")); options.addOption( OptionBuilder.withArgName("configtype").hasArg().withDescription("configuration type").create("t")); CommandLineParser parser = new GnuParser(); CommandLine commandLine = null; String clockType = "wall"; try { commandLine = parser.parse(options, args); } catch (ParseException pe) { System.err.println(pe.getLocalizedMessage()); System.exit(1); } int instanceId = -1; if (commandLine.hasOption("i")) { String instanceIdStr = commandLine.getOptionValue("i"); try { instanceId = Integer.parseInt(instanceIdStr); } catch (NumberFormatException nfe) { System.err.println("Bad instance id: %s" + instanceIdStr); System.exit(1); } } if (commandLine.hasOption("c")) { coreHome = commandLine.getOptionValue("c"); } if (commandLine.hasOption("a")) { appsHome = commandLine.getOptionValue("a"); } if (commandLine.hasOption("d")) { clockType = commandLine.getOptionValue("d"); } if (commandLine.hasOption("e")) { extsHome = commandLine.getOptionValue("e"); } String configType = "typical"; if (commandLine.hasOption("t")) { configType = commandLine.getOptionValue("t"); } long seedTime = 0; if (commandLine.hasOption("s")) { seedTime = Long.parseLong(commandLine.getOptionValue("s")); } File coreHomeFile = new File(coreHome); if (!coreHomeFile.isDirectory()) { System.err.println("Bad core home: " + coreHome); System.exit(1); } File appsHomeFile = new File(appsHome); if (!appsHomeFile.isDirectory()) { System.err.println("Bad applications home: " + appsHome); System.exit(1); } if (instanceId > -1) { System.setProperty("instanceId", "" + instanceId); } else { System.setProperty("instanceId", "" + S4Util.getPID()); } List loArgs = commandLine.getArgList(); if (loArgs.size() < 1) { // System.err.println("No bean configuration file specified"); // System.exit(1); } // String s4ConfigXml = (String) loArgs.get(0); // System.out.println("s4ConfigXml is " + s4ConfigXml); ClassPathResource propResource = new ClassPathResource("s4-core.properties"); Properties prop = new Properties(); if (propResource.exists()) { prop.load(propResource.getInputStream()); } else { System.err.println("Unable to find s4-core.properties. It must be available in classpath"); System.exit(1); } ApplicationContext coreContext = null; String configBase = coreHome + File.separatorChar + "conf" + File.separatorChar + configType; String configPath = ""; List<String> coreConfigUrls = new ArrayList<String>(); File configFile = null; // load clock configuration configPath = configBase + File.separatorChar + clockType + "-clock.xml"; coreConfigUrls.add(configPath); // load core config xml configPath = configBase + File.separatorChar + "s4-core-conf.xml"; configFile = new File(configPath); if (!configFile.exists()) { System.err.printf("S4 core config file %s does not exist\n", configPath); System.exit(1); } coreConfigUrls.add(configPath); String[] coreConfigFiles = new String[coreConfigUrls.size()]; coreConfigUrls.toArray(coreConfigFiles); String[] coreConfigFileUrls = new String[coreConfigFiles.length]; for (int i = 0; i < coreConfigFiles.length; i++) { coreConfigFileUrls[i] = "file:" + coreConfigFiles[i]; } coreContext = new FileSystemXmlApplicationContext(coreConfigFileUrls, coreContext); ApplicationContext context = coreContext; Clock clock = (Clock) context.getBean("clock"); if (clock instanceof EventClock && seedTime > 0) { EventClock s4EventClock = (EventClock) clock; s4EventClock.updateTime(seedTime); System.out.println("Intializing event clock time with seed time " + s4EventClock.getCurrentTime()); } PEContainer peContainer = (PEContainer) context.getBean("peContainer"); Watcher w = (Watcher) context.getBean("watcher"); w.setConfigFilename(configPath); // load extension modules String[] configFileNames = getModuleConfigFiles(extsHome, prop); if (configFileNames.length > 0) { String[] configFileUrls = new String[configFileNames.length]; for (int i = 0; i < configFileNames.length; i++) { configFileUrls[i] = "file:" + configFileNames[i]; } context = new FileSystemXmlApplicationContext(configFileUrls, context); } // load application modules configFileNames = getModuleConfigFiles(appsHome, prop); if (configFileNames.length > 0) { String[] configFileUrls = new String[configFileNames.length]; for (int i = 0; i < configFileNames.length; i++) { configFileUrls[i] = "file:" + configFileNames[i]; } context = new FileSystemXmlApplicationContext(configFileUrls, context); // attach any beans that implement ProcessingElement to the PE // Container String[] processingElementBeanNames = context.getBeanNamesForType(AbstractPE.class); for (String processingElementBeanName : processingElementBeanNames) { AbstractPE bean = (AbstractPE) context.getBean(processingElementBeanName); bean.setClock(clock); try { bean.setSafeKeeper((SafeKeeper) context.getBean("safeKeeper")); } catch (NoSuchBeanDefinitionException ignored) { // no safe keeper = no checkpointing / recovery } // if the application did not specify an id, use the Spring bean name if (bean.getId() == null) { bean.setId(processingElementBeanName); } System.out.println("Adding processing element with bean name " + processingElementBeanName + ", id " + ((AbstractPE) bean).getId()); peContainer.addProcessor((AbstractPE) bean); } } }
From source file:com.auditbucket.client.Importer.java
public static void main(String args[]) { try {/*www. j a v a 2 s. com*/ ArgumentParser parser = ArgumentParsers.newArgumentParser("ABImport").defaultHelp(true) .description("Import file formats to AuditBucket"); parser.addArgument("-s", "--server").setDefault("http://localhost/ab-engine") .help("Host URL to send files to"); parser.addArgument("-b", "--batch").setDefault(100).help("Default batch size"); parser.addArgument("-x", "--xref").setDefault(false).help("Cross References Only"); parser.addArgument("files").nargs("*").help( "Path and filename of Audit records to import in the format \"[/filepath/filename.ext],[com.import.YourClass],{skipCount}\""); Namespace ns = null; try { ns = parser.parseArgs(args); } catch (ArgumentParserException e) { parser.handleError(e); System.exit(1); } List<String> files = ns.getList("files"); if (files.isEmpty()) { parser.handleError(new ArgumentParserException("No files to parse", parser)); System.exit(1); } String b = ns.getString("batch"); int batchSize = 100; if (b != null && !"".equals(b)) batchSize = Integer.parseInt(b); StopWatch watch = new StopWatch(); watch.start(); logger.info("*** Starting {}", DateFormat.getDateTimeInstance().format(new Date())); long totalRows = 0; for (String file : files) { int skipCount = 0; List<String> items = Arrays.asList(file.split("\\s*,\\s*")); if (items.size() == 0) parser.handleError(new ArgumentParserException("No file arguments to process", parser)); int item = 0; String fileName = null; String fileClass = null; for (String itemArg : items) { if (item == 0) { fileName = itemArg; } else if (item == 1) { fileClass = itemArg; } else if (item == 2) skipCount = Integer.parseInt(itemArg); item++; } logger.debug("*** Calculated process args {}, {}, {}, {}", fileName, fileClass, batchSize, skipCount); totalRows = totalRows + processFile(ns.get("server").toString(), fileName, (fileClass != null ? Class.forName(fileClass) : null), batchSize, skipCount); } endProcess(watch, totalRows); logger.info("Finished at {}", DateFormat.getDateTimeInstance().format(new Date())); } catch (Exception e) { logger.error("Import error", e); } }
From source file:ee.ria.xroad.common.signature.BatchSignerIntegrationTest.java
/** * Main program entry point./* w w w . j a v a 2 s . c om*/ * @param args command-line arguments * @throws Exception in case of any errors */ public static void main(String[] args) throws Exception { if (args.length == 0) { printUsage(); return; } ActorSystem actorSystem = ActorSystem.create("Proxy", ConfigFactory.load().getConfig("proxy")); SignerClient.init(actorSystem); Thread.sleep(SIGNER_INIT_DELAY); // wait for signer client to connect BatchSigner.init(actorSystem); X509Certificate subjectCert = TestCertUtil.getConsumer().cert; X509Certificate issuerCert = TestCertUtil.getCaCert(); X509Certificate signerCert = TestCertUtil.getOcspSigner().cert; PrivateKey signerKey = TestCertUtil.getOcspSigner().key; List<String> messages = new ArrayList<>(); for (String arg : args) { messages.add(FileUtils.readFileToString(new File(arg))); } latch = new CountDownLatch(messages.size()); Date thisUpdate = new DateTime().plusDays(1).toDate(); final OCSPResp ocsp = OcspTestUtils.createOCSPResponse(subjectCert, issuerCert, signerCert, signerKey, CertificateStatus.GOOD, thisUpdate, null); for (final String message : messages) { new Thread(() -> { try { byte[] hash = hash(message); log.info("File: {}, hash: {}", message, hash); MessagePart hashPart = new MessagePart(MessageFileNames.MESSAGE, SHA512_ID, calculateDigest(SHA512_ID, message.getBytes()), message.getBytes()); List<MessagePart> hashes = Collections.singletonList(hashPart); SignatureBuilder builder = new SignatureBuilder(); builder.addPart(hashPart); builder.setSigningCert(subjectCert); builder.addOcspResponses(Collections.singletonList(ocsp)); log.info("### Calculating signature..."); SignatureData signatureData = builder.build( new SignerSigningKey(KEY_ID, CryptoUtils.CKM_RSA_PKCS_NAME), CryptoUtils.SHA512_ID); synchronized (sigIdx) { log.info("### Created signature: {}", signatureData.getSignatureXml()); log.info("HashChainResult: {}", signatureData.getHashChainResult()); log.info("HashChain: {}", signatureData.getHashChain()); toFile("message-" + sigIdx + ".xml", message); String sigFileName = signatureData.getHashChainResult() != null ? "batch-sig-" : "sig-"; toFile(sigFileName + sigIdx + ".xml", signatureData.getSignatureXml()); if (signatureData.getHashChainResult() != null) { toFile("hash-chain-" + sigIdx + ".xml", signatureData.getHashChain()); toFile("hash-chain-result.xml", signatureData.getHashChainResult()); } sigIdx++; } try { verify(signatureData, hashes, message); log.info("Verification successful (message hash: {})", hash); } catch (Exception e) { log.error("Verification failed (message hash: {})", hash, e); } } catch (Exception e) { log.error("Error", e); } finally { latch.countDown(); } }).start(); } latch.await(); actorSystem.shutdown(); }
From source file:org.apiwatch.cli.APIWatch.java
public static void main(String[] argv) { try {//from w ww .j a v a 2 s .c om Namespace args = parseArgs(argv); Logger log = Logger.getLogger(APIWatch.class.getName()); @SuppressWarnings("unchecked") Map<String, Map<String, String>> rulesConfig = (Map<String, Map<String, String>>) args .get(Args.RULES_CONFIG_OPTION); if (rulesConfig != null) { RulesFinder.configureRules(rulesConfig); } APIScope referenceScope = IO.getAPIData(args.getString(REFERENCE_API_DATA), args.getString(Args.INPUT_FORMAT_OPTION), args.getString(Analyser.ENCODING_OPTION), args.getString(Args.USERNAME_OPTION), args.getString(Args.PASSWORD_OPTION)); DirectoryWalker walker = new DirectoryWalker(args.<String>getList(Args.EXCLUDES_OPTION), args.<String>getList(Args.INCLUDES_OPTION)); Set<String> files = walker.walk(args.<String>getList(INPUT_PATHS)); APIScope newScope = Analyser.analyse(files, args.getAttrs()); log.trace("Calculation of differences..."); List<APIDifference> diffs = DifferencesCalculator.getDiffs(referenceScope, newScope); log.trace("Detection of API stability violations..."); ViolationsCalculator violationsClac = new ViolationsCalculator(RulesFinder.rules().values()); Severity threshold = (Severity) args.get(Args.SEVERITY_THRESHOLD_OPTION); List<APIStabilityViolation> violations = violationsClac.getViolations(diffs, threshold); OutputStreamWriter writer = new OutputStreamWriter(System.out); Serializers.dumpViolations(violations, writer, args.getString(Args.OUTPUT_FORMAT_OPTION)); writer.flush(); writer.close(); log.info(violations.size() + " violations."); } catch (HttpException e) { Logger.getLogger(APIWatch.class.getName()).error(e.getMessage()); System.exit(1); } catch (Exception e) { e.printStackTrace(); System.exit(1); } }
From source file:com.sliit.neuralnetwork.RecurrentNN.java
public static void main(String[] args) { RecurrentNN neural_network = new RecurrentNN(); System.out.println("start======================="); try {//from w w w . j a v a 2 s . c om neural_network.inputs = 10; neural_network.numHiddenNodes = 5; neural_network.HIDDEN_LAYER_COUNT = 2; neural_network.outputNum = 2; neural_network.buildModel(); String output = neural_network.trainModel("nn", "D:/Data/originalnormkddaddeddata.csv", 2, 10); System.out.println("output " + output); System.out.println("Testing........................"); Charset charset = Charset.forName("ISO-8859-1"); Path wiki_path = Paths.get("D:/SLIIT/deadlocks/data/", "normtrainadded.csv"); List<String> lines = Files.readAllLines(wiki_path, charset); String[] testDataArr = lines.toArray(new String[lines.size()]); Map<Integer, String> map = new HashMap<Integer, String>(); String testOutput = neural_network.testModel("nn", testDataArr, map, 10, 2, "D:/Data/Test", ""); System.out.println("Test output " + testOutput); } catch (Exception e) { e.printStackTrace(); } }
From source file:MdDetect.java
public static void main(String[] args) throws InterruptedException { if (null != args && args.length > 0 && null != args[0]) { System.out.println("Parsing lang: " + args[0]); try {// ww w. j ava2s. co m prefer = Lang.valueOf(args[0]); } catch (IllegalArgumentException e) { System.err.println("Lang switch must be one of:"); for (Lang lang : Lang.values()) { System.err.println("\t" + lang.name()); } System.exit(1); } } List<File> files = asFiles(getSysIn()); System.out.println("Processing " + files.size() + " files"); if (files.size() < 1) System.exit(0); // quit if nothing to do initExecutor(files.size()); for (File file : files) executorService.submit(newProcessFileAction(file)); executorService.shutdown(); executorService.awaitTermination(30, TimeUnit.SECONDS); }
From source file:com.heliosapm.streams.collector.ds.pool.TestMQPool.java
/** * @param args//w ww. ja va 2 s . c o m */ public static void main(String[] args) { try { log("Pool Test"); log(TEST_PROPS); JMXHelper.fireUpJMXMPServer(1077); final Properties p = Props.strToProps(TEST_PROPS); log("Props:" + p); final GenericObjectPool<Object> pool = null;//(GenericObjectPool<Object>)PoolConfig.deployPool(p); pool.preparePool(); log("Pool Deployed:" + pool.getNumIdle()); final List<Object> objects = new ArrayList<Object>(); for (int i = 0; i < 4; i++) { try { final Object o = pool.borrowObject(); log("Borrowed:" + o); objects.add(o); } catch (Exception e) { e.printStackTrace(); } } log("Objects:" + objects.size()); StdInCommandHandler.getInstance().registerCommand("close", new Runnable() { public void run() { for (Object o : objects) { pool.returnObject(o); } objects.clear(); try { pool.close(); } catch (Exception ex) { ex.printStackTrace(System.err); } } }).run(); } catch (Exception ex) { ex.printStackTrace(System.err); } }
From source file:eu.crisis_economics.configuration.CommaListExpression.java
public static void main(String[] args) { System.out.println("testing CommaListExpression type.."); {//from w ww. j a va2s .c om String expression = "Type[2] { first, second , NUMBER=$( 1 + 1 ) }"; List<String> expected = Arrays.asList("Type[2]", "first", "second", "NUMBER=$( 1 + 1 )"), gained = CommaListExpression.isExpressionOfType(expression, '{', '}', null); Assert.assertEquals(expected.size(), gained.size()); for (int i = 0; i < expected.size(); ++i) { Assert.assertEquals(expected.get(i), gained.get(i)); } } { String expression = "Type{ A }"; List<String> expected = Arrays.asList("Type", "A"), gained = CommaListExpression.isExpressionOfType(expression, '{', '}', null); Assert.assertEquals(expected.size(), gained.size()); for (int i = 0; i < expected.size(); ++i) { Assert.assertEquals(expected.get(i), gained.get(i)); } } { String expression = "Type{ }"; Assert.assertEquals(CommaListExpression.isExpressionOfType(expression, '{', '}', null) == null, true); } { List<String> expected = Arrays.asList( "ARGUMENT_ONE = OBJECT { FIRST = $(1.0/(1.0+1.0)), SECOND = objRef }", "ARGUMENT_TWO = OBJECT(FIRST = $(1.0/(1.0+1.0)), SECOND = objRef)", "ARGUMENT_THREE = objRef", "ARGUMENT_FOUR = objRef", "ARGUMENT_FIVE = OBJECT { FIRST = $(1.0/(1.0+1.0)), SECOND = objRef }", "ARGUMENT_SIX = objRef", "ARGUMENT_SEVEN = OBJECT(FIRST = $(1.0/(1.0+1.0)), SECOND = objRef)", "ARGUMENT_EIGHT = OBJECT(FIRST = $(1.0/(1.0+1.0)), SECOND = objRef, " + " THIRD = OBJECT[$(2+2)] { FIRST=$(1), SECOND=OBJECT(FIRST=objRef) } )"); List<String> gained = CommaListExpression .topLevelSplit("ARGUMENT_ONE = OBJECT { FIRST = $(1.0/(1.0+1.0)), SECOND = objRef }, " + "ARGUMENT_TWO = OBJECT(FIRST = $(1.0/(1.0+1.0)), SECOND = objRef), " + "ARGUMENT_THREE = objRef, " + "ARGUMENT_FOUR = objRef, " + "ARGUMENT_FIVE = OBJECT { FIRST = $(1.0/(1.0+1.0)), SECOND = objRef }, " + "ARGUMENT_SIX = objRef, " + "ARGUMENT_SEVEN = OBJECT(FIRST = $(1.0/(1.0+1.0)), SECOND = objRef), " + "ARGUMENT_EIGHT = OBJECT(FIRST = $(1.0/(1.0+1.0)), SECOND = objRef, " + " THIRD = OBJECT[$(2+2)] { FIRST=$(1), SECOND=OBJECT(FIRST=objRef) } )"); Assert.assertEquals(expected.size(), gained.size()); for (int i = 0; i < expected.size(); ++i) { Assert.assertEquals(expected.get(i), gained.get(i)); } } System.out.println("CommaListExpression tests pass."); }
From source file:com.bluepixel.security.manager.ServerClient_test.java
public static void main(String[] args) throws NoSuchAlgorithmException, InvalidKeyException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, Base64DecoderException, InvalidKeySpecException { // TODO Auto-generated method stub // ServerClient_test test = new ServerClient_test(); // Key key = test.getSecretKey(); // String plainKey = Base64.encodeWebSafe(key.getEncoded(), false); // String cipherMessage = test.encryptMessage(key, message); ////from w ww.j a v a2 s.co m // System.out.println("*********** Sender *************"); // System.out.println("Plain Text : " + cipherMessage); // System.out.println("cipher Text : " + cipherMessage); // System.out.println("secret key : " + plainKey); // // KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA"); // keyGen.initialize(1024); // KeyPair keyPair = keyGen.generateKeyPair(); // Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); // cipher.init(Cipher.ENCRYPT_MODE, keyPair.getPrivate()); // String cipherText = Base64.encodeWebSafe(cipher.doFinal(plainKey.getBytes()), false); // System.out.println("secret key (encrypted with PKI): " + cipherText); // // // cipher.init(Cipher.DECRYPT_MODE, keyPair.getPublic()); // byte[] plainKeyByte = cipher.doFinal(Base64.decodeWebSafe(cipherText)); // String original = test.decryptMessage(getKeyFromString(new String(plainKeyByte)), cipherMessage); // // System.out.println("\n*********** Receiver *************"); // System.out.println("secret key (encrypted with PKI): " + cipherText); // System.out.println("secret key : " + new String(plainKey)); // System.out.println("original message : " + original); // // // System.out.println("cipher key : " + cipherText); // System.out.println("cipher message : " + cipherMessage); System.out.println("\n*********** Test Client authentication *************"); //Server.init(); // try { // Client.connect(); // } catch (NoSuchProviderException e) { // // } List<String> str = decodePoly( "ie}Fq}wxRj@uBFUd@yBLm@h@_C^mBp@sC`AeEH[BENq@?AFYDO?C?AFW@A@IFUPy@TcAFWF[~@aEhAgF@S?M?aAAQ?YAe@?]?e@"); for (int i = 0; i < str.size(); i++) { System.out.println(i + " " + str.get(i)); } }