コード例 #1
0
  @Test
  public void shouldCreateValidUnsubscribeRequest() throws OXFException, XmlException {
    ParameterContainer parameters = new ParameterContainer();
    parameters.addParameterShell(SESRequestBuilder_00.UNSUBSCRIBE_SES_URL, "http://ses.host");
    parameters.addParameterShell(SESRequestBuilder_00.UNSUBSCRIBE_REFERENCE, "urn:n52:dummy");

    SESRequestBuilder_00 request = new SESRequestBuilder_00();
    String asText = request.buildUnsubscribeRequest(parameters);
    EnvelopeDocument envelope = EnvelopeDocument.Factory.parse(asText);

    Collection<XmlError> errors = XMLBeansParser.validate(envelope);
    Assert.assertTrue("Unsubscribe request is not valid: " + errors, errors.isEmpty());

    parameters = new ParameterContainer();
    parameters.addParameterShell(SESRequestBuilder_00.UNSUBSCRIBE_SES_URL, "http://ses.host");
    parameters.addParameterShell(
        SESRequestBuilder_00.UNSUBSCRIBE_REFERENCE_XML,
        "<muse-wsa:ResourceId "
            + "xmlns:muse-wsa=\"http://ws.apache.org/muse/addressing\" wsa:IsReferenceParameter=\"true\" "
            + " xmlns:wsa=\"http://www.w3.org/2005/08/addressing\">"
            + "Subscription-2</muse-wsa:ResourceId>");

    asText = request.buildUnsubscribeRequest(parameters);
    envelope = EnvelopeDocument.Factory.parse(asText);

    errors = XMLBeansParser.validate(envelope);
    Assert.assertTrue("Unsubscribe request is not valid: " + errors, errors.isEmpty());
  }
コード例 #2
0
  @Test
  public void shouldCreateValidSubscribeRequest() throws OXFException, XmlException, IOException {
    String sesUrl = "http://ses.host";
    ParameterContainer parameters = new ParameterContainer();
    parameters.addParameterShell(SESRequestBuilder_00.SUBSCRIBE_SES_URL, sesUrl);
    parameters.addParameterShell(
        SESRequestBuilder_00.SUBSCRIBE_CONSUMER_REFERENCE_ADDRESS, "http://consum.er");
    parameters.addParameterShell(
        SESRequestBuilder_00.SUBSCRIBE_INITIAL_TERMINATION_TIME, "2099-12-12");
    parameters.addParameterShell(
        SESRequestBuilder_00.SUBSCRIBE_FILTER_MESSAGE_CONTENT, readFilter(), readFilter());
    parameters.addParameterShell(
        SESRequestBuilder_00.SUBSCRIBE_FILTER_MESSAGE_CONTENT_DIALECT,
        "http://www.opengis.net/ses/filter/level3",
        "http://www.opengis.net/ses/filter/level3");

    parameters.addParameterShell(
        SESRequestBuilder_00.SUBSCRIBE_FILTER_TOPIC, "<start>topic</start>");
    parameters.addParameterShell(
        SESRequestBuilder_00.SUBSCRIBE_FILTER_TOPIC_DIALECT, "http://my-funny/dialect");

    SESRequestBuilder_00 request = new SESRequestBuilder_00();
    String asText = request.buildSubscribeRequest(parameters);
    EnvelopeDocument envelope = EnvelopeDocument.Factory.parse(asText);

    Collection<XmlError> errors = XMLBeansParser.validate(envelope);
    Assert.assertTrue("SubscribeRequest is not valid: " + errors, errors.isEmpty());
  }
コード例 #3
0
 /**
  * @deprecated Use {@link SOSSensorStore#SOSSensorStore(OperationResult)} with {@link
  *     SOSSensorStore#unmarshalFeatures(OperationResult)}
  */
 public OXFFeatureCollection unmarshalFeatures(OperationResult operationResult)
     throws OXFException {
   try {
     this.xmlObject = XMLBeansParser.parse(operationResult.getIncomingResultAsStream());
     this.version = getVersion(operationResult);
   } catch (XMLHandlingException e) {
     throw new OXFException("Could not parse OperationResult", e);
   }
   return unmarshalFeatures();
 }
コード例 #4
0
 /**
  * @deprecated use instead {@link #SOSObservationStore(OperationResult)} and {@link
  *     #unmarshalFeatures()}
  */
 @Deprecated
 protected OXFFeatureCollection unmarshalFeatures100(OperationResult operationResult)
     throws OXFException {
   try {
     this.xmlObject = XMLBeansParser.parse(operationResult.getIncomingResultAsStream());
     return unmarshalFeatures(operationResult);
   } catch (XMLHandlingException e) {
     throw new OXFException("Could not parse OperationResult.", e);
   }
 }
