コード例 #1
0
 public void testIndirectTypeConnection() {
   System.setProperty("test.type", "HisSQL");
   Resource root = resourceInModel("x rdf:type ja:Connection; x ja:dbTypeProperty 'test.type'");
   Assembler a = new ConnectionAssembler();
   ConnectionDescription d = (ConnectionDescription) a.open(root);
   assertEquals("HisSQL", d.dbType);
 }
コード例 #2
0
 public void testIndirectURLConnection() {
   System.setProperty("test.url", "bbb");
   Resource root = resourceInModel("x rdf:type ja:Connection; x ja:dbURLProperty 'test.url'");
   Assembler a = new ConnectionAssembler();
   ConnectionDescription d = (ConnectionDescription) a.open(root);
   assertEquals("bbb", d.dbURL);
 }
コード例 #3
0
 public void testIndirectUserConnection() {
   System.setProperty("test.user", "blenkinsop");
   Resource root = resourceInModel("x rdf:type ja:Connection; x ja:dbUserProperty 'test.user'");
   Assembler a = new ConnectionAssembler();
   ConnectionDescription d = (ConnectionDescription) a.open(root);
   assertEquals("blenkinsop", d.dbUser);
 }
コード例 #4
0
 public void testIndirectPasswordConnection() {
   System.setProperty("test.password", "Top/Secret");
   Resource root =
       resourceInModel("x rdf:type ja:Connection; x ja:dbPasswordProperty 'test.password'");
   Assembler a = new ConnectionAssembler();
   ConnectionDescription d = (ConnectionDescription) a.open(root);
   assertEquals("Top/Secret", d.dbPassword);
 }
コード例 #5
0
  public void test() throws Exception {
    ConfigurationFactory config = new ConfigurationFactory();
    Assembler assembler = new Assembler();

    // System services
    assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));

    // JMS persistence datasource
    ResourceInfo dataSourceInfo =
        config.configureService("Default Unmanaged JDBC Database", ResourceInfo.class);
    dataSourceInfo.properties.setProperty("JdbcUrl", "jdbc:hsqldb:mem:MdbConfigTest");
    assembler.createResource(dataSourceInfo);

    // JMS
    assembler.createResource(
        config.configureService("Default JMS Resource Adapter", ResourceInfo.class));

    // JMS Container
    MdbContainerInfo mdbContainerInfo = config.configureService(MdbContainerInfo.class);
    assembler.createContainer(mdbContainerInfo);

    // FakeRA
    ResourceInfo resourceInfo = new ResourceInfo();
    resourceInfo.service = "Resource";
    resourceInfo.className = FakeRA.class.getName();
    resourceInfo.id = "FakeRA";
    resourceInfo.properties = new Properties();
    assembler.createResource(resourceInfo);

    // FakeRA container
    ContainerInfo containerInfo = config.configureService(MdbContainerInfo.class);
    containerInfo.id = "FakeContainer";
    containerInfo.displayName = "Fake Container";
    containerInfo.properties.setProperty("ResourceAdapter", "FakeRA");
    containerInfo.properties.setProperty(
        "MessageListenerInterface", FakeMessageListener.class.getName());
    containerInfo.properties.setProperty("ActivationSpecClass", FakeActivationSpec.class.getName());
    assembler.createContainer(containerInfo);

    // generate ejb jar application
    EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(
        createJaxbMdb("JmsMdb", BasicMdbBean.class.getName(), MessageListener.class.getName()));
    ejbJar.addEnterpriseBean(
        createJaxbMdb("FakeMdb", FakeMdb.class.getName(), FakeMessageListener.class.getName()));
    EjbModule ejbModule =
        new EjbModule(getClass().getClassLoader(), "FakeEjbJar", "fake.jar", ejbJar, null);

    // configure and deploy it
    EjbJarInfo info = config.configureApplication(ejbModule);
    assembler.createEjbJar(info);
  }
