/** @throws Exception If failed. */ public void testNames() throws Exception { assertEquals("value1", svc.cacheable(1)); Collection<String> names = mgr.getCacheNames(); assertEquals(names.toString(), 2, names.size()); }
/** * Loads all GROUPValueObjects through the business facade using information in the * HttpServletRequest. * * @return String as result * @exception ProcessingException */ public String loadAllGROUPs() throws ProcessingException { String sReturnValue = null; logMessage(FrameworkLogEventType.DEBUG_LOG_EVENT_TYPE, "Inside GROUPWorkerBean::loadAllGROUPs"); try { // load the GROUPValueObject Collection coll = GROUPProxy.getGROUPs(); if (coll != null) { logMessage( FrameworkLogEventType.DEBUG_LOG_EVENT_TYPE, "GROUPWorkerBean:loadAllGROUPs() - successfully loaded all GROUPValueObjects - " + coll.toString()); // assign the GROUPValueObject to the ApplicationUSOM ApplicationUSOM objectManager = (ApplicationUSOM) getUSOM(); objectManager.setGROUPs(coll); } } catch (Exception exc) { throw new ProcessingException( "GROUPWorkerBean:loadAllGROUPs() - successfully loaded all GROUPValueObjects - " + exc, exc); } return (sReturnValue); }
@Override public Optional<String> getValueDescription(MutableModelNode modelNodeInternal) { Collection<?> values = ScalarCollectionSchema.get(modelNodeInternal); if (values == null) { return Optional.absent(); } return Optional.of(values.toString()); }
private static void testImplementation(Class<? extends Collection> implClazz) throws Throwable { testPotato(implClazz, Vector.class); testPotato(implClazz, CopyOnWriteArrayList.class); final Constructor<? extends Collection> constr = implClazz.getConstructor(Collection.class); final Collection<Object> coll = constr.newInstance(Arrays.asList(new String[] {})); coll.add(1); equal(coll.toString(), "[1]"); }
public void testDuplicateObjectInBinaryAndSources() throws Exception { Collection<DeclarationDescriptor> allDescriptors = analyzeAndGetAllDescriptors(compileLibrary("library")); assertEquals(allDescriptors.toString(), 2, allDescriptors.size()); for (DeclarationDescriptor descriptor : allDescriptors) { assertTrue("Wrong name: " + descriptor, descriptor.getName().asString().equals("Lol")); assertTrue("Should be an object: " + descriptor, isObject(descriptor)); } }
public OChannelBinary writeCollectionString(final Collection<String> iCollection) throws IOException { if (debug) OLogManager.instance() .info( this, "%s - Writing strings (4+%d=%d items): %s", socket.getRemoteSocketAddress(), iCollection != null ? iCollection.size() : 0, iCollection != null ? iCollection.size() + 4 : 4, iCollection.toString()); updateMetricTransmittedBytes(OBinaryProtocol.SIZE_INT); if (iCollection == null) writeInt(-1); else { writeInt(iCollection.size()); for (String s : iCollection) writeString(s); } return this; }
/** * @return the owner of this property sheet. In most cases this will be the configurable instance * which was instrumented by this property sheet. */ public synchronized Configurable getOwner() { try { if (!isInstanciated()) { // ensure that all mandatory properties are set before instantiating the component Collection<String> undefProps = getUndefinedMandatoryProps(); if (!undefProps.isEmpty()) { throw new InternalConfigurationException( getInstanceName(), undefProps.toString(), "not all mandatory properties are defined"); } owner = ownerClass.newInstance(); owner.newProperties(this); } } catch (IllegalAccessException e) { throw new InternalConfigurationException( e, getInstanceName(), null, "Can't access class " + ownerClass); } catch (InstantiationException e) { throw new InternalConfigurationException( e, getInstanceName(), null, "Can't instantiate class " + ownerClass); } return owner; }
public static void assertEmpty(final Collection<?> collection) { assertEmpty(collection.toString(), collection); }
/** * Main class that test the functionality of methods in Card and BinSet class. * * @param args */ public static void main(java.lang.String[] args) { Card one = new Card(Ranks.FIVE, "SPADES"); Card two = new Card(Ranks.NINE, "HEARTS"); Card three = new Card(Ranks.KING, "DIAMONDS"); Card four = new Card(Ranks.ACE, "DIAMONDS"); Card five = new Card(Ranks.ACE, "CLUBS"); Card six = new Card(Ranks.FIVE, "SPADES"); System.out.println("Five of Spades equals Nine of Hearts:"); System.out.println(one.equals(two)); System.out.println(); System.out.println("Five of Spades equals King of Diamonds:"); System.out.println(one.equals(three)); System.out.println(); System.out.println("Five of Spades equals Ace of Diamonds:"); System.out.println(one.equals(four)); System.out.println(); System.out.println("Five of Spades equals Ace of Clubs:"); System.out.println(one.equals(five)); System.out.println(); System.out.println("Five of Spades equals Five of Spades:"); System.out.println(one.equals(six)); System.out.println(); System.out.println("___________________________________________________"); System.out.println("Value is greater than 0 when 1 is compared to 2."); System.out.println(one.compareTo(two)); System.out.println(); System.out.println("Value is greater than 0 when 1 is compared to 3."); System.out.println(one.compareTo(three)); System.out.println(); System.out.println("Value is greater than 0 when 1 is compared to 4."); System.out.println(one.compareTo(four)); System.out.println(); System.out.println("Value is greater than 0 when 1 is compared to 5."); System.out.println(one.compareTo(five)); System.out.println(); System.out.println("Value is equal to 0 when 1 is compared to 6."); System.out.println(one.compareTo(six)); System.out.println(); System.out.println("___________________________________________________"); System.out.println("Card1 as a String:"); System.out.println(one.toString()); System.out.println(); System.out.println("Card2 as a String:"); System.out.println(two.toString()); System.out.println(); System.out.println("Card3 as a String:"); System.out.println(three.toString()); System.out.println(); System.out.println("Card4 as a String:"); System.out.println(four.toString()); System.out.println(); System.out.println("Card5 as a String:"); System.out.println(five.toString()); System.out.println(); System.out.println("Card6 as a String:"); System.out.println(six.toString()); System.out.println(); System.out.println("___________________________________________________"); System.out.println("Create List1."); BinSet<String> List1 = new BinSet<String>(); System.out.println(); System.out.println("Add A to List1:"); System.out.println(List1.add("A")); System.out.println(); System.out.println("Add B to List1:"); System.out.println(List1.add("B")); System.out.println(); System.out.println("Add A to List1:"); System.out.println(List1.add("A")); System.out.println(); System.out.println("Print out List1:"); System.out.println(List1.toString()); System.out.println(); System.out.println("___________________________________________________"); System.out.println("Create List2."); Collection<String> List2 = new ArrayList<String>(); System.out.println(); System.out.println("Add C to List2:"); List2.add("C"); System.out.println("Add D to List2:"); List2.add("D"); System.out.println("Add E to List2:"); List2.add("E"); System.out.println(); System.out.println("Are we able to add List2 to List1?"); System.out.println(List1.addAll(List2)); System.out.println(); System.out.println("Clear List2."); List2.clear(); System.out.println(); System.out.println("Add A to List2."); List2.add("A"); System.out.println("Add C to List2."); List2.add("C"); System.out.println("Add D to List2."); List2.add("D"); System.out.println("Add E to List2."); List2.add("E"); System.out.println(); System.out.println("Can I add List2 to List1?"); System.out.println(List1.addAll(List2)); System.out.println(); System.out.println("Display List1:"); System.out.println(List1.toString()); System.out.println(); System.out.println("Is List2 Empty?"); System.out.println(List2.isEmpty()); System.out.println(); System.out.println("Clear List2."); List2.clear(); System.out.println(); System.out.println("Is List2 Empty?"); System.out.println(List2.isEmpty()); System.out.println(); System.out.println("Can I add List1 to List2?"); System.out.println(List2.addAll(List1)); System.out.println(); System.out.println("Does List1 Contain all of List2?"); System.out.println(List1.containsAll(List2)); System.out.println(); System.out.println("Does List2 Contain Z?"); System.out.println(List2.contains("Z")); System.out.println(); System.out.println("Does List2 Contain A?"); System.out.println(List2.contains("A")); System.out.println(); System.out.println("Can I remove Z from List2?"); System.out.println(List2.remove("Z")); System.out.println(); System.out.println("Can I remove A from List2?"); System.out.println(List2.remove("A")); System.out.println(); System.out.println("Display List2:"); System.out.println(List2.toString()); System.out.println(); System.out.println("Display List1:"); System.out.println(List1.toString()); System.out.println(); Object[] array = List1.toArray(); System.out.println("Display the array created from List1:"); System.out.println(Arrays.toString(array)); System.out.println(); }
public void load(String queryFile, String modules, String tables) throws SQLException, IOException, InterruptedException, ExecutionException { Properties properties = new Properties(); properties.load(new FileInputStream(queryFile)); Collection<String> keys = properties.stringPropertyNames(); // Filtering by validating if property starts with any of the module names if (!Config.ALL.equalsIgnoreCase(modules)) { keys = Util.filter( keys, "^(" + modules.replaceAll(Config.COMMA_SEPARATOR, Config.MODULE_SUFFIX) + ")"); } // Filtering by table names if (!Config.ALL.equalsIgnoreCase(tables)) { keys = Util.filter( keys, "(" + tables.replaceAll(Config.COMMA_SEPARATOR, Config.TABLE_SUFFIX) + ")$"); } logger.info("The final modules and tables that are being considered" + keys.toString()); ExecutorService executor = Executors.newFixedThreadPool(keys.size() * 3); CompletionService completion = new ExecutorCompletionService(executor); for (String key : keys) { String query = properties.getProperty(key); key = (key.contains(Config.DOT_SEPARATOR) ? key.substring(key.indexOf(Config.DOT_SEPARATOR) + 1) : key); while (query.contains("[:")) { String param = query.substring(query.indexOf("[:") + 2, query.indexOf("]")); query = query.replaceFirst("\\[\\:" + param + "\\]", properties.getProperty(param)); } int pages = 1; String base = ""; if (config.srisvoltdb) { if (config.isPaginated) { try { // find count String countquery = query; if (countquery.contains("<") || countquery.contains(">")) { int bracketOpen = countquery.indexOf("<"); int bracketClose = countquery.indexOf(">"); String orderCol = countquery.substring(bracketOpen + 1, bracketClose); countquery = countquery.replace("<" + orderCol + ">", ""); } VoltTable vcount = client.callProcedure("@AdHoc", countquery).getResults()[0]; int count = vcount.getRowCount(); pages = (int) Math.ceil((double) count / config.pageSize); } catch (Exception e) { System.out.println("Count formation failure!"); } } // set up data in order } else { // find count String countquery = query.replace("*", "COUNT(*)"); Connection conn = DriverManager.getConnection(config.jdbcurl, config.jdbcuser, config.jdbcpassword); base = conn.getMetaData().getDatabaseProductName().toLowerCase(); System.out.println("BASE: " + base); Statement jdbcStmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); if (countquery.contains("<") || countquery.contains(">")) { int bracketOpen = countquery.indexOf("<"); int bracketClose = countquery.indexOf(">"); String orderCol = countquery.substring(bracketOpen + 1, bracketClose); countquery = countquery.replace("<" + orderCol + ">", ""); } ResultSet rcount = jdbcStmt.executeQuery(countquery); rcount.next(); int count = Integer.parseInt(rcount.getArray(1).toString()); // THIS IF NEEDS A WAY TO DETERMINE IF POSTGRES if (base.contains("postgres") && config.isPaginated) { pages = (int) Math.ceil((double) count / config.pageSize); } // set up data in order } // establish new SourceReaders and DestinationWriters for pages SourceReader[] sr = new SourceReader[pages]; DestinationWriter[] cr = new DestinationWriter[pages]; for (int i = 0; i < pages; i++) { sr[i] = new SourceReader(); cr[i] = new DestinationWriter(); } Controller processor = new Controller<ArrayList<Object[]>>( client, sr, cr, query, key.toUpperCase() + ".insert", config, pages, base); completion.submit(processor); } // wait for all tasks to complete. for (int i = 0; i < keys.size(); ++i) { logger.info( "****************" + completion.take().get() + " completed *****************"); // will block until the next sub task has // completed. } executor.shutdown(); }
public String toString() { return wrapped.toString(); }
@Override public String toString() { return theValues.toString(); }