@Test public void findFlow() { Dummy alg = new Dummy(3, 2, 200, ImageUInt8.class); alg.minScore = 0.1f; alg.targetX = 4; alg.targetY = 8; ImageUInt8 image = new ImageUInt8(30, 40); ImageFlow.D flow = new ImageFlow.D(); // see if it selects the obvious minimum assertEquals(0.1f, alg.findFlow(6, 7, image, flow), 1e-4); assertTrue(flow.valid); assertEquals(-2, flow.x, 1e-4); assertEquals(1, flow.y, 1e-4); // now try the case where the error is too high alg.minScore = 100000000f; alg.findFlow(6, 7, image, flow); assertFalse(flow.valid); // now give it a case where everything has the same score. See if it picks the one with the // least motion alg.sameScore = true; alg.minScore = 0.1f; alg.findFlow(6, 7, image, flow); assertTrue(flow.valid); assertEquals(0, flow.x, 1e-4); assertEquals(0, flow.y, 1e-4); }
public void testObjectExpression() { Dummy payload = new Dummy(); payload.setContent("foobar"); UMOMessage message = new MuleMessage(payload); filter.setExpression("content.endsWith(\"bar\")"); assertTrue(filter.accept(message)); }
@Test public void checkNeighbors() { int r = 3; Dummy alg = new Dummy(r, 2, 200, ImageUInt8.class); alg.scores = new float[20 * 30]; ImageFlow flows = new ImageFlow(20, 30); ImageFlow.D tmp = new ImageFlow.D(); tmp.valid = true; tmp.x = -1; tmp.y = 2; // checks to see if a pixel is invalid that it's flow is always set // if a pixel is valid then the score is only set if the score is better flows.get(6, 5).valid = true; alg.scores[5 * 20 + 6] = 10; flows.get(5, 5).valid = true; alg.scores[5 * 20 + 5] = 4; // same score, but more motion flows.get(5, 6).valid = true; alg.scores[6 * 20 + 5] = 5; flows.get(5, 6).x = 2; flows.get(5, 6).y = 2; // same score, but less motion flows.get(6, 6).valid = true; alg.scores[6 * 20 + 6] = 5; flows.get(6, 6).x = 0; flows.get(6, 6).y = 1; alg.checkNeighbors(6, 7, tmp, flows, 5); for (int i = -r; i <= r; i++) { for (int j = -r; j <= r; j++) { int x = j + 6; int y = i + 7; ImageFlow.D f = flows.get(x, y); assertTrue(f.valid); if (x == 5 && y == 5) { assertEquals(4, alg.scores[y * 20 + x], 1e-4); assertEquals(0, f.x, 1e-4); assertEquals(0, f.y, 1e-4); } else if (x == 6 && y == 6) { assertEquals(5, alg.scores[y * 20 + x], 1e-4); assertEquals(0, f.x, 1e-4); assertEquals(1, f.y, 1e-4); } else { assertEquals(x + " " + y, 5, alg.scores[y * 20 + x], 1e-4); assertEquals(-1, f.x, 1e-4); assertEquals(2, f.y, 1e-4); } } } }
@Test public void testBatchEnding() throws TNCException { System.out.println( Dummy.getTestDescriptionHead(this.getClass().getSimpleName(), "Test batch ending.")); try { this.initializeImv(); } catch (TNCException e) { e.printStackTrace(); } this.imv.batchEnding(Dummy.getIMVConnection()); }
@Test public void testReceiveMessage() throws TNCException { System.out.println( Dummy.getTestDescriptionHead(this.getClass().getSimpleName(), "Test receive message.")); ImRawComponent component = Dummy.getRawComponentForImv(); long messageType = (component.getVendorId() << 8) | (component.getType() & 0xFF); try { this.initializeImv(); } catch (TNCException e) { e.printStackTrace(); } this.imv.receiveMessage(Dummy.getIMVConnection(), messageType, component.getMessage()); }
@Test public void testNotifyConnectionChange() throws TNCException { System.out.println( Dummy.getTestDescriptionHead( this.getClass().getSimpleName(), "Test notify connection change with CREATE.")); try { this.initializeImv(); } catch (TNCException e) { e.printStackTrace(); } this.imv.notifyConnectionChange( Dummy.getIMVConnection(), DefaultTncConnectionStateEnum.TNC_CONNECTION_STATE_CREATE.id()); }
@Test(expected = TNCException.class) public void testNotInitialized() throws TNCException { System.out.println( Dummy.getTestDescriptionHead( this.getClass().getSimpleName(), "Test error for missing initialization.")); try { this.imv.notifyConnectionChange( Dummy.getIMVConnection(), DefaultTncConnectionStateEnum.TNC_CONNECTION_STATE_CREATE.id()); } catch (TNCException e) { if (e.getResultCode() == TNCException.TNC_RESULT_NOT_INITIALIZED) { throw e; } else { System.err.println("Unexpected error was thrown. " + e.getMessage()); } } }
private void initializeImv() throws TNCException { this.imv.initialize(Dummy.getTncs()); // if(this.imc instanceof AttributeSupport){ // ((AttributeSupport) imc).setAttribute(AttributeSupport.TNC_ATTRIBUTEID_PRIMARY_IMC_ID, new // Long(new Random().nextInt(100))); // } }
private void createPageRankLinksDirectly() throws IOException, URISyntaxException { log.info("Creating PageRank links", null); JobConf job = new JobConf(PagerankData.class); String jobname = "Create pagerank links"; Path fout = new Path(options.getResultPath(), EDGES_DIR_NAME); job.setJobName(jobname); setPageRankLinksOptions(job); job.setOutputKeyClass(LongWritable.class); job.setOutputValueClass(Text.class); // job.setMapOutputKeyClass(LongWritable.class); // job.setMapOutputValueClass(Text.class); job.setNumReduceTasks(0); FileInputFormat.setInputPaths(job, dummy.getPath()); job.setInputFormat(NLineInputFormat.class); job.setMapperClass(DummyToPageRankLinksMapper.class); if (options.isSequenceOut()) { job.setOutputFormat(SequenceFileOutputFormat.class); } else { job.setOutputFormat(TextOutputFormat.class); } if (null != options.getCodecClass()) { job.set("mapred.output.compression.type", "BLOCK"); job.set("mapreduce.output.fileoutputformat.compress.type", "BLOCK"); FileOutputFormat.setCompressOutput(job, true); FileOutputFormat.setOutputCompressorClass(job, options.getCodecClass()); } FileOutputFormat.setOutputPath(job, fout); log.info("Running Job: " + jobname); log.info("Dummy file " + dummy.getPath() + " as input"); log.info("Edges file " + fout + " as output"); JobClient.runJob(job); log.info("Finished Running Job: " + jobname); }
public static void init() { Add.init(); Address.init(); Align.init(); Alloc.init(); Anchor.init(); And.init(); Bad.init(); Bitcast.init(); Block.init(); Builtin.init(); Call.init(); Cmp.init(); Cond.init(); Confirm.init(); Const.init(); Conv.init(); CopyB.init(); Deleted.init(); Div.init(); Dummy.init(); End.init(); Eor.init(); Free.init(); IJmp.init(); Id.init(); Jmp.init(); Load.init(); Member.init(); Minus.init(); Mod.init(); Mul.init(); Mulh.init(); Mux.init(); NoMem.init(); Not.init(); Offset.init(); Or.init(); Phi.init(); Pin.init(); Proj.init(); Raise.init(); Return.init(); Sel.init(); Shl.init(); Shr.init(); Shrs.init(); Size.init(); Start.init(); Store.init(); Sub.init(); Switch.init(); Sync.init(); Tuple.init(); Unknown.init(); }
public static void main(String[] args) { Dummy bob = new Dummy("Bob", 20); Dummy jim = new Dummy("Jim", 25); Dummy alex = new Dummy("Alex", 30); Dummy tim = new Dummy("Tim", 35); Dummy maxwell = new Dummy("Maxwell", 40); Dummy john = new Dummy("John", 45); Dummy julie = new Dummy("Julie", 50); Dummy christy = new Dummy("Christy", 55); Dummy tim2 = new Dummy("Tim", 100); // This should replace the first "tim" Dummy[] dummies = {bob, jim, alex, tim, maxwell, john, julie, christy, tim2}; /* Test: Insert Elements. */ Hash<String, Dummy> hash = new Hash<String, Dummy>(); for (Dummy d : dummies) { hash.put(d.getName(), d); } hash.debugPrintHash(); /* Test: Recall */ for (Dummy d : dummies) { String name = d.getName(); Dummy dummy = hash.get(name); System.out.println("Dummy named " + name + ": " + dummy.toString()); } }
@Test(expected = TNCException.class) public void testDoubleInitialize() throws TNCException { System.out.println( Dummy.getTestDescriptionHead( this.getClass().getSimpleName(), "Test error for redundant initialization.")); try { this.initializeImv(); this.initializeImv(); } catch (TNCException e) { if (e.getResultCode() == TNCException.TNC_RESULT_ALREADY_INITIALIZED) { throw e; } else { System.err.println("Unexpected error was thrown. " + e.getMessage()); } } }
public static void main(String[] args) { // TODO Auto-generated method stub Dummy d = RestInfo.buildProxy(Dummy.class, "http://localhost:8080/api"); d.what().the(); }
@BeforeClass public static void logSetUp() { Dummy.setLogSettings(); }
@Override public String compute(String arg) throws InterruptedException { return dummy.echoWith(arg); }
@Test public void testInitialize() throws TNCException { System.out.println( Dummy.getTestDescriptionHead(this.getClass().getSimpleName(), "Test initialize method.")); this.initializeImv(); }
public int getIndexFromAnotherDummy() throws IOException { return anotherDummy.getIndex(); }
public void test_get_fieldOnRoot() { obj.string = "value"; assertEquals("value", accessor.get(obj, "string")); }
private void createPageRankNodesDirectly() throws IOException { log.info("Creating PageRank nodes...", null); Path fout = new Path(options.getResultPath(), VERTICALS_DIR_NAME); JobConf job = new JobConf(PagerankData.class); String jobname = "Create pagerank nodes"; job.setJobName(jobname); setPageRankNodesOptions(job); job.setOutputKeyClass(LongWritable.class); job.setOutputValueClass(Text.class); FileInputFormat.setInputPaths(job, dummy.getPath()); job.setInputFormat(NLineInputFormat.class); if (balance) { /** * * Balance the output order of nodes, to prevent the running of pagerank bench from * potential data skew */ job.setMapOutputKeyClass(LongWritable.class); job.setMapOutputValueClass(NullWritable.class); job.setMapperClass(BalancedLinkNodesMapper.class); job.setReducerClass(BalancedLinkNodesReducer.class); // job.setPartitionerClass(ModulusPartitioner.class); if (options.getNumReds() > 0) { job.setNumReduceTasks(options.getNumReds()); } else { job.setNumReduceTasks(Utils.getMaxNumReds()); } } else { job.setMapOutputKeyClass(Text.class); job.setMapperClass(DummyToNodesMapper.class); job.setNumReduceTasks(0); } if (options.isSequenceOut()) { job.setOutputFormat(SequenceFileOutputFormat.class); } else { job.setOutputFormat(TextOutputFormat.class); } if (null != options.getCodecClass()) { job.set("mapred.output.compression.type", "BLOCK"); job.set("mapreduce.output.fileoutputformat.compress.type", "BLOCK"); FileOutputFormat.setCompressOutput(job, true); FileOutputFormat.setOutputCompressorClass(job, options.getCodecClass()); } FileOutputFormat.setOutputPath(job, fout); log.info("Running Job: " + jobname); log.info("Dummy file " + dummy.getPath() + " as input"); log.info("Vertices file " + fout + " as output"); JobClient.runJob(job); log.info("Finished Running Job: " + jobname); }