コード例 #6
0
ファイル: AssemblerTest.java プロジェクト: stupidsing/suite
 @Test
 public void testAssemble() {
   boolean isProverTrace0 = Suite.isProverTrace;
   Suite.isProverTrace = true;
   try {
     Assembler assembler = new Assembler(32);
     assembler.assemble(Suite.parse(".org = 0, .l LEA (EAX, `EAX * 4 + (0 - 4)`),"));
   } finally {
     Suite.isProverTrace = isProverTrace0;
   }
 }
コード例 #7
0
 public void testCannotLoadClass() {
   Assembler a = new ConnectionAssembler();
   Resource root = resourceInModel("x rdf:type ja:Connection; x ja:dbClass 'no.such.class'");
   try {
     a.open(root);
     fail("should catch class load failure");
   } catch (CannotLoadClassException e) {
     assertEquals(resource("x"), e.getRoot());
     assertEquals("no.such.class", e.getClassName());
     assertInstanceOf(ClassNotFoundException.class, e.getCause());
   }
 }
コード例 #8
0
 public void testConnection() {
   Assembler a = new ConnectionAssembler();
   Resource root =
       resourceInModel(
           "x rdf:type ja:Connection; x ja:dbUser 'test'; x ja:dbPassword ''; x ja:dbURL jdbc:mysql://localhost/test; x ja:dbType 'MySQL'");
   Object x = a.open(root);
   assertInstanceOf(ConnectionDescription.class, x);
   ConnectionDescription d = (ConnectionDescription) x;
   assertEquals("test", d.dbUser);
   assertEquals("", d.dbPassword);
   assertEquals("MySQL", d.dbType);
   assertEquals("jdbc:mysql://localhost/test", d.dbURL);
 }
コード例 #9
0
ファイル: EditFrame.java プロジェクト: BrotherPhil/ROPE
  private void assembleAction() {
    String line;
    messages = new Vector();

    mainFrame.resetExecWindow();

    save();

    assembleFailed = false;
    haveAssemblyErrors = false;

    if (Assembler.version()) {
      while ((line = Assembler.output()) != null) {
        messages.addElement(line);
      }

      Assembler.setPaths(baseName, sourcePath);

      if (Assembler.assemble()) {
        while ((line = Assembler.output()) != null) {
          System.out.println(line);

          messages.addElement(line);

          if (line.startsWith(" [ERROR:")) {
            haveAssemblyErrors = true;
          }
        }

        messageList.setListData(messages);
        messageList.ensureIndexIsVisible(0);

        mainFrame.showExecWindow(baseName);
      } else {
        assembleFailed = true;
      }
    } else {
      assembleFailed = true;
    }

    if (assembleFailed) {
      String message =
          String.format(
              "Autocoder failed!\nVerify the correctness of autocoder path\n%s",
              AssemblerOptions.assemblerPath);
      System.out.println(message);

      JOptionPane.showMessageDialog(this, message, "ROPE", JOptionPane.ERROR_MESSAGE);
    }
  }
コード例 #10
0
 public SearchPaymentResponse searchPayment(SearchPaymentRequest request) {
   SearchPaymentResponse searchPaymentResponse = new SearchPaymentResponse();
   List<Payment> paymentInfoList =
       paymentDao.getPaymentsInfo(
           request.getPaymentId(),
           Assembler.convertToStatus(request.getPaymentStatus()),
           request.getMerchantId());
   ArrayList<PaymentInfo> paymentInfos = new ArrayList<>();
   if (paymentInfoList != null) {
     for (Payment payment : paymentInfoList) {
       paymentInfos.add(Assembler.convertToPaymentInfo(payment));
     }
   }
   searchPaymentResponse.setPaymentInfos(paymentInfos);
   return searchPaymentResponse;
 }
