Examples of ValidationService


Examples of com.alibaba.dubbo.examples.validation.api.ValidationService

    public static void main(String[] args) throws Exception {
        String config = ValidationConsumer.class.getPackage().getName().replace('.', '/') + "/validation-consumer.xml";
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(config);
        context.start();
       
        ValidationService validationService = (ValidationService)context.getBean("validationService");
       
        // Save OK
        ValidationParameter parameter = new ValidationParameter();
        parameter.setName("liangfei");
        parameter.setEmail("liangfei@liang.fei");
        parameter.setAge(50);
        parameter.setLoginDate(new Date(System.currentTimeMillis() - 1000000));
        parameter.setExpiryDate(new Date(System.currentTimeMillis() + 1000000));
        validationService.save(parameter);
        System.out.println("Validation Save OK");
       
        // Save Error
        try {
            parameter = new ValidationParameter();
            validationService.save(parameter);
            System.err.println("Validation Save ERROR");
        } catch (RpcException e) {
            ConstraintViolationException ve = (ConstraintViolationException)e.getCause();
            Set<ConstraintViolation<?>> violations = ve.getConstraintViolations();
            System.out.println(violations);
        }
       
        // Delete OK
        validationService.delete(2, "abc");
        System.out.println("Validation Delete OK");
       
        // Delete Error
        try {
            validationService.delete(0, "abc");
            System.err.println("Validation Delete ERROR");
        } catch (RpcException e) {
            ConstraintViolationException ve = (ConstraintViolationException)e.getCause();
            Set<ConstraintViolation<?>> violations = ve.getConstraintViolations();
            System.out.println(violations);
View Full Code Here

Examples of com.alibaba.dubbo.examples.validation.api.ValidationService

        providerContext.start();
        try {
            ClassPathXmlApplicationContext consumerContext = new ClassPathXmlApplicationContext(ValidationTest.class.getPackage().getName().replace('.', '/') + "/validation-consumer.xml");
            consumerContext.start();
            try {
                ValidationService validationService = (ValidationService) consumerContext.getBean("validationService");
               
                // Save OK
                ValidationParameter parameter = new ValidationParameter();
                parameter.setName("liangfei");
                parameter.setEmail("liangfei@liang.fei");
                parameter.setAge(50);
                parameter.setLoginDate(new Date(System.currentTimeMillis() - 1000000));
                parameter.setExpiryDate(new Date(System.currentTimeMillis() + 1000000));
                validationService.save(parameter);
               
                try {
                    parameter = new ValidationParameter();
                    parameter.setName("l");
                    parameter.setEmail("liangfei@liang.fei");
                    parameter.setAge(50);
                    parameter.setLoginDate(new Date(System.currentTimeMillis() - 1000000));
                    parameter.setExpiryDate(new Date(System.currentTimeMillis() + 1000000));
                    validationService.save(parameter);
                    Assert.fail();
                } catch (RpcException e) {
                    ConstraintViolationException ve = (ConstraintViolationException)e.getCause();
                    Set<ConstraintViolation<?>> violations = ve.getConstraintViolations();
                    Assert.assertNotNull(violations);
                }
               
                // Save Error
                try {
                    parameter = new ValidationParameter();
                    validationService.save(parameter);
                    Assert.fail();
                } catch (RpcException e) {
                    ConstraintViolationException ve = (ConstraintViolationException)e.getCause();
                    Set<ConstraintViolation<?>> violations = ve.getConstraintViolations();
                    Assert.assertNotNull(violations);
                }
               
                // Delete OK
                validationService.delete(2, "abc");
               
                // Delete Error
                try {
                    validationService.delete(2, "a");
                    Assert.fail();
                } catch (RpcException e) {
                    ConstraintViolationException ve = (ConstraintViolationException)e.getCause();
                    Set<ConstraintViolation<?>> violations = ve.getConstraintViolations();
                    Assert.assertNotNull(violations);
                    Assert.assertEquals(1, violations.size());
                }
               
                // Delete Error
                try {
                    validationService.delete(0, "abc");
                    Assert.fail();
                } catch (RpcException e) {
                    ConstraintViolationException ve = (ConstraintViolationException)e.getCause();
                    Set<ConstraintViolation<?>> violations = ve.getConstraintViolations();
                    Assert.assertNotNull(violations);
                    Assert.assertEquals(1, violations.size());
                }
                try {
                    validationService.delete(2, null);
                    Assert.fail();
                } catch (RpcException e) {
                    ConstraintViolationException ve = (ConstraintViolationException)e.getCause();
                    Set<ConstraintViolation<?>> violations = ve.getConstraintViolations();
                    Assert.assertNotNull(violations);
                    Assert.assertEquals(1, violations.size());
                }
                try {
                    validationService.delete(0, null);
                    Assert.fail();
                } catch (RpcException e) {
                    ConstraintViolationException ve = (ConstraintViolationException)e.getCause();
                    Set<ConstraintViolation<?>> violations = ve.getConstraintViolations();
                    Assert.assertNotNull(violations);
View Full Code Here

Examples of com.puppetlabs.geppetto.validation.ValidationService

  public void test_ValidateStackhammerDemo() throws Exception {
    {
      File root = new File("/Users/henrik/gitrepos/stackhammer-demo");
      // TestDataProvider.getTestFile(new Path(
      // "testData/test-modules/"));
      ValidationService vs = getValidationService();
      Diagnostic chain = new Diagnostic();
      ValidationOptions options = getValidationOptions();
      options.setCheckLayout(true);
      options.setCheckModuleSemantics(true);
      options.setCheckReferences(true);
      options.setFileType(FileType.PUPPET_ROOT);
      BuildResult br = vs.validate(chain, root, options, null, SubMonitor.convert(null));

      // System.err.println(errorsToString(chain));
      StringBuilder builder = new StringBuilder();
      builder.append("Diagnostic: A version should be specified.\n");
      builder.append("Diagnostic: A version should be specified.\n");
View Full Code Here

Examples of com.puppetlabs.geppetto.validation.ValidationService

  public void test_ValidateStackhammerDemoFiltered() throws Exception {
    {
      File root = new File("/Users/henrik/gitrepos/stackhammer-demo");
      // TestDataProvider.getTestFile(new Path(
      // "testData/test-modules/"));
      ValidationService vs = getValidationService();
      Diagnostic chain = new Diagnostic();
      ValidationOptions options = getValidationOptions();
      options.setCheckLayout(true);
      options.setCheckModuleSemantics(true);
      options.setCheckReferences(true);
      options.setFileType(FileType.PUPPET_ROOT);
      BuildResult br = vs.validate(chain, root, options, new File[] { new File(
        "/Users/henrik/gitrepos/stackhammer-demo/nodes/foo/") }, SubMonitor.convert(null));

      // System.err.println(errorsToString(chain));
      StringBuilder builder = new StringBuilder();
      builder.append("Diagnostic: A version should be specified.\n");
View Full Code Here

Examples of com.puppetlabs.geppetto.validation.ValidationService

  public void test_ValidateStackhammerPuppetConfDemo() throws Exception {
    {
      File root = new File("/Users/henrik/git/khussey-puppetconf-demo");
      // TestDataProvider.getTestFile(new Path(
      // "testData/test-modules/"));
      ValidationService vs = getValidationService();
      Diagnostic chain = new Diagnostic();
      ValidationOptions options = getValidationOptions();
      options.setCheckLayout(true);
      options.setCheckModuleSemantics(true);
      options.setCheckReferences(true);
      options.setFileType(FileType.PUPPET_ROOT);
      BuildResult br = vs.validate(chain, root, options, null, SubMonitor.convert(null));

      // System.err.println(errorsToString(chain));
      // StringBuilder builder = new StringBuilder();

      assertEquals("There should be the expected errors", "", errorsToString(chain));
View Full Code Here

Examples of com.puppetlabs.geppetto.validation.ValidationService

    if(!root.isDirectory())
      return;

    // TestDataProvider.getTestFile(new Path(
    // "testData/test-modules/"));
    ValidationService vs = getValidationService();
    Diagnostic chain = new Diagnostic();
    ValidationOptions options = getValidationOptions();
    options.setCheckLayout(true);
    options.setCheckModuleSemantics(true);
    options.setCheckReferences(true);
    options.setFileType(FileType.PUPPET_ROOT);
    vs.validate(chain, root, options, null, SubMonitor.convert(null));
    assertEquals("There should be 0 errors", 0, chain.getChildren().size());
  }
View Full Code Here

Examples of com.puppetlabs.geppetto.validation.ValidationService

    assertTrue(
      "CONFIGURATION ERROR: Testdata directory must be a directory: check test config!", root.isDirectory());
    File theRakefile = new File(root, "a/Rakefile");
    assertTrue("CONFIGURATION ERROR: Testdata a/Rakefile must exist: check test config!", theRakefile.exists());

    ValidationService vs = getValidationService();
    Diagnostic chain = new Diagnostic();
    BuildResult result = vs.validate(chain, root, null, null, SubMonitor.convert(null));
    assertTrue(
      "CONFIGURATION ERROR:: Configuration should include ruby services!!", result.isRubyServicesAvailable());
  }
View Full Code Here

Examples of com.puppetlabs.geppetto.validation.ValidationService

  }

  @Test
  public void oneRakefile4Tasks() throws Exception {
    File root = TestDataProvider.getTestFile(new Path("testData/rakefiledata/simple/"));
    ValidationService vs = getValidationService();
    Diagnostic chain = new Diagnostic();
    BuildResult result = vs.validate(chain, root, null, null, SubMonitor.convert(null));
    DiagnosticsAsserter asserter = new DiagnosticsAsserter(chain);
    asserter.assertAll(asserter.issue(IPPDiagnostics.ISSUE__STRING_BOOLEAN).optional().greedy());

    RakefileInfo rakefileInfo = result.getRakefileInfo();
    assertEquals("Should have found a rakefile", 1, rakefileInfo.getRakefiles().size());
View Full Code Here

Examples of com.puppetlabs.geppetto.validation.ValidationService

  }

  @Test
  public void oneRakefileWithCode() throws Exception {
    File root = TestDataProvider.getTestFile(new Path("testData/rakefiledata/withcode/"));
    ValidationService vs = getValidationService();
    Diagnostic chain = new Diagnostic();
    BuildResult result = vs.validate(chain, root, null, null, SubMonitor.convert(null));
    DiagnosticsAsserter asserter = new DiagnosticsAsserter(chain);
    asserter.assertAll(asserter.issue(IPPDiagnostics.ISSUE__STRING_BOOLEAN).optional().greedy());

    RakefileInfo rakefileInfo = result.getRakefileInfo();
    assertEquals("Should have found a rakefile", 1, rakefileInfo.getRakefiles().size());
View Full Code Here

Examples of com.puppetlabs.geppetto.validation.ValidationService

  }

  @Test
  public void rakefileFromJenkinsModule() throws Exception {
    File root = TestDataProvider.getTestFile(new Path("testData/rakefiledata/fromJenkinsModule/"));
    ValidationService vs = getValidationService();
    Diagnostic chain = new Diagnostic();
    BuildResult result = vs.validate(chain, root, null, null, SubMonitor.convert(null));
    DiagnosticsAsserter asserter = new DiagnosticsAsserter(chain);
    asserter.assertAll(asserter.issue(IPPDiagnostics.ISSUE__STRING_BOOLEAN).optional().greedy());

    RakefileInfo rakefileInfo = result.getRakefileInfo();
    assertEquals("Should have found one rakefile", 1, rakefileInfo.getRakefiles().size());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.