コード例 #5
0
  @Test
  public void shouldCreateValidDescribeSensorRequest() throws OXFException, XmlException {
    ParameterContainer parameters = new ParameterContainer();
    parameters.addParameterShell(SESRequestBuilder_00.DESCRIBE_SENSOR_SES_URL, "http://ses.host");
    parameters.addParameterShell(SESRequestBuilder_00.DESCRIBE_SENSOR_SENSOR_ID, "urn:n52:dummy");

    SESRequestBuilder_00 request = new SESRequestBuilder_00();
    String asText = request.buildDescribeSensorRequest(parameters);
    EnvelopeDocument envelope = EnvelopeDocument.Factory.parse(asText);

    Collection<XmlError> errors = XMLBeansParser.validate(envelope);
    Assert.assertTrue("DescribeSensor request is not valid: " + errors, errors.isEmpty());
  }
コード例 #6
0
  @Test
  public void shouldCreateValidNotification() throws XmlException, IOException, OXFException {
    String sesUrl = "http://ses.host";
    String dialect = "http://my-funny/dialect";
    ParameterContainer parameters = new ParameterContainer();
    parameters.addParameterShell(SESRequestBuilder_00.NOTIFY_SES_URL, sesUrl);
    parameters.addParameterShell(SESRequestBuilder_00.NOTIFY_TOPIC_DIALECT, dialect);
    parameters.addParameterShell(SESRequestBuilder_00.NOTIFY_TOPIC, "<start>topic</start>");
    parameters.addParameterShell(SESRequestBuilder_00.NOTIFY_XML_MESSAGE, readMessage());

    SESRequestBuilder_00 request = new SESRequestBuilder_00();
    String asText = request.buildNotifyRequest(parameters);
    EnvelopeDocument envelope = EnvelopeDocument.Factory.parse(asText);

    XMLBeansParser.registerLaxValidationCase(SASamplingPointCase.getInstance());
    Collection<XmlError> errors = XMLBeansParser.validate(envelope);
    Assert.assertTrue("Notification is not valid: " + errors, errors.isEmpty());

    XmlCursor bodyCur = envelope.getEnvelope().getBody().newCursor();
    bodyCur.toFirstChild();
    Assert.assertTrue(bodyCur.getObject() instanceof Notify);
    XmlCursor tmpCur =
        ((Notify) bodyCur.getObject()).getNotificationMessageArray()[0].getMessage().newCursor();
    tmpCur.toFirstChild();
    Assert.assertTrue(tmpCur.getObject() instanceof ObservationType);

    Assert.assertTrue(
        ((Notify) bodyCur.getObject())
            .getNotificationMessageArray()[0]
            .getTopic()
            .getDialect()
            .trim()
            .equals(dialect));

    tmpCur = ((Notify) bodyCur.getObject()).getNotificationMessageArray()[0].getTopic().newCursor();

    Assert.assertTrue(tmpCur.getObject().xmlText().contains("<start>"));
  }
コード例 #7
0
  @Test
  public void shouldCreateMinimalSubscribeRequest() throws OXFException, XmlException, IOException {
    ParameterContainer parameters = new ParameterContainer();
    parameters.addParameterShell(SESRequestBuilder_00.SUBSCRIBE_SES_URL, "http://ses.host");
    parameters.addParameterShell(
        SESRequestBuilder_00.SUBSCRIBE_CONSUMER_REFERENCE_ADDRESS, "http://consum.er");

    SESRequestBuilder_00 request = new SESRequestBuilder_00();
    String asText = request.buildSubscribeRequest(parameters);
    EnvelopeDocument envelope = EnvelopeDocument.Factory.parse(asText);

    Collection<XmlError> errors = XMLBeansParser.validate(envelope);
    Assert.assertTrue("SubscribeRequest is not valid: " + errors, errors.isEmpty());
  }
コード例 #8
0
  @Test
  public void shouldCreateValidCapabilitiesRequest()
      throws OXFException, XmlException, IOException {
    String sesUrl = "http://ses.host";
    ParameterContainer parameters = new ParameterContainer();
    parameters.addParameterShell(SESRequestBuilder_00.GET_CAPABILITIES_SES_URL, sesUrl);

    SESRequestBuilder_00 request = new SESRequestBuilder_00();
    String asText = request.buildGetCapabilitiesRequest(parameters);
    EnvelopeDocument envelope = EnvelopeDocument.Factory.parse(asText);

    Collection<XmlError> errors = XMLBeansParser.validate(envelope);
    Assert.assertTrue("GetCapabilities is not valid: " + errors, errors.isEmpty());
  }
コード例 #9
0
  @Test
  public void shouldCreateValidDestroyRegistrationRequest()
      throws OXFException, XmlException, IOException {
    String sesUrl = "http://ses.host";
    ParameterContainer parameters = new ParameterContainer();
    parameters.addParameterShell(SESRequestBuilder_00.DESTROY_REGISTRATION_SES_URL, sesUrl);
    parameters.addParameterShell(
        SESRequestBuilder_00.DESTROY_REGISTRATION_REFERENCE, "Publisher-1");

    SESRequestBuilder_00 request = new SESRequestBuilder_00();
    String asText = request.buildDestroyRegistrationRequest(parameters);
    EnvelopeDocument envelope = EnvelopeDocument.Factory.parse(asText);

    Collection<XmlError> errors = XMLBeansParser.validate(envelope);
    Assert.assertTrue("DestroyRegistration is not valid: " + errors, errors.isEmpty());
  }