コード例 #11
0
ファイル: AssemblerTest.java プロジェクト: EchNet/postal
 private void verifyAssembly(String templateName) throws Exception {
   StringWriter output = new StringWriter();
   assembler.assemble(
       createClassPathUrl("templates/" + templateName + ".xhtml"), namespace, output);
   String expectedOutput = loadText(createClassPathUrl("solutions/" + templateName + ".html"));
   assertEquals(expectedOutput, output.toString());
 }
コード例 #12
0
  private void assemble() {
    if (sourceFile == null) {
      printError("-i : No source file specified");
    }

    if (assembler == null) {
      printError("-f : No format specified");
    }

    print("...Assembling " + sourceFile.getName());

    assembler.assemble(sourceFile);

    print("..." + assembler.getErrors().length + " error(s) found");

    try {
      PrintWriter output = null;

      if (!assembler.hasErrors()) {
        if (!machineCode) {
          print("...saving .pco file");

          output = new PrintWriter(new FileWriter(baseFileName + ".pco"));

          for (Instruction instruction : assembler.getInstructions()) {
            output.print(instruction.getInstruction());
            output.println(" ;" + instruction.getSourceCode());
          }
        } else {
          print("Machine code file varified");
        }
      } else {
        print("...saving .err file");

        output = new PrintWriter(new FileWriter(baseFileName + ".err"));
        for (AssemblyError error : assembler.getErrors()) {
          output.println(error.toString());
        }
      }

      if (output != null) {
        output.close();
      }
    } catch (IOException e) {
      printError(e.getMessage());
    }
  }
コード例 #13
0
  public static Assembler createGenericAssembler(String toolName, ConanExecutorService ces) {

    AssemblerArgs args = createProcessArgs(toolName);

    if (args == null) return null;

    ServiceLoader<Assembler> procLoader = ServiceLoader.load(Assembler.class);

    for (Assembler assembler : procLoader) {
      if (assembler.getName().equalsIgnoreCase(toolName.trim())) {
        assembler.initialise(args.toConanArgs(), ces);
        return assembler;
      }
    }

    return null;
  }
コード例 #14
0
ファイル: ReadRegInstruction.java プロジェクト: troore/scale
 /** Insert the assembler representation of the instruction into the output stream. */
 public void assembler(Assembler gen, Emit emit) {
   emit.emit(Opcodes.getOp(this));
   emit.emit("\t%");
   if (opcode == Opcodes.RR) emit.emit(SparcGenerator.sRegs[rs1]);
   else emit.emit(SparcGenerator.pRegs[rs1]);
   emit.emit(',');
   emit.emit(gen.assembleRegister(rd));
 }
コード例 #15
0
ファイル: X86RBranch.java プロジェクト: troore/scale
  /** Insert the assembler representation of the instruction into the output stream. */
  public void assembler(Assembler asm, Emit emit) {
    if (nullified()) emit.emit("nop ! ");

    emit.emit(Opcodes.getOp(this));
    emit.emit(getOperandSizeLabel());
    emit.emit('\t');

    emit.emit(asm.assembleRegister(reg));
  }
コード例 #16
0
ファイル: AssemblerTest.java プロジェクト: EchNet/postal
  @Test
  public void testMinimalTemplate() throws Exception {
    final String INPUT = "<html xmlns=\"http://www.w3.org/1999/xhtml\"/>";
    final String EXPECTED_OUTPUT =
        "<!DOCTYPE html>\n" + "<html xmlns=\"http://www.w3.org/1999/xhtml\"/>";

    StringWriter output = new StringWriter();
    assembler.assemble(createLiteralUrl(INPUT), output);
    assertEquals(EXPECTED_OUTPUT, output.toString());
  }
コード例 #17
0
 public SearchDiscountResponse searchDiscount(SearchDiscountRequest request) {
   List<Discount> discounts =
       discountDao.find(
           request.getDiscountFrom(),
           request.getDistanceLessThan(),
           request.getGroupName(),
           request.getMerchantName(),
           request.getTags());
   return Assembler.convertToDiscountResponse(discounts, request);
 }
コード例 #18
0
ファイル: FDccInstruction.java プロジェクト: troore/scale
  /** Insert the assembler representation of the instruction into the output stream. */
  public void assembler(Assembler asm, Emit emit) {
    if (nullified()) emit.emit("nop ! ");

    emit.emit(Opcodes.getOp(opcode));
    emit.emit('\t');
    emit.emit(asm.assembleRegister(rd));
    emit.emit(',');
    emit.emit("0x" + Integer.toHexString(cv));
    emit.emit(',');
    emit.emit("0x" + Integer.toHexString(cv2));
  }
コード例 #19
0
ファイル: AssemblerTest.java プロジェクト: EchNet/postal
  @Test
  public void testBadInputPath() throws Exception {
    final String BAD_PATH = "no-such";

    Throwable error = null;
    try {
      assembler.assemble(createClassPathUrl(BAD_PATH), new StringWriter());
    } catch (AssemblerException e) {
      error = e.getCause();
    }
    assertEquals(BAD_PATH, error.getMessage());
  }
コード例 #20
0
ファイル: AssemblerTest.java プロジェクト: EchNet/postal
  @Test
  public void testMissingDocumentElement() throws Exception {
    final String INPUT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";

    Throwable error = null;
    try {
      assembler.assemble(createLiteralUrl(INPUT), new StringWriter());
    } catch (AssemblerException e) {
      error = e.getCause();
    }
    assertNotNull(error);
  }