コード例 #10
0
  @Test
  public void shouldCreateValidRegisterPublisherRequest()
      throws OXFException, XmlException, IOException {
    String sesUrl = "http://ses.host";
    ParameterContainer parameters = new ParameterContainer();
    parameters.addParameterShell(SESRequestBuilder_00.REGISTER_PUBLISHER_SES_URL, sesUrl);
    parameters.addParameterShell(
        SESRequestBuilder_00.REGISTER_PUBLISHER_FROM, "http://my-funny/sender/address");
    parameters.addParameterShell(
        SESRequestBuilder_00.REGISTER_PUBLISHER_LIFETIME_DURATION, "2012-12-02");
    parameters.addParameterShell(
        SESRequestBuilder_00.REGISTER_PUBLISHER_TOPIC_DIALECT, "http://my-funny/dialect");
    parameters.addParameterShell(
        SESRequestBuilder_00.REGISTER_PUBLISHER_TOPIC, "<start>topic</start>");
    parameters.addParameterShell(SESRequestBuilder_00.REGISTER_PUBLISHER_SENSORML, readSensorML());

    SESRequestBuilder_00 request = new SESRequestBuilder_00();
    String asText = request.buildRegisterPublisherRequest(parameters);
    EnvelopeDocument envelope = EnvelopeDocument.Factory.parse(asText);

    Collection<XmlError> errors = XMLBeansParser.validate(envelope);
    Assert.assertTrue("RegisterPublisher is not valid: " + errors, errors.isEmpty());
  }
コード例 #11
0
  @Test
  public void shouldCreateValidLevel1SubscribeRequest() throws OXFException, XmlException {
    String consumer = "http://*****:*****@xlink:href='urn:ogc:object:procedure:CITE:WeatherService:LGA'";

    ParameterContainer parameter = new ParameterContainer();
    parameter.addParameterShell(ISESRequestBuilder.SUBSCRIBE_SES_URL, host);
    parameter.addParameterShell(ISESRequestBuilder.SUBSCRIBE_CONSUMER_REFERENCE_ADDRESS, consumer);
    parameter.addParameterShell(ISESRequestBuilder.SUBSCRIBE_FILTER_TOPIC, topicString);
    parameter.addParameterShell(
        ISESRequestBuilder.SUBSCRIBE_FILTER_MESSAGE_CONTENT_DIALECT, dialect);
    parameter.addParameterShell(ISESRequestBuilder.SUBSCRIBE_FILTER_MESSAGE_CONTENT, xpath);

    SESRequestBuilder_00 request = new SESRequestBuilder_00();
    String asText = request.buildSubscribeRequest(parameter);
    EnvelopeDocument envelope = EnvelopeDocument.Factory.parse(asText);

    Collection<XmlError> errors = XMLBeansParser.validate(envelope);
    Assert.assertTrue("SubscribeRequest is not valid: " + errors, errors.isEmpty());

    Body body = envelope.getEnvelope().getBody();
    XmlCursor cur = body.newCursor();
    cur.toFirstChild();
    XmlObject subscribeRequestObject = cur.getObject();
    cur.dispose();

    if (!(subscribeRequestObject instanceof Subscribe))
      throw new IllegalStateException("Body does not contain a Subscribe request.");

    Subscribe subscribeRequest = (Subscribe) subscribeRequestObject;
    Assert.assertTrue(
        subscribeRequest
            .getConsumerReference()
            .getAddress()
            .getStringValue()
            .trim()
            .equals(consumer.trim()));

    cur = subscribeRequest.getFilter().newCursor();
    cur.toFirstChild();
    do {
      XmlObject filterElement = cur.getObject();
      if (filterElement instanceof QueryExpressionType) {
        QueryExpressionType qet = (QueryExpressionType) filterElement;
        Assert.assertTrue(qet.getDialect().trim().equals(dialect.trim()));
        XmlCursor tmpCur = qet.newCursor();
        Assert.assertTrue(tmpCur.toFirstContentToken() == TokenType.TEXT);
        Assert.assertTrue(tmpCur.getChars().trim().equals(xpath.trim()));
      } else if (filterElement instanceof TopicExpressionType) {
        TopicExpressionType tet = (TopicExpressionType) filterElement;
        Assert.assertTrue(
            tet.getDialect().trim().equals(SESRequestBuilder_00.DEFAULT_TOPIC_DIALECT));
        XmlCursor tmpCur = tet.newCursor();
        Assert.assertTrue(tmpCur.toFirstContentToken() == TokenType.TEXT);
        Assert.assertTrue(tmpCur.getChars().trim().equals(topicString.trim()));
      }
    } while (cur.toNextSibling());
  }