コード例 #21
0
ファイル: IdeMain.java プロジェクト: aimozg/ja-dcpu
 private void assemble() {
   Assembler assembler = new Assembler();
   assembler.genMap = true;
   try {
     binary = new char[] {};
     binary = assembler.assemble(sourceTextarea.getText());
     cpu.upload(binary);
     memoryModel.fireUpdate(0, binary.length);
     asmMap = assembler.asmmap;
     for (Character addr : debugger.getBreakpoints()) {
       debugger.setBreakpoint(addr, false);
     }
     for (Integer breakpoint : srcBreakpoints) {
       Character addr = asmMap.src2bin(breakpoint);
       if (addr != null) { // TODO if null, mark breakpoint somehow
         debugger.setBreakpoint(addr, true);
       }
     }
   } catch (Exception ex) {
     JOptionPane.showMessageDialog(
         frame, "Compilation error " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
     ex.printStackTrace();
   }
 }
コード例 #22
0
  private void execute() {
    if (sourceFile == null) {
      printError("-i : No source file specified");
    }

    if (assembler == null || computer == null) {
      printError("-f : No format specified");
    }

    if (assembler.hasErrors()) {
      printError("Unable to execute file due to errors");
    }

    print("...preparing to execute program");

    if (trace) {
      print("...opening computer trace files");
      addTraceListeners();
    }

    computer.setExecutionSpeed(ExecutionSpeed.FULL);
    computer.setInstructions(assembler.getInstructions());

    computer.addComputerListener(
        new ComputerAdapter() {
          public void computerStarted(Computer computer) {
            print("...Execution started");
          }

          public void computerStopped(Computer computer) {
            print("...Execution complete");
          }
        });

    computer.execute();
  }
コード例 #23
0
ファイル: CarBuilder.java プロジェクト: quietcoolwu/TIJ4
 public void run() {
   try {
     powerDown(); // Wait until needed
     while (!Thread.interrupted()) {
       performService();
       assembler.barrier().await(); // Synchronize
       // We're done with that job...
       powerDown();
     }
   } catch (InterruptedException e) {
     print("Exiting " + this + " via interrupt");
   } catch (BrokenBarrierException e) {
     // This one we want to know about
     throw new RuntimeException(e);
   }
   print(this + " off");
 }
コード例 #24
0
ファイル: AssemblerTest.java プロジェクト: EchNet/postal
  @Test
  public void testConflictingIncludeAndContent() throws Exception {
    final String INPUT =
        "<html xmlns=\"http://www.w3.org/1999/xhtml\""
            + " xmlns:dwc=\"http://shopximity.com/schema/dwc\""
            + " dwc:content=\"\""
            + " dwc:include=\"\"/>";

    Throwable error = null;
    try {
      assembler.assemble(createLiteralUrl(INPUT), new StringWriter());
    } catch (AssemblerException e) {
      error = e.getCause();
    }
    // TODO: assert that the error message contains meaningful information.
    assertNotNull(error);
  }
コード例 #25
0
    @Override
    public ContourAggregates<N> process(Aggregates<? extends N> aggregates, Renderer rend) {
      Aggregates<? extends N> padAggs = new PadAggregates<>(aggregates, null);

      Aggregates<Boolean> isoDivided = rend.transfer(padAggs, new ISOBelow<>(threshold));
      Aggregates<MC_TYPE> classified = rend.transfer(isoDivided, new MCClassifier());
      Shape s = Assembler.assembleContours(classified, isoDivided);
      GlyphList<Shape, N> contours = new GlyphList<>();

      contours.add(new SimpleGlyph<>(s, threshold));
      if (!fill) {
        isoDivided = rend.transfer(isoDivided, new General.Simplify<>(isoDivided.defaultValue()));
      }
      Aggregates<N> base =
          rend.transfer(
              isoDivided, new General.MapWrapper<>(true, threshold, aggregates.defaultValue()));
      return new ContourAggregates<>(base, contours);
    }
コード例 #26
0
  /**
   * Retrieve detailed information about a particular module.
   *
   * @param type module type
   * @param name module name
   * @return detailed module information
   */
  @RequestMapping(value = "/{type}/{name}", method = RequestMethod.GET)
  @ResponseStatus(HttpStatus.OK)
  public DetailedModuleRegistrationResource info(
      @PathVariable("type") ArtifactType type, @PathVariable("name") String name) {
    Assert.isTrue(type != ArtifactType.library, "Only modules are supported by this endpoint");
    ArtifactRegistration registration = registry.find(name, type);
    if (registration == null) {
      return null;
    }
    DetailedModuleRegistrationResource result =
        new DetailedModuleRegistrationResource(moduleAssembler.toResource(registration));
    Resource resource = moduleResolver.resolve(adapt(registration.getCoordinates()));

    List<ConfigurationMetadataProperty> properties =
        moduleConfigurationMetadataResolver.listProperties(resource);
    for (ConfigurationMetadataProperty property : properties) {
      result.addOption(property);
    }
    return result;
  }
コード例 #27
0
ファイル: AssemblerTest.java プロジェクト: stupidsing/suite
 @Test
 public void testAssemblePerformance() {
   Assembler assembler = new Assembler(32);
   for (int i = 0; i < 4096; i++) assembler.assemble(Suite.parse(".org = 0, .l CLD (),"));
 }
コード例 #28
0
ファイル: AssemblerTest.java プロジェクト: stupidsing/suite
 @Test
 public void testAssembleMisc() throws IOException {
   Assembler assembler = new Assembler(32, true);
   assembler.assemble(Suite.parse(".org = 0, _ JMP (BYTE .label), .label (),"));
 }
コード例 #29
0
ファイル: AssemblerTest.java プロジェクト: stupidsing/suite
 @Test
 public void testAssembleLongMode() throws IOException {
   Assembler assembler = new Assembler(32, true);
   Bytes bytes = assembler.assemble(Suite.parse(".org = 0, .l MOV (R9D, DWORD 16),"));
   assertEquals(bytes.size(), 7);
 }
コード例 #30
0
 public static <T> Collection<T> assembleAll(Collection<Object> models, Class<T> dtoClass) {
   Assembler<T> ae = new AssemblerImpl<T>();
   return ae.assembleAll(models, dtoClass);